draft-ietf-rtfm-ruleset-language-00.txt   draft-ietf-rtfm-ruleset-language-01.txt 
Internet Engineering Task Force Nevil Brownlee Internet Engineering Task Force Nevil Brownlee
INTERNET-DRAFT The University of Auckland INTERNET-DRAFT The University of Auckland
Expires September 1998
SRL: A Simple Ruleset Language SRL: A Simple Ruleset Language
<draft-ietf-rtfm-ruleset-language-00.txt> <draft-ietf-rtfm-ruleset-language-01.txt>
Status of this Memo Status of this Memo
This document is an Internet-Draft. Internet-Drafts are working This document is an Internet-Draft. Internet-Drafts are working
documents of the Internet Engineering Task Force (IETF), its Areas, and documents of the Internet Engineering Task Force (IETF), its Areas, and
its Working Groups. Note that other groups may also distribute working its Working Groups. Note that other groups may also distribute working
documents as Internet-Drafts. This Internet Draft is a product of the documents as Internet-Drafts. This Internet Draft is a product of the
Realtime Traffic Flow Measurement Working Group of the IETF. Realtime Traffic Flow Measurement Working Group of the IETF.
Internet Drafts are draft documents valid for a maximum of six months. Internet Drafts are draft documents valid for a maximum of six months.
Internet Drafts may be updated, replaced, or obsoleted by other Internet Drafts may be updated, replaced, or obsoleted by other
documents at any time. It is not appropriate to use Internet Drafts as documents at any time. It is not appropriate to use Internet Drafts as
reference material or to cite them other than as a "working draft" or reference material or to cite them other than as a "working draft" or
"work in progress." "work in progress."
To view the entire list of current Internet-Drafts, please check the To view the entire list of current Internet-Drafts, please check the
"1id-abstracts.txt" listing contained in the Internet-Drafts Shadow "1id-abstracts.txt" listing contained in the Internet-Drafts Shadow
Directories on ftp.is.co.za (Africa), ftp.nordu.net (Europe), Directories on ftp.is.co.za (Africa), ftp.nordu.net (Northern Europe),
munnari.oz.au (Pacific Rim), ds.internic.net (US East Coast), or ftp.nis.garr.it (Southern Europe), munnari.oz.au (Pacific Rim),
ftp.isi.edu (US West Coast). ftp.ietf.org (US East Coast), or ftp.isi.edu (US West Coast).
Abstract Abstract
This document describes a language for specifying rulesets, i.e. This document describes a language for specifying rulesets, i.e.
configuration files which may be loaded into an traffic flow meter so as configuration files which may be loaded into a traffic flow meter so
to determine which traffic flows are measured by the meter, and the as to specify which traffic flows are measured by the meter, and the
information it will store for each flow. Although the language is information it will store for each flow. Although the language is
primarily intended for RTFM traffic flows, it may also be useful in primarily intended for RTFM traffic flows, it may also be useful in
other areas as a general way of specifying flows to be measured or other areas as a general way of specifying flows to be measured or
collected. collected.
Contents Contents
1 Purpose and Scope 3 1 Purpose and Scope 3
1.1 RTFM Meters and Traffic Flows . . . . . . . . . . . . . . . . 3 1.1 RTFM Meters and Traffic Flows . . . . . . . . . . . . . . . . 3
1.2 SRL Overview . . . . . . . . . . . . . . . . . . . . . . . . . 4 1.2 SRL Overview . . . . . . . . . . . . . . . . . . . . . . . . . 4
2 SRL Language Description 4 2 SRL Language Description 4
2.1 Define Directive . . . . . . . . . . . . . . . . . . . . . . . 5 2.1 Define Directive . . . . . . . . . . . . . . . . . . . . . . . 5
3 Statement 5 3 Statement 5
3.1 IF_Statement . . . . . . . . . . . . . . . . . . . . . . . . . 6 3.1 IF_statement . . . . . . . . . . . . . . . . . . . . . . . . . 6
3.1.1 operand_list . . . . . . . . . . . . . . . . . . . . . . . 6 3.1.1 expression . . . . . . . . . . . . . . . . . . . . . . . . 6
3.1.2 operand . . . . . . . . . . . . . . . . . . . . . . . . . 6 3.1.2 factor . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3.1.3 Test Part . . . . . . . . . . . . . . . . . . . . . . . . 6 3.1.3 term . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.1.4 Action Part . . . . . . . . . . . . . . . . . . . . . . . 7 3.1.4 operand_list . . . . . . . . . . . . . . . . . . . . . . . 7
3.2 Imperative_Statement . . . . . . . . . . . . . . . . . . . . . 8 3.1.5 operand . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.2.1 GOTO Statement . . . . . . . . . . . . . . . . . . . . . . 8 3.1.6 Test Part . . . . . . . . . . . . . . . . . . . . . . . . 7
3.2.2 SAVE Statement . . . . . . . . . . . . . . . . . . . . . . 8 3.1.7 Action Part . . . . . . . . . . . . . . . . . . . . . . . 8
3.2.3 COUNT Statement . . . . . . . . . . . . . . . . . . . . . 9
3.2.4 IGNORE Statement . . . . . . . . . . . . . . . . . . . . . 9
3.2.5 NOMATCH Statement . . . . . . . . . . . . . . . . . . . . 9
3.2.6 STORE Statement . . . . . . . . . . . . . . . . . . . . . 10
3.2.7 RETURN Statement . . . . . . . . . . . . . . . . . . . . . 10
3.3 SUBROUTINE_declaration . . . . . . . . . . . . . . . . . . . . 10
3.4 CALL_Statement . . . . . . . . . . . . . . . . . . . . . . . . 11
4 Example Programs 12 3.2 Imperative_statement . . . . . . . . . . . . . . . . . . . . . 9
4.1 Classify IP Port Numbers . . . . . . . . . . . . . . . . . . . 12 3.2.1 GOTO Statement . . . . . . . . . . . . . . . . . . . . . . 9
4.2 Classify Traffic into Groups of Networks . . . . . . . . . . . 13 3.2.2 SAVE Statement . . . . . . . . . . . . . . . . . . . . . . 9
3.2.3 COUNT Statement . . . . . . . . . . . . . . . . . . . . . 10
3.2.4 IGNORE Statement . . . . . . . . . . . . . . . . . . . . . 10
3.2.5 NOMATCH Statement . . . . . . . . . . . . . . . . . . . . 10
3.2.6 STORE Statement . . . . . . . . . . . . . . . . . . . . . 11
3.2.7 RETURN Statement . . . . . . . . . . . . . . . . . . . . . 11
5 APPENDICES 14 3.3 Subroutine_declaration . . . . . . . . . . . . . . . . . . . . 11
5.1 Appendix A: SRL Syntax in BNF . . . . . . . . . . . . . . . . 14
6 Acknowledgments 16 3.4 CALL_statement . . . . . . . . . . . . . . . . . . . . . . . . 12
7 References 16 4 Example Programs 13
4.1 Classify IP Port Numbers . . . . . . . . . . . . . . . . . . 13
4.2 Classify Traffic into Groups of Networks . . . . . . . . . . 14
8 Author's Addresses 16 5 APPENDICES 15
5.1 Appendix A: SRL Syntax in BNF . . . . . . . . . . . . . . . . 15
6 Acknowledgments 17
7 References 17
8 Author's Addresses 17
1 Purpose and Scope 1 Purpose and Scope
A ruleset for an RTFM Meter is a sequence of instructions to be executed A ruleset for an RTFM Meter is a sequence of instructions to be executed
by the meter's Pattern Matching Engine (PME). The form of these by the meter's Pattern Matching Engine (PME). The form of these
instructions is described in detail in RFCs 2063 and 2064 [1], [2], but instructions is described in detail in RFCs 2063 and 2064 [1], [2], but
most users - at least inititially - find them confusing and difficult to most users - at least inititially - find them confusing and difficult to
write, mainly because the effect of each instruction is strongly write, mainly because the effect of each instruction is strongly
dependent on the state of the meter's Packet Matching Engine at the dependent on the state of the meter's Packet Matching Engine at the
moment of its execution. moment of its execution.
skipping to change at page 3, line 26 skipping to change at page 3, line 26
designed to be simple for people to understand, using statements which designed to be simple for people to understand, using statements which
help to clarify the execution context in which they operate. SRL help to clarify the execution context in which they operate. SRL
programs will be compiled into rulesets, which can then be downloaded to programs will be compiled into rulesets, which can then be downloaded to
RTFM meters. RTFM meters.
1.1 RTFM Meters and Traffic Flows 1.1 RTFM Meters and Traffic Flows
The RTFM Architecture [1] defines a set of 'attributes' which apply to The RTFM Architecture [1] defines a set of 'attributes' which apply to
network traffic. Among the attributes are 'address attributes,' such as network traffic. Among the attributes are 'address attributes,' such as
PeerType, PeerAddress, TransType and TransAddress, which have meaning PeerType, PeerAddress, TransType and TransAddress, which have meaning
for many protocols, but for IP traffic (PeerType = IP) PeerAddress is an for many protocols, e.g. for IP traffic (PeerType == IP) PeerAddress is
IP address, TransType is TCP, UDP, ICMP, etc., and TransAddress is an IP address, TransType is TCP, UDP, ICMP, etc., and TransAddress is
usually an IP port number. usually an IP port number.
An 'RTFM Traffic Flow' is simply a stream of packets observed by a meter An 'RTFM Traffic Flow' is simply a stream of packets observed by a meter
as they pass across a network between two end points (or from a single as they pass across a network between two end points (or from a single
end point). Each 'end point' of a flow is determined by the set of end point). Each 'end point' of a flow is determined by the set of
values of its address attributes. values of its address attributes.
An 'RTFM Meter' is a measuring device - e.g. a program running on a An 'RTFM Meter' is a measuring device - e.g. a program running on a
Unix or PC host - which observes passing packets and builds 'Flow Data Unix or PC host - which observes passing packets and builds 'Flow Data
Records' for the flows of interest. Records' for the flows of interest.
skipping to change at page 3, line 49 skipping to change at page 3, line 49
RTFM traffic flows have another important property - they are RTFM traffic flows have another important property - they are
bi-directional. This means that each flow data record in the meter has bi-directional. This means that each flow data record in the meter has
two sets of counters, one for packets travelling from source to two sets of counters, one for packets travelling from source to
destination, the other for returning packets. Within the RTFM destination, the other for returning packets. Within the RTFM
architecture such counters appear as further attributes of the flow. architecture such counters appear as further attributes of the flow.
An RTFM meter must be configured by the user, which means creating a An RTFM meter must be configured by the user, which means creating a
'Ruleset' so as to specify which flows are to be measured, and how much 'Ruleset' so as to specify which flows are to be measured, and how much
information (i.e. which attributes) should be stored for each of them. information (i.e. which attributes) should be stored for each of them.
A rulset is effectively a program for a minimal virtual machine, the A rulset is effectively a program for a minimal virtual machine, the
'Packet Matching Engine (PME),' which is described in detail in [1]. 'Packet Matching Engine (PME),' which is described in detail in [1]. An
RTFM meter may run multiple rule sets, with every passing packet being
processed by each of the rulesets. The rule 'actions' in this document
are described as though only a single ruleset were running.
In the past creating a ruleset has meant writing machine code for the In the past creating a ruleset has meant writing machine code for the
PME, which has proved rather difficult to do. SRL provides a high-level PME, which has proved rather difficult to do. SRL provides a high-level
language which should enable users to create effective rulesets without language which should enable users to create effective rulesets without
having to understand the PME in detail. having to understand the details of the PME.
1.2 SRL Overview 1.2 SRL Overview
An SRL program is executed from the beginning for each new packet An SRL program is executed from the beginning for each new packet
arriving at the meter. It has two essential goals. arriving at the meter. It has two essential goals.
(a) Decide whether the current packet is part of a flow which is of (a) Decide whether the current packet is part of a flow which is of
interest and if necessary, determine its direction (i.e. decide interest and, if necessary, determine its direction (i.e. decide
which of its end-points is considered to be its source). Other which of its end-points is considered to be its source). Other
flows will be ignored. packets will be ignored.
(b) SAVE whatever information is required to identify the flow and (b) SAVE whatever information is required to identify the flow and
accumulate (COUNT) quantitative information for that flow. accumulate (COUNT) quantitative information for that flow.
At execution, the meter's Packet Matching Engine (PME) begins by using At execution, the meter's Packet Matching Engine (PME) begins by using
source and destination attributes as they appear 'on the wire.' If the source and destination attributes as they appear 'on the wire.' If the
attributes do not match those of a flow to be recorded, the PME will attributes do not match those of a flow to be recorded, the PME will
normally execute the program again, this time with the source and normally execute the program again, this time with the source and
destination addresses interchanged. Because of this bi- directional destination addresses interchanged. Because of this bi- directional
matching, an RTFM meter is able to build up tables of flows with two matching, an RTFM meter is able to build up tables of flows with two
sets of counters - one for forward packets, the other for backward sets of counters - one for forward packets, the other for backward
packets. The programmer can if required suppress the reverse-direction packets. The programmer can, if required, suppress the
matching and assign 'forward' and 'backward' directions which conform to reverse-direction matching and assign 'forward' and 'backward'
the conventions of the external context. directions which conform to the conventions of the external context.
Goal (a) is achieved using IF statements which perform comparisons on Goal (a) is achieved using IF statements which perform comparisons on
information from the packet or from SRL variables. Goal (b) is achieved information from the packet or from SRL variables. Goal (b) is achieved
using one or more SAVE statements to store the flow's identification using one or more SAVE statements to store the flow's identification
attributes; a COUNT statement then increments the statistical data attributes; a COUNT statement then increments the statistical data
accumulating for it. accumulating for it.
2 SRL Language Description 2 SRL Language Description
The SRL language is explained below using 'railway diagrams' to describe The SRL language is explained below using 'railway diagrams' to describe
skipping to change at page 4, line 46 skipping to change at page 5, line 4
using one or more SAVE statements to store the flow's identification using one or more SAVE statements to store the flow's identification
attributes; a COUNT statement then increments the statistical data attributes; a COUNT statement then increments the statistical data
accumulating for it. accumulating for it.
2 SRL Language Description 2 SRL Language Description
The SRL language is explained below using 'railway diagrams' to describe The SRL language is explained below using 'railway diagrams' to describe
the syntax. Flow through a diagram is from left to right. The only the syntax. Flow through a diagram is from left to right. The only
exception to this is that lines carrying a left arrow may only be exception to this is that lines carrying a left arrow may only be
traversed right to left. In the diagrams, keywords are written in traversed right to left. In the diagrams, keywords are written in
capital letters; in practice an SRL compiler will be insensitive to case capital letters; in practice an SRL compiler will be insensitive to case
in keywords. Lower-case identifiers are explained in the text, or they in keywords. Lower-case identifiers are explained in the text, or they
refer to another diagram. refer to another diagram.
Comments may appear on any line of an SRL program, following a #. The tokens of an SRL program obey the following rules:
- Comments may appear on any line of an SRL program, following a #
- White space is used to separate tokens
- Semicolon is used as the statement terminator
- Identifiers (e.g. for defines and labels) must start with a letter
- Identifiers may contain letters, digits and underscores
- The case of letters is not significant
2.1 Define Directive 2.1 Define Directive
--- DEFINE -- defname ---- = ---- defined_text ------------------ ; --- DEFINE -- defname ---- = ---- defined_text ------------------ ;
Simple, parameterless, defines are supported, via the syntax above. The Simple, parameterless, defines are supported, via the syntax above. The
define name, defname, is an identifier made up of letters, digits and define name, defname, is an identifier made up of letters, digits and
underscores. The defined text starts after the equal sign, and underscores. The defined text starts after the equal sign, and
continues up to (but not including) the closing semicolon. (If a continues up to (but not including) the closing semicolon. (If a
semicolon is required within define text, it must be preceded by a semicolon is required within define text, it must be preceded by a
backslash). Whereever defname appears elsewhere in the program, it will backslash). Wherever defname appears elsewhere in the program, it will
be replaced by the defined text. be replaced by the defined text.
For example, For example,
DEFINE telnet = 23; DEFINE telnet = 23;
DEFINE smtp = 25; DEFINE smtp = 25;
DEFINE http = {80, 8080}; DEFINE http = (80, 8080);
3 Statement 3 Statement
----+-------------+-----+--- IF_statement -------------------+--- ; ----+-------------+-----+--- IF_statement -------------------+--- ;
| | | | | | | |
+-- label : --+ +--- Imperative_statement -----------+ +-- label : --+ +--- Imperative_statement -----------+
| | | | | | | |
+------<------+ +--- Subroutine_declaration ---------+ +------<------+ +--- Subroutine_declaration ---------+
| | | |
+--- CALL_statement -----------------+ +--- CALL_statement -----------------+
An SRL program is a sequence of SRL statements, each one terminated by a An SRL program is a sequence of SRL statements, each one terminated by a
semicolon. There are four kinds of statements, as follows. semicolon. There are four kinds of statements, as follows.
Each statement may be labelled, i.e. preceded by a sequence of one or Each statement may be labelled, i.e. preceded by a sequence of one or
more labels. A label may contain letters, digits and underscores more labels. A label is an identifier, which must be followed by a
followed by a semi-colon. Each statement is executed in sequence, semi-colon. Each statement is executed in sequence, unless one of them
unless one of them performs a GOTO, in which case execution transfers to performs a GOTO, in which case execution transfers to the statement
the statement bearing the given label. bearing the target label.
Labels are global; each must be unique within an SRL program. Labels have a well-defined scope, within which they must be unique.
Labels within a subroutine (i.e. between a SUBROUTINE and its matching
ENDSUB) are local to that subroutine and are not visible outside it.
Labels outside subroutines are part of a program's outer block.
3.1 IF_Statement 3.1 IF_statement
Test Part Action Part Test Part Action Part
............. ............... ............. ...............
--- IF attrib --- = operand_list ------+-------- GOTO label -+--- ; --- IF --------- expression -----------+-------- GOTO label -+--- ;
| | | |
+- SAVE , GOTO label -+ +- SAVE , GOTO label -+
| | | |
+- SAVE --------------+ +- SAVE --------------+
| | | |
+- IGNORE ------------+ +- IGNORE ------------+
| | | |
+- NOMATCH -----------+ +- NOMATCH -----------+
| | | |
+- RETURN --+-------+-+ +- RETURN --+-------+-+
| | | |
+-- n --+ +-- n --+
3.1.1 operand_list 3.1.1 expression
------------+------------ factor -------------+--------------------
| |
+-------------- || ---------------+ logical OR
3.1.2 factor
------------+------------- term --------------+--------------------
| |
+-------------- && ---------------+ logical AND
3.1.3 term
------------+------- attrib == operand_list ---------+-------------
| |
+------------ ( expression ) ------------+
3.1.4 operand_list
------------+-------------- operand -----------------+------------- ------------+-------------- operand -----------------+-------------
| | | |
+--- { operand--+---------------+-- } ---+ +--- ( operand--+---------------+-- ) ---+
| | | |
+-- , operand --+ +-- , operand --+
| | | |
+-------<-------+ +-------<-------+
3.1.2 operand 3.1.5 operand
------------- value ---------+----------------------+-------------- ------------- value ---------+----------------------+--------------
| | | |
+------- / width ------+ +------- / width ------+
| | | |
+------- & mask -------+ +------- & mask -------+
3.1.3 Test Part 3.1.6 Test Part
The IF statement takes an RTFM Attribute value (from the packet or from The IF statement evaluates a logical expression. If the expression
an SRL variable), ANDs it with a mask and compares it with a value. If value is TRUE, the action indicated by the keyword on the right of the
this test succeeds, the action indicated by the keyword on the right of diagram is executed. If the value is FALSE, the following statement is
the diagram is executed. If the test fails, the following statement is
executed. executed.
The simplest form of expression is a test for equality (== operator); in
this an RTFM attribute value (from the packet or from an SRL variable)
is ANDed with a mask and compared with a value. More complicated
expressions may be built up using parentheses and the && (logical AND)
and || (logical OR) operators.
Operand values may be specified as dotted decimal,hexadecimal or as a
character constant (enclosed in apostrophes).
Masks may be specified as numbers, Masks may be specified as numbers,
dotted decimal e.g. &255.255.0.0 dotted decimal e.g. &255.255.0.0
or hexadecimal e.g. &FF-FF-00-00 or hexadecimal e.g. &FF-FF-00-00
or as a width in bits e.g. /16 or as a width in bits e.g. /16
If a mask is not specified, an all-ones mask is used. If a mask is not specified, an all-ones mask is used.
Values may be specified as dotted decimal,hexadecimal or as a character
constant (enclosed in apostrophes).
In SRL a value is always combined with a mask; this combination is In SRL a value is always combined with a mask; this combination is
referred to as an operand.For example, if we were interested in flows referred to as an operand.For example, if we were interested in flows
originating from IP network 130.216, we might write: originating from IP network 130.216, we might write:
IF SourcePeerAddress = 130.216.0.0 & 255.255.0.0 IF SourcePeerAddress == 130.216.0.0 & 255.255.0.0
GOTO my_network; GOTO my_network;
or equivalently or equivalently
IF SourcePeerAddress = 130.216/16 GOTO my_network; IF SourcePeerAddress == 130.216/16 GOTO my_network;
A list of values enclosed in braces may also be specified; the test A list of values enclosed in parentheses may also be specified; the test
succeeds if the masked attribute equals any of the values in the list. succeeds if the masked attribute equals any of the values in the list.
For example For example
IF SourcePeerAddress = { 130.216.7/24, 130.216.34/24 } IF SourcePeerAddress == ( 130.216.7/24, 130.216.34/24 )
GOTO special_network; GOTO special_network;
As this last example indicates, values are right-padded with zeroes, As this last example indicates, values are right-padded with zeroes,
i.e. the given numbers specify the leading bytes of masks and values. i.e. the given numbers specify the leading bytes of masks and values.
3.1.4 Action Part The operand values and masks used in an IF statement must be consistent
with the attribute being tested. For example, a four-byte value is
acceptable as a peer address, but would not be accepted as a transport
address (which may not be longer than two bytes).
A SAVE action saves attribute, mask and value as given in the statement. 3.1.7 Action Part
If the statement has a value_list, the value saved is the value which the
packet actually matched. See below for further description of SAVE A SAVE action saves attribute(s), mask(s) and value(s) as given in the
statements. statement. If the statement's expression tests more than one attribute,
the masks and values are saved for all the attributes. For each
value_list in the statement the value saved is the one which the packet
actually matched. See below for further description of SAVE statements.
Other actions are described in detail under "Imperative statements" Other actions are described in detail under "Imperative statements"
below. Note that the RETURN action is valid only within subroutines. below. Note that the RETURN action is valid only within subroutines.
3.2 Imperative_Statement 3.2 Imperative_statement
--+------------------------------------------- GOTO label ----+-- ; --+------------------------------------------- GOTO label ----+-- ;
| | | |
+-- SAVE attrib --+--+-----------+--+---+----------------+--+ +-- SAVE attrib --+--+-----------+--+---+----------------+--+
| | | | | | | | | | | | | | | |
| | +- / width -+ | +- , GOTO label -+ | | | +- / width -+ | +- , GOTO label -+ |
| | | | | | | | | | | |
| | +- & mask --+ | | | | +- & mask --+ | |
| | | | | | | |
| +--- = operand ---+ | | +--- = operand ---+ |
skipping to change at page 9, line 13 skipping to change at page 10, line 13
do not perform a test - you may save an arbitrary value. do not perform a test - you may save an arbitrary value.
SAVE attrib SAVE attrib
SAVE attrib / width SAVE attrib / width
SAVE attrib & mask SAVE attrib & mask
saves the attribute and mask from the statement, and the saves the attribute and mask from the statement, and the
value resulting from their application to the current packet. value resulting from their application to the current packet.
This is most useful when used to save a value with a wider This is most useful when used to save a value with a wider
mask than than was used to select the packet. For example mask than than was used to select the packet. For example
IF DestPeerAddress = 130.216/16 IF DestPeerAddress == 130.216/16
NOMATCH; NOMATCH;
IF SourcePeerAddress = 130.216/16 IF SourcePeerAddress == 130.216/16
GOTO my_network; GOTO my_network;
IGNORE; # Executes only if preceding IGNORE; # Executes only if preceding
# IF statements both fail. # IF statements both fail.
my_network: SAVE SourcePeerAddress /24; my_network: SAVE SourcePeerAddress /24;
COUNT; COUNT;
3.2.3 COUNT Statement 3.2.3 COUNT Statement
The COUNT statement appears after all testing and saving is complete; it The COUNT statement appears after all testing and saving is complete; it
instructs the PME to build the flow identifier from the attributes which instructs the PME to build the flow identifier from the attributes which
have been Saved, find it in the meter's flow table (creating a new entry have been SAVEd, find it in the meter's flow table (creating a new entry
if this is the first packet observed for the flow), and increment its if this is the first packet observed for the flow), and increment its
counters. The meter then moves on to examine the next incoming packet. counters. The meter then moves on to examine the next incoming packet.
3.2.4 IGNORE Statement 3.2.4 IGNORE Statement
The IGNORE statement terminates examination of the current packet The IGNORE statement terminates examination of the current packet
without saving any information from it; the meter moves on to examine without saving any information from it; the meter moves on to examine
the next incoming packet, beginning again at the first statement of its the next incoming packet, beginning again at the first statement of its
program. program.
3.2.5 NOMATCH Statement 3.2.5 NOMATCH Statement
The NOMATCH statement indicates that matching has failed for this The NOMATCH statement indicates that matching has failed for this
execution of the program (i.e. this packet). If it is executed when a execution of the program. If it is executed when a packet is being
packet is being processed with its addresses in 'on the wire' order, the processed with its addresses in 'on the wire' order, the PME will
PME will perform the program again from the beginning with source and perform the program again from the beginning with source and destination
destination addresses interchanged. If it is executed following such an addresses interchanged. If it is executed following such an
interchange, the packet will be ignored. NOMATCH is illustrated in the interchange, the packet will be IGNOREd. NOMATCH is illustrated in the
above example, where it is used to ensure that flows having 130.216/16 above example, where it is used to ensure that flows having 130.216/16
as an end-point are counted as though 130.216 had been their source peer as an end-point are counted as though 130.216 had been those flows'
(IP) address. source peer (IP) address.
3.2.6 STORE Statement 3.2.6 STORE Statement
The STORE statement assigns a value to an SRL variable and SAVEs it. The STORE statement assigns a value to an SRL variable and SAVEs it.
There are six SRL variables: There are six SRL variables:
SourceClass SourceKind SourceClass SourceKind
DestClass DestKind DestClass DestKind
FlowClass FlowKind FlowClass FlowKind
skipping to change at page 10, line 25 skipping to change at page 11, line 25
chosen as likely RTFM attributes but can be used to store any integer chosen as likely RTFM attributes but can be used to store any integer
values. Their values are set to zero each time examination of a new values. Their values are set to zero each time examination of a new
packet begins. packet begins.
3.2.7 RETURN Statement 3.2.7 RETURN Statement
The RETURN statement is used to return from subroutines and can be used The RETURN statement is used to return from subroutines and can be used
only within the context of a subroutine. It is described in detail only within the context of a subroutine. It is described in detail
below (CALL statement). below (CALL statement).
3.3 SUBROUTINE_declaration 3.3 Subroutine_declaration
-- SUBROUTINE subname ( -+--+---ADDRESS ----pname---+--+- ) --> -- SUBROUTINE subname ( -+--+---ADDRESS ----pname---+--+- ) -->
| | | | | | | |
| +-- VARIABLE -- pname --+ | | +-- VARIABLE -- pname --+ |
| | | | | | | |
| +------<------- , ------+ | | +------<------- , ------+ |
| | | |
+-----------------------------+ +-----------------------------+
>------+--- Imperative_statement ---+----- ENDSUB -------- ; >------+--- Imperative_statement ---+----- ENDSUB -------- ;
| | | |
+----IF_statement -----------+ +----IF_statement -----------+
| | | |
+----CALL_statement ---------+ +----CALL_statement ---------+
| | | |
+-------------<--------------+ +-------------<--------------+
A Subroutine declaration has three parts: A Subroutine declaration has three parts:
the Name is like a label, it may have letters, digits the subname is an indentifier, used to name the subroutine.
and underscores.
the Parameter list specifies the subroutine's parameters. the Parameter list specifies the subroutine's parameters.
Each parameter is preceded with a keyword indicating its Each parameter is preceded with a keyword indicating its
type - VARIABLE indicates an SRL variable (see the STORE type - VARIABLE indicates an SRL variable (see the STORE
statement above), ADDRESS indicates any other RTFM attribute. statement above), ADDRESS indicates any other RTFM attribute.
The parameter name (pname in the diagram) must be the name of The parameter name (pname in the diagram) must be the name of
a meter 'parameter' variable, i.e. P1, P2, P3, P4 or P5. a meter 'parameter' variable, i.e. P1, P2, P3, P4 or P5.
The meter implements these as global variables, which means The meter implements these as global variables, which means
that the SRL programmer must be careful to avoid conflicts that the SRL programmer must be careful to avoid conflicts
when calling one subroutine from another. when calling one subroutine from another.
the Body specifies what processing the subroutine will perform. the Body specifies what processing the subroutine will perform.
This is simply a sequence of Imperative, IF and CALL statements, This is simply a sequence of Imperative, IF and CALL statements,
terminated by the ENDSUB keyword. terminated by the ENDSUB keyword.
3.4 CALL_Statement Note that GOTOs in a subroutine may not refer to labels outside it. The
only way to leave a subroutine is via a RETURN statement.
3.4 CALL_statement
--- CALL subname ( -+--+-- parameter --+--+- ) --> --- CALL subname ( -+--+-- parameter --+--+- ) -->
| | | | | | | |
| +---<---- , ----+ | | +---<---- , ----+ |
| | | |
+---------------------+ +---------------------+
>---+--- n: Imperative_statement ---+---- ENDCALL -------- ; >---+--- n: Imperative_statement ---+---- ENDCALL -------- ;
| | | |
+---------------<---------------+ +---------------<---------------+
skipping to change at page 12, line 15 skipping to change at page 13, line 15
If the return statement does not specify a return label, the first If the return statement does not specify a return label, the first
statement executed after RETURN will be the statement immediately statement executed after RETURN will be the statement immediately
following ENDCALL. following ENDCALL.
4 Example Programs 4 Example Programs
4.1 Classify IP Port Numbers 4.1 Classify IP Port Numbers
# SRL program to classify IP port numbers # SRL program to classify IP port numbers
# #
IF SourcePeerType = IP SAVE, GOTO IP_pkt; IF SourcePeerType == IP SAVE, GOTO IP_pkt;
IGNORE; # Not an IP packet IGNORE; # Not an IP packet
# #
IP_pkt: IP_pkt:
IF SourceTransType = { tcp, udp } SAVE, GOTO tcp_udp; IF SourceTransType == ( tcp, udp ) SAVE, GOTO tcp_udp;
GOTO fin; # Not tcp or udp (probably doesn't have ports) GOTO fin; # Not tcp or udp (probably doesn't have ports)
# #
tcp_udp: tcp_udp:
IF SourceTransAddress = { www, ftp, telnet } NOMATCH; IF SourceTransAddress == ( www, ftp, telnet ) NOMATCH;
# #
IF DestTransAddress = www GOTO c_www; IF DestTransAddress == www GOTO c_www;
IF DestTransAddress = ftp GOTO c_ftp; IF DestTransAddress == ftp GOTO c_ftp;
IF DestTransAddress = telnet GOTO c_telnet; IF DestTransAddress == telnet GOTO c_telnet;
# #
GOTO fin; # Count as 'unknown' GOTO fin; # Count as 'unknown'
# #
c_www: c_www:
STORE FlowKind := 'W', GOTO fin; STORE FlowKind := 'W', GOTO fin;
c_ftp: c_ftp:
STORE FlowKind := 'F', GOTO fin; STORE FlowKind := 'F', GOTO fin;
c_telnet: c_telnet:
STORE FlowKind := 'T', GOTO fin; STORE FlowKind := 'T', GOTO fin;
# #
skipping to change at page 13, line 16 skipping to change at page 14, line 16
# SRL program to classify traffic into network groups # SRL program to classify traffic into network groups
# #
CALL net_kind (SourcePeerAddress, SourceKind) CALL net_kind (SourcePeerAddress, SourceKind)
ENDCALL; ENDCALL;
CALL net_kind (DestPeerAddress, DestKind) CALL net_kind (DestPeerAddress, DestKind)
ENDCALL; ENDCALL;
COUNT; COUNT;
# #
SUBROUTINE net_kind (ADDRESS p1, VARIABLE p2) SUBROUTINE net_kind (ADDRESS p1, VARIABLE p2)
IF p1 = 130.216/16 IF p1 == 130.216/16
SAVE, GOTO nk_mysite; SAVE, GOTO nk_mysite;
IF p1 = { 130.217/16, 130.123/16, 130.195/16, IF p1 == ( 130.217/16, 130.123/16, 130.195/16,
132.181/16, 138.75/16, 139.80/16 } 132.181/16, 138.75/16, 139.80/16 )
SAVE, GOTO nk_mynetwork; SAVE, GOTO nk_mynetwork;
SAVE p1 /24; # Not my site or my network SAVE p1 /24; # Not my site or my network
STORE p2 := 30; RETURN 3; STORE p2 := 30; RETURN 3;
nk_mysite: nk_mysite:
STORE p2 := 10; RETURN 1; STORE p2 := 10; RETURN 1;
nk_mynetwork: nk_mynetwork:
STORE p2 := 20; RETURN 2; STORE p2 := 20; RETURN 2;
ENDSUB; ENDSUB;
The net_kind subroutine determines whether p1 is my network (130.216), The net_kind subroutine determines whether p1 is my network (130.216),
skipping to change at page 14, line 27 skipping to change at page 15, line 27
<statement> ::= <label list> <actual statement> ; | <statement> ::= <label list> <actual statement> ; |
<actual statement> ; <actual statement> ;
<label list> ::= <label> : | <label list> <label> : <label list> ::= <label> : | <label list> <label> :
<actual statement> ::= <IF statement> | <actual statement> ::= <IF statement> |
<Imperative statement> | <Imperative statement> |
<Subroutine declaration> | <Subroutine declaration> |
<CALL statement> <CALL statement>
<IF statement> ::= IF <attribute> = <operand list> <if action> ; <IF statement> ::= IF <expression> <if action> ;
<operand list> ::= <operand> | { <actual operand list> } <expression> ::= <factor> | <factor> || <factor>
<factor> ::= <term> | <term> && <term>
<term> ::= <attrib> == <operand list> | ( <expression> )
<operand list> ::= <operand> | ( <actual operand list> )
<actual operand list> ::= <operand> | <actual operand list> ::= <operand> |
<actual operand list> , <operand> <actual operand list> , <operand>
<operand> ::= <value> | <operand> ::= <value> |
<value> / <width> | <value> / <width> |
<value> & <mask> <value> & <mask>
<if action> ::= GOTO <label> | <if action> ::= GOTO <label> |
SAVE , GOTO <label> | SAVE , GOTO <label> |
skipping to change at page 16, line 32 skipping to change at line 735
2064, The University of Auckland, January 1997. 2064, The University of Auckland, January 1997.
8 Author's Addresses 8 Author's Addresses
Nevil Brownlee Nevil Brownlee
Information Technology Systems & Services Information Technology Systems & Services
The University of Auckland The University of Auckland
Phone: +64 9 373 7599 x8941 Phone: +64 9 373 7599 x8941
E-mail: n.brownlee@auckland.ac.nz E-mail: n.brownlee@auckland.ac.nz
Expires September 1998
 End of changes. 56 change blocks. 
96 lines changed or deleted 153 lines changed or added

This html diff was produced by rfcdiff 1.34. The latest version is available from http://tools.ietf.org/tools/rfcdiff/