可根据所配置的过滤器,将交换机上接收到的数据包划分到特定的服务类。可在转发数据包之前应用某些策略。以下任务说明了交换机中所接收的 TCP 数据包的分类,以及如何将 TCP 数据包的 IP 头中的 DSCP 值更改为 46。
有关此任务的拓扑,请参见Basic SEFOS Topology。将端口 25 连接到主机 A,端口 26 连接到主机 B。主机 B 应具有通过网络接口转储通信的命令,例如 tcpdump 或 snoop。否则,可以将端口 25 和端口 26 连接到数据捕获设备,如Basic SEFOS Topology中所示。
请参见Connect to SEFOS。
SEFOS-1# configure terminal SEFOS-1(config)# interface xl-ethernet 0/26 SEFOS-1(config-if)# no shutdown SEFOS-1(config-if)# exit SEFOS-1(config)# interface xl-ethernet 0/25 SEFOS-1(config-if)# no shutdown SEFOS-1(config-if)# exit SEFOS-1(config)# vlan 1 SEFOS-1(config-vlan)# ports xl-ethernet 0/25 xl-ethernet 0/26 untagged xl-ethernet 0/25 xl-ethernet 0/26
如果 VLAN 1 中已存在这两个接口,可能会看到以下消息。
% Member Ports cannot be added/deleted on Default VLAN SEFOS-1(config-vlan)# end
SEFOS-1# configure terminal SEFOS-1(config)# qos enable SEFOS-1(config)# end
SEFOS-1# configure terminal SEFOS-1(config)# ip access-list extended 11 SEFOS-1(config-ext-nacl)# permit tcp any any SEFOS-1(config-ext-nacl)# exit SEFOS-1(config)# interface xl-ethernet 0/25 SEFOS-1(config-if)# ip access-group 11 in SEFOS-1(config-if)# end
SEFOS-1# configure terminal
SEFOS-1(config)# class-map 10
SEFOS-1(config-cls-map)# match access-group ip-access-list 11 SEFOS-1(config-cls-map)# set class 100
SEFOS-1(config-cls-map)# exit
SEFOS-1(config)# policy-map 10
SEFOS-1(config-ply-map)# set policy class 100 default-priority-type ipdscp 46 SEFOS-1(config-ply-map)# exit
46 (0x2e) 是一个十进制数字。如果显示 8 位 TOS 值,则该值将显示为 0xb8,因为 0x2e 必须向左移动 2 位才能获取 6 位的 DSCP 值。
SEFOS-1# show access-lists ... Filter Protocol Type : TCP IP address Type : IPV4 ... In Port List : X10/25 ... Filter Action : Permit Status : Active... L3FilterId : 11 PriorityMapId : None CLASS : 100 PolicyMapId : 10 ... SEFOS-1# show policy-map 10 QoS Policy Map Entries ---------------------- PolicyMapId : 10IfIndex : 0 Class : 100 DefaultPHB : IP DSCP 46 ...
从主机 A 向主机 B 发送 TCP 数据包,并使用该主机所支持的数据包转储命令确认 DSCP 值。
# tcpdump -xx -n -i eth3 ip ... 16:34:27.979962 IP 12.0.0.100.905 > 12.0.0.17.shell: ... 16:34:27.980163 IP 12.0.0.17.shell > 12.0.0.100.905: 0x0000: 0014 4f6c 7de9 001b 2147 d479 0800 4500 0x0000: 001b 2147 d479 0014 4f6c 7de9 0800 45b8 ...
这些数据包在端口 26 上接收,其 DSCP 值为 46。在本示例中,dump 命令显示的 DSCP 值为 0xb8。