案例配置拓扑:
2 案例配置需求
1、 根据拓扑配置IP,
2、 在五台路由器之间运行OSPF协议,发布直连网段和环回口;
3、 在R3上对1.1.1.1去往4.4.4.4的数据做流量管制,设置CIR为8000,BE和BC为1000;
4、 在R3上对2.2.2.2去往5.5.5.5的数据做流量整形,设置CIR为8000,BE和BC为1000;
案例配置思路
1.根据拓扑配置IP地址
R1:
interface Loopback0
ip address 1.1.1.1 255.255.255.0
ip ospf network point-to-point
interface Serial1/1
ip address 13.1.1.1 255.255.255.0
serial restart-delay 0
R2:
interface Loopback0
ip address 2.2.2.2 255.255.255.0
ip ospf network point-to-point
interface Serial1/2
ip address 23.1.1.1 255.255.255.0
R3:
interface Loopback0
ip address 3.3.3.3 255.255.255.0
interface Serial1/1
ip address 13.1.1.2 255.255.255.0
interface Serial1/2
ip address 23.1.1.2 255.255.255.0
interface Serial1/4
ip address 34.1.1.2 255.255.255.0
interface Serial1/5
ip address 35.1.1.2 255.255.255.0
R4:
interface Loopback0
ip address 4.4.4.4 255.255.255.0
ip ospf network point-to-point
interface Serial1/4
ip address 34.1.1.1 255.255.255.0
R5:
interface Loopback0
ip address 5.5.5.5 255.255.255.0
ip ospf network point-to-point
interface Serial1/5
ip address 35.1.1.1 255.255.255.0
2.配置OSPF协议
R1:
router ospf 100
router-id 91.1.1.1
log-adjacency-changes
network 1.1.1.0 0.0.0.255 area 0
network 13.1.1.0 0.0.0.255 area 0
R2:
router ospf 100
router-id 92.2.2.2
log-adjacency-changes
network 2.2.2.0 0.0.0.255 area 0
network 23.1.1.0 0.0.0.255 area 0
R3:
router ospf 100
router-id 93.3.3.3
log-adjacency-changes
network 13.1.1.0 0.0.0.255 area 0
network 23.1.1.0 0.0.0.255 area 0
network 34.1.1.0 0.0.0.255 area 0
network 35.1.1.0 0.0.0.255 area 0
R4:
router ospf 100
router-id 94.4.4.4
log-adjacency-changes
network 4.4.4.0 0.0.0.255 area 0
network 34.1.1.0 0.0.0.255 area 0
R5:
router ospf 100
router-id 95.5.5.5
log-adjacency-changes
network 5.5.5.0 0.0.0.255 area 0
network 35.1.1.0 0.0.0.255 area 0
3.在R3配置流量管制
access-list 100 permit ip host 1.1.1.1 host 4.4.4.4
class-map match-all 1-4 /创建类图/
match access-group 100
policy-map 1-4 /创建策略图/
class 1-4 /调用类图/
police cir 8000 bc 1000 be 1000 conform-action transmit exceed-action drop /流量管制,速率为8000 bit,BC为1000,Be为1000,正常流量传输,超出流量丢弃/
4.在R3配置流量整形
access-list 101 permit ip host 2.2.2.2 host 5.5.5.5
class-map match-all 2-5
match access-group 101
policy-map 2-5
class 2-5
shape average 8000 1000 1000
/做流量整形,承诺速率为8000bit,BC为1000,Be为1000,超出的流量缓存/
案例配置结果
1、 配置完成后,用1.1.1.1去ping 4.4.4.4,包大小为分别为1000 byte、500byte、300byte:
2、 配置完成后,用R2的2.2.2.2ping 5.5.5.5,包大小为 1000 byte:
3、 配置完成后,在R3上查看整形策略集:
R3#show policy-map interface serial 1/2
Serial1/2
Service-policy output: 2-5
Class-map: 2-5 (match-all)
0 packets, 0 bytes
5 minute offered rate 0 bps, drop rate 0 bps
Match: access-group 101
Queueing
queue limit 64 packets
(queue depth/total drops/no-buffer drops) 0/0/0
(pkts output/bytes output) 0/0
shape (average) cir 8000, bc 1000, be 1000
target shape rate 8000
Class-map: class-default (match-any)
56 packets, 13588 bytes
5 minute offered rate 0 bps, drop rate 0 bps
Match: any
queue limit 64 packets
(queue depth/total drops/no-buffer drops) 0/0/0
(pkts output/bytes output) 56/13648
4、 配置完成后,用R2的2.2.2.2ping 5.5.5.5,包大小为 2001 byte:
案例总结及其它
1、 流量管制和流量整形使用令牌桶计算流量是否出现拥塞;
2、 令牌桶的参数有承诺速率CIR、添加令牌数量BC、第二个桶速率BE;
3、 管制会将超出令牌桶的流量直接丢弃;
4、 整形会将超出令牌桶的流量缓存起来,知道可用带宽足够时继续传输;
5、 整形的缓存空间是有限的,当数据包大小超过限制时,数据可能被丢弃;