拓扑描述
R1: f1/0 10.1.1.1/24
R2: f0/0 10.1.2.2/24
R3: f0/0 10.1.2.3/24 f1/0 10.1.1.3/24 s2/0 10.1.3.3/24
R4: s2/0 10.1.3.4/24
全网启用RIPv2
初始配置
R1
conf t
int f1/0
ip ad 10.1.1.1 255.255.255.0
no shut
router rip
ver 2
no au
net 10.0.0.0
line vty 0 4
password cisco
login
end
R2
conf t
int f 0/0
ip ad 10.1.2.2 255.255.255.0
no shut
router rip
ver 2
no au
net 10.0.0.0
end
R3
conf t
int f 0/0
ip ad 10.1.2.3 255.255.255.0
no shut
int f1/0
ip ad 10.1.1.3 255.255.255.0
no shut
int s2/0
ip ad 10.1.3.3 255.255.255.0
encap f
no arp f
no frame inver
frame map ip 10.1.3.4 304 b
no shut
router rip
ver 2
no au
net 10.0.0.0
end
R4
conf t
int s2/0
ip ad 10.1.3.4 255.255.255.0
encap f
no arp f
no frame inver
frame map ip 10.1.3.3 403 b
no shut
router rip
ver 2
no au
net 10.0.0.0
line vty 0 4
password cisco
login
end
1,使用Generic Traffic Shaping(GTS)对流量整型
在R3的F1/0上对R4去往R1的telnet流量整型,限速1MBPS
在R3的F0/0上对R4去往R2的所有流量整型,限速5MBPS
在R3的S2/0上对R1去往R4的UDP流量整型, 发送速率500KBPS,最低速率300KBPS
R3
conf t
access-list 100 permit tcp host 10.1.3.4 host 10.1.1.1 eq telnet
int f1/0
traffic-shape group 100 1000000
int f0/0
traffic-shape rate 5000000
int s2/0
traffic-shape rate 500000
traffic-shape adaptive 300000
traffic-shape fecn-adapt
end
校验
先在R4上PING R2
R4#ping 10.1.2.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.1.2.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 16/92/248 ms
在R4上TELNET R1
R4#telnet 10.1.1.1
Trying 10.1.1.1 ... Open
User Access Verification
Password:
R1>quit
[Connection to 10.1.1.1 closed by foreign host]
在R1上trace R4
R1#trace 10.1.3.4
Type escape sequence to abort.
Tracing the route to 10.1.3.4
1 10.1.1.3 84 msec 32 msec 72 msec
2 10.1.3.4 56 msec * 100 msec
在R3上看结果
R3#sh traffic-shape statistics f1/0
Acc. Queue Packets Bytes Packets Bytes Shaping
I/F List Depth Delayed Delayed Active
Fa1/0
100 0 30 1667 0 0 no
R3#sh traffic-shape statistics f0/0
Acc. Queue Packets Bytes Packets Bytes Shaping
I/F List Depth Delayed Delayed Active
Fa0/0 0 17 1673 0 0 no
R3#sh traffic-shape f1/0
Interface Fa1/0
Access Target Byte Sustain Excess Interval Increment Adapt
VC List Rate Limit bits/int bits/int (ms) (bytes) Active
- 100
1000000 6250 25000 25000 25 3125 -
R3#sh traffic-shape f0/0
Interface Fa0/0
Access Target Byte Sustain Excess Interval Increment Adapt
VC List Rate Limit bits/int bits/int (ms) (bytes) Active
-
5000000 31250 125000 125000 25 15625 -
R3#sh traffic-shape statistics s2/0
Acc. Queue Packets Bytes Packets Bytes Shaping
I/F List Depth Delayed Delayed Active
Se2/0
101 0 3 96 0 0 no
R3#sh traffic-shape s2/0
Interface Se2/0
Access Target Byte Sustain Excess Interval Increment Adapt
VC List Rate Limit bits/int bits/int (ms) (bytes) Active
- 101
500000 3000 12000 12000 24 1500 BECN
2, Class-based Shaping
在R3上定义两个类CBS1和CBS2,使得R1去往R4的telnet流量的带宽512K,在出口时整型为平均速率为600K。R2去往R4的流量时整型,使得其peak值为256K
R3
conf t
access-list 100 permit tcp host 10.1.1.1 host 10.1.3.4 eq telnet
access-list 101 permit ip host 10.1.2.2 host 10.1.3.4
class-map CBS1
match access-group 100
class-map CBS2
match access-group 101
policy-map TOR4
class CBS1
shape average 600000
bandwidth 512
class CBS2
shape peak 256000
int s2/0
service-policy output TOR4
end
校验
在R1上TELNET R4
R1#trace 10.1.3.4
Type escape sequence to abort.
Tracing the route to 10.1.3.4
1 10.1.1.3 84 msec 32 msec 72 msec
2 10.1.3.4 56 msec * 100 msec
R1#telnet 10.1.3.4
Trying 10.1.3.4 ... Open
User Access Verification
Password:
R4>quit
[Connection to 10.1.3.4 closed by foreign host]
R1#
在R2上PING R4
R2#ping 10.1.3.4
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.1.3.4, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 8/66/148 ms
在R3上检查结果
R3#SH policy-map int s2/0
Serial2/0
Service-policy output: TOR4
Class-map: CBS1 (match-all)
23 packets, 1053 bytes
5 minute offered rate 0 bps, drop rate 0 bps
Match: access-group 100
Traffic Shaping
Target/Average Byte Sustain Excess Interval Increment
Rate Limit bits/int bits/int (ms) (bytes)
600000/600000 3750 15000 15000 25 1875
Adapt Queue Packets Bytes Packets Bytes Shaping
Active Depth Delayed Delayed Active
- 0 23 1053 0 0 no
Queueing
Output Queue: Conversation 265
Bandwidth
512 (kbps) Max Threshold 64 (packets)
(pkts matched/bytes matched) 1/53
(depth/total drops/no-buffer drops) 0/0/0
Class-map: CBS2 (match-all)
20 packets, 2080 bytes
5 minute offered rate 0 bps, drop rate 0 bps
Match: access-group 101
Traffic Shaping
Target/Average Byte Sustain Excess Interval Increment
Rate Limit bits/int bits/int (ms) (bytes)
512000/256000 1984 7936 7936 31 1984
Adapt Queue Packets Bytes Packets Bytes Shaping
Active Depth Delayed Delayed Active
- 0 20 2080 0 0 no
Class-map: class-default (match-any)
14 packets, 524 bytes
5 minute offered rate 0 bps, drop rate 0 bps
Match: any
本文出自 “穿过地狱去看海” 博客,谢绝转载!