第 1 章 WAN协议(HDLC)
1.1 HDLC协议概述
高级数据链路控制(HDLC)是一种高效协议,Cisco版的HDLC协议和各厂商均不兼容,主要有以下特点:
-
与其它厂商不兼容
-
快速,高效
-
支持keepalive机制
-
支持SLARP
-
支持STAC
Cisco路由器默认的串口封装即为HDLC,可以通过show interface serial 1/0的输出看到默认的设置:
例1-1 通过show interface serial 1/0的输出结果:
Serial1/1 is administratively down, line protocol is down
Hardware is M4T
MTU 1500 bytes, BW 1544 Kbit, DLY 20000 usec,
reliability 255/255, txload 1/255, rxload 1/255
Encapsulation HDLC, crc 16, loopback not set
Keepalive set (10 sec)
Restart-Delay is 0 secs
Last input never, output never, output hang never
Last clearing of "show interface" counters never
Input queue: 0/75/0/0 (size/max/drops/flushes); Total output drops: 0
Queueing strategy: weighted fair
Output queue: 0/1000/64/0 (size/max total/threshold/drops)
Conversations 0/0/256 (active/max active/max total)
Reserved Conversations 0/0 (allocated/max allocated)
Available Bandwidth 1158 kilobits/sec
5 minute input rate 0 bits/sec, 0 packets/sec
5 minute output rate 0 bits/sec, 0 packets/sec
0 packets input, 0 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
0 packets output, 0 bytes, 0 underruns
0 output errors, 0 collisions, 0 interface resets
0 output buffer failures, 0 output buffers swapped out
1 carrier transitions DCD=down DSR=down DTR=up RTS=up CTS=down
HDLC需要的控制开销很小,1个位和一个结束标志字段,一个可变地址字段,一个控制字段和一个信息长度字段。整个数据帧长度控制在7-12个byte。
利用keepalive机制验证连接完整性,DCE端发送序列号到DTE端,DTE按顺序返回,如果序列号连续丢失3次,即关闭此链路。例1-2中可以看到链路由于没有收到keepalive信号返回而断开。使用debug serial interface 命令看到相关的keepalive信息。
例1-2 HDLC帧上没有收到keepalive
R1#debug serial interface
Serial network interface debugging is .
01:05:47: Serial1/0: HDLC myseq 6, mineseen 6, yourseen 2, line up
ßkeepalive KA
01:12:11: Serial1/0: HDLC myseq 7, mineseen 6, yourseen 2, line up
ßKA not received
01:12:21: Serial1/0: HDLC myseq 8, mineseen 6, yourseen 2, line down
ßstill not KA
01:12:31: Serial1/0: HDLC myseq 9, mineseen 6, yourseen 2, line down
01:12:32: %LINEPROTO-5-UPDOWN: Line protocol . Interface Serial1/0, changed state to down
01:12:41: Serial1/0: HDLC myseq 10, mineseen 6, yourseen 2, line down
例1-2中,序列号myseq字段与mineseen字段不匹配,相差大于3,表明keepalive已经丢失3次以上,即重新初始化该链路。另一台路由器的keepalive在yourseen字段中显示。例1-3显示了解决些问题后的调试结果:
例1-3 正常工作时的
HDLC链路调试结果
01:20:11: Serial1/0: HDLC myseq 55, mineseen 0*, yourseen 1, line up
01:20:12: %LINEPROTO-5-UPDOWN: Line protocol . Interface Serial1/0, changed state to up
01:20:21: Serial1/0: HDLC myseq 56, mineseen 56*, yourseen 2, line up
01:20:31: Serial1/0: HDLC myseq 57, mineseen 57*, yourseen 3, line up
01:20:41: Serial1/0: HDLC myseq 58, mineseen 58*, yourseen 4, line up
01:20:51: Serial1/0: HDLC myseq 59, mineseen 59*, yourseen 5, line up
01:21:01: Serial1/0: HDLC myseq 60, mineseen 60*, yourseen 6, line up
01:21:11: Serial1/0: HDLC myseq 61, mineseen 61*, yourseen 7, line up
01:21:21: Serial1/0: HDLC myseq 62, mineseen 62*, yourseen 8, line up
01:21:31: Serial1/0: HDLC myseq 63, mineseen 63*, yourseen 9, line up
只有链路的
layer 1正常工作时,交换keepalive机制才有效。如果DCD=up DSR=up DTR=up RTS=up CTS=up这些项中有一项是down状态,keepalive就不工作。
HDLC通过使用STAC压缩算法支持有效载荷压缩。使用的是压缩技术是Lempel-Ziv压缩算法,能提供良好压缩率,但是占用CPU资源。也适用于LAPB、X.25和帧中继。
1.1.1 HDLC设置
HDLC是串口的默认封装,可以分为3个步骤:
第1步 encapsulation hdlc 配置数据封装格式为HDLC
第2步 clock rate
clock_speed 对DCE端设备设置时钟,在背背实验时设置
第3步 compression stac
配置压缩(可选)
1.1.2 HDLC的“big show”和“big D”
HDLC的big show 和big debug命令包括:show interface
serial_interface 和show controllers
serial_interface。
1、 show interface
serial_interface
例1-4 串口的show interface 信息
R1# sho interfaces serial 1/0
Serial1/0 is up, line protocol is up
<--这两个字段分别代表OSI分层的第1层和第2层
Hardware is M4T
Internet address is 1.1.1.1/30
MTU 1500 bytes, BW 1544 Kbit, DLY 20000 usec,
reliability 255/255, txload 1/255, rxload 1/255
Encapsulation HDLC, crc 16, loopback not set
<--显示封装的格式和CRC信息
Keepalive set (10 sec)
<--keepalive值
Restart-Delay is 0 secs
Last input 00:00:08, output 00:00:03, output hang never
Last clearing of "show interface" counters 00:17:12
Input queue: 0/75/0/0 (size/max/drops/flushes); Total output drops: 0
Queueing strategy: weighted fair
Output queue: 0/1000/64/0 (size/max total/threshold/drops)
Conversations 0/1/256 (active/max active/max total)
Reserved Conversations 0/0 (allocated/max allocated)
Available Bandwidth 1158 kilobits/sec
5 minute input rate 0 bits/sec, 0 packets/sec
5 minute output rate 0 bits/sec, 0 packets/sec
120 packets input, 8201 bytes, 0 no buffer
Received 120 broadcasts, 0 runts, 0 giants, 0 throttles
0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored, 0 abort
120 packets output, 8048 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
2、 show controller serial_interface
例1-5 show controller 信息
R1#sho controller serial 1/0
M4T: show controller:
PAS unit 0, subunit 0, f/w version 1-45, rev ID 0x2800001, version 1
idb = 0x63064FD0, ds = 0x63066D28, ssb=0x63067024
Clock mux=0x0, ucmd_ctrl=0x1C, port_status=0x7B
Serial config=0x8, line config=0x200
maxdgram=1608, bufpool=199Kb, 120 particles
DCD=up DSR=up DTR=up RTS=up CTS=up
line state: up
cable type : V.11 (X.21) DCE cable, received clockrate 2015232
<--线缆类型及确定DCE or DTE,时钟
base0 registers=0x3D000000, base1 registers=0x3D002000
mxt_ds=0x6349A76C, rx ring entries=66, tx ring entries=128
rxring=0x5A363A0, rxr shadow=0x6306CDD0, rx_head=37
txring=0x5A365E0, txr shadow=0x6306D114, tx_head=88, tx_tail=88, tx_count=0
throttled=0, enabled=0
halted=0, last halt reason=0
Microcode fatal errors=0
rx_no_eop_err=0, rx_no_stp_err=0, rx_no_eop_stp_err=0
rx_no_buf=0, rx_soft_overrun_err=0, dump_err= 0, bogus=0, mxt_flags=0x0
tx_underrun_err=0, tx_soft_underrun_err=0, tx_limited=1(2)
tx_fullring=0, tx_started=857
rx_int_count=764, tx_int_count=865
3、命令debug serial interface
使用debug前在设置中设定logging buffered 10000。这样可以避免大量数据占用控制台,无法正常工作。
1.2 HDLC配置
本节中学习HDLC配置步骤方法及相关内容。
1.2.1 实验内容
-
使用HDLC配置三个分公司的路由器
-
使用有效载荷压缩提高传输效率
-
只涉及WAN的配置,LAN不讨论
-
如图1-1配置网络
图1-1
RouterA(1.1.1.1)---------(1.1.1.2)routerB(2.2.2.2)-------- (2.2.2.1)routerC
A为上海分公司 B为北京总公司 C为沈阳分公司
1.2.2 所需设备
1.2.3 实验步骤
北京总公司的router配置为DCE端,提供时钟
北京部公司的router配置主要步骤如下:
第1步 (可选)设置主机名为beijing
第2步 用encapsulation hdlc命令配置串口的HDLC封装
第3步 设置串口上的波特率 (DTE端不需要配置)
第4步 配置压缩
第5步 给串口配置IP地址
1.2.4 完整配置示例
例1-6,三台设置的配置示例
北京总公司路由器B
的配置
version 12.2
service timestamps debug uptime
service timestamps log uptime
no service password-encryption
!
hostname Beijing
interface FastEthernet0/0
no ip address
shutdown
duplex auto
speed auto
!
interface FastEthernet0/1
no ip address
shutdown
duplex auto
speed auto
!
interface Serial1/0
ip address 1.1.1.2 255.255.255.252
serial restart_delay 0
compress stac
clockrate 115200
!
interface Serial1/1
ip address 2.2.2.2 255.255.255.252
serial restart_delay 0
compress stac
clockrate 115200
上海分公司路由器A
的配置
version 12.2
service timestamps debug uptime
service timestamps log uptime
no service password-encryption
!
hostname shanghai
!
logging buffered 10000 debugging
!
ip subnet-zero
!
interface FastEthernet0/0
no ip address
shutdown
duplex auto
speed auto
!
interface FastEthernet0/1
no ip address
shutdown
duplex auto
speed auto
!
interface Serial1/0
ip address 1.1.1.1 255.255.255.252
no ip mroute-cache
compress stac
serial restart_delay 0
沈阳分公司路由器C
的配置
version 12.2
service timestamps debug uptime
service timestamps log uptime
no service password-encryption
!
hostname shenyang
!
ip subnet-zero
!
interface FastEthernet0/0
no ip address
shutdown
duplex auto
speed auto
!
interface FastEthernet0/1
no ip address
shutdown
duplex auto
speed auto
!
interface Serial1/0
ip address 2.2.2.1 255.255.255.252
compress stac
serial restart_delay 0