draft-ietf-rtfm-ruleset-language-01.txt   draft-ietf-rtfm-ruleset-language-02.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
SRL: A Simple Ruleset Language Expires January 1999
<draft-ietf-rtfm-ruleset-language-01.txt> SRL: A Language for Describing Traffic Flows
and Specifying Actions for Flow Groups
<draft-ietf-rtfm-ruleset-language-02.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.
skipping to change at page 2, line ? skipping to change at page 2, line ?
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 (Northern Europe), Directories on ftp.is.co.za (Africa), ftp.nordu.net (Northern Europe),
ftp.nis.garr.it (Southern Europe), munnari.oz.au (Pacific Rim), ftp.nis.garr.it (Southern Europe), munnari.oz.au (Pacific Rim),
ftp.ietf.org (US East Coast), or 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 a traffic flow meter so configuration files which may be loaded into a traffic flow meter so as
as to specify which traffic flows are measured by the meter, and the 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 should 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 5
2.1 Define Directive . . . . . . . . . . . . . . . . . . . . . . . 5 2.1 Define Directive . . . . . . . . . . . . . . . . . . . . . . . 5
2.2 Program . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.3 Declaration . . . . . . . . . . . . . . . . . . . . . . . . . 6
3 Statement 5 3 Statement 6
3.1 IF_statement . . . . . . . . . . . . . . . . . . . . . . . . . 6 3.1 IF_statement . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.1.1 expression . . . . . . . . . . . . . . . . . . . . . . . . 6 3.1.1 expression . . . . . . . . . . . . . . . . . . . . . . . . 7
3.1.2 factor . . . . . . . . . . . . . . . . . . . . . . . . . . 6 3.1.2 term . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.1.3 term . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 3.1.3 factor . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.1.4 operand_list . . . . . . . . . . . . . . . . . . . . . . . 7 3.1.4 operand_list . . . . . . . . . . . . . . . . . . . . . . . 8
3.1.5 operand . . . . . . . . . . . . . . . . . . . . . . . . . 7 3.1.5 operand . . . . . . . . . . . . . . . . . . . . . . . . . 8
3.1.6 Test Part . . . . . . . . . . . . . . . . . . . . . . . . 7 3.1.6 Test Part . . . . . . . . . . . . . . . . . . . . . . . . 8
3.1.7 Action Part . . . . . . . . . . . . . . . . . . . . . . . 8 3.1.7 Action Part . . . . . . . . . . . . . . . . . . . . . . . 9
3.1.8 Else Clause . . . . . . . . . . . . . . . . . . . . . . . 9
3.2 Imperative_statement . . . . . . . . . . . . . . . . . . . . . 9 3.2 Compound_statement . . . . . . . . . . . . . . . . . . . . . . 10
3.2.1 GOTO Statement . . . . . . . . . . . . . . . . . . . . . . 9
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
3.3 Subroutine_declaration . . . . . . . . . . . . . . . . . . . . 11 3.3 Imperative_statement . . . . . . . . . . . . . . . . . . . . . 10
3.3.1 SAVE Statement . . . . . . . . . . . . . . . . . . . . . . 11
3.3.2 COUNT Statement . . . . . . . . . . . . . . . . . . . . . 11
3.3.3 EXIT Statement . . . . . . . . . . . . . . . . . . . . . . 11
3.3.4 IGNORE Statement . . . . . . . . . . . . . . . . . . . . . 12
3.3.5 NOMATCH Statement . . . . . . . . . . . . . . . . . . . . 12
3.3.6 STORE Statement . . . . . . . . . . . . . . . . . . . . . 12
3.3.7 RETURN Statement . . . . . . . . . . . . . . . . . . . . . 12
3.4 CALL_statement . . . . . . . . . . . . . . . . . . . . . . . . 12 3.4 Subroutine_declaration . . . . . . . . . . . . . . . . . . . . 13
3.5 CALL_statement . . . . . . . . . . . . . . . . . . . . . . . . 13
4 Example Programs 13 4 Example Programs 14
4.1 Classify IP Port Numbers . . . . . . . . . . . . . . . . . . 13 4.1 Classify IP Port Numbers . . . . . . . . . . . . . . . . . . . 14
4.2 Classify Traffic into Groups of Networks . . . . . . . . . . 14 4.2 Classify Traffic into Groups of Networks . . . . . . . . . . . 15
5 APPENDICES 15 5 APPENDICES 16
5.1 Appendix A: SRL Syntax in BNF . . . . . . . . . . . . . . . . 15 5.1 Appendix A: SRL Syntax in BNF . . . . . . . . . . . . . . . . 16
5.2 Appendix B: Syntax for Values and Masks . . . . . . . . . . . 18
5.3 Appendix C: RTFM Attribute Information . . . . . . . . . . . . 18
6 Acknowledgments 17 6 Acknowledgments 20
7 References 17 7 References 20
8 Author's Addresses 17 8 Author's Addresses 20
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.
SRL is a procedural language for creating RTFM rulesets. It has been SRL is a procedural language for creating RTFM rulesets. It has been
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.
An SRL compiler is available as part of NeTraMet (a free-software
implementation of the RTFM meter and manager), version 4.2 [3].
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, e.g. for IP traffic (PeerType == IP) PeerAddress is for many protocols, e.g. for IP traffic (PeerType == IP) PeerAddress is
an 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
skipping to change at page 3, line 48 skipping to change at page 4, line 4
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 ruleset is effectively a program for a minimal virtual machine, the
'Packet Matching Engine (PME),' which is described in detail in [1]. An 'Packet Matching Engine (PME),' which is described in detail in [1]. An
RTFM meter may run multiple rule sets, with every passing packet being RTFM meter may run multiple rule sets, with every passing packet being
processed by each of the rulesets. The rule 'actions' in this document processed by each of the rulesets. The rule 'actions' in this document
are described as though only a single ruleset were running. 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 details of the PME. having to understand the details of the PME.
The language could easily be adapted to other uses, being suitable for
any application area which involves selecting traffic flows from a
stream of packets.
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
packets will be ignored. packets will be ignored.
skipping to change at page 5, line 4 skipping to change at page 5, line 11
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
capital letters; in practice an SRL compiler will be insensitive to case case. Lower-case identifiers are explained in the text, or they refer
in keywords. Lower-case identifiers are explained in the text, or they to another diagram.
refer to another diagram.
The tokens of an SRL program obey the following rules: The tokens of an SRL program obey the following rules:
- Comments may appear on any line of an SRL program, following a # - Comments may appear on any line of an SRL program, following a #
- White space is used to separate tokens - White space is used to separate tokens
- Semicolon is used as the statement terminator - Semicolon is used as the terminator for most statements
- Identifiers (e.g. for defines and labels) must start with a letter - Identifiers (e.g. for defines and labels) must start with a letter
- Identifiers may contain letters, digits and underscores - Identifiers may contain letters, digits and underscores
- The case of letters is not significant - 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). Wherever 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 2.2 Program
----+-------------+-----+--- IF_statement -------------------+--- ; ------------+-------+-------- Statement -------+-------+-----------
| | | |
+-- label : --+ +--- Imperative_statement -----------+
| | | | | | | |
+------<------+ +--- Subroutine_declaration ---------+ | +------- Declaration ------+ |
| | | |
+--- CALL_statement -----------------+ +---------------------<--------------------+
An SRL program is a sequence of SRL statements, each one terminated by a An SRL program is a sequence of statements or declarations. It does not
semicolon. There are four kinds of statements, as follows. have any special enclosing symbols. Statements and declarations
terminate with a semicolon, except for Compound statements, which
terminate with a right brace.
Each statement may be labelled, i.e. preceded by a sequence of one or 2.3 Declaration
more labels. A label is an identifier, which must be followed by a
semi-colon. Each statement is executed in sequence, unless one of them
performs a GOTO, in which case execution transfers to the statement
bearing the target label.
Labels have a well-defined scope, within which they must be unique. ---------------------- Subroutine_declaration ---------------------
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 SRL's only explicit declaration is the subroutine declaration. Other
implicit declarations are labels (declared where they appear in front of
a statement) and subroutine parameters (declared in the subroutine
header).
Test Part Action Part 3 Statement
............. ...............
--- IF --------- expression -----------+-------- GOTO label -+--- ; ----------------+---- IF_statement ----------------+---------------
| |
+- SAVE , GOTO label -+
| | | |
+- SAVE --------------+ +---- Compound_statement ----------+
| | | |
+- IGNORE ------------+ +---- Imperative_statement --------+
| | | |
+- NOMATCH -----------+ +---- CALL_statement --------------+
An SRL program is a sequence of SRL statements, generally terminated by
a semicolon. There are four kinds of statements, as follows.
3.1 IF_statement
Test Part Action Part
............. ...............
--- IF --- expression ---+------------+---- Statement ----+--->
| | |
+-- SAVE , --+ |
| | | |
+- RETURN --+-------+-+ +-- SAVE ; ----------------------+
>-----------+-----------------------------+-----------------
| | | |
+-- n --+ +-----ELSE --- Statement -----+
3.1.1 expression 3.1.1 expression
------------+------------ factor -------------+-------------------- -------- term --------+------------------------+-------------------
| | | |
+-------------- || ---------------+ logical OR +--<-- term ----- || ----+ logical OR
3.1.2 factor 3.1.2 term
------------+------------- term --------------+-------------------- ------- factor -------+------------------------+-------------------
| | | |
+-------------- && ---------------+ logical AND +--<-- factor --- && ----+ logical AND
3.1.3 term 3.1.3 factor
------------+------- attrib == operand_list ---------+------------- ------------+-------- attrib == operand_list --------+-----------
| | | |
+------------ ( expression ) ------------+ +------------ ( expression ) --------------+
3.1.4 operand_list 3.1.4 operand_list
------------+-------------- operand -----------------+------------- ------------+-------------- operand -----------------+-------------
| | | |
+--- ( operand--+---------------+-- ) ---+ +--- ( operand--+---------------+-- ) ---+
| | | |
+-- , operand --+ +-- , operand --+
| | | |
+-------<-------+ +-------<-------+
skipping to change at page 7, line 32 skipping to change at page 8, line 26
------------- value ---------+----------------------+-------------- ------------- value ---------+----------------------+--------------
| | | |
+------- / width ------+ +------- / width ------+
| | | |
+------- & mask -------+ +------- & mask -------+
3.1.6 Test Part 3.1.6 Test Part
The IF statement evaluates a logical expression. If the expression The IF statement evaluates a logical expression. If the expression
value is TRUE, the action indicated by the keyword on the right of the value is TRUE, the action indicated in the 'Action Part' of the diagram
diagram is executed. If the value is FALSE, the following statement is is executed. If the value is FALSE, the statement after the IF is
executed. executed.
The simplest form of expression is a test for equality (== operator); in 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) 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 is ANDed with a mask and compared with a value. A list of RTFM
expressions may be built up using parentheses and the && (logical AND) attributes is given in Appendix C. More complicated expressions may be
and || (logical OR) operators. built up using parentheses and the && (logical AND) and || (logical OR)
operators.
Operand values may be specified as dotted decimal,hexadecimal or as a Operand values may be specified as dotted decimal,hexadecimal or as a
character constant (enclosed in apostrophes). character constant (enclosed in apostrophes). The syntax for operand
values is given in Appendix B.
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
or hexadecimal e.g. &FF-FF-00-00 or hexadecimal e.g. &FF-FF
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.
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 IGNORE;
GOTO my_network;
or equivalently or equivalently
IF SourcePeerAddress == 130.216/16 GOTO my_network; IF SourcePeerAddress == 130.216/16 IGNORE;
A list of values enclosed in parentheses 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 ) SAVE;
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.
The operand values and masks used in an IF statement must be consistent 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 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 acceptable as a peer address, but would not be accepted as a transport
address (which may not be longer than two bytes). address (which may not be longer than two bytes).
3.1.7 Action Part 3.1.7 Action Part
A SAVE action saves attribute(s), mask(s) and value(s) as given in the A SAVE action (i.e. SAVE , or SAVE ;) saves attribute(s), mask(s) and
statement. If the statement's expression tests more than one attribute, value(s) as given in the statement. If the IF expression tests more
the masks and values are saved for all the attributes. For each than one attribute, the masks and values are saved for all the
value_list in the statement the value saved is the one which the packet attributes. For each value_list in the statement the value saved is the
actually matched. See below for further description of SAVE statements. 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.1.8 Else Clause
--+------------------------------------------- GOTO label ----+-- ; An Else Clause provides a statement which will be executed if the IF's
test fails. The statement following ELSE will often be another IF
statement, providing SRL's version of a 'select' statement. Note that
an ELSE clause always matches the immediately preceding IF.
3.2 Compound_statement
-------+-------------+----- { ---+---- Statement ----+--- } -------
| | | |
+-- label : --+ +--------<----------+
A compound statement is a sequence of statements enclosed in braces.
Each statement will terminate with a semicolon, unless it is another
compound statement (which terminates with a right brace).
A compound statement may be labelled, i.e. preceded by an identifier
followed by a semi-colon. Each statement inside the braces is executed
in sequence unless an EXIT statement is performed, as explained below.
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.3 Imperative_statement
------+---------------------------------------------------+------ ;
| | | |
+-- SAVE attrib --+--+-----------+--+---+----------------+--+ +-- SAVE attrib --+--+-----------+--+---------------+
| | | | | | | | | | | | | |
| | +- / width -+ | +- , GOTO label -+ | | | +- / width -+ | |
| | | | | | | | | | | |
| | +- & mask --+ | | | | +- & mask --+ | |
| | | | | | | |
| +--- = operand ---+ | | +--- = operand ---+ |
| | | |
+-- COUNT --------------------------------------------------+ +-- COUNT ------------------------------------------+
| | | |
+-- IGNORE -------------------------------------------------+ +-- EXIT label ------------------------------------+
| | | |
+-- NOMATCH ------------------------------------------------+ +-- IGNORE -----------------------------------------+
| | | |
+-- RETURN --+-------+--------------------------------------+ +-- NOMATCH ----------------------------------------+
| |
+-- RETURN --+-------+------------------------------+
| | | | | | | |
| +-- n --+ | | +-- n --+ |
| | | |
+-- STORE variable := value ------------+----------------+--+ +-- STORE variable := value ------------------------+
| |
+- , GOTO label -+
3.2.1 GOTO Statement
The GOTO statement (either on its own or as the last part of a larger
statement) specifies the label of the statement to be executed next.
3.2.2 SAVE Statement 3.3.1 SAVE Statement
The SAVE statement saves information which will (later) identify the The SAVE statement saves information which will (later) identify the
flow in the meter's flow table. It does not actually record anything in flow in the meter's flow table. It does not actually record anything in
the table; this is done when a subsequent COUNT statement executes. the table; this is done when a subsequent COUNT statement executes.
SAVE has two possible forms: SAVE has two possible forms:
SAVE attrib = operand SAVE attrib = operand ;
saves the attribute, mask and value as given in the statement. saves the attribute, mask and value as given in the statement.
This form of the SAVE statement is similar to that allowed This form of the SAVE statement is similar to that allowed
in an IF statement, except that - since imperative statements in an IF statement, except that - since imperative statements
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 ELSE IF SourcePeerAddress == 130.216/16 {
GOTO my_network; SAVE SourcePeerAddress /24;
IGNORE; # Executes only if preceding
# IF statements both fail.
my_network: SAVE SourcePeerAddress /24;
COUNT; COUNT;
}
ELSE IGNORE;
3.2.3 COUNT Statement 3.3.2 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.3.3 EXIT Statement
The EXIT statement exits a labelled compound statement. The next
statement to be executed will be the one following that compound
statement. This provides a well-defined way to jump to a clearly
identified point in a program.
3.3.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.3.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. If it is executed when a packet is being execution of the program. If it is executed when a packet is being
processed with its addresses in 'on the wire' order, the PME will processed with its addresses in 'on the wire' order, the PME will
perform the program again from the beginning with source and destination perform the program again from the beginning with source and 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 those flows' as an end-point are counted as though 130.216 had been those flows'
source peer (IP) address. source peer (IP) address.
3.2.6 STORE Statement 3.3.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
Their names have no particular significance; they were arbitrarily Their names have no particular significance; they were arbitrarily
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
values. Their values are set to zero each time examination of a new single-byte integer values. Their values are set to zero each time
packet begins. examination of a new packet begins.
3.2.7 RETURN Statement 3.3.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.4 Subroutine_declaration
-- SUBROUTINE subname ( -+--+---ADDRESS ----pname---+--+- ) -->
| | | |
| +-- VARIABLE -- pname --+ |
| | | |
| +------<------- , ------+ |
| |
+-----------------------------+
>------+--- Imperative_statement ---+----- ENDSUB -------- ; --- SUBROUTINE subname ( ---+---ADDRESS ----pname---+--- ) --->;
| | | |
+----IF_statement -----------+ +-- VARIABLE -- pname --+
| | | |
+----CALL_statement ---------+ +------<------- , ------+
>------+-------- Statement ---------+----- ENDSUB -------- ;
| | | |
+-------------<--------------+ +-------------<--------------+
A Subroutine declaration has three parts: A Subroutine declaration has three parts:
the subname is an indentifier, used to name the subroutine. the subname is an indentifier, used to name the subroutine.
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 A parameter name may be any identifier, and its scope is
a meter 'parameter' variable, i.e. P1, P2, P3, P4 or P5. limited to the subroutine's body.
The meter implements these as global variables, which means
that the SRL programmer must be careful to avoid conflicts
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 Statements, terminated by the
terminated by the ENDSUB keyword. ENDSUB keyword.
Note that GOTOs in a subroutine may not refer to labels outside it. The Note that EXITs in a subroutine may not refer to labels outside it. The
only way to leave a subroutine is via a RETURN statement. only way to leave a subroutine is via a RETURN statement.
3.4 CALL_statement 3.5 CALL_statement
--- CALL subname ( -+--+-- parameter --+--+- ) --> ---- CALL subname ( ---+-- parameter --+--- ) ---->
| | | |
| +---<---- , ----+ |
| | | |
+---------------------+ +---<---- , ----+
>---+--- n: Imperative_statement ---+---- ENDCALL -------- ; >-----+---+-- n : --+---- Statement ----+---- ENDCALL ----- ;
| | | |
| +----<----+ |
| | | |
+---------------<---------------+ +----------------<----------------+
The CALL statement invokes an SRL subroutine. The parameters are SRL The CALL statement invokes an SRL subroutine. The parameters are SRL
variables or other RTFM attributes, and their types must match those in variables or other RTFM attributes, and their types must match those in
the subroutine declaration. Following the parameters is a sequence of the subroutine declaration. Following the parameters is a sequence of
statements, each preceded by an integer label. These labels will statements, each preceded by an integer label. These labels will
normally be 1:, 2:, 3:, etc, but they do not have to be contiguous. normally be 1:, 2:, 3:, etc, but they do not have to be contiguous, nor
They are referred to in RETURN statements. in any particular order. They are referred to in RETURN statements.
e.g. RETURN 2; would return to the statement labelled 2: e.g. RETURN 2; would return to the statement labelled 2:
in the subroutine call. in the subroutine call.
If this statement does not execute a GOTO, execution
will then continue with the first statement after ENDCALL.
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
#
IF SourcePeerType == IP SAVE, GOTO IP_pkt;
IGNORE; # Not an IP packet
# #
IP_pkt: # Classify IP port numbers
IF SourceTransType == ( tcp, udp ) SAVE, GOTO tcp_udp;
GOTO fin; # Not tcp or udp (probably doesn't have ports)
#
tcp_udp:
IF SourceTransAddress == ( www, ftp, telnet ) NOMATCH;
# #
IF DestTransAddress == www GOTO c_www; if SourcePeerType == IP save;
IF DestTransAddress == ftp GOTO c_ftp; else ignore; # Not an IP packet
IF DestTransAddress == telnet GOTO c_telnet;
# #
GOTO fin; # Count as 'unknown' if SourceTransAddress == (www, ftp, telnet) nomatch;
# We want the well-known port as Dest
# #
c_www: if DestTransAddress == telnet
STORE FlowKind := 'W', GOTO fin; save, store FlowKind := 'T';
c_ftp: else if DestTransAddress == www
STORE FlowKind := 'F', GOTO fin; save, store FlowKind := 'W';
c_telnet: else if DestTransAddress == ftp
STORE FlowKind := 'T', GOTO fin; save, store FlowKind := 'F';
else {
save DestTransAddress;
store FlowKind := '?';
}
save SourcePeerAddress /32;
save DestPeerAddress /32;
count;
# #
fin:
SAVE SourcePeerAddress /32;
SAVE DestPeerAddress /32;
COUNT;
This program counts only IP packets, saving SourceTransType (tcp, udp or This program counts only IP packets, saving SourceTransType (tcp, udp or
0), Source- and DestPeerAddress (32-bit IP addresses) and FlowKind ('W' 0), Source- and DestPeerAddress (32-bit IP addresses) and FlowKind ('W'
for www, 'F' for ftp, 'T' for telnet, 0 for inclassified). The program for www, 'F' for ftp, 'T' for telnet, '?' for unclassified). The
uses NOMATCH actions to specify the packet direction - its resulting program uses a NOMATCH action to specify the packet direction - its
flows will have the well-known ports as their destination. resulting flows will have the well-known ports as their destination.
4.2 Classify Traffic into Groups of Networks 4.2 Classify Traffic into Groups of Networks
#
# SRL program to classify traffic into network groups # SRL program to classify traffic into network groups
# #
CALL net_kind (SourcePeerAddress, SourceKind) define my_net = 130.216/16;
ENDCALL; define k_nets = ( 130.217/16, 130.123/16, 130.195/16,
CALL net_kind (DestPeerAddress, DestKind) 132.181/16, 138.75/16, 139.80/16 );
ENDCALL; #
COUNT; call net_kind (SourcePeerAddress, SourceKind)
endcall;
call net_kind (DestPeerAddress, DestKind)
endcall;
count;
#
subroutine net_kind (address addr, variable net)
if addr == my_net save, {
store net := 10; return 1;
}
else if addr == k_nets save, {
store net := 20; return 2;
}
save addr/24; # Not my_net or in k_nets
store net := 30; return 3;
endsub;
# #
SUBROUTINE net_kind (ADDRESS p1, VARIABLE p2)
IF p1 == 130.216/16
SAVE, GOTO nk_mysite;
IF p1 == ( 130.217/16, 130.123/16, 130.195/16,
132.181/16, 138.75/16, 139.80/16 )
SAVE, GOTO nk_mynetwork;
SAVE p1 /24; # Not my site or my network
STORE p2 := 30; RETURN 3;
nk_mysite:
STORE p2 := 10; RETURN 1;
nk_mynetwork:
STORE p2 := 20; RETURN 2;
ENDSUB;
The net_kind subroutine determines whether p1 is my network (130.216), The net_kind subroutine determines whether addr is my network (130.216),
one of the networks in my network (one of the networks in the list), or one of the Kawaihiko networks (in the k_nets list), or some other
some other network. It saves the network address from p1 (16 bits for network. It saves the network address from addr (16 bits for my_net and
my site and my network, 24 bits for others), stores a value of 10, 20 or the k_net networks, 24 bits for others), stores a value of 10, 20 or 30
30 in p2, and returns to 1:, 2: or 3:. in net, and returns to 1:, 2: or 3:. Note that the network numbers
used are contained within the two DEFINEs, making them easy to change.
net_kind is called twice, saving Source- and DestPeerAddress and Source- net_kind is called twice, saving Source- and DestPeerAddress and Source-
and DestKind; the COUNT statement produces flows identified by these and DestKind; the COUNT statement produces flows identified by these
four RTFM attributes, with no particular source-dest ordering. four RTFM attributes, with no particular source-dest ordering.
In the program no use is made of return numbers amd they could have been In the program no use is made of return numbers amd they could have been
omitted. However, we might wish to re-use the subroutine in another omitted. However, we might wish to re-use the subroutine in another
program doing different things for different return numbers, as in the program doing different things for different return numbers, as in the
version below. version below.
CALL net_kind (DestPeerAddress, DestKind) call net_kind (DestPeerAddress, DestKind)
1: NOMATCH; 1: nomatch; # We want my_net as source
ENDCALL; endcall;
CALL net_kind (SourcePeerAddress, SourceKind) call net_kind (SourcePeerAddress, SourceKind)
1: COUNT; # site -> network or other 1: count; # my_net -> other networks
ENDCALL; endcall;
SAVE SourcePeerAddress /24; save SourcePeerAddress /24; #
SAVE DestPeerAddress /24; save DestPeerAddress /24;
COUNT; count;
This version uses a NOMATCH statement to ensure that site -> network or This version uses a NOMATCH statement to ensure that its resulting flows
other flows have site as their source. The NOMATCH also rejects site -> have my_net as their source. The NOMATCH also rejects my_net -> my_
site traffic. Traffic which doesn't have site as source or destination traffic. Traffic which doesn't have my_net as source or destination
saves 24 bits of its addresses (the subroutine might only have saved 16) saves 24 bits of its peer addresses (the subroutine might only have
before counting such an unusual flow. saved 16) before counting such an unusual flow.
5 APPENDICES 5 APPENDICES
5.1 Appendix A: SRL Syntax in BNF 5.1 Appendix A: SRL Syntax in BNF
<SRL program> ::= <statement> | <SRL program> <statement> <SRL program> ::= <S or D> | <SRL program> <S or D>
<statement> ::= <label list> <actual statement> ; | <S or D> ::= <statement> | <declaration>
<actual statement> ;
<label list> ::= <label> : | <label list> <label> : <declaration> ::= <Subroutine declaration>
<actual statement> ::= <IF statement> | <statement> ::= <IF statement> |
<Compound statement> |
<Imperative statement> | <Imperative statement> |
<Subroutine declaration> |
<CALL statement> <CALL statement>
<IF statement> ::= IF <expression> <if action> ; <IF statement> ::= IF <expression> <if action> <opt else>;
<expression> ::= <factor> | <factor> || <factor> <if action> ::= SAVE ; |
SAVE , <statement> |
<statement>
<factor> ::= <term> | <term> && <term> <opt else> ::= <null> |
ELSE <statement>
<term> ::= <attrib> == <operand list> | ( <expression> ) <expression> ::= <term> | <term> || <term>
<term> ::= <factor> | <factor> && <factor>
<factor> ::= <attrib> == <operand list> | ( <expression> )
<operand list> ::= <operand> | ( <actual operand list> ) <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> | <Compound statement> ::= <opt label> { <statement seq> }
SAVE , GOTO <label> |
SAVE | <opt label> ::= <null> |
IGNORE | <identifier> :
NOMATCH |
RETURN | <statement seq> ::= <statement> | <statement seq> <statement>
RETURN <integer label>
<Imperative statement> ::= GOTO <label> ; | <Imperative statement> ::= ; |
SAVE <attribute> <opt operand> <opt goto> ; | SAVE <attribute> <opt operand> ; |
COUNT ; | COUNT ; |
EXIT <label> ; |
IGNORE ; | IGNORE ; |
NOMATCH ; | NOMATCH ; |
RETURN <integer> ; |
RETURN ; | RETURN ; |
RETURN <integer label> ; | STORE <variable> := <value> ;
STORE <variable> := <value> <opt goto> ;
<opt goto> ::= <null> |
, GOTO <label>
<opt operand> ::= <null> | <opt operand> ::= <null> |
<width or mask> | <width or mask> |
= <operand> = <operand>
<width or mask> ::= / <width> | & <mask> <width or mask> ::= / <width> | & <mask>
<Subroutine declaration> ::= <Subroutine declaration> ::=
SUBROUTINE <sub header> <sub body> ENDSUB ; SUBROUTINE <sub header> <sub body> ENDSUB ;
<sub header> ::= <subname> ( <sub param list> ) | <sub header> ::= <subname> ( <sub param list> )
<subname> ( )
<sub param list> ::= <sub param> | <sub param list> , <sub param> <sub param list> ::= <sub param> | <sub param list> , <sub param>
<sub param> ::= ADDRESS <pname> | VARIABLE <pname> <sub param> ::= ADDRESS <pname> | VARIABLE <pname>
<pname> ::= P1 | P2 | P3 | P4 | P5 <pname> ::= <identifier>
<sub body> ::= <sub statement> | <sub body> <sub statement>
<sub statement> ::= <Imperative statement> | <sub body> ::= <statement sequence>
<IF statement> |
<CALL statement>
<CALL statement> ::= CALL <call header> <call body> ENDCALL ; <CALL statement> ::= CALL <call header> <call body> ENDCALL ;
<call header> ::= <subname> ( <call param list> )
<call header> ::= <subname> ( <call param list> ) |
<subname> ( )
<call param list> ::= <call param> | <call param list> ::= <call param> |
<call param list> , <call param> <call param list> , <call param>
<call param> ::= <attribute> | <variable> <call param> ::= <attribute> | <variable>
<call body> ::= <call statement> | <call body> <call statement> <call body> ::= <call statement> | <call body> <call statement>
<call statement> ::= <integer label> : <Imperative statement> <call statement> ::= <int label seq> : <statement>
<int label seq> ::= <integer> : | <int label seq> <integer> :
5.2 Appendix B: Syntax for Values and Masks
Values and masks consist of sequences of numeric fields, each of one or
more bytes. The non-blank character following a field indicates the
field width, and whether the number is decimal or hexadecimal. These
'field type' characters may be:
. period decimal, single byte
- minus hex, single byte
! exclaim decimal, two bytes
For example, 130.216.0.0 is an IP address (in dotted decimal), and
FF-FF-00-00 is an IP address in hexadecimal.
The last field of a value or mask has no field width character. Instead
it takes the same width as the preceding field. For example, 1.3.10!50
and 1.3.0.10.0.50 are two different ways to specify the same value.
Unspecified fields (at the right-hand side of a value or mask) are set
to zero, i.e. 130.216 is the same as 130.216.0.0.
If only a single field is specified (no field width character), the
value given fills the whole field. For example, 23 and 0.23 specify the
same value for a SourceTransAddress operand. For variables (which have
one-byte values) a C-style character constant may also be used.
5.3 Appendix C: RTFM Attribute Information
The following attributes may be tested in an IF statement, and their
values may be SAVEd (except for MatchingStoD). Their size (in bytes) is
shown to the left, and a brief description is given for each.
1 SourceInterface, DestInterface
Interface(s) on which the flow was observed
1 SourceAdjacentType, DestAdjacentType
Indicates the interface type(s)
6 SourceAdjacentAddress, DestAdjacentAddress
For IEEE 802.x interfaces, the MAC addresses for the flow
1 SourcePeerType, DestPeerType
Peer protocol types, e.g. IPv4, Novell, Ethertalk, ..
4 SourcePeerAddress, DestPeerAddress
Peer Addresses (size varies, e.g. 4 for IPv4, 3 for Ethertalk))
1 SourceTransType, DestTransType
Transport layer type, e.g TCP, UDP, IS-IS
2 SourceTransAddress, DestTransAddress
Transport layer addresses (port numbers for TCP and UDP)
1 FlowRuleset
Rule set number for the flow
1 MatchingStoD
Indicates whether the packet is being matched with its
addresses in 'wire order.' See reference [1] for details.
The following variables may be tested in an IF, and their values may be
set by a STORE. They all have one-byte values.
SourceClass, DestClass, FlowClass,
SourceKind, DestKind, FlowKind
The following RTFM attributes are not address attributes - they are
measured attributes of a flow. Their values may be read from an RTFM
meter. (For example, NeTraMet uses a FORMAT statement to specify which
attribute values are to be read from the meter.)
8 ToOctets, FromOctets
Total number of octets seen for each direction of the flow
8 ToPDUs, FromPDUs
Total number of PDUs seen for each direction of the flow
4 FirstTime, LastTime
Time (in centiseconds) that first and last PDUs were seen
for the flow
Other attributes will be defined by the RTFM working group from time to
time.
6 Acknowledgments 6 Acknowledgments
The SRL language is part of the RTFM Working Group's efforts to make the The SRL language is part of the RTFM Working Group's efforts to make the
RTFM traffic measurement system easier to use. Initial work on the RTFM traffic measurement system easier to use. Initial work on the
language was done by Cyndi Mills and Brad Frazee in Boston. SRL was language was done by Cyndi Mills and Brad Frazee in Boston. SRL was
developed in Auckland; it was greatly assisted by detailed discussion developed in Auckland; it was greatly assisted by detailed discussion
with John White and Russell Fulton. Discussion has continued on the with John White and Russell Fulton. Discussion has continued on the
RTFM mailing list. RTFM mailing list.
7 References 7 References
[1] Brownlee, N., Mills, C., and G. Ruth, "Traffic Flow [1] Brownlee, N., Mills, C., and G. Ruth, "Traffic Flow
Measurement: Architecture", RFC 2063, The University of Measurement: Architecture", RFC 2063, The University of
Auckland, Bolt Beranek and Newman Inc., GTE Laboratories, Inc, Auckland, Bolt Beranek and Newman Inc., GTE Laboratories, Inc,
January 1997. January 1997.
[2] Brownlee, N., "Traffic Flow Measurement: Meter MIB", RFC [2] Brownlee, N., "Traffic Flow Measurement: Meter MIB", RFC
2064, The University of Auckland, January 1997. 2064, The University of Auckland, January 1997.
[3] Brownlee, N., NeTraMet home page,
http://www.auckland.ac.nz/net/NeTraMet
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 January 1999
 End of changes. 121 change blocks. 
266 lines changed or deleted 384 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/