拥塞管理简介
当一个接口到达流量过大时,可以通过流量×××,控制输出的流量大小。但是接口上将会导致拥塞,
在拥塞产生后通常使用进入接口前的 WRED 等随机丢弃策略,然后进行标记并使用 PQ、CQ、WFQ 等 QoS
队列进行数据流重新排队输出。如下图所示:

 

DE位 优先丢弃 DE=1
同时,在帧中继环境中仅有一个 DE 位提供优先级设置,而在 IP 环境中可以使用 WFQ+WRED、PQ、
CQ等多种方式进行队列处理,同时IP使用 3位  来表示优先级。所以此时还需要一些策略来使帧中继和 IP
QoS 互联。例如,可以将 IP 优先级为 0 的精力而为通信映射为设置了 DE 位的帧中继,而发送其他比尽力
而为更高及的通信时不标记其DE位。这确保了尽力而为的通信在其他重要通信之前被丢弃。
 
45.4.2  帧中继队列技术
通过上一节的介绍,我们了解了帧中继和IP QoS的互联策略。在Cisco帧中继设备上,通常支持  2个
层次(基于 interface-level 和基于 VC-level)的拥塞管理。在接口模式下,当链路带宽低于 E1(2.048Mbps)时,
WFQ被默认启用。接口队列的配置和以前提及的QoS配置完全相同。而对于VC-level的队列需要在帧中继
主接口上启动FRTS后才会被启用。默认情况下VC-level使用FIFO队列,队列长度为40 个Packets,可以通过
以下命令调整队列长度:
Router(config-map-class)#frame-relay holdq size
在 VC-level 也支持 PQ、CQ 等多种队列,通常使用的队列为 VC-level 队列和 Interface-level 队列串联的
结构,例如,我们在接口模式下启用FRTS,并关闭默认的WFQ队列,同时在接口模式下配置CQ:
interface Serial2/1
  encapsulation frame-relay
  no fair
  frame-relay traffic-shaping
!
interface Serial2/1.100 point-to-point
  ip address 172.16.1.1 255.255.255.0
  frame-relay interface-dlci 201
class CQ
!

interface Serial2/1.101 point-to-point
  ip address 172.16.1.2 255.255.255.0
  frame-relay interface-dlci 202
class CQ
!
map-class frame-relay CQ
  no frame-relay adaptive-shaping
  frame-relay custom-queue-list 1
queue-list 1 protocol ip 1
queue-list 1 protocol ip 2 tcp www
queue-list 1 protocol ip 3 tcp telnet
queue-list 1 protocol ip 4 tcp ftp
queue-list 1 protocol ip 5 tcp smtp
queue-list 1 default 6
配置完成后,将会产生如下图的一个队列:

 

查看接口信息也可以看到由于我们使用了no fair命令产生的FIFO队列信息:
Router#show interface serial2/0
Serial2/0 is up, line protocol is up
   Hardware is M4T
   MTU 1500 bytes, BW 1544 Kbit, DLY 20000 usec,
      reliability 255/255, txload 1/255, rxload 1/255
   Encapsulation FRAME-RELAY, crc 16, loopback not set
<output omitted>
 
   Input queue: 0/75/0/0 (size/max/drops/flushes); Total output drops: 0
   Queueing strategy: fifo
   Output queue: 0/40 (size/max)
   5 minute input rate 0 bits/sec, 0 packets/sec
   5 minute output rate 0 bits/sec, 0 packets/sec
      5 packets input, 65 bytes, 0 no buffer
      Received 0 broadcasts, 0 runts, 0 giants, 0 throttles
      0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored, 0 abort
      9 packets output, 119 bytes, 0 underruns
      0 output errors, 0 collisions, 3 interface resets
      0 output buffer failures, 0 output buffers swapped out
3 carrier transitions          DCD=up    DSR=up    DTR=up    RTS=up    CTS=up

45.4.3  配置帧中继广播队列  
在一个大规模帧中继网络中,当很多 DLCI 端接在一个 FRAD上是,由于必须向每条 DLCI 复制路由选择更
新和服务通告更新,可能会出现性能问题,  为了避免该性能问题,为接口创建一个特殊的广播队列是一种选
择.这个广播队列与普通的接口队列独立分开管理.有自己的缓冲区,可以配置的大小和服务速率.
我们需要定义最大的传输速率或吞吐量限制,以 Byte/s 或者 pps 为单位.提供该队列是为了保证提供不
大于这个最大值.广播队列以低于配置的最大传输速率发送时具有优先权并确保最低带宽分配,这两个传输
速率的限制是为了避免因广播包拥堵在接口上,  在任意测量时间内,实际的传输速率限制是首先达到的那个
速率限制.
Router(config)#interface serial4/2
Router(config-if)#frame-relay broadcast-queue ?
     <1-65535>    Queue size for broadcasts, <cr> to set default values
Router(config-if)#frame-relay broadcast-queue 20 ?
<1000-8000000>    Byte rate per sec. for broadcasts transmission
Router(config-if)#frame-relay broadcast-queue 20 1000 ?
<1-80000>    Max. packets/S broadcasts transmission
Router(config-if)#frame-relay broadcast-queue 20 1000 1000
 

45.4.4  帧中继PVC队列
对于每个PVC都可以使用帧中继  Map-Class来配置队列以及其他属性。常见的几种队列配置方式如下:
Interface Serial 2/1
encapsulation frame-relay
!
interface Serial 2/1.1 point-to-point
frame-relay interface-dlci 101
class    pervcpq
!
interface Serial 2/1.2 point-to-point
frame-relay interface-dlci 102
class    pervccq
!
interface Serial 2/1.3 point-to-point
frame-relay interface-dlci 103
class    pervcwfq
!
map-class frame-relay pervcpq
  frame-relay priority-group 1
priority-list 1 protocol ip high list 1
priority-list 1 default normal
priority-list 1 interface Serial 2/0 low
priority-list 1 queue-limit 30 50 70 20
!
map-class frame-relay pervccq
  no frame-relay adaptive-shaping
  frame-relay custom-queue-list 1
queue-list 1 protocol ip 1
queue-list 1 protocol ip 2 tcp www
queue-list 1 protocol ip 3 tcp telnet
queue-list 1 protocol ip 4 tcp ftp
queue-list 1 protocol ip 5 tcp smtp
queue-list 1 default 6
!
map class frame-relay pervcwfq
frame-relay fair-queue

45.4.5  帧中继PIPQ
在帧中继队列中,通常一个接口会链接多个 VC,虽然我们可以定义基于 PVC 的队列,也可以在接口
上配置各种队列,但是在多VC情况下对于各VC间数据流的控制还需要细化。如下图所示:

 

在DLCI 202中,远端有服务器和语音传输要求,我们希望它的优先级最高,而DLCI 203中仅有语音传
送要求,我们可以将其定义为一个中等流量的VC。而对于DLCI 201 204为普通数据流量。此时我们可以借
助帧中继PIPQ 的方式来区分他们。PIPQ的配置方法如下:
首先需要在物理主接口上配置
Router(config-if)#frame-relay interface-queue priority
 
然后需要定义帧中继映射类,来定义PIPQ 的4个池
map-class frame-relay MEDIUM
  no frame-relay adaptive-shaping
  frame-relay interface-queue priority medium
!
map-class frame-relay NORMAL
  no frame-relay adaptive-shaping
!
map-class frame-relay LOW
  no frame-relay adaptive-shaping
  frame-relay interface-queue priority low
!
map-class frame-relay HIGH
  no frame-relay adaptive-shaping
  frame-relay interface-queue priority high
注意:我们可以注意到,在 Normal配置中,由于默认情况下是将所有的VC放入Normal
池中处理,所以frame-relay interface-queue normal并没有显示出来。
  
最后将其挂接到VC上即可:
interface Serial4/0.102 point-to-point
  ip address 172.16.1.1 255.255.255.252
  frame-relay interface-dlci 202
   class HIGH  

通过show frame-relay PVC命令可以看到不同DLCI的优先级
R1#show frame-relay pvc 202
PVC Statistics for interface Serial4/0 (Frame Relay DTE)
DLCI = 202, DLCI USAGE = LOCAL, PVC STATUS = ACTIVE, INTERFACE = Serial4/0.102
   input pkts 188                      output pkts 187                    in bytes 60826
   out bytes 60836            dropped pkts 0                      in FECN pkts 0
   in BECN pkts 0                      out FECN pkts 0                    out BECN pkts 0
   in DE pkts 0                          out DE pkts 0
   out bcast pkts 182              out bcast bytes 60316
   pvc create time 03:03:40, last time pvc status changed 02:59:20
priority high
 
R1#show frame-relay pvc 203
PVC Statistics for interface Serial4/0 (Frame Relay DTE)
DLCI = 203, DLCI USAGE = LOCAL, PVC STATUS = ACTIVE, INTERFACE = Serial4/0.102
   input pkts 188                      output pkts 187                    in bytes 60826
   out bytes 60836                    dropped pkts 0                      in FECN pkts 0
   in BECN pkts 0                      out FECN pkts 0                    out BECN pkts 0
   in DE pkts 0                          out DE pkts 0
   out bcast pkts 182              out bcast bytes 60316
   pvc create time 03:03:40, last time pvc status changed 02:59:20
priority medium
 

45.4.6  帧中继数据分段
以上我们通过队列的配置虽然解决了很多拥塞时优化的问题。但是对于语音等延迟和抖动敏感的数据
流量还需要做一些特别的处理。相对于以太网而言,大多是用 MTU=1500 字节长度的帧。而帧中继格式下,
帧的长度是可变的,有可能一个大分组排在语音数据流前,这样就会导致语音流量出现抖动。帧中继论坛
(FRF)定义了FRF.12标准,确保小分组被定期发送,从而减少抖动。
如下图所示,在未使用数据分段时,当大长度数据流通过时,  实时的语音流量立刻被丢弃。

 

而在数据分段支持的传输过程中,数据化整为零,变为较小长度的数据段传送,数据段之间可以插入
实时的语音数据流,可以很好的改善语音流被丢弃的情况  。

 


但是,此时我们又将考虑一个问题:在数据化整为零传输后,  接收端如何重组这些数据流,当一个
完整的数据流在分段传送的过程中,有些报文被丢弃,如何保证数据的完整性和丢弃数据段的重发?

帧中继在处理分段的时候,将会为每个帧添加专用的分段报头(Fragmentation Header).对于端到端的分
段而言,其报文格式如下

 

在 Fragmentation-Header 中,B 用于标记第一个分段,而 E 用于标记最后一个分段,C 用于一些未来的
属性配置,现阶段其值为 0。对于数据分段的大小,默认值为 53Bytes,经统计计算 50~70Bytes 是一个相对
有效的区间,Cisco路由器可以配置16~1600Bytes 的分段大小。
在UNI段使用fragmentation 的配置方法如下:
首先还是需要在主接口上激活FRTS

Router(config)#interface serial2/1
Router(config-if)#encapsulation frame-relay
Router(config-if)#frame-relay traffic-shaping
   然后在接口上配置Fragement如下:
Router(config-if)#frame-relay fragment 100 end-to-end
有时候需要对于某些VC使用分段,则在帧中继Map-Class中配置:
Router(config-map-class)#frame-relay fragment 70 end-to-end
 
在NNI段中配置Fragementation的方法类似,在帧中继map-class 中配置:
Router(config-map-class)#frame-relay fragment fragment_size switched
   注意:同样接口必须启用FRTS,同时,接口队列为双FIFO 或者PIPQ。并且对于可交换的PVC
必须使用connect命令配置,而传统的frame-relay route不会有效。
 
支持Fragmentation的帧中继交换机配置如下所示:
interface Serial3/1
  no ip address
  encapsulation frame-relay
  clockrate 64000
  frame-relay interface-dlci 104 switched
  frame-relay intf-type dce
  !
interface Serial3/3
  no ip address
  encapsulation frame-relay
  clockrate 64000
  frame-relay traffic-shaping
  frame-relay interface-dlci 200 switched
   class fr_frag

  frame-relay intf-type nni
  !
map-class frame-relay fr_frag
  frame-relay cir 64000
  frame-relay bc 1000
  no frame-relay adaptive-shaping
  frame-relay fair-queue
  frame-relay fragment 100 switched
  !
connect FRF12 Serial3/1 104 Serial3/3 200
前文提到的双FIFO队列原理如下图所示:

 

通常这种双 FIFO 队列用于帧中继数据分割后将 Fragmentation 产生的数据块放入低优先级的队列,进
行尽力而为的传输  。具体配置如下:
interface Serial2/1
  encapsulation frame-relay
  no fair
  frame-relay traffic-shaping
!
interface Serial2/1.100 point-to-point
  ip address 172.16.1.1 255.255.255.0
  frame-relay interface-dlci 100
   class Fragmentation
   !
map-class frame-relay Fragmentation
   frame-relay fair-queue
   frame-relay fragment 100
 
此时,我们查看接口配置将看到接口启用双FIFO队列的信息:
Router#show interface serial2/0
Serial2/0 is up, line protocol is up
   Hardware is M4T
   MTU 1500 bytes, BW 1544 Kbit, DLY 20000 usec,
      reliability 255/255, txload 1/255, rxload 1/255
   Encapsulation FRAME-RELAY, crc 16, loopback not set
<output omitted>
 
   Input queue: 0/75/0/0 (size/max/drops/flushes); Total output drops: 0
    Queueing strategy: dual fifo

   Output queue: high size/max/dropped 0/256/0
   Output queue: 0/128 (size/max)
   5 minute input rate 0 bits/sec, 0 packets/sec
   5 minute output rate 0 bits/sec, 0 packets/sec
      16 packets input, 208 bytes, 0 no buffer
      Received 0 broadcasts, 0 runts, 0 giants, 0 throttles
      0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored, 0 abort
      21 packets output, 656 bytes, 0 underruns
      0 output errors, 0 collisions, 4 interface resets
      0 output buffer failures, 0 output buffers swapped out
      4 carrier transitions          DCD=up    DSR=up    DTR=up    RTS=up    CTS=up
 
在Fragmentation过程中,有专门针对VoFR情况下的处理方法,通常为FRF.11 Annex C.,在interface-DLCI
模式下启动vofr。然后使用帧中继map-class 配置frame-relay fragment即可,FRF.11 Annex C仅对数据流
量进行分割,对语音流量不进行分割,虽然对语音流量优化十分明显,但通常情况下更倾向于使用 FRF.12.
当然,Cisco也有私有的分段协议用于处理在帧中继环境下的语音传输,  在interface-DLCI模式下使用vofr
cisco,当然和 FRF.11 Annex C一样,也需要使用map-class 或者在接口上配置fragmentation。  
interface Serial2/1
  no ip address
  encapsulation frame-relay
  frame-relay class fragment
  frame-relay traffic-shaping
!
interface Serial2/1.102 point-to-point
  ip address 172.16.1.1 255.255.255.252
  frame-relay interface-dlci 102
!
interface Serial2/1.103 point-to-point
  ip address 172.16.1.5 255.255.255.252
  frame-relay interface-dlci 103
   vofr data 4 call-control 5
!
interface Serial2/1.104 point-to-point
  ip address 172.16.1.9 255.255.255.252
  frame-relay interface-dlci 104
vofr cisco
!
map-class frame-relay fragment
  frame-relay cir 64000
  no frame-relay adaptive-shaping
  frame-relay fair-queue
  frame-relay voice bandwidth 16000
  frame-relay fragment 100

 
对于帧中继数据分段,可以通过以下命令进行查看:
R2#show frame-relay fragment
interface                  dlci      frag-type        frag-size    in-frag        out-frag      dropped-frag
Serial3/3                  200      end-to-end      100                0                    0                    0
 
R1#show frame-relay vofr
interface                vofr-type          dlci      cid      cid-type
Serial2/1.104          VoFR cisco         104        4          data
Serial2/1.104          VoFR cisco      104        5          voice call-control
Serial2/1.103          end-to-end     103        4          data
Serial2/1.103          VoFR                  103        5          voice call-control

R2#show frame-relay fragment interface Serial3/3 200
fragment size 100                                            fragment type end-to-end
  in fragmented pkts 20                                    out fragmented pkts 20
  in fragmented bytes 1140                              out fragmented bytes 1140
  in un-fragmented pkts 0                                out un-fragmented pkts 0
  in un-fragmented bytes 0                              out un-fragmented bytes 0
  in assembled pkts 10                                      out pre-fragmented pkts 10
  in assembled bytes 1040                                out pre-fragmented bytes 1040
  in dropped reassembling pkts 0                  out dropped fragmenting pkts 0
  in timeouts 0
  in out-of-sequence fragments 0
  in fragments with unexpected B bit set 0
  in fragments with skipped sequence number 0
  out interleaved packets 0
 
45.4.7  帧中继拥塞避免
通常在帧中继流量×××中使用的 BECN、FECN 标记由交换机设置,  帧中继交换机采用拥塞检测机制,
当流量到达一个门限时,对所传送的帧进行ECN标记或者DE标记。
首先在帧中继主接口上配置拥塞管理(仅对可交换PVC有效)
Router(config-if)#frame-relay congestion-management  
然后通过设置门限来标记DE
Router(config-fr-congest)#threshold de ?
   <0-100>    DE discard threshold, percentage of maximum queue size
也可以配置ECN消息的门限,以及参数(Be/Bc)门限
Router(config-fr-congest)#threshold ecn ?
   <0-100>    ECN threshold, percentage of maximum queue size
   bc              Configure Frame Relay ECN congestion threshold for Bc traffic
   be              Configure Frame Relay ECN congestion threshold for Be traffic
例如当队列长度超过最大长度的 75%时,标记 ECN,同时要求额定突发速率不超过 Bc 队列最大长度
的50%,并要求不使用Be队列。同时当最大队列长度超过40%后,标记DE位
interface serial1
encapsulation frame-relay
frame-relay intf-type dce
frame-relay congestion-management
threshold ecn 75
threshold ecn be 0
threshold ecn bc 50
threshold de 40

在帧中继PVC 上要配置这样的拥塞检测机制则需要在帧中继map-class 中配置:
Router(config-map-class)#frame-relay congestion threshold de 40
Router(config-map-class)#frame-relay congestion threshold ecn 75
Router(config-map-class)#frame-relay congestion threshold ecn be 0
还有一种方法是配置接口拥塞队列
Router(config-map-class)#frame-relay adaptive-shaping interface-congestion
[queue-depth].
 
Cisco IOS支持在接口上利用Policy-map进行 QoS配置,所以可以利用WRED等方法来避免拥塞。
  首先需要定义一个class-map来匹配需要处理的流量,例如匹配ip流  :
Router(config)#class-map wred
Router(config-cmap)#match protocol ip
  然后配置policy-map,并设置带宽使用
Router(config)#policy-map fr

Router(config-pmap)#class wred
Router(config-pmap-c)#bandwidth percent 75
  此后启用WRED:
Router(config-pmap-c)#random-detect  
Router(config-pmap-c)#random-detect ecn
最后我们将这个policy-map挂接到接口上,在挂接到接口上之前,可以设置接口的最大保留带宽
Router(config-if)#max-reserved-bandwidth 85
Router(config-if)#service-policy output fr
 
通过show interface可以看到队列配置
Router#show interface serial2/2
Serial2/2 is up, line protocol is up  
   Hardware is CD2430 in sync mode
   MTU 1500 bytes, BW 128 Kbit, DLY 20000 usec,  
      reliability 255/255, txload 15/255, rxload 5/255
   Encapsulation FRAME-RELAY, loopback not set
   Keepalive set (10 sec)
   LMI enq sent    24, LMI stat recvd 24, LMI upd recvd 0, DTE LMI up
   LMI enq recvd 0, LMI stat sent    0, LMI upd sent    0
   LMI DLCI 1023    LMI type is CISCO    frame relay DTE
   FR SVC disabled, LAPF state down
   Broadcast queue 0/64, broadcasts sent/dropped 55/0, interface broadcasts 51
   Last input 00:00:00, output 00:00:00, output hang never
   Last clearing of "show interface" counters 00:03:57
   Input queue: 0/75/0/0 (size/max/drops/flushes); Total output drops: 1605
   Queueing strategy: random early detection(RED)
   5 minute input rate 3000 bits/sec, 8 packets/sec
   5 minute output rate 7000 bits/sec, 23 packets/sec
      1954 packets input, 88628 bytes, 0 no buffer
      Received 0 broadcasts, 0 runts, 0 giants, 0 throttles
      0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored, 0 abort
      5778 packets output, 256362 bytes, 0 underruns
      0 output errors, 0 collisions, 0 interface resets
      0 output buffer failures, 0 output buffers swapped out
      0 carrier transitions
      DCD=up    DSR=up    DTR=up    RTS=up    CTS=up

也可以查看队列信息  
R2#show queueing random-detect
Current random-detect configuration:
   Serial2/2
     Queueing strategy: random early detection (WRED)
     Exp-weight-constant: 9 (1/512)
     Mean queue depth: 39
     Class          Random drop              Tail drop                Minimum      Maximum          Mark
     (Prec)        pkts/bytes            pkts/bytes            threshold threshold probability
         0            504/22176                  1068/47114                  20                40              1/10
         1                0/0                                0/0                          22                40              1/10
         2                0/0                                0/0                          24                40              1/10
         3                0/0                                0/0                          26                40              1/10
         4                0/0                                0/0                          28                40              1/10
         5                0/0                                0/0                          31                40              1/10
          6                0/0                                0/0                          33                40              1/10
          7                0/0                                0/0                          35                40              1/10
           rsvp                0/0                                0/0                          37                40              1/10