流技术基础
1.流量流向监控技术
1.1 概述
传统的网络流量监测技术的局限性
SNMP采集端口的数据主要是在网元层用来监控网络流量和设备的性能,而且SNMP采集的数据是基于端口的,无法提供端到端的准确的流量信息,因此对流向的统计手段不明确。
利用RMON探针对运营商网络进行流量和流向管理可以部分弥补SNMP的技术局限性,其业务分析和协议分析功能较强。但是,采用RMON探针建设的流量监测系统也有处理性能不足和难以在大型网络普遍部署的局限性。
提出新的流量监测技术
为克服现有网管系统对网络流量和流向分析功能的技术局限性,运营商迫切需要寻找一种功能丰富、成熟稳定的新技术,对现有管理系统中流量信息的采集和分析方式进行改造和升级。新的流量信息采集和分析技术应具备对运营商的运行网络影响小、无需对网络拓扑进行改变就能平滑升级的技术特征,既可以对网络中各个链路的带宽使用率进行统计,又可以对每条链路上不同类型业务的流量和流向进行分析和统计。
本文主要介绍应用广泛的Cisco NetFlow技术、华为 Netstream技术、Sflow、Cflowd和IPFIX以及支持上述流监测技术的厂家和设备情况 。
1.2 相关厂家及设备
供应商 | 支持的流 | 设备列表 |
Cisco | NetFlow | Cisco - 800、1700、2600、1800、2800、3800、4500、6500、7200、7300、7500、7600、10000、12000、CRS-1 |
3Com | NetFlow | 8800系列交换机 |
Adtran | NetFlow | NetVanta 3200、3305、4305、5305、1524、1624、3430、3448、3130、340和344 |
Riverbed | NetFlow | |
Enterasys | NetFlow | |
Extreme Networks | NetFlow | Alpine 3800系列、BlackDiamond 6800系列、BlackDiamond 8800系列、BlackDiamond 10808、BlackDiamond 12804C、BlackDiamond 12804R、Summit X450系列、Summit i系列(不支持输入/输出接口、octets和最初及最后次数) |
Foundry Networks | NetFlow、sFlow | BigIron系列、FastIron系列、IronPoint系列、NetIron系列、 SecureIron系列、ServerIron系列 |
Juniper Networks | NetFlow、J-Flow | 请参考Juniper Networks白皮书(针对Netflow不支持取样间隔参数、最初和最后次数以秒单位存储) |
Huawei | NetStream | |
H3C | NetStream | |
Nortel | IPFIX | 5500和8600系列 |
AlaxalA Networks | sFlow | AX7800R、AX7800S、AX7700R、AX5400S
|
Alcatel | sFlow | OmniSwitch 6850、OmniSwitch 9000
|
Allied Telesis | sFlow | SwitchBlade 7800R系列、SwitchBlade 7800S系列、SwitchBlade 5400S系列
|
Comtec Systems | sFlow | |
Force10 Networks | sFlow | |
Hewlett-Packard | sFlow | ProCurve 2800系列、ProCurve 3400cl系列、ProCurve 3500yl系列、ProCurve 4200vl系列、ProCurve 5300xl系列、ProCurve 5400zl系列、ProCurve 6200yl系列、ProCurve 6400cl系列、ProCurve 9300m系列、ProCurve Routing Switch 9408sl |
Hitachi | sFlow | |
NEC | sFlow |
2 Netflow
2.1 流原理
netflow 的信息单元是flow。flow是一个单向的带有唯一标识字节组的传输流。基本的标识为:source-IP-address(源IP地址), source-port(源端口), destination-IP-address(目标IP地址), destination-port(目标端口), IP-protocol(IP协议), TOS, input interface ID。当路由器接收到一个没有flow入口的数据包时,一个flow的结构将被初始化以保存其状态信息如:交换的字节数、IP地址、端口、自治区域等。随后所有满足这个flow结构的数据包都将增加flow结构的字节计数和包计数,直至这个flow中止并输出。
Netflow功能是在一个路由器内独立完成,它不涉及路由器之间的任何连接设置协议,也不要求对数据包本身或其它任何网络设备进行任何外部修改。Netflow交换中要创建一个信息高速缓存,第一个数据包到来时,路由器利用标准的快速交换处理信息包,同时生成一个Netflow高速缓存,随后到来的数据包即可以依据高速缓存信息被交换,对于所有活动信息流,在Netflow高速缓存中保留相应的信息流信息。当一定时间内没有相应的数据包通过,则结束这个数据流的交换和统计,并释放高速缓存,数据输出的条件在后续部分描述。
在netflow中到期的flow被绑在UDP数据报中发出。在V5的版本中最多30个flow记录,V1中25个记录,V8中28个记录。至少每秒钟发一次flow。
虽然netflow只提供单向的流量统计。如果希望得到表现双向的统计数据,netflow提供了“canned”的SQL程序来获得一个IP地址对的流量统计数据。
典型的路由器netflow的资源占用率为8%~30%。一般情况下一个netflow收集器接收3-5个路由器的netflow输出。
2.2 输出缓存条件
NetFlow是通过建立高速缓存来实现的,该缓存存放所有活动的流信息。当有一个报文符合流定义时,NetFlow缓存将被建立。缓存终止并输出数据的条件如下:
**传输完成(当看到TCP FIN或RST标志)
**缓存满
**非活动时间超时。空闲流超过n秒,默认15秒,可通过Router(config)# ip flow-cache timeout inactive 130改变默认值
**活动时间超时。流超过n分钟,默认30分钟,可通过Router(config)# ip flow-cache timeout active 20改变默认值
NetFlow缓存如图1所示。
图1 NetFlow Cache示例
2.3 Netflow 报文格式说明
2.3.1 V1
头格式
字段 | 值 |
Version | 0x0001 |
Count | 该报文含有的流记录数 |
System Uptime | 该设备启动的时间(毫秒) |
UNIX Seconds | 自0000 UTC 1970计的时间(秒) |
UNIX NanoSenconds | 自0000 UTC 1970计剩余时间(十亿分之一秒) |
输出报文格式
0 | 1 | 2 | 3 byte | |||
srcaddr | ||||||
dstaddr | ||||||
nexthop | ||||||
input | output | |||||
dPkts | ||||||
dOctets | ||||||
first | ||||||
Last | ||||||
srcport | dstport | |||||
Pad1 | prot | tos | Tcp_flags | |||
Pad2 | Pad3 | reserved |
Bytes | 字段 | 值 |
0-3 | srcaddr | 源ip地址 |
4-7 | dstaddr | 目的ip地址 |
8-11 | nexthop | 下一跳路由器地址 |
12-13 | input | SNMP入口接口ifIndex |
14-15 | output | SNMP出口接口ifIndex |
16-19 | dPkts | 该流的Packets数 |
20-23 | dOctets | 该流的Bytes数 |
24-27 | first | 流开始系统时间 |
28-31 | Last | 流结束系统时间 |
32-33 | srcport | 四层源端口 |
34-35 | dstport | 四层目的端口 |
36 | Pad1 | 未用(0) |
37 | prot | 四层协议(如TCP=6,UDP=17) |
38 | tos | 服务类型 |
39 | Tcp_flags | Cumulative OR of TCP flags |
40 | Pad2 | 未用(0) |
41-42 | Pad3 | 未用(0) |
43 | reserved | 保留 |
2.3.2 V5
头格式
备注:红色部分是Version 5较Version 1新添字段。
字段 | 值 |
Version | 0x0005 |
Count | 该报文含有的流记录数 |
System Uptime | 该设备启动的时间(毫秒) |
UNIX Seconds | 自0000 UTC 1970计的时间(秒) |
UNIX NanoSenconds | 自0000 UTC 1970计剩余时间(十亿分之一秒) |
Sequence Number | 流序号 |
Engine Type | 流转发引擎,0代表RP,1代表VIP/LC |
Engine ID | VIP或LC插槽号码 |
输出报文格式
备注:红色部分是Version 5不同于Version 1的字段。Version 5新增了4个字段用以标示自治域和掩码位。
0 | 1 | 2 | 3 byte | |||
srcaddr | ||||||
dstaddr | ||||||
nexthop | ||||||
input | output | |||||
dPkts | ||||||
dOctets | ||||||
first | ||||||
Last | ||||||
srcport | dstport | |||||
Pad1 | Tcp_flags | prot | tos | |||
src_as | dst_as | |||||
src_mask | dst_mask | pad2 |
Bytes | 字段 | 值 |
0-3 | srcaddr | 源ip地址 |
4-7 | dstaddr | 目的ip地址 |
8-11 | nexthop | 下一跳路由器地址 |
12-13 | input | SNMP入口接口ifIndex |
14-15 | output | SNMP出口接口ifIndex |
16-19 | dPkts | 该流的Packets数 |
20-23 | dOctets | 该流的Bytes数 |
24-27 | first | 流开始系统时间 |
28-31 | Last | 流结束系统时间 |
32-33 | srcport | 四层源端口 |
34-35 | dstport | 四层目的端口 |
36 | Pad1 | 未用(0) |
37 | Tcp_flags | Cumulative OR of TCP flags |
38 | prot | 四层协议(如TCP=6,UDP=17) |
39 | tos | 服务类型 |
40-41 | src_as | 源AS号 |
42-43 | dst_as | 目的AS号 |
44 | Src_mask | 源地址掩码位数 |
45 | Dst_mask | 目的地址掩码位数 |
46-47 | Pad2 | 未用(0) |
2.3.3 V7
头格式
备注:红色部分是Version 7较Version 1新添字段。
字段 | 值 |
Version | 0x0007 |
Count | 该报文含有的流记录数 |
System Uptime | 该设备启动的时间(毫秒) |
UNIX Seconds | 自0000 UTC 1970计的时间(秒) |
UNIX NanoSenconds | 自0000 UTC 1970计剩余时间(十亿分之一秒) |
Sequence Number | 流序号 |
输出报文格式
备注:红色部分是Version 7不同于Version 5的字段
0 | 1 | 2 | 3 byte | |||
Srcaddr | ||||||
Dstaddr | ||||||
Nexthop | ||||||
input | Output | |||||
dPkts | ||||||
dOctets | ||||||
First | ||||||
Last | ||||||
srcport | Dstport | |||||
flags | Tcp_flags | prot | Tos | |||
src_as | dst_as | |||||
src_mask | dst_mask | |||||
pad2 | MLS RP |
|
Bytes | 字段 | 值 |
0-3 | srcaddr | 源ip地址 |
4-7 | dstaddr | 目的ip地址 |
8-11 | nexthop | 下一跳路由器地址 |
12-13 | input | SNMP入口接口ifIndex |
14-15 | output | SNMP出口接口ifIndex |
16-19 | dPkts | 该流的Packets数 |
20-23 | dOctets | 该流的Bytes数 |
24-27 | first | 流开始系统时间 |
28-31 | Last | 流结束系统时间 |
32-33 | srcport | 四层源端口 |
34-35 | dstport | 四层目的端口 |
36 | flags | flow mask in use |
37 | Tcp_flags | Cumulative OR of TCP flags |
38 | prot | 四层协议(如TCP=6,UDP=17) |
39 | tos | 服务类型 |
40-41 | src_as | 源AS号 |
42-43 | dst_as | 目的AS号 |
44-45 | Src_mask | 源地址掩码位数 |
46-47 | Dst_mask | 目的地址掩码位数 |
48 | Pad2 | 未用(0) |
49-50 | MLS RP | IP address of MLS router |
2.3.4 V8
注意:支持IOS12.0(3)T,12.0(3)S12.1及其后续IOS版本
头格式
备注:红色部分是Version 8较Version 5新增字段,该字段体现汇聚功能。
字段 | 值 |
Version | 0x0008 |
Count | 该报文含有的流记录数 |
System Uptime | 该设备启动的时间(毫秒) |
UNIX Seconds | 自0000 UTC 1970计的时间(秒) |
UNIX NanoSenconds | 自0000 UTC 1970计剩余时间(十亿分之一秒) |
Sequence Number | 流序号 |
Engine Type | 0代表RP,1代表VIP/LC |
Engine ID | VIP或LC插槽号码 |
Aggregation | 标识汇聚模式 需添加具体值 |
Agg_version | 汇聚版本 = 2 |
Version 8支持汇聚功能,不同的汇聚模式有其相应的报文格式,下文分别叙述11种汇聚模式的、报文格式。
汇聚功能是Version 8提出的新功能,在Version 9中也支持,它将输出的原始流信息报文按照不同的汇聚模式再一次分类,减少报文量,减轻对网络的负担,同时也能从某种角度来总结网络状况。
为了实现汇聚,设备建立名为汇聚缓存的高速缓存,该缓存用不同字段的组合来实现传统的流的再组合。当流从流缓存中输出时,送入汇聚缓存,进行进一步的组合。汇聚的好处是可以使得最终输出给采集者的报文量减少,减轻对网络的影响。图3表示流输出的过程:
图3 建立NetFlow汇聚缓存
汇聚缓存的超时时间可由以下命令改变:
Router(config)# ip flow-aggregation cache prefix
Router(config)# cache timeout active 25
Router(config)# cache timeout inactive 400
汇聚模式分两类——non-TOS based aggregation schemes、TOS based aggregation schemes.
non-TOS based aggregation schemes有5类,分别是:
• AS Aggregation Scheme
•Destination-Prefix Aggregation Scheme
•Protocol-Port Aggregation Scheme
•Source Prefix Aggregation Scheme
TOS based aggregation schemes有6类,分别是:
•AS-ToS Aggregation Scheme
•Destination-Prefix-ToS Aggregation Scheme
•Prefix-ToS Aggregation Scheme
•Protocol-Port-ToS Aggregation Scheme
•Source Prefix-ToS Aggregation Scheme
•Prefix-Port Aggregation Scheme
每一种汇聚模式都对应相应的报文,下文分别叙述各种汇聚模式所对应的报文格式。
non-TOS based aggregation scheme
下表总结了基于non-TOS 5种汇聚模式所使用的字段
字段 | AS | Protocol Port | Source Prefix | Destination Prefix | Prefix |
源网络前缀 |
|
| Y |
| Y |
源网络前缀掩码 |
|
| Y |
| Y |
目的网络前缀 |
|
|
| Y | Y |
目的网络前缀掩码 |
|
|
| Y | Y |
源端口号 |
| Y |
|
|
|
目的端口号 |
| Y |
|
|
|
输入接口号 | Y |
| Y |
| Y |
输出接口号 | Y |
|
| Y | Y |
IP协议类型 |
| Y |
|
|
|
源AS | Y |
| Y |
| Y |
目的AS | Y |
|
| Y | Y |
第一个报文时间戳 | Y | Y | Y | Y | Y |
最后一个报文时间戳 | Y | Y | Y | Y | Y |
流个数 | Y | Y | Y | Y | Y |
报文个数 | Y | Y | Y | Y | Y |
字节数 | Y | Y | Y | Y | Y |
AS 汇聚
该汇聚模式基于BGP AS进行汇聚,产生AS-AS的流记录,记录以下信息:
源和目的BGP AS
汇聚记录的流个数
汇聚记录的报文个数
汇聚记录的字节数
第一个报文转发时间戳及最后一个报文转发时间戳
Bytes | 字段 | 值 |
0-3 | Flows | 汇聚的原始流个数 |
4-7 | dPkts | 汇聚的流报文个数 |
8-11 | dOctets | 汇聚的流字节数 |
12-15 | First | 第一个报文转发的系统时间 |
16-19 | Last | 最后一个报文转发的系统时间 |
20-21 | Src_as | 源ip的AS号 |
22-23 | Dst_as | 目的ip的AS号 |
24-25 | Input | 输入接口的SNMP索引号 |
26-27 | Output | 输出接口的SNMP索引号 |
目的网络前缀汇聚
该汇聚模式基于目的网络地址,掩码以及目的AS进行汇聚,记录以下信息:
目的网络前缀,即IP地址的网络部分
目的网络前缀掩码,即网络地址掩码
目的BGP AS号
汇聚记录的流个数
汇聚记录的报文个数
汇聚记录的字节数
输出接口
第一个报文转发时间戳及最后一个报文转发时间戳
Bytes | 字段 | 值 |
0-3 | Flows | 汇聚的原始流个数 |
4-7 | dPkts | 汇聚的流报文个数 |
8-11 | dOctets | 汇聚的流字节数 |
12-15 | First | 第一个报文转发的系统时间 |
16-19 | Last | 最后一个报文转发的系统时间 |
20-23 | Dst_prefix | 目的地址的网络前缀,即网络号 |
24 | Dst_mask | 目的地址的掩码位的个数(bits) |
25 | Pad | 0 |
26-27 | Dst_as | 目的ip的AS号 |
28-29 | Output | 输出接口的SNMP索引号 |
30-31 | Reserved | 0 |
网络前缀汇聚
该汇聚模式基于网络前缀、掩码和AS号进行汇聚,记录以下信息:
源和目的地址网络前缀
源和目的地址掩码
源和目的BGP AS号
汇聚记录的流个数
汇聚记录的报文个数
汇聚记录的字节数
输入和输出接口
第一个报文转发时间戳及最后一个报文转发时间戳
Bytes | 字段 | 值 |
0-3 | Flows | 汇聚的原始流个数 |
4-7 | dPkts | 汇聚的流报文个数 |
8-11 | dOctets | 汇聚的流字节数 |
12-15 | First | 第一个报文转发的系统时间 |
16-19 | Last | 最后一个报文转发的系统时间 |
20-23 | Src_prefix | 源地址的网络前缀,即网络号 |
24-27 | Dst_prefix | 目的地址的网络前缀,即网络号 |
28 | Dst_mask | 目的地址的掩码位的个数(bits) |
29 | Src_mask | 源地址的掩码位的个数(bits) |
30 | Pad | 0 |
31-32 | Src_as | 源ip的AS号 |
33-34 | Dst_as | 目的ip的AS号 |
35-36 | Input | 输入接口的SNMP索引号 |
37-28 | Output | 输出接口的SNMP索引号 |
协议_端口汇聚
该模式基于协议类型进行汇聚,产生同属一类协议的流记录,记录以下信息:
源和目的端口号
IP协议类型
汇聚记录的流个数
汇聚记录的报文个数
汇聚记录的字节数
第一个报文转发时间戳及最后一个报文转发时间戳
Bytes | 字段 | 值 |
0-3 | Flows | 汇聚的原始流个数 |
4-7 | dPkts | 汇聚的流报文个数 |
8-11 | dOctets | 汇聚的流字节数 |
12-15 | First | 第一个报文转发的系统时间 |
16-19 | Last | 最后一个报文转发的系统时间 |
20 | prot | IP协议类型 |
21 | Pad | 0 |
22-23 | reserved | 0 |
24-25 | Srcport | 源端口号 |
26-27 | dstport | 目标端口号 |
源网络前缀汇聚
该汇聚模式基于源网络地址、掩码及AS号进行汇聚,记录以下信息:
源网络前缀,即IP地址的网络部分
源网络前缀掩码,即网络地址掩码
源BGP AS号
汇聚记录的流个数
汇聚记录的报文个数
汇聚记录的字节数
输入接口
第一个报文转发时间戳及最后一个报文转发时间戳
Bytes | 字段 | 值 |
0-3 | Flows | 汇聚的原始流个数 |
4-7 | dPkts | 汇聚的流报文个数 |
8-11 | dOctets | 汇聚的流字节数 |
12-15 | First | 第一个报文转发的系统时间 |
16-19 | Last | 最后一个报文转发的系统时间 |
20-23 | Src_prefix | 源地址的网络前缀,即网络号 |
24 | Src_mask | 源地址的掩码位的个数(bits) |
25 | Pad | 0 |
26-27 | Src_as | 源ip的AS号 |
28-29 | input | 输入接口的SNMP索引号 |
30-31 | Reserved | 0 |
下表总结了基于TOS 6种汇聚模式所使用的字段
字段 | AS-TOS | Protocol Port-TOS | Source Prefix-TOS | Destination Prefix-TOS | Prefix-TOS | Prefix-Port |
源网络前缀 |
|
| Y |
| Y | Y |
源网络前缀掩码 |
|
| Y |
| Y | Y |
目的网络前缀 |
|
|
| Y | Y | Y |
目的网络前缀掩码 |
|
|
| Y | Y | Y |
源端口号 |
| Y |
|
|
| Y |
目的端口号 |
| Y |
|
|
| Y |
输入接口号 | Y | Y | Y |
| Y | Y |
输出接口号 | Y | Y |
| Y | Y | Y |
IP协议类型 |
| Y |
|
|
| Y |
源AS | Y |
| Y |
| Y |
|
目的AS | Y |
|
| Y | Y |
|
服务类型 | Y | Y | Y | Y | Y | Y |
第一个报文时间戳 | Y | Y | Y | Y |
| Y |
最后一个报文时间戳 | Y | Y | Y | Y |
| Y |
流个数 | Y | Y | Y | Y |
| Y |
报文个数 | Y | Y | Y | Y |
| Y |
字节数 | Y | Y | Y | Y |
| Y |
AS-ToS 汇聚
该汇聚模式基于源和目的AS,源和目的接口以及ToS进行汇聚,记录以下信息:
源和目的BGP AS
ToS
汇聚记录的流个数
汇聚记录的报文个数
汇聚记录的字节数
源和目的接口
第一个报文转发时间戳及最后一个报文转发时间戳
Bytes | 字段 | 值 |
0-3 | Flows | 汇聚的原始流个数 |
4-7 | dPkts | 汇聚的流报文个数 |
8-11 | dOctets | 汇聚的流字节数 |
12-15 | First | 第一个报文转发的系统时间 |
16-19 | Last | 最后一个报文转发的系统时间 |
20-21 | Src_as | 源ip的AS号 |
22-23 | Dst_as | 目的ip的AS号 |
24-25 | Input | 输入接口的SNMP索引号 |
26-27 | Output | 输出接口的SNMP索引号 |
28 | Tos | 服务类型 |
29 | pad | 0 |
30-31 | reserved | 0 |
目的网络前缀-ToS 汇聚
该汇聚模式基于目的网络地址,掩码,目的AS以及ToS进行汇聚,记录以下信息:
目的网络前缀,即IP地址的网络部分
目的网络前缀掩码,即网络地址掩码
目的BGP AS号
ToS
汇聚记录的流个数
汇聚记录的报文个数
汇聚记录的字节数
输出接口
第一个报文转发时间戳及最后一个报文转发时间戳
Bytes | 字段 | 值 |
0-3 | Flows | 汇聚的原始流个数 |
4-7 | dPkts | 汇聚的流报文个数 |
8-11 | dOctets | 汇聚的流字节数 |
12-15 | First | 第一个报文转发的系统时间 |
16-19 | Last | 最后一个报文转发的系统时间 |
20-23 | Dst_prefix | 目的地址的网络前缀,即网络号 |
24 | Dst_mask | 目的地址的掩码位的个数(bits) |
25 | Tos | 服务类型 |
26-27 | Dst_as | 目的ip的AS号 |
28-29 | Output | 输出接口的SNMP索引号 |
30-31 | Reserved | 0 |
网络前缀-ToS 汇聚
该汇聚模式基于网络前缀、掩码、AS号以及ToS进行汇聚,记录以下信息:
源和目的地址网络前缀
源和目的地址掩码
源和目的BGP AS号
ToS
汇聚记录的流个数
汇聚记录的报文个数
汇聚记录的字节数
输入和输出接口
第一个报文转发时间戳及最后一个报文转发时间戳
Bytes | 字段 | 值 |
0-3 | Flows | 汇聚的原始流个数 |
4-7 | dPkts | 汇聚的流报文个数 |
8-11 | dOctets | 汇聚的流字节数 |
12-15 | First | 第一个报文转发的系统时间 |
16-19 | Last | 最后一个报文转发的系统时间 |
20-23 | Src_prefix | 源地址的网络前缀,即网络号 |
24-27 | Dst_prefix | 目的地址的网络前缀,即网络号 |
28 | Dst_mask | 目的地址的掩码位的个数(bits) |
29 | Src_mask | 源地址的掩码位的个数(bits) |
30 | Tos | 服务类型 |
31 | pad | 0 |
32-33 | Src_as | 源ip的AS号 |
34-35 | Dst_as | 目的ip的AS号 |
36-37 | Input | 输入接口的SNMP索引号 |
38-39 | Output | 输出接口的SNMP索引号 |
协议-端口-ToS 汇聚
该模式基于协议类型、ToS以及入口出口接口进行汇聚,记录以下信息:
源和目的端口号
源和目的接口
IP协议类型
ToS
汇聚记录的流个数
汇聚记录的报文个数
汇聚记录的字节数
第一个报文转发时间戳及最后一个报文转发时间戳
Bytes | 字段 | 值 |
0-3 | Flows | 汇聚的原始流个数 |
4-7 | dPkts | 汇聚的流报文个数 |
8-11 | dOctets | 汇聚的流字节数 |
12-15 | First | 第一个报文转发的系统时间 |
16-19 | Last | 最后一个报文转发的系统时间 |
20 | prot | IP协议类型 |
21 | Tos | 服务类型 |
22-23 | reserved | 0 |
24-25 | Srcport | 源端口号 |
26-27 | dstport | 目标端口号 |
28-29 | Input | 输入接口的SNMP接口索引 |
30-31 | output | 输出接口的SNMP接口索引 |
源网络前缀-ToS 汇聚
该汇聚模式基于源网络地址、掩码、AS号及ToS进行汇聚,记录以下信息:
源网络前缀,即IP地址的网络部分
源网络前缀掩码,即网络地址掩码
源BGP AS号
ToS
汇聚记录的流个数
汇聚记录的报文个数
汇聚记录的字节数
输入接口
第一个报文转发时间戳及最后一个报文转发时间戳
Bytes | 字段 | 值 |
0-3 | Flows | 汇聚的原始流个数 |
4-7 | dPkts | 汇聚的流报文个数 |
8-11 | dOctets | 汇聚的流字节数 |
12-15 | First | 第一个报文转发的系统时间 |
16-19 | Last | 最后一个报文转发的系统时间 |
20-23 | Src_prefix | 源地址的网络前缀,即网络号 |
24 | Src_mask | 源地址的掩码位的个数(bits) |
25 | Tos | 服务类型 |
26-27 | Src_as | 源ip的AS号 |
28-29 | input | 输入接口的SNMP索引号 |
30-31 | Reserved | 0 |
网络前缀-端口 汇聚
该汇聚模式基于网络前缀、掩码、端口号、接口号、协议类型以及ToS进行汇聚,记录以下信息:
源和目的地址网络前缀
源和目的地址掩码
源和目的端口号
源和目的接口
协议类型
ToS
汇聚记录的流个数
汇聚记录的报文个数
汇聚记录的字节数
输入和输出接口
第一个报文转发时间戳及最后一个报文转发时间戳
Bytes | 字段 | 值 |
0-3 | Flows | 汇聚的原始流个数 |
4-7 | dPkts | 汇聚的流报文个数 |
8-11 | dOctets | 汇聚的流字节数 |
12-15 | First | 第一个报文转发的系统时间 |
16-19 | Last | 最后一个报文转发的系统时间 |
20-23 | Src_prefix | 源地址的网络前缀,即网络号 |
24-27 | Dst_prefix | 目的地址的网络前缀,即网络号 |
28 | Dst_mask | 目的地址的掩码位的个数(bits) |
29 | Src_mask | 源地址的掩码位的个数(bits) |
30 | Tos | 服务类型 |
31 | prot | IP协议类型 |
32-33 | Srcport | 源端口号 |
34-35 | Dstport | 目的端口号 |
36-37 | Input | 输入接口的SNMP索引号 |
38-39 | Output | 输出接口的SNMP索引号 |
2.3.5 V9
2.3.5.1 Template简介
在Version 9之前的NetFlow流记录版本都是固定格式的,报文中的字段都是固定的,不可更改。版本9提出了模版的概念,使得管理者可以根据自己的需求定义流记录中的字段。模版提供了一种可扩展的方式,使得在不改变现有的基础流记录的条件下,增加更多的信息。使用模版有以下好处:
提供采集器或NetFlow显示服务的三方无需在新的NetFlow特性加入后修改自己的产品
新的特性可以很快地加入NetFlow,而不用停掉当前使用
随着协议的发展,NetFlow可随之发展,这是因为Version 9的灵活性和适应性
2.3.5.2 相关术语
Observation Point:观察点,通常就是一个接口。定义为在网络中可以观察到IP报文的点。
Observation Domain:观察域,通常就是一个线卡,由很多接口组成。定义为一组观察点,这些观察点都运行了NetFlow服务,可提供一组流的汇聚记录。
FlowSet:报文头之后的内容。FlowSet是输出数据中流记录的通称,包括两类:模版和数据。一个输出报文中包含一个或多个FlowSets,模版和数据FlowSets可以混入同一个输出报文。
模版FlowSet:一个输出报文中含有一个或多个模版FlowSets。
模版记录:定义模版,之后的输出数据记录报文必须符合模版记录。在同一个报文中,如果既有模版记录又有数据记录,那么数据记录不需要一定符合该模版记录,采集器必须缓存模版记录,数据记录只要符合采集器中的模版就可以了。
模版ID:用以区分不同的模版。
数据FlowSet:一个数据报文可含有多个数据FlowSets。
数据记录:数据记录提供ip流信息,数据记录必须含有模版ID,采集器根据模版ID分析数据内容。
可选模版:可选模版是一种特殊的模版记录,用以与NetFlow处理器沟通数据格式。
可选数据记录:可选数据记录是一种特殊的数据记录,使用保留的模版ID,提供NetFlow处理器本身的信息。
2.3.5.3 V9模版管理
输出端负责输出模版和数据,理论上讲,应该在数据输出之前输出模版,这样接收端采集器才可以知道怎样来解析接收到的数据。输出端的模版记录是随着NetFlow进程而产生和消亡的。如果输出端或NetFlow进程死掉或重起,那么所有的模版信息都会丢失,而会创建新的模版ID。如果模版配置改变,丢弃现有的模版id,而这个id将不能再重用,直到重起NetFlow进程或整个输出端。当接收端采集器接收到一个现存模版id的定义,丢弃原有的定义,使用新的定义。当输出端的模版记录删除并有一条参数完全一样的记录,可以使用同样的模版ID。在以下三种情况,输出端将输出模版FlowSet:
NetFlow进程重起,输出端在输出数据之前必须将相应的模版发送给采集者,模版信息要么包含在数据之前的报文里,要么包含在该数据所在报文里。这一点保证接收者可以正确解析收到的数据。
当配置改变时,输出端必须尽快的发送新的模版定义。
定时更新。根据两种模式,输出端必须发送所有的模版和options模版记录给采集者:基于报文,即每发送N个报文就必须嵌入模版信息发送给采集者;基于时间,即每过N分钟就要发送一次模版信息。这两个参数都必须在输出端进行配置,当一个超时,输出端必须发送模版FlowSet和Options模版。
输出端时钟配置发生改变,输出端应尽快发送模版定义。(In the event of a clock configuration change on the Exporter, the Exporter SHOULD send the template definitions at an accelerated rate.)
一般来讲,采集器收到数据前,都应先收到相应的模版,但如果收到的数据中的模版ID在本地没有记录,应将该报文保存下来,等到收到模版定义之后再解析,而不是简单的丢弃该报文。采集器存储的模版定时死亡,需要定时更新,如果模版没有得到输出端的定义更新,超时之后将宣告死亡,采集器不能再使用该模版解析数据。采集器维护以下参数:Exporter、Observation Domain、模版ID、模版定义、最近一次接收时间。模版ID在每个输出端的每个Observation域里是唯一的。
2.3.5.4 V9报文
一个报文里至少含有1个或多个模版或数据FlowSets。如下图:
一个报文中模版和数据可能的组合包括以下三种:
模版FlowSets和数据FlowSets交叉组合—这种方式中的模版和数据并没有必然联系。
纯数据FlowSets—大部分的输出数据都是这种模式。
纯模版FlowSets—这种情况比较少。一般来讲,模版都是插入数据中发送的。当路由器刚刚启动或重起时,为了跟采集器同步,路由器发送只含有模版的报文。模版记录是有寿命的,它们必须周期性的更新。在更新期间,有可能没有合适的数据发送,那么将发送只含模版的报文。
思科支持的字段类型:
2.3.5.5 FlowSet格式
2.3.5.6 Options模板
该模版不是用于描述ip流,而是描述NetFlow处理器本身的元数据信息。
|
|
2.3.5.7 软硬件支持
V9首次在12.0(24)S中提出,在后来的12.3(1)中,debug ip flow export加入了v9的信息,v9还被整合到了12.2(18)S中。
支持的硬件平台有:
Cisco 2600 series
Cisco 3600 series
Cisco 7100 series
Cisco 7200 series
Cisco 7300 series
Cisco 7400 series
Cisco 7500 series
Cisco 12000 series
2.3.5.8 限制条件
V9并不兼容V5或V8。如果需要V5或V8,必须配置它们。
带宽需求比V5大,这是因为增加了模版。
V9轻微的降低了性能,因为产生和保存模版需要额外的处理。
2.3.5.9 V9配置方法
本节以IOS12.3为例,介绍其配置方法,对照12.0S配置,两者一样。12.4参见6.1.4.1。
1. enable
4. ip flow-export template refresh-rate packets
5. ip flow-export template timeout-rate minutes
6. ip flow-export template options export-stats
7. ip flow-export template options refresh-rate packets
8. ip flow-export template options timeout-rate minutes
具体步骤:
总体步骤
1. enable
3. ip flow-aggregation cache {as | as-tos | bgp-nexthop-tos | destination-prefix | destination-prefix-tos | prefix | prefix-port | prefix-tos | protocol-port | protocol-port-tos | source-prefix | source-prefix-tos}
***在12.4配置中,这条命令加入了输出目的地址,事实上,其他配置均一样,就这点区别***
5. export template refresh-rate packets
6. export template timeout-rate minutes
具体步骤:
debug ip flow export
举例
例1
Src IP addr. | Dst IP addr. | Next Hop addr. | Packet | Bytes
198.168.1.12 | 10.5.12.254 | 192.168.1.1 | 5009 | 5344385
192.168.1.27 | 10.5.12.23 | 192.168.1.1 | 748 | 388934
192.168.1.56 | 10.5.12.65 | 192.168.1.1 | 5 | 6534
• 输出报文既有模版又有数据Export packets can be composed of both template and data FlowSets.
• 模版和数据是交叉组合的Template and data FlowSets can be interleaved.
2.4 配置方法
2.4.1 开启NetFlow的先决条件
•配置路由器IP路由
***事实上,我查阅了其他版本的IOS,如12.1,并没有这一项的限制,由于CEF功能影响NetFlow的其它功能的开启,我个人观点是如果路由器支持CEF功能,那就把它打开***
2.4.2 在接口上开启NetFlow
总体步骤:
1. enable
4. interface type slot/port-adapter/port
或
interface type slot/port
5. ip address ip-address mask [secondary]
6. ip flow ingress
或
ip route-cache flow 启动信息流交换
7. do show ip interface [type number] [brief]
具体步骤:
举例:
如果NetFlow已开启,输入(do)show ip interface会有如下显示:“IP Flow switching is enabled”,在该命令之后加竖线,之后include Flow,就可以看到只含“flow”字样的输出。
Router(config-if)# do show ip interface ethernet 3/1 | include Flow
IP Selective flow switching turbo vector
IP route-cache flags are Fast, Flow cache, Subif Flow
也可以使用(do)show running_config来查看:
Router(config-if)# do show running-config interface ethernet 3/1
Current configuration : 83 bytes
ip address 172.16.245.2 255.255.255.0
2.4.3 配置输出NetFlow数据
总体步骤:
1. enable
3. ip flow-export version 5 [origin-as | peer-as] [bgp-nexthop]
***在早期的IOS版本中,该命令bgp-nexthop是不支持的,只有origin-as | peer-as两种选择***
或
ip flow-export version 9 [origin-as | peer-as] [bgp-nexthop]
***只有支持Version 9的才支持该命令***
如果是早期IOS(12.1之前),使用以下命令:
ip flow-export ip-address udp-port [version 1]
ip flow-export ip-address udp-port version 5 [origin-as | peer-as] 把统计信息输出到一个指定工作站
4. ip flow-export destination ip-address udp-port
具体步骤:
2.4.4 验证配置
命令如下:
1.show ip interface [type number] [brief]
2.show ip cache [prefix mask] flow
3.show ip cache [prefix mask] verbose flow
举例:
1.show ip interface [type number] [brief]
Router# show ip interface ethernet 1/0 | include Flow
Router# show ip interface ethernet 1/0 | include Flow
IP Selective Flow switching turbo vector
IP route-cache flags are Fast, Flow cache, Subif Flow
2.show ip cache [prefix mask] flow
Router# show ip cache flow
IP packet size distribution (25 total packets):
1-32 64 96 128 160 192 224 256 288 320 352 384 416 448 480
.000 .000 .000 1.00 .000 .000 .000 .000 .000 .000 .000 .000 .000 .000 .000
512 544 576 1024 1536 2048 2560 3072 3584 4096 4608
.000 .000 .000 .000 .000 .000 .000 .000 .000 .000 .000
IP Flow Switching Cache, 4456704 bytes
1 active, 65535 inactive, 5 added
68 ager polls, 0 flow alloc failures
Active flows timeout in 30 minutes
Inactive flows timeout in 15 seconds
last clearing of statistics never
Protocol Total Flows Packets Bytes Packets Active(Sec) Idle(Sec)
-------- Flows /Sec /Flow /Pkt /Sec /Flow /Flow
Total: 4 0.0 5 100 0.0 0.0 15.2
SrcIf SrcIPaddress DstIf DstIPaddress Pr SrcP DstP Pkts
Et1/2 10.0.0.2 Local 10.0.0.1 01 0000 0800 5
3.show ip cache [prefix mask] verbose flow
Router# show ip cache verbose flow
IP packet size distribution (6 total packets):
1-32 64 96 128 160 192 224 256 288 320 352 384 416 448 480
.000 .833 .166 .000 .000 .000 .000 .000 .000 .000 .000 .000 .000 .000 .000
512 544 576 1024 1536 2048 2560 3072 3584 4096 4608
.000 .000 .000 .000 .000 .000 .000 .000 .000 .000 .000
IP Flow Switching Cache, 278544 bytes
1 active, 4095 inactive, 2 added
25 ager polls, 0 flow alloc failures
Active flows timeout in 30 minutes
Inactive flows timeout in 15 seconds
IP Sub Flow Cache, 17096 bytes
1 active, 1023 inactive, 2 added, 2 added to flow
0 alloc failures, 0 force free
last clearing of statistics never
Protocol Total Flows Packets Bytes Packets Active(Sec) Idle(Sec)
-------- Flows /Sec /Flow /Pkt /Sec /Flow /Flow
TCP-BGP 1 0.0 4 57 0.0 0.3 15.4
Total: 1 0.0 4 57 0.0 0.3 15.4
SrcIf SrcIPaddress DstIf DstIPaddress Pr TOS Flgs Pkts
Port Msk AS Port Msk AS NextHop B/Pk Active
Et0/0 10.3.3.3 Local 10.3.3.4 06 C0 18 2
2AF8 /24 0 00B3 /24 0 172.16.0.2 49 0.2
4.show ip flow export
Router# show ip flow export
Exporting flows to 10.42.42.1 (9991) 10.0.101.254 (9991)
Exporting using source IP address 10.0.101.203
Export Stats for 10.42.42.1 (9991)
3 flows exported in 3 udp datagrams
0 flows failed due to lack of export packet
3 export packets were sent up to process level
0 export packets were dropped due to no fib
0 export packets were dropped due to adjacency issues
0 export packets were dropped enqueuing for the RP
0 export packets were dropped due to IPC rate limiting
Export Stats for 10.0.101.254 (9991)
7 flows exported in 7 udp datagrams
0 flows failed due to lack of export packet
6 export packets were sent up to process level
0 export packets were dropped due to no fib
0 export packets were dropped due to adjacency issues
0 export packets were dropped enqueuing for the RP
0 export packets were dropped due to IPC rate limiting
2.5 采样NetFlow
2.5.1 采样模式
思科首次将报文采样技术应用在Cisco12000路由器上,采样NetFlow从流入数据中进行采样,大大减少了路由器CPU的使用,减少输出数据的数目,但仍可以得到大部分IP流的状态视图。
采样模式有三种:确定式采样,定时采样和随机采样。确定式采样固定的每N个报文采第N个,N可以指定。随机采样则每N个报文随机采其中一个。定时采样固定的每N毫秒采一个。一般的,随机采样是最佳选择。
2.5.2 采样NetFlow软硬件平台支持
下表列举支持采样的软硬件平台。
Cisco12000采样模式跟line card有关,如下表所列:
| ||
|
| |
|
下表列举Cisco12000采样NetFlow和普通NetFlow版本信息与IOS版本之间的关系
| ||||
下文以随机采样模式为例,介绍其配置过程。(IOS 12.3T)
2.5.3 随机采样 NetFlow先决条件
在配置随机抽样NetFlow之前,必须先配置以下条目:
CEF转发或dCEF转发(不支持快速转发)
NetFlow Version5或9
如果要使用sampler options templates需得到NetFlow sampler的id,配置NetFlow Version 9
2.5.4 随机采样 NetFlow路由器配置
随机抽样NetFlow支持在子接口上配置,也可以在物理接口上配置,但在物理接口上配置的随机抽样将不会自动应用于对应的子接口。
随机抽样使用NetFlow采样地图(NetFlow sampler map)来定义抽样特性,比如采样率和采样地图名等。每一个地图都可用于一个或多个子接口和物理接口,最多可定义8个采样地图。
随机采样将大大减少输出的数据量。百分之一采样率可使NetFlow数据输出减少一半。
整个配置过程分为四步,其中前两步是必选的,后两项是可选的。
定义NetFlow Sampler Map
将定义的NetFlow Sampler Map应用于一个接口
检查配置
排错
定义NetFlow Sampler Map
总体步骤:
3. flow-sampler-map sampler-map-name
4. mode random one-out-of sampling-rate
具体步骤:
| ||
Step 1 | Example: | |
Step 2 | Example: | |
Step 3 | flow-sampler-map sampler-map-name Example: | |
Step 4
| mode random one-out-of sampling-rate Example: | |
Step 5 | Example: |
举例:
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)# flow-sampler-map mysampler1
Router(config-sampler)# mode random one-out-of 100
3w5d: %SYS-5-CONFIG_I: Configured from console by console
将定义好的NetFlow Sampler Map应用到接口上
总体步骤:
4. flow-sampler sampler-map-name
| ||
Step 1 | Example: | 如有密码,输入密码 |
Step 2 | Example: | |
Step 3 | Example: | |
Step 4 | Example: | |
Step 5 | Example: |
举例:
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)# interface ethernet 1
Router(config-if)# flow-sampler mysampler1
3w5d:%SYS-5-CONFIG_I: Configured from console by console
验证配置
总体步骤:
show flow-sampler
具体步骤:
show flow-sampler [sampler-map-name] Example: | |
Example: | |
Example: |
2.5.5 举例
Router# show ip cache flow
IP packet size distribution (12718M total packets):
1-32 64 96 128 160 192 224 256 288 320 352 384 416 448 480
.000 .554 .042 .017 .015 .009 .009 .009 .013 .030 .006 .007 .005 .004 .004
512 544 576 1024 1536 2048 2560 3072 3584 4096 4608
.003 .007 .139 .019 .098 .000 .000 .000 .000 .000 .000
IP Flow Switching Cache, 4456448 bytes
65509 active, 27 inactive, 820628747 added
955454490 ager polls, 0 flow alloc failures
Exporting flows to 1.1.15.1 (2057)
820563238 flows exported in 34485239 udp datagrams, 0 failed
last clearing of statistics 00:00:03
Protocol Total Flows Packets Bytes Packets Active(Sec) Idle(Sec)
Flows /Sec /Flow /Pkt /Sec /Flow /Flow
TCP-Telnet 2656855 4.3 86 78 372.3 49.6 27.6
TCP-FTP 5900082 9.5 9 71 86.8 11.4 33.1
TCP-FTPD 3200453 5.1 193 461 1006.3 45.8 33.4
TCP-WWW 546778274 887.3 12 325 11170.8 8.0 32.3
TCP-SMTP 25536863 41.4 21 283 876.5 10.9 31.3
TCP-X 116391 0.1 231 269 43.8 68.2 27.3
TCP-BGP 24520 0.0 28 216 1.1 26.2 39.0
TCP-Frag 56847 0.0 24 952 2.2 13.1 33.2
TCP-other 49148540 79.7 47 338 3752.6 30.7 32.2
UDP-DNS 117240379 190.2 3 112 570.8 7.5 34.7
UDP-NTP 9378269 15.2 1 76 16.2 2.2 38.7
UDP-TFTP 8077 0.0 3 62 0.0 9.7 33.2
UDP-Frag 51161 0.0 14 322 1.2 11.0 39.4
UDP-other 45502422 73.8 30 174 2272.7 8.5 37.8
ICMP 14837957 24.0 5 224 125.8 12.1 34.3
IGMP 40916 0.0 170 207 11.3 197.3 13.5
IPINIP 3988 0.0 48713 393 315.2 644.2 19.6
GRE 3838 0.0 79 101 0.4 47.3 25.9
IP-other 77406 0.1 47 259 5.9 52.4 27.0
Total: 820563238 1331.7 15 304 20633.0 9.8 33.0
SrcIf SrcIPaddress DstIf DstIPaddress Pr SrcP DstP Pkts B/Pk Active
Fd0/0 80.0.0.3 Hs1/0 200.1.9.1 06 0621 0052 7 87 5.9
Fd0/0 80.0.0.3 Hs1/0 200.1.8.1 06 0620 0052 7 87 1.8
Hs1/0 200.0.0.3 Fd0/0 80.1.10.1 06 0052 0621 6 58 1.8
Hs1/0 200.0.0.3 Fd0/0 80.1.1.1 06 0052 0620 5 62 5.9
Fd0/0 80.0.0.3 Hs1/0 200.1.3.1 06 0723 0052 16 68 0.3
HS1/0 200.0.0.3 Fd0/0 80.1.2.1 06 0052 0726 6 58 11.8
Fd0/0 80.0.0.3 Hs1/0 200.1.5.1 06 0726 0052 6 96 0.3
Hs1/0 200.0.0.3 Fd0/0 80.1.4.1 06 0052 0442 3 76 0.3
Hs1/0 200.0.0.3 Fd0/0 80.1.7.1 06 0052 D381 11 1171 0.6
Router# show ip cache verbose flow
IP packet size distribution (12718M total packets):
1-32 64 96 128 160 192 224 256 288 320 352 384 416 448 480
.000 .554 .042 .017 .015 .009 .009 .009 .013 .030 .006 .007 .005 .004 .004
512 544 576 1024 1536 2048 2560 3072 3584 4096 4608
.003 .007 .139 .019 .098 .000 .000 .000 .000 .000 .000
IP Flow Switching Cache, 4456448 bytes
65509 active, 27 inactive, 820628747 added
955454490 ager polls, 0 flow alloc failures
Exporting flows to 1.1.15.1 (2057)
820563238 flows exported in 34485239 udp datagrams, 0 failed
last clearing of statistics 00:00:03
Protocol Total Flows Packets Bytes Packets Active(Sec) Idle(Sec)
Flows /Sec /Flow /Pkt /Sec /Flow /Flow
TCP-Telnet 2656855 4.3 86 78 372.3 49.6 27.6
TCP-FTP 5900082 9.5 9 71 86.8 11.4 33.1
TCP-FTPD 3200453 5.1 193 461 1006.3 45.8 33.4
TCP-WWW 546778274 887.3 12 325 11170.8 8.0 32.3
TCP-SMTP 25536863 41.4 21 283 876.5 10.9 31.3
TCP-X 116391 0.1 231 269 43.8 68.2 27.3
TCP-BGP 24520 0.0 28 216 1.1 26.2 39.0
TCP-Frag 56847 0.0 24 952 2.2 13.1 33.2
TCP-other 49148540 79.7 47 338 3752.6 30.7 32.2
UDP-DNS 117240379 190.2 3 112 570.8 7.5 34.7
UDP-NTP 9378269 15.2 1 76 16.2 2.2 38.7
UDP-TFTP 8077 0.0 3 62 0.0 9.7 33.2
UDP-Frag 51161 0.0 14 322 1.2 11.0 39.4
UDP-other 45502422 73.8 30 174 2272.7 8.5 37.8
ICMP 14837957 24.0 5 224 125.8 12.1 34.3
IGMP 40916 0.0 170 207 11.3 197.3 13.5
IPINIP 3988 0.0 48713 393 315.2 644.2 19.6
GRE 3838 0.0 79 101 0.4 47.3 25.9
IP-other 77406 0.1 47 259 5.9 52.4 27.0
Total: 820563238 1331.7 15 304 20633.0 9.8 33.0
SrcIF SrcIPaddress DstIf DstIPaddress Pr TOS Flgs Pkts
port Msk AS Port Msk AS NextHop B/Pk Active
Se0/1 193.1.1.3 Se0/0 172.17.246.228 11 00 10 5
00A1 /24 193 C628 /0 0 0.0.0.0 84 39.7
2.6 Cisco路由器
2.6.1 版本支持系列
Cisco IOS软件发布版本 | 支持的Cisco硬件平台 |
11.1CA, 11.1CC | Cisco 7200 及 7500系列, RSP 7200系列 |
12.0 | Cisco 1720, 2600, 3600, 4500, 4700, AS5800 |
12.0T, 12.0S | Cisco 1720, 2600, 3600, 4500, 4700, AS5800 |
12.0(3)T, 12.0(3)S | Cisco 1720, 2600, 3600, 4500, 4700, AS5300, AS5800 |
12.0(4)T | Cisco 1400, 1600, 1720, 2500, 2600, 3600, 4500, |
12.0(4)XE | Cisco 7100 系列 |
12.0(6)S | Cisco 12000 系列 |
Cisco 800, 1700, 1800, 2800, 3800, 6500, 7300, 7600, 10000, CRS-1以及Catalyst系列的45xx, 55xx, 6xxx交换机也支持NetFlow。
以下设备不支持NetFlow: Cisco 2900, 3500, 3660, 3750
2.6.2 特殊系列
在4000系列交换机上配置NDE
注意 | 4000和4500系列交换机需要具有NetFlow服务的daughter卡(WS-F4531)和IOS版本12.1(19)EW或者更高来支持NDE。 |
在IOS设备上配置Netflow输出,并且需要在各端口上执行ip route-cache flow 命令,则可执行以下命令:
ip route-cache flow infer-fields
该命令将在流中包含路由信息,不需要为每个接口输入ip route-cache flow命令。
设备配置示例
下面的一组执行在4000系列上的命令,启用NetFlow版本7并且以FastEthernet 0/1作为源接口,输出到192.168.9.101的9996端口。
switch>(enable)ip flow-export destination 192.168.9.101 9996 |
在Catalyst 6000系列交换机上配置NDE
在Catalyst 6000系列交换机上执行以下步骤来配置NDE
在管理员引擎上进入特权模式,执行以下命令来配置NDE:
命令 | 目的 |
set mls nde {hostname|ip_address} 9996 | 指定NetFlow分析仪作为NDE收集方,并且为硬件交换包的输出,配置Netflow监听端口的UDP端口。 |
ip flow-export destination {hostname|ip_address} 9996 | 指定NetFlow分析仪作为NDE收集方,并且为软件交换包的输出,配置Netflow监听端口的UDP端口。* |
set mls agingtime long 64 | 分割活动期长的流为1分钟的片段,这将使流量图比较圆滑。 设定 该值为1分钟非常重要。 |
set mls agingtime 32 | 保证定期输出完成的流 |
set mls flow full | 将设定流掩码为全(full)流。有便从交换机取得有用信息。 |
set mls nde enable | 启用NDE |
*要监视由MSFC软交换的第3层的流量数据以及统计,你必须在MSF上指定NDE收集器以及UDP端口。
需要在MSFC上输入ip flow-export destination命 令。使用show mls调试命令来调试NDE配置
2.7 开启后的性能影响分析
亿阳的流量流向精细化分析工具,是一套非常有效的实用工具,它是通过网络设备提供Netflow,Netstream等flow类协议,对网络流进行采样分析。下面是一个国内研究机构对Netflow协议开启前后的性能影响对比。
测试环境为一个多业务系统,多个Vlan的环境,采样交换机为6509,出入流量在100Mbit/s,包的个数在100,000/s以上,Netflow的采样抽样比例为1:100。
6509忙时,Netflow开启前后的CPU性能对比
6509忙时,Netflow开启前后的Free Memory对比
6509闲时,Netflow开启前后的CPU性能对比
他们给出的测试结论是:在6509上开启Netflow对网络设备影响不大,在平均100M/100,000包/秒的情况下,CPU的利用率提升最大不超过5%,内存消耗增加稳定在4.1MByte。我们在以往项目是按照设备厂商建议的1:1000采样率,实施中观测到的情况,平均对网络设备的性能影响平均在1%左右,最高不超过3%,与这个测试类似。
开启Netflow对骨干局域网络链路增加的负荷,根据我们的观察,在链路忙时,采样率为1:1000, Netflow所产生的流信息,平均流量低于链路本身带宽的0.02%,对局域网络基本上没有什么影响。
3 Netstream
3.1 V5
华为路由器Netstream 也是采用输出UDP包到指定采集服务器的模式,数据有V5,V8和V9三种格式,V8同cisco,V9格式增加了模版定义和深度业务搜索功能,属于刚刚推出的版本,与cisco v9的标准兼容,目前未列入此次开发计划,这里仅列出我们使用的V5格式:
Netstream V5格式定义:
输出UDP包格式
V5头 | V5记录 | V5记录 | V5记录 | ... |
V5输出头格式定义:红色字体标明与Netflow V5 不同之处
0 byte | 1 byte | 2 byte | 3 byte |
NS_ID | Version | Count | |
SysUpTime | |||
UnixSecs | |||
UnixNsecs | |||
StreamSeq | |||
EngineType | SlotID | Reserved |
字段 | 描述 |
NS_ID | 方向标志位 , 0x00 入方向统计,0x80出方向统计 |
Version | 版本号,即为5 |
Count | 报文中记录数 |
SysUpTime | 报文产生时间,系统启动以来的毫秒数 |
UnixSecs | 报文产生时间,从1970/7/1以来时间的整秒数 |
UnixNsecs | 报文产生时间,从1970/7/1以来时间不足1秒的纳秒数 |
StreamSeq | 输出流记录顺序号 |
EngineType | 流交换引擎类型,为0 |
SlotID | 当前Netstream处理板的槽号 |
Reserved | 保留字段,全零 |
V5输出记录格式
0 byte | 1 byte | 2 byte | 3 byte |
SrcAddr |
| ||
DstAddr |
| ||
NextHop |
| ||
Input |
| ||
Output |
| ||
Pkts |
| ||
Octets |
| ||
First |
| ||
Last |
| ||
SrcPort | DstPort | ||
Pad1 | TcpFlags | Prot | Tos |
SrcAs | DstAs | ||
SrcMask | DstMask | Pad2 |
字段 | 描述 |
SrcAddr | 源IP地址 |
DstAddr | 目的IP地址 |
NextHop | 下一跳地址 |
Input | 输入接口 |
Output | 输出接口 |
Pkts | 流过IP包数 |
Octets | 流过字节数 |
First | 流创建时间 |
Last | 最后一个报文时间 |
SrcPort | 源端口 |
DstPort | 目的端口 |
Pad1 | 地址对齐,无意义 |
TcpFlags | TCP标志位 |
Prot | 三层协议号 |
Tos | 服务类型 |
SrcAs | 源自治系统号 |
DstAs | 目的自治系统号 |
SrcMask | 源掩码 |
DstMask | 目的掩码 |
Pad2 | 地址对齐,无意义 |
3.2 显示命令
显示流缓存区
【命令】
集中式设备:
display ip netstream cache
分布式设备:
display ip netstream cache [ slot slot-id ]
【缺省级别】
1:监控级
【参数】
slot slot-id:显示指定槽号的NetStream 流缓冲区表项。
【描述】
display ip netstream cache 命令用来查看NetStream 流缓存区的配置和状态信
息。
【举例】
# 集中式路由器上查看NetStream 流缓冲区信息。
<Sysname> display ip netstream cache
IP netstream cache information
Stream active timeout(minute) : 60
Stream inactive timeout(second): 10
Active stream entry : 0
Inactive stream entry : 2000
Stream entry been created : 0
Last statistics reset time : 1/1/2000, 4:27:19
IP packet number of different size
Protocol Total Packets Stream Packets Active(sec) Idle(sec)
Streams /Sec /Sec /stream /stream /stream
--------------------------------------------------------------------------
Total 0 0 0 0 0 0
DstIP DstP SrcIP SrcP Pro Tos Interface Pkts
--------------------------------------------------------------------------
3.3.3.2 0 1.1.1.1 0 1 0 ET1/0 872
# 分布式路由器上查看NetStream 流缓冲区信息
<Sysname> display ip netstream cache slot 5
IP netstream cache information
Stream active timeout(minute) : 60
Stream inactive timeout(second): 10
Active stream entry : 0
Inactive stream entry : 2000
Stream entry been created : 0
Last statistics reset time : 1/1/2000, 4:27:19
IP packet number of different size
1-80 81-552 553-576 577-612 613-1480 1481-1500 1501-
0 0 0 0 0 0 0
Protocol Total Packets Stream Packets Active(sec) Idle(sec)
Streams /Sec /Sec /stream /stream /stream
--------------------------------------------------------------------------
Total 0 0 0 0 0 0
DstIP DstP SrcIP SrcP Pro Tos Interface Pkts
--------------------------------------------------------------------------
3.3.3.2 0 1.1.1.1 0 1 0 ET1/0 872
Stream active timeout(minute) 当前的活跃老化时间
Stream inactive timeout(second) 当前的不活跃老化时间
Active stream entry NetStream 流缓存区中活跃的流数
字段 描述
Inactive stream entry NetStream 流缓存区中不活跃的流数
Stream entry been created NetStream 流缓存区中创建成功的流数
Last statistics reset time
上次清除统计的时间,此时间为清除时刻的绝对时
间,它不会随系统时间的修改而变化
该字段只在执行了reset ip netstream statistics
命令后才会出现,否则显示Last statistics reset
time never
IP packet number of different size IP 报文按大小分布情况
1-80 81-552 553-576 577-612
613-1480 1481-1500 1501-
报文尺寸区间,以字节为单位,例如:“1-80”是
长度为1~80 个字节的报文数目,“1501-”是长
度超过1500 字节的报文数目
Protocol Total Streams Packets
/Sec Stream /Sec Packets /stream
Active(sec) /stream Idle(sec) /stream
按协议分类的报文统计信息:协议号、总流数、每
秒的报文数、每秒的流数、平均每条流的报文数、
平均每条流的活跃时间、平均每条流的非活跃时间
DstIP DstP SrcIP SrcP Pro
Tos Interface Pkts
当前流缓存区中活跃流的详细信息:目的IP 地址、
目的端口号、源IP 地址、源端口号、协议、ToS、
接口名、包数
输出报文信息
【命令】
display ip netstream export
【缺省级别】
1:监控级
【参数】
无
【描述】
display ip netstream export 命令用来查看NetStream 统计输出报文的各种信息。
【举例】
# 路由器上查看NetStream 统计输出信息。
<Sysname> display ip netstream export
Version 5 IP export information:
Stream source interface: GigabitEthernet1/0
Stream destination IP(UDP): 10.10.0.10 (30000)
Exported stream number: 16
Exported UDP datagram number(failed number): 16(0)
Version 8 AS aggreagtion information:
Stream source interface: GigabitEthernet1/0
Stream destination IP(UDP): 10.10.0.10 (30000)
Exported stream number: 16
Exported UDP datagram number(failed number): 2(0)
Version 5 export information 版本5 统计输出信息
Stream source interface 输出信息的源接口
Stream destination IP(UDP) 输出信息(UDP)的目的地址和目的端口号
Exported stream number 已发送的流信息数
Exported UDP datagram number(failed
number) 已发送的UDP 报文数(发送失败数)
Version 8 AS aggregation export
information
启用自治系统聚合的版本8 统计输出信息。没有启
用的聚合功能不显示(各项信息同上)
输出报文主机IP
【命令】
ip netstream export host ip-address udp-port
undo ip netstream export host [ ip-address ]
【参数】
ip-address:NetStream 统计输出报文的目的IP 地址。
udp-port:NetStream 统计输出报文的目的端口号,取值范围为0~65535。
【描述】
ip netstream export host 命令用来配置NetStream 统计输出报文的目的IP 地址和
目的端口号。undo ip netstream export host 命令用来恢复缺省情况。
缺省情况下,系统视图下没有配置目的IP 地址和目的端口号,聚合视图下目的IP
地址和目的端口号为系统视图下所配置的值。
需要注意的是:
� 如果某类聚合视图没有使能,则查看不到它的目的IP 地址和目的端口号。
� 不同聚合视图下可以配置不同的目的主机。
� 在一个视图下最多允许配置2 个不同的目的主机。单条流统计输出报文会发给
系统视图下配置的所有目的主机。聚合统计输出报文会发给聚合类型对应的的
聚合视图下配置的所有目的主机。
相关配置可参考命令ip netstream aggregation 和ip netstream export source。
【举例】
# 设置NetStream 统计输出报文的目的IP 地址为172.16.105.48,UDP 端口号为
5000。
<Sysname> system-view
[Sysname] ip netstream export host 172.16.105.48 5000
输出报文源接口
【命令】
ip netstream export source interface interface-type interface-number
undo ip netstream export source
【视图】
系统视图/NetStream 聚合视图
【缺省级别】
3:管理级
【参数】
interface-type interface-number:NetStream 统计输出报文的源接口,由接口类型
和接口编号组成。
【描述】
ip netstream export source interface 命令用来配置NetStream 统计输出报文的
源接口。undo ip netstream export source 命令用来取消配置的输出报文的源接
口。
缺省情况下,采用统计输出报文的接口做为源接口。
不同聚合视图下可以配置不同的源接口。
相关配置可参考命令ip netstream aggregation。
【举例】
# 将NetStream 统计输出报文源接口设置为GigabitEthernet1/0。
<Sysname> system-view
[Sysname] ip netstream export source interface gigabitethernet 1/0
输出报文版本号
【命令】
ip netstream export version version-number [ origin-as | peer-as ]
undo ip netstream export version
【缺省级别】
3:管理级
【参数】
version-number:NetStream 统计输出报文版本号,目前取值为5。
origin-as:流信息中记录的自治系统号为起始自治系统号。
peer-as:流信息中记录的自治系统号为邻接自治系统号。
【描述】
ip netstream export version 命令用来配置NetStream统计输出报文的版本号和自
治系统选项。undo ip netstream export version 命令用来恢复缺省情况。
缺省情况下,单条流信息通过版本5 的NetStream 统计输出报文发送,聚合统计流
信息通过版本8 的NetStream 统计输出报文发送。自治系统选项使用邻接自治系统
号(peer-as)。
需要注意的是,流信息中会记录流的源IP 地址和目的IP 地址的自治系统号。因为
每个IP 地址对应两个自治系统号:起始自治系统号和邻接自治系统号,系统将根据
用户配置的自治系统选项来选择记录哪个自治系统号。
【举例】
# 将NetStream 统计输出报文版本号设为5,并采用起始自治系统号做为给定IP 地
址的自治系统号。
<Sysname> system-view
[Sysname] ip netstream export version 5 origin-as
流活跃老化时间
缺省情况下,流的活跃老化时间为30分钟,不活跃老化时间为30秒
【命令】
ip netstream timeout active minutes
undo ip netstream timeout active
【缺省级别】
3:管理级
【参数】
minutes:NetStream 流活跃老化时间,取值范围为1~60,单位为分钟。
【描述】
ip netstream timeout active 命令用来配置NetStream 流的活跃老化时间。undo ip
netstream timeout active 命令用来恢复缺省情况。
缺省情况下,NetStream 流活跃老化时间是30 分钟。
相关配置可参考命令ip netstream timeout inactive。
注意:
NetStream 活跃老化时间和不活跃老化时间可以同时配置,满足任一个老化时间就
会对流进行老化,时间精度为10 秒钟。
【举例】
# 将NetStream 流活跃老化时间设置为60 分钟。
<Sysname> system-view
命令手册 系统分册 NetStream 第1 章 NetStream 配置命令
1-8
[Sysname] ip netstream timeout active 60
流不活跃老化时间
【命令】
ip netstream timeout inactive seconds
undo ip netstream timeout inactive
【缺省级别】
3:管理级
【参数】
seconds:NetStream 流不活跃老化时间,取值范围为60~600,单位为秒。
【描述】
ip netstream timeout inactive 命令用来配置NetStream 流的不活跃老化时间。
undo ip netstream timeout inactive 命令用来恢复缺省情况。
缺省情况下,NetStream 流的不活跃老化时间是60 秒。
相关配置可参考命令ip netstream timeout active。
注意:
NetStream 活跃老化时间和不活跃老化时间可以同时配置,满足任一个老化时间就
会对流进行老化,时间精度为10 秒钟。
【举例】
# 将NetStream 流不活跃老化时间设置为60 秒。
<Sysname> system-view
[Sysname] ip netstream timeout inactive 60
1.1.8 reset ip netstream statistics
【命令】
reset ip netstream statistics
【缺省级别】
2:系统级
【参数】
无
【描述】
reset ip netstream statistics 命令用来将流缓存区中所有流强制老化,并清除
NetStream 缓冲区的状态信息和输出报文信息。输出报文信息从强制老化时刻开始
重新统计。
【举例】
# 将流缓存区中所有流老化,并清除NetStream 缓冲区的状态信息和输出报文信息。
<Sysname> reset ip netstream statistics
__
3.3 配置实例
MSR系列路由Netstream功能的典型配置
一、组网需求:
在路由器上配置NetStream,对端口的流量进行统计,把结果输出到服务器上。
设备清单:MSR系列路由器1台
二、组网图:
三、配置步骤:
设备和版本:MSR系列、version 5.20, Beta 1106。
RTA关键配置脚本
#
//配置UDP报文的目的IP地址和目的端口,源接口采用缺省配置
ip netstream export host 10.0.0.5 9996
#
//配置连接Netstream_collector的主机地址
interface Ethernet0/0
port link-mode route
ip address 10.0.0.1 255.255.255.0
#
//连接到internet端口
interface Ethernet0/1
port link-mode route
ip address 20.0.0.1 255.255.255.0
//在此接口上启动NetStream出入统计
ip netstream inbound
ip netstream outbound
3.4 硬件支持
设备列表 | 备注 |
Quidway NetEngine5000E核心路由器 | 支持NetStream业务板卡 |
CX600 | CX600支持NetStream特性V5、V8、V9格式,但需要配置独立的NetStream硬件板卡。 |
H3C SR6608路由器 |
|
H3C S7500 系列、S7502 | 通过配置了多业务功能板(启用Nestream功能) |
H3C NE40/80系列路由器 | 支持Netstream业务板卡 |
华为S8500/S6500系列交换机 | 每板支持的流条数300000条 |
H3C S9500
| NetStream功能采用NAM板来实现,一台S9500设备可以支持多块NAM板。NAM板上使用网络处理器NP作为核心报文处理芯片;NP是可编程的,可以提供业务灵活可扩展性。 |
Quidway AR 28-3X系列路由器 |
|
4 Sflow
4.1 Sflow简介
sFlow(RFC 3176)是基于标准的最新网络导出协议,能够解决当前网络管理人员面临的很多问题。sFlow已经成为一项线速运行的“永远在线”技术,可以将sFlow技术嵌入到网络路由器和交换机ASIC芯片中。sFlow代理主要采用JetCore ASIC统计数据包采样技术或VM管理模块,通过集成在JetCore ASIC芯片内的数据包采样算法,实现基于硬件的网络流量统计。sFlow可以通过更长的汇聚周期、提高采样的数率和更高的利用率来增加采样数,达到更高的精度。
丰富的数据包信息
sFlow数据包中包含有大量的宝贵信息,这些信息可以用于网络监视、流量分析和安全分析等。根据RFC 3176规定,可以为每一个数据包转发最少256字节的信息。Foundry sFlow代理能够转发多种信息。所有IP、TCP和UDP包头的相关信息,都与部分数据包有效载荷一起转发到采集器,以进行监视分析。
同时,它采集的数据包头信息包括IPv4-IP包头信息(无选项集,有版本、TOS、字节长度、ID域、 碎片偏移量、TTL、协议、包头校验和、源IP地址、目标IP地址),IPv4 -TCP包头信息(无选项集,有源端口、目标端口、序列号、确认号、数据偏移量、保留域、控制位、窗口、校验和、紧急指针)和IPv4-UDP包头信息(源端口、目标端口、长度、校验和)。
除了数据包头信息外,Foundry sFlow代理还能够与每个被采样数据包一起转发数据包发出的端口,下一跳的网关地址,BGP信息,用于认证(例如802.1x)的用户ID信息,接口统计信息(RFC 1573、RFC 2233和RFC 2358)和有效载荷信息(如URL)。
灵活的采样机制
与那些需要镜像端口或网络旁路器,来监视传输流量的解决方案不同,在 sFlow的解决方案中,并不是每一个数据包都发送到采集器(接收sFlow数据包的设备)。
sFlow使用两种独立的采样方法来获取数据—针对交换数据流的基于数据包统计采样方法和基于时间采样的针对网络接口统计数据。
sFlow还能使用不同的采样率,对交换机或仅对其中一些端口实施监视,这样保证了在设计管理方案时的灵活性。
4.2 Sflow与Netflow比较
Sflow | Netflow |
非完全基于流的技术(不保留流的状态信息) | 完全基于流的技术(比如两个包同属于相同的流,必须得统计在一个流纪录,在输出流之前必须保留流的状态。) |
采样速率is communicated in_band with the packet.同一个设备上可以配置多个不同采样速率。 | 整个设备仅应用一个采样速率,(this rate must be configured out of band) |
支持L2信息,MPLS、BGP、以及推式的SNMP计数输出 (非Snmp轮询) 支持VLAN(802.1q)和服务级别(802.1p),ipx和appletalk协议 网络线速性能流量统计 | 除去Netflow V9 ,不能输出L2信息 |
4.3 Sflow报文格式说明
4.3.1 数据包头信息
简述:描述L2_L7 的数据包,以及定义采样比率
图表 1 Sflow Datagram
struct sample_datagram_v5 {
address agent_address /*采样代理的IP地址sFlowAgentAddress*/
unsigned int sub_agent_id; /* 子代理ID */
unsigned int sequence_number; /*流序号*/
unsigned int uptime; /*设备启动时间*/
sample_record samples<>; /*采集流记录组*/
}
图表 2 Sflow Sample Datagram
Sflow V4 Datagram
/* sFlow Datagram Version 4 */
- version 4 增加支持 BGP共同体
- version 3 增加支持 扩展url 信息
*/
/* sFlow Sample types */
/* Address Types */
typedef opaque ip_v4[4];
typedef opaque ip_v6[16];
enum address_type {
IP_V4 = 1,
IP_V6 = 2
}
union address (address_type type) {
case IP_V4:
ip_v4;
case IP_V6:
ip_v6;
}
/* 包头数据 */
const MAX_HEADER_SIZE = 256; /*采样包头最大值
/* 头协议描述采样包头格式*/
enum header_protocol {
ETHERNET-ISO8023 = 1,
ISO88024-TOKENBUS = 2,
ISO88025-TOKENRING = 3,
FDDI = 4,
FRAME-RELAY = 5,
X25 = 6,
PPP = 7,
SMDS = 8,
AAL5 = 9,
AAL5-IP = 10, /* e.g., Cisco AAL5 mux */
IPv4 = 11,
IPv6 = 12,
MPLS = 13
}
struct sampled_header {
header_protocol protocol; /* Format of sampled header */
unsigned int frame_length; /* Original length of packet before
sampling */
opaque header<MAX_HEADER_SIZE>; /* Header bytes */
}
/* Packet IP version 4 data */
struct sampled_ipv4 {
unsigned int length; /* IP 数据包长度包含底层的封装*/
unsigned int protocol; /* 协议类型(for example, TCP = 6, UDP = 1*/
ip_v4 src_ip; /* 源 IP 地址 */
ip_v4 dst_ip; /* 目的 IP 地址 */
unsigned int src_port; /* TCP/UDP 源端口号*/
unsigned int dst_port; /* TCP/UDP 目的端口号 */
unsigned int tcp_flags; /* TCP flags */
unsigned int tos; /* IP 服务类型*/
}
/* Packet IP version 6 data */
struct sampled_ipv6 {
unsigned int length; /* IP 数据包长度包含底层的封装*/
unsigned int protocol; /*协议类型(for example, TCP = 6, UDP = 17)*/
ip_v6 src_ip; /* 源IP地址 */
ip_v6 dst_ip; /* 目的IP 地址 */
unsigned int src_port; /* TCP/UDP 源端口号*/
unsigned int dst_port; /* TCP/UDP目的端口号 */
unsigned int tcp_flags; /* TCP flags */
unsigned int priority; /* IP 优先级 */
}
/* Packet data */
enum packet_information_type {
HEADER = 1, /* Packet headers are sampled */
IPV4 = 2, /* IP version 4 data */
IPV6 = 3 /* IP version 6 data */
}
union packet_data_type (packet_information_type type) {
case HEADER:
sampled_header header;
case IPV4:
sampled_ipv4 ipv4;
case IPV6:
sampled_ipv6 ipv6;
}
/* 扩展数据类型 */
/* Extended switch data */
struct extended_switch {
unsigned int src_vlan; /* 源帧802.1Q VLAN id */
unsigned int src_priority; /* 源帧的优先级802.1p */
unsigned int dst_vlan; /* 目的帧802.1Q VLAN id */
unsigned int dst_priority; /* 目的帧802.1p 优先级 */
}
/* Extended router data */
struct extended_router {
address nexthop; /* 下一跳路由地址*/
unsigned int src_mask; /* 源地址前缀码 */
unsigned int dst_mask; /*目的地址前缀码 */
}
/* Extended gateway data */
enum as_path_segment_type {
AS_SET = 1, /* Unordered set of ASs */
AS_SEQUENCE = 2 /* Ordered set of ASs */
}
union as_path_type (as_path_segment_type) {
case AS_SET:
unsigned int as_set<>;
case AS_SEQUENCE:
unsigned int as_sequence<>;
}
struct extended_gateway {
unsigned int as; /* 路由器所在自治系统号*/
unsigned int src_as; /* 源自治系统号*/
unsigned int src_peer_as; /* 同等的自治系统号*/
as_path_type dst_as_path<>; /* 自治系统到目的地的路径*/
unsigned int communities<>; /* Communities associated with this
route */
unsigned int localpref; /* LocalPref associated with this
route */
}
/* Extended user data */
struct extended_user {
string src_user<>; /* User ID associated with packet
source */
string dst_user<>; /* User ID associated with packet
destination */
}
/* Extended URL data */
enum url_direction {
src = 1, /* URL is associated with source
address */
dst = 2 /* URL is associated with destination
address */
}
struct extended_url {
url_direction direction; /* URL associated with packet source */
string url<>; /* URL associated with the packet flow */
}
/* Extended data */
enum extended_information_type {
SWITCH = 1, /* Extended switch information */
ROUTER = 2, /* Extended router information */
GATEWAY = 3, /* Extended gateway router information */
USER = 4, /* Extended TACACS/RADIUS user information */
URL = 5 /* Extended URL information */
}
union extended_data_type (extended_information_type type) {
case SWITCH:
extended_switch switch;
case ROUTER:
extended_router router;
case GATEWAY:
extended_gateway gateway;
case USER:
extended_user user;
case URL:
extended_url url;
}
/* Format of a single flow sample */
struct flow_sample {
unsigned int sequence_number; /* 流序列号 */
unsigned int source_id; /* sFlow数据源如下:
(0 = ifIndex,
1 = smonVlanDataSource,
2 = entPhysicalEntry) */
unsigned int sampling_rate; /* sFlowPacket采样速率 */
unsigned int sample_pool; /* Total number of packets that could
have been sampled (i.e., packets
skipped by sampling process + total
number of samples) */
unsigned int drops; /*被丢的包数 */
unsigned int input; /* SNMP入口接口ifIndex */
unsigned int output; /* SNMP 出口接口ifInde
packet_data_type packet_data; /* Information about sample packet */ extended_data_type extended_data<>; /* Extended flow information */
}
4.3.2 接口统计信息
简述:描述接口属性(类似SNMP物理接口状态 ,基于推式报文输出)无需SNMP轮询。
/* Counter types */
/* Generic interface counters - see RFC 2233 */
struct if_counters {
unsigned int ifIndex;
unsigned int ifType;
unsigned hyper ifSpeed;
unsigned int ifDirection; /* derived from MAU MIB (RFC 2668)
0 = unknown, 1=full-duplex,
2=half-duplex, 3 = in, 4=out */
unsigned int ifStatus; /* bit field with the following bits
assigned
bit 0 = ifAdminStatus
(0 = down, 1 = up)
bit 1 = ifOperStatus
(0 = down, 1 = up) */
unsigned hyper ifInOctets;
unsigned int ifInUcastPkts;
unsigned int ifInMulticastPkts;
unsigned int ifInBroadcastPkts;
unsigned int ifInDiscards;
unsigned int ifInErrors;
unsigned int ifInUnknownProtos;
unsigned hyper ifOutOctets;
unsigned int ifOutUcastPkts;
unsigned int ifOutMulticastPkts;
unsigned int ifOutBroadcastPkts;
unsigned int ifOutDiscards;
unsigned int ifOutErrors;
unsigned int ifPromiscuousMode;
}
/* Ethernet interface counters - see RFC 2358 */
struct ethernet_counters {
if_counters generic;
unsigned int dot3StatsAlignmentErrors;
unsigned int dot3StatsFCSErrors;
unsigned int dot3StatsSingleCollisionFrames;
unsigned int dot3StatsMultipleCollisionFrames;
unsigned int dot3StatsSQETestErrors;
unsigned int dot3StatsDeferredTransmissions;
unsigned int dot3StatsLateCollisions;
unsigned int dot3StatsExcessiveCollisions;
unsigned int dot3StatsInternalMacTransmitErrors;
unsigned int dot3StatsCarrierSenseErrors;
unsigned int dot3StatsFrameTooLongs;
unsigned int dot3StatsInternalMacReceiveErrors;
unsigned int dot3StatsSymbolErrors;
}
/* FDDI interface counters - see RFC 1512 */
struct fddi_counters {
if_counters generic;
}
/* Token ring counters - see RFC 1748 */
struct tokenring_counters {
if_counters generic;
unsigned int dot5StatsLineErrors;
unsigned int dot5StatsBurstErrors;
unsigned int dot5StatsACErrors;
unsigned int dot5StatsAbortTransErrors;
unsigned int dot5StatsInternalErrors;
unsigned int dot5StatsLostFrameErrors;
unsigned int dot5StatsReceiveCongestions;
unsigned int dot5StatsFrameCopiedErrors;
unsigned int dot5StatsTokenErrors;
unsigned int dot5StatsSoftErrors;
unsigned int dot5StatsHardErrors;
unsigned int dot5StatsSignalLoss;
unsigned int dot5StatsTransmitBeacons;
unsigned int dot5StatsRecoverys;
unsigned int dot5StatsLobeWires;
unsigned int dot5StatsRemoves;
unsigned int dot5StatsSingles;
unsigned int dot5StatsFreqErrors;
}
/* 100 BaseVG interface counters - see RFC 2020 */
struct vg_counters {
if_counters generic;
unsigned int dot12InHighPriorityFrames;
unsigned hyper dot12InHighPriorityOctets;
unsigned int dot12InNormPriorityFrames;
unsigned hyper dot12InNormPriorityOctets;
unsigned int dot12InIPMErrors;
unsigned int dot12InOversizeFrameErrors;
unsigned int dot12InDataErrors;
unsigned int dot12InNullAddressedFrames;
unsigned int dot12OutHighPriorityFrames;
unsigned hyper dot12OutHighPriorityOctets;
unsigned int dot12TransitionIntoTrainings;
unsigned hyper dot12HCInHighPriorityOctets;
unsigned hyper dot12HCInNormPriorityOctets;
unsigned hyper dot12HCOutHighPriorityOctets;
}
/* WAN counters */
struct wan_counters {
if_counters generic;
}
/* VLAN counters */
struct vlan_counters {
unsigned int vlan_id;
unsigned hyper octets;
unsigned int ucastPkts;
unsigned int multicastPkts;
unsigned int broadcastPkts;
unsigned int discards;
}
/* Counter data */
enum counters_version {
GENERIC = 1,
ETHERNET = 2,
TOKENRING = 3,
FDDI = 4,
VG = 5,
WAN = 6,
VLAN = 7
}
union counters_type (counters_version version) {
case GENERIC:
if_counters generic;
case ETHERNET:
ethernet_counters ethernet;
case TOKENRING:
tokenring_counters tokenring;
case FDDI:
fddi_counters fddi;
case VG:
vg_counters vg;
case WAN:
wan_counters wan;
case VLAN:
vlan_counters vlan;
}
/* Format of a single counter sample */
struct counters_sample {
unsigned int sequence_number; /* 流序号*/
unsigned int source_id; /* sFlow数据源如下:
(0 = ifIndex,
1 = smonVlanDataSource,
2 = entPhysicalEntry).*/
unsigned int sampling_interval; /* sFlowCounter采样时间间隔*/
counters_type counters;
}
/* Format of a sample datagram */
enum sample_types {
FLOWSAMPLE = 1,
COUNTERSSAMPLE = 2
}
union sample_type (sample_types sampletype) {
case FLOWSAMPLE:
flow_sample flowsample;
case COUNTERSSAMPLE:
counters_sample counterssample;
}
struct sample_datagram_v4 {
address agent_address /* IP address of sampling agent,
sFlowAgentAddress. */
unsigned int sequence_number; /* 流序号*/
unsigned int uptime; /*设备启动时间*/
sample_type samples<>; /* An array of flow, counter and delay
samples */
}
enum datagram_version {
VERSION4 = 4
}
union sample_datagram_type (datagram_version version) {
case VERSION4:
sample_datagram_v4 datagram;
}
struct sample_datagram {
sample_datagram_type version;
}
4.3.3 V5
IPv4 Data
IPv6 Data
Extended Switch Data
Extended Router Data
上述四个部分同Sflow V4 Datagram , Sflow V5 Datagram 详细请看PDF文件 :
header
int header protocol (1=ethernet, .... 11=IPv4, 12=IPv6)
int frame length (length before sampling)
int header size (bytes)
int stripped (number of bytes removed from the packet)
enterprise = 0, format = 2
Ethernet Frame Data
Struct{
int length (of the mac packet) / MAC层帧的长度/
int type (ethernet packet type) /以太网类型/
src mac (6 byte + 2 pad bytes) 源MAC 地址
dest mac (6 bytes + 2 pad bytes) 目的MAC 地址
}
enterprise = 0, format = 3
Extended Gateway Data +nexthop router ip
enterprise = 0, format = 1003
int as number of router
int as number of source
int as number of source peer
int LocalPref
int n dest as paths
int n length communities list
n * int communities
n * dest as path
int IP version of next hop router (1=v4|2=v6)
IP address next hop router (v4=4byte|v6=16byte) 4-16 byte
AS Path
int as path segment type (1=set/unordered|2=sequence/ordered)
int n length of as list
n * int as number
Extended User Data +charset
enterprise = 0, format = 1004
{ int length source user string
int length destination user string
string source user
string destination user
int source charset
int destination charset
}
enterprise = 0, format = 1005
Extended Url Data +host
int direction (1=src|2=dest)
string url
int length url
string host
int length host
Extended MPLS Data
enterprise = 0, format = 1006
int IP version of next hop router (1=v4|2=v6)
IP address next hop router (v4=4byte|v6=16byte) 4-16 byte
int in label stack
int n in label stack
int out label stack
int n out label stack
Extended NAT Data
enterprise = 0, format = 1007
int IP version of source address (1=v4|2=v6)
IP address source address (v4=4byte|v6=16byte)
int IP version of destination address (1=v4|2=v6)
IP address destination address (v4=4byte|v6=16byte)
Extended MPLS Tunnel
enterprise = 0, format = 1008
string tunnel name
int length tunnel name
int tunnel id
int tunnel cos value
Extended MPLS VC
enterprise = 0, format = 1009
string vc instance name
int length vc instance name
int vll/vc id
int vc label cos value
Extended MPLS FEC
enterprise = 0, format = 1010
string mplsFTNDescr
int length mplsFTNDescr
int mplsFTNMask
Extended MPLS LVP FEC
enterprise = 0, format = 1011
int length mplsFecAddrPrefixLength
enterprise = 0, format = 1012
Extended VLAN tunnel
int layer
intn layer stack
4.4 硬件支持
厂家 | 备注 |
Foundry Networks http://www.foundrynetworks.com.cn/technologies/sflow1.html | BigIron系列、FastIron系列、IronPoint系列、NetIron(NetIron40G)系列、SecureIron系列、ServerIron系列 |
AlaxalANetwork http://www.alaxala.com/en/ | A7800R、 AX7800S、AX7700R、 AX5400S |
Alcatel http://www.alcatel-sbell.com.cn/live/home/index.jsp | Omniswith6850、 OmniSwith9000 |
Allied Telesis
http://www.alliedtelesis.com.cn/ | SwitchBlade 7800R系列 SwitchBlade 7800S系列 SwitchBlade 5400S 系列 |
ComtecSystemS | !_Rex 16Gi 、24Gi和24Gi_Combo |
Force10 Networks | E 系列 |
NEC | IP8800/R400系列、 IP8800/S400系列、IP8800/S300系列 |
Hitachi | GR4000 GS4000 GS3000 |
Hewlett_packard | ProCurve 2800系列、ProCurve 3400cl系列、ProCurve 3500yl系列、ProCurve 4200vl系列、ProCurve 5300xl系列、ProCurve 5400zl系列、ProCurve 6200yl系列、ProCurve 6400cl系列、ProCurve 9300m系列、ProCurve Routing Switch 9408sl |
|
|
|
|
|
4.5 配置实例
Foundry 交换机
在Foundry交换机上配置: 采样比率 1:512 ,并将Sflow包从UDP端口6343送到192.168.4.5
config> int e 1/1 to 1/8
interface> sflow forwarding
<repeat for all blades>>
config> sflow destination 192.168.4.5
config> sflow sample 512
config> sflow polling-interval 30
config> sflow enable
Force10 交换机
在Force10 交换机192.168.1.1上配置: 采样比率 1:512 ,并将Sflow包从UDP端口6343送到192.168.4.5
config> sflow collector 192.168.4.5 agent-addr 192.168.1.1
config> sflow sample 512
config> sflow polling 30
config> sflow enable
Extreme 交换机
在Extreme 交换机192.168.1.1上配置: 采样比率 1:512 ,并将Sflow包从UDP端口6343送到192.168.4.5
enable sflow
configure sflow agent 192.168.1.1
configure sflow collector 192.168.4.5
configure sflow sample-rate 512 configure sflow poll-interval 30
enable sflow backoff-threshold
configure sflow backoff-threshold 100
enable sflow port 1
enable sflow port 2
enable sflow port 3
enable sflow port 4
enable sflow port 5
enable sflow port 6
enable sflow port 7
enable sflow port 8
在alcatel_lucent omniswitch交换机192.168.1.1上配置: 采样比率 1:512 ,并将Sflow包从UDP端口6343送到192.168.4.5
ip interface loopback0 192.168.1.1
sflow receiver 1 name TrafficSentinel address 192.168.4.5 udp-port 6343
sflow sampler 1 1/1-24 receiver 1 rate 512
sflow poller 1 1/1-24 receiver 1 interval 30
4.6 显示Sflow信息举例
FastIron Router(config)# show sflow
sFlow services are enabled.
sFlow agent IP address: 123.123.123.1
4 collector destinations configured:
Collector IP 192.168.4.204, UDP 6343
Collector IP 192.168.4.200, UDP 6333
Collector IP 192.168.4.202, UDP 6355
Collector IP 192.168.4.203, UDP 6565
Polling interval is 0 seconds.
Configured default sampling rate: 1 per 512 packets.
Actual default sampling rate: 1 per 512 packets.
10552 UDP packets exported
24127 sFlow samples collected.
sFlow ports: ethe 1/2 to 1/12 ethe 1/15 ethe 1/25 to 1/26 ethe 4/1 ethe 5/10 to
5/20 ethe 8/1 ethe 8/4
Module Sampling Rates
---------------------
Slot 1 configured rate=512, actual rate=512
Slot 3 configured rate=0, actual rate=0
Slot 4 configured rate=10000, actual rate=32768
Slot 5 configured rate=512, actual rate=512
Slot 7 configured rate=0, actual rate=0
Slot 8 configured rate=512, actual rate=512
Port Sampling Rates
-------------------
Port 8/4, configured rate=512, actual rate=512, Subsampling factor=1
Port 8/1, configured rate=512, actual rate=512, Subsampling factor=1
Port 5/20, configured rate=3000, actual rate=8192, Subsampling factor=16
Port 5/19, configured rate=512, actual rate=512, Subsampling factor=1
Port 5/18, configured rate=512, actual rate=512, Subsampling factor=1
Port 5/17, configured rate=1500, actual rate=2048, Subsampling factor=4
Port 5/16, configured rate=1500, actual rate=2048, Subsampling factor=4
Port 5/15, configured rate=1500, actual rate=2048, Subsampling factor=4
Port 5/14, configured rate=1500, actual rate=2048, Subsampling factor=4
Port 5/13, configured rate=512, actual rate=512, Subsampling factor=1
Port 5/12, configured rate=512, actual rate=512, Subsampling factor=1
Port 5/11, configured rate=512, actual rate=512, Subsampling factor=1
Port 5/10, configured rate=512, actual rate=512, Subsampling factor=1
Port 4/1, configured rate=10000, actual rate=32768, Subsampling factor=1
Port 1/26, configured rate=512, actual rate=512, Subsampling factor=1
Port 1/25, configured rate=512, actual rate=512, Subsampling factor=1
Port 1/15, configured rate=512, actual rate=512, Subsampling factor=1
Port 1/12, configured rate=512, actual rate=512, Subsampling factor=1
Port 1/11, configured rate=512, actual rate=512, Subsampling factor=1
Port 1/10, configured rate=512, actual rate=512, Subsampling factor=1
Port 1/9, configured rate=512, actual rate=512, Subsampling factor=1
Port 1/8, configured rate=512, actual rate=512, Subsampling factor=1
Port 1/7, configured rate=1000, actual rate=2048, Subsampling factor=4
Port 1/6, configured rate=512, actual rate=512, Subsampling factor=1
Port 1/5, configured rate=512, actual rate=512, Subsampling factor=1
Port 1/4, configured rate=512, actual rate=512, Subsampling factor=1
Port 1/3, configured rate=512, actual rate=512, Subsampling factor=1
Port 1/2, configured rate=1000, actual rate=2048, Subsampling factor=4
5 Cflowd
注意点:
1)缓存输出条件:非活动时间超时。默认60秒,(对应于Netflow 非活动时间超时 默认15秒)
其他缓存输出条件 和Netflow 相同 参看 2.1
2)Cflowd需要安装 arts++ 包
3) 需要PIC导出cflowd V5和V8数据
5.1 Cflowd V1
5.1.1 头格式
同Netflow V1 相同 参见2.2.1
5.1.2 输出报文格式
5.2 Cflowd V5
同Netflow V5 相同 参见2.3
5.3 Cflowd V8
5.3.1 头格式
5.3.2 输出报文格式
同Netflow V8 non_tos 汇聚模式下 报文格式
如下几种方式 详细请参见:2.5.2
协议_端口汇聚
目的网络前缀汇聚
5.4 配置Cflowd
v9模版配置:
flow-monitoring {
version9 {
template ip-template {
flow-active-timeout 20;
flow-inactive-timeout 120;
ipv4-template;
}
template mpls-template-1 {
mpls-template {
label-positions [1 3 4];
}
}
template mpls-ipv4-template-1 {
mpls-ipv4-template {
label-positions [1 5 7];
}
}
}
}
}
firewall /MPLS
family mpls {
filter mpls_sample {
term default {
then {
accept;
sample;
}
}
}
}
}
MPLS /AS PIC/IPv4
at-0/1/1 {
unit 0 {
family mpls {
filter {
input mpls_sample;
}
}
}
}
sp-7/0/0 {
unit 0 {
family inet;
family mpls;
}
}
}
MPLS version 9 template to the sampling output and sends it to the AS PIC:
sampling {
input {
family mpls {
rate 1;
}
}
output {
flow-active-timeout 60;
flow-inactive-timeout 30;
cflowd 1.2.3.4 {
port 2055;
version9 {
template mpls-ipv4-template-1;
}
}
interface sp-7/0/0 {
source-address 1.1.1.1;
}
}
}
}
5.5 硬件支持
Juniper | M系列路由器 需要 PIC卡支持 |
T 系列路由器 需要PIC卡支持 | |
J系列路由器 |
6 IPFIX
6.1 概述
IETF正在推行Internet Protocol Flow Information eXport即IP流量信息输出,IPFIX偏向于使用流控制传输协议(SCTP)作为其传输层协议,但同时也允许使用传输控制协议(TCP)和用户数据报协议(UDP)(基于Netflow V9)。
IPFIX(IP Flow Information Export,IP流动信息输出)是IETF的技术人员2004年才制订的一项规范,使得网络中流量统计信息的格式趋于标准化。该协议工作于任何厂商的路由器和管理系统平台之上,并用于输出基于路由器的流量统计信息。
IPFIX定义的格式为Cisco的NetFlow Version 9数据输出格式作为基础,可使IP流量信息从一个输出器(路由器或交换机)传送到另一个收集器。因为IPFIX具有很强的可扩展性,因此网络管理员们可以自由地添加或更改域(特定的参数和协议),以便更方便地监控IP流量信息。使用模板的方便之处在于网管和厂商不必为了用户能够查看流量统计信息,而每次都要更换软件。
特点:
基于Netflow V9 模板概念 , 易于扩展
采用SCTP 协议传输流信息,可靠性传输。
6.2 硬件支持
Nortel 5500 系列和8600 系列(详细如图示)
6.3 配置
ERS8600交换机
配置命令
配置实例
ERS5500交换机
配置命令
配置实例