打开hdlc debug开关的命令:
debug hdlc 
打开HDLCdebug开关

1
Keepaliv
缺省情况下每10秒发一个Keepalive帧(可以用keepalive 0命令禁止发Keepalive帧),Keepalive帧用来检测链路是否正常,并向上层报告。
下面是发送和接收的Keepalive
Serial0 HDLC O: len 22, addr 0x 8f , protocol KEEPALIVE,
type KEEPALIVE_REQ, myseq 5, mineseen 5, yourseen 4, line UP
Serial0 HDLC I: len 22, addr 0x 8f , protocol KEEPALIVE,
type KEEPALIVE_REQ, LocalSeq 6, RemoteSeq 5
O I分别表示输出和输入
第一行
len 22
:长度22字节
addr 0x 8f
:地址字段0x 8f MULTICAST
protocol KEEPALIVE
:协议字段表明为Keepalive
第二行
type KEEPALIVE_REQ
:帧类型为Keepalive请求
myseq 5
:本地发送编号为5
mineseen 5
:本地最近收到的Keepalive帧中所反应出的对方的发送编号为
5
yourseen 4
: 本地最近收到的Keepalive帧中所反应出的本地的发送编号为
4
line UP
:链路正常

第四行为输入Keepalive帧的信息
LocalSeq6
:从收到的帧中看出对方的发送编号为6
RemoteSeq5
:从收到的帧中看出对方最近一次收到本地的帧的发送编号为5
2、上层数据帧
IP 数据
Serial0 HDLC O: len 88, addr 0xf, protocol IP
Serial0 HDLC I: len 88, addr 0xf, protocol IP
IPX 数据
Serial0 HDLC O: len 104, addr 0xf, protocol IPX
Serial0 HDLC I: len 104, addr 0xf, protocol IPX
3、常见问题
两边Keepalive值设置不等一端较大一端较小或一端keepalive值为0,一端不为0
这样发送keepalive间隔较短的一方有可能重发5次都没受到应答,就以为链路出现故障
type KEEPALIVE_REQ, myseq 0, mineseen 0, yourseen 0, line UP
Serial0 HDLC O: len 22, addr 0x 8f , protocol KEEPALIVE,
type KEEPALIVE_REQ, myseq 1, mineseen 0, yourseen 0, line UP
Serial0 HDLC O: len 22, addr 0x 8f , protocol KEEPALIVE,
type KEEPALIVE_REQ, myseq 2, mineseen 0, yourseen 0, line UP
Serial0 HDLC O: len 52, addr 0xf, protocol IPX
Serial0 HDLC O: len 22, addr 0x 8f , protocol KEEPALIVE,
type KEEPALIVE_REQ, myseq 3, mineseen 0, yourseen 0, line UP
Serial0 HDLC O: len 22, addr 0x 8f , protocol KEEPALIVE,
type KEEPALIVE_REQ, myseq 4, mineseen 0, yourseen 0, line UP
Serial0 HDLC O: len 22, addr 0x 8f , protocol KEEPALIVE,
type KEEPALIVE_REQ, myseq 5, mineseen 0, yourseen 0, line UP
% Line protocol ip on interface Serial0, changed state to DOWN
% Line protocol ipx on interface Serial0, changed state to DOWN
Serial0 HDLC O: len 22, addr 0x 8f , protocol KEEPALIVE,
type KEEPALIVE_REQ, myseq 6, mineseen 0, yourseen 0, line DOWN
其中
% Line protocol ip on interface Serial0, changed state to DOWN
% Line protocol ipx on interface Serial0, changed state to DOWN
是因为HDLC认为链路出现了故障,向上层协议报了Down
随后如果物理层是UPKeepalive帧还会继续发

Serial0 HDLC O: len 22, addr 0x8f, protocol KEEPALIVE,
type KEEPALIVE_REQ, myseq 6, mineseen 0, yourseen 0, line DOWN
最后的Down表示现在收不到正确的Keepalive应答
如果将对端的Keepalive值改得和本地一样,过一会就会收到应答,如果编号正确就会向上层报UP,再发送Keepalive时后面就是line UP