rfc2723.txt
来自「RFC 的详细文档!」· 文本 代码 · 共 1,236 行 · 第 1/3 页
TXT
1,236 行
Network Working Group N. Brownlee
Request for Comments: 2723 The University of Auckland
Category: Informational October 1999
SRL: A Language for Describing Traffic Flows and
Specifying Actions for Flow Groups
Status of this Memo
This memo provides information for the Internet community. It does
not specify an Internet standard of any kind. Distribution of this
memo is unlimited.
Copyright Notice
Copyright (C) The Internet Society (1999). All Rights Reserved.
Abstract
This document describes a language for specifying rulesets, i.e.
configuration files which may be loaded into a traffic flow meter so
as to specify which traffic flows are measured by the meter, and the
information it will store for each flow.
Table of Contents
1 Purpose and Scope . . . . . . . . . . . . . . . . . . . . . . 2
1.1 RTFM Meters and Traffic Flows . . . . . . . . . . . . . . 2
1.2 SRL Overview . . . . . . . . . . . . . . . . . . . . . . 3
2 SRL Language Description . . . . . . . . . . . . . . . . . . 4
2.1 Define Directive . . . . . . . . . . . . . . . . . . . . 4
2.2 Program . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.3 Declaration . . . . . . . . . . . . . . . . . . . . . . . 5
3 Statement . . . . . . . . . . . . . . . . . . . . . . . . . . 5
3.1 IF_statement . . . . . . . . . . . . . . . . . . . . . . 6
3.1.1 expression . . . . . . . . . . . . . . . . . . . . 6
3.1.2 term . . . . . . . . . . . . . . . . . . . . . . . 6
3.1.3 factor . . . . . . . . . . . . . . . . . . . . . . 6
3.1.4 operand_list . . . . . . . . . . . . . . . . . . . 6
3.1.5 operand . . . . . . . . . . . . . . . . . . . . . . 6
3.1.6 Test Part . . . . . . . . . . . . . . . . . . . . . 7
3.1.7 Action Part . . . . . . . . . . . . . . . . . . . . 8
3.1.8 ELSE Clause . . . . . . . . . . . . . . . . . . . . 8
3.2 Compound_statement . . . . . . . . . . . . . . . . . . . 8
3.3 Imperative_statement . . . . . . . . . . . . . . . . . . 9
3.3.1 SAVE Statement . . . . . . . . . . . . . . . . . . 9
3.3.2 COUNT Statement . . . . . . . . . . . . . . . . . . 10
Brownlee Informational [Page 1]
RFC 2723 SRL: A Traffic Flow Language October 1999
3.3.3 EXIT Statement . . . . . . . . . . . . . . . . . . 10
3.3.4 IGNORE Statement . . . . . . . . . . . . . . . . . 10
3.3.5 NOMATCH Statement . . . . . . . . . . . . . . . . . 10
3.3.6 STORE Statement . . . . . . . . . . . . . . . . . . 11
3.3.7 RETURN Statement . . . . . . . . . . . . . . . . . 11
3.4 Subroutine_declaration . . . . . . . . . . . . . . . . . 11
3.5 CALL_statement . . . . . . . . . . . . . . . . . . . . . 12
4 Example Programs . . . . . . . . . . . . . . . . . . . . . . 13
4.1 Classify IP Port Numbers . . . . . . . . . . . . . . . . 13
4.2 Classify Traffic into Groups of Networks . . . . . . . . 14
5 Security Considerations . . . . . . . . . . . . . . . . . . . 15
6 IANA Considerations . . . . . . . . . . . . . . . . . . . . . 15
7 APPENDICES . . . . . . . . . . . . . . . . . . . . . . . . . 16
7.1 Appendix A: SRL Syntax in BNF . . . . . . . . . . . . . . 16
7.2 Appendix B: Syntax for Values and Masks . . . . . . . . . 18
7.3 Appendix C: RTFM Attribute Information . . . . . . . . . 19
8 Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . 20
9 References . . . . . . . . . . . . . . . . . . . . . . . . . 20
10 Author's Address . . . . . . . . . . . . . . . . . . . . . . 21
11 Full Copyright Statement . . . . . . . . . . . . . . . . . . 22
1 Purpose and Scope
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 instructions is described in detail in the 'RTFM Architecture'
and 'RTFM Meter MIB' documents [RTFM-ARC, RTFM-MIB], but most users -
at least initially - find them confusing and difficult to write,
mainly because the effect of each instruction is strongly dependent
on the state of the meter's Packet Matching Engine at the moment of
its execution.
SRL (the Simple Ruleset Language) is a procedural language for
creating RTFM rulesets. It has been designed to be simple for people
to understand, using statements which help to clarify the execution
context in which they operate. SRL programs will be compiled into
rulesets which can then be downloaded to RTFM meters.
An SRL compiler is available as part of NeTraMet (a free-software
implementation of the RTFM meter and manager), version 4.2
[NETRAMET].
1.1 RTFM Meters and Traffic Flows
The RTFM Architecture [RTFM-ARC] defines a set of 'attributes' which
apply to network traffic. Among the attributes are 'address
attributes,' such as PeerType, PeerAddress, TransType and
TransAddress, which have meaning for many protocols, e.g. for IPv4
Brownlee Informational [Page 2]
RFC 2723 SRL: A Traffic Flow Language October 1999
traffic (PeerType == 1) PeerAddress is an IP address, TransType is
TCP(6), UDP(17), ICMP(1), etc., and TransAddress is usually an IP
port number.
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
to/from a single end point). Each 'end point' of a flow is specified
by the set of values of its address attributes.
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 Records' for the flows of interest.
RTFM traffic flows have another important property - they are bi-
directional. This means that each flow data record in the meter has
two sets of counters, one for packets travelling from source to
destination, the other for returning packets. Within the RTFM
architecture such counters appear as further attributes of the flow.
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 information (i.e. which attributes) should be stored for each of
them. A ruleset is effectively a program for a minimal virtual
machine, the 'Packet Matching Engine (PME),' which is described in
detail in [RTFM-ARC]. 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
PME, which has proved rather difficult to do. SRL provides a high-
level language which should enable users to create effective rulesets
without having to understand the details of the PME.
The language may be useful in other applications, being suitable for
any application area which involves selecting traffic flows from a
stream of packets.
1.2 SRL Overview
An SRL program is executed from the beginning for each new packet
arriving at the meter. It has two essential goals.
(a) Decide whether the current packet is part of a flow which is of
interest and, if necessary, determine its direction (i.e. decide
which of its end-points is considered to be its source). Other
packets will be ignored.
Brownlee Informational [Page 3]
RFC 2723 SRL: A Traffic Flow Language October 1999
(b) SAVE whatever information is required to identify the flow and
accumulate (COUNT) quantitative information for that flow.
At execution, the meter's Packet Matching Engine (PME) begins by
using 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 normally execute the program again, this time with the
source and destination addresses interchanged. Because of this bi-
directional 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 packets. The programmer can, if required, suppress the
reverse-direction matching and assign 'forward' and 'backward'
directions which conform to the conventions of the external context.
Goal (a) is achieved using IF statements which perform comparisons on
information from the packet or from SRL variables. Goal (b) is
achieved using one or more SAVE statements to store the flow's
identification attributes; a COUNT statement then increments the
statistical data accumulating for it.
2 SRL Language Description
The SRL language is explained below using 'railway diagrams' to
describe 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 traversed right to left. In the diagrams, keywords are
written in capital letters; in practice an SRL compiler must be
insensitive to case. Lower-case identifiers are explained in the
text, or they refer to another diagram.
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 terminator for most statements
- 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
- Reserved words (shown in upper case in this document) may not be
used as identifiers
2.1 Define Directive
--- DEFINE -- defname ---- = ---- defined_text ------------------ ;
Simple parameterless defines are supported via the syntax above. The
define name, defname, is an identifier. The defined text starts
after the equal sign, and continues up to (but not including) the
Brownlee Informational [Page 4]
RFC 2723 SRL: A Traffic Flow Language October 1999
closing semicolon. If a semicolon is required within the defined
text it must be preceded by a backslash, i.e. \; in an SRL define
produces ; in the text.
Wherever defname appears elsewhere in the program, it will be
replaced by the defined text.
For example,
DEFINE ftp = (20, 21); # Well-known Port numbers from [ASG-NBR]
DEFINE telnet = 23;
DEFINE www = 80;
2.2 Program
------------+-------+-------- Statement -------+-------+-----------
| | | |
| +------- Declaration ------+ |
| |
+---------------------<--------------------+
An SRL program is a sequence of statements or declarations. It does
not have any special enclosing symbols. Statements and declarations
terminate with a semicolon, except for compound statements, which
terminate with a right brace.
2.3 Declaration
---------------------- Subroutine_declaration ---------------------
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).
3 Statement
----------------+---- IF_statement ----------------+---------------
| |
+---- Compound_statement ----------+
| |
+---- Imperative_statement --------+
| |
+---- CALL_statement --------------+
An SRL program is a sequence of SRL statements. There are four kinds
of statements, as follows.
Brownlee Informational [Page 5]
RFC 2723 SRL: A Traffic Flow Language October 1999
3.1 IF_statement
Test Part Action Part
............. ...............
--- IF --- expression ---+------------+---- Statement ----+--->
| | |
+-- SAVE , --+ |
| |
+-- SAVE ; ----------------------+
>-----------+-----------------------------+-----------------
| |
+-----ELSE --- Statement -----+
3.1.1 expression
-------- term --------+------------------------+-------------------
| |
+--<-- term ----- || ----+ logical OR
3.1.2 term
------- factor -------+------------------------+-------------------
| |
+--<-- factor --- && ----+ logical AND
3.1.3 factor
------------+-------- attrib == operand_list --------+-----------
| |
+------------ ( expression ) --------------+
3.1.4 operand_list
----------+------------------ operand -----------------+-----------
| |
+-- ( operand ---+-------------------+-- ) --+
| |
+-<-- operand , ---+
3.1.5 operand
------------- value ---------+----------------------+--------------
| |
+------- / width ------+
| |
+------- & mask -------+
Brownlee Informational [Page 6]
RFC 2723 SRL: A Traffic Flow Language October 1999
3.1.6 Test Part
The IF statement evaluates a logical expression. If the expression
value is TRUE, the action indicated in the 'Action Part' of the
diagram is executed. If the value is FALSE and the IF has an ELSE
clause, that ELSE clause is executed (see below).
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. A list of
RTFM attributes is given in Appendix C. 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). The syntax for
operand values is given in Appendix B.
Masks may be specified as numbers,
dotted decimal e.g. &255.255
or hexadecimal e.g. &FF-FF
or as a width in bits e.g. /16
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
referred to as an operand. For example, if we were interested in
flows originating from IP network 130.216, we might write:
IF SourcePeerAddress == 130.216.0.0 & 255.255.0.0 SAVE;
or equivalently
IF SourcePeerAddress == 130.216/16 SAVE;
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. For example:
IF SourcePeerAddress == ( 130.216.7/24, 130.216.34/24 ) SAVE;
As this last example indicates, values are right-padded with zeroes,
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 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).
Brownlee Informational [Page 7]
RFC 2723 SRL: A Traffic Flow Language October 1999
3.1.7 Action Part
A SAVE action (i.e. SAVE , or SAVE ;) saves attribute(s), mask(s) and
value(s) as given in the statement. If the IF expression tests more
than one attribute, the masks and values are saved for all the
matched 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"
below. Note that the RETURN action is valid only within subroutines.
3.1.8 ELSE Clause
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?