PPP协议帧格式
PPP(Point-to-Point Protocol)协议处于OSI(Open Systems Interconnection)参考模型的数据链路层,同时也处于TCP/IP协议栈的链路层,主要用在支持全双工的同异步链路上,进行点到点之间的数据传输。PPP帧的内容是指Address、Control、Protocol和Information四个域的内容。
一、PPP协议帧格式
|<-------------------------- 7 - 1508 bytes --------------------------->|
+---0x7E---+---0xFF---+---0x03---+----------+---------------+----------+---0x7E----
| Flag | Address | Control | Protocol | Information | FCS | Flag |
| 01111110 | 11111111 | 00000011 | 8/16bits | * | 16 bits | 01111110 |
+----------+----------+----------+----------+---------------+----------+-----------
| 0-1500 bytes |
| |
| |
| |
| |
+----------+----------+-----------------+-------
Format of an LCP packet: | Code |Identifier| Length | Data |
| 8 bits | 8 bits | 16 bits | ... |
+----------+----------+-----------------+-------
| |
| |
| |
| |
| |
+----------+----------+--------+----------+----------+------+------
Format of LCP | Type | Length1 | Data1 | Type | Length1 | Data2| ... |
configuration parameters: | 8 bits | 8 bits | ... | 8 bits | 8 bits | ... | |
+----------+----------+--------+----------+----------+------+------
二、PPP协议帧字段解释
字段 |
长度 |
含义 |
Flag |
1字节 |
标志域,标识了一个物理帧的起始和结束,该字节为0x7E。 |
Address |
1字节 |
PPP协议被运用在点对点的链路上,它可唯一标识对方,因此无须知道对方数据链路层地址。所以该字节无任何意义,按协议规定填充为全1广播地址。 |
Control |
1字节 |
同Address域一样,PPP数据帧的Control域也没有实际意义,规定值为0x03,该域与Address域一起标识了PPP报文,即PPP报文头为FF03。 |
Protocol |
1或2字节 |
协议域,可用来区分PPP数据帧中信息域所承载的数据报文的内容。协议域的内容必须依据ISO 3309的地址扩展机制所给出的规定。该机制规定协议域所填充的内容必须为奇数,也就是要求低字节的最低位为“1”,高字节的最低位为“0”。如果当发送端发送的PPP数据帧的协议域字段不符合上述规定,接收端则会认为此数据帧是不可识别的。接收端向发送端发送一个Protocol-Reject报文,在该报文尾部将填充被拒绝报文的协议号。 · 0x0021: Internet Protocol · 0x002b: Novell IPX · 0x002d: Van Jacobson Compressed TCP/IP · 0x002f: Van Jacobson Uncompressed TCP/IP · 0x0057: Internet Protocol Version 6 · 0x8021: Internet Protocol Control Protocol · 0x802b: Novell IPX Control Protocol · 0x8031: Bridging NC · 0x8057: IPv6 Control Protocol · 0xC021: Link Control Protocol · 0xC023: Password Authentication Protocol · 0xC223: Challenge Handshake Authentication Protocol |
Information |
0~1500字节 |
信息域,缺省最大长度是1500字节,其中包括填充域的内容。信息域的最大长度等于PPP协议中MRU(Maximum Receive Unit)的缺省值。在实际应用当中可根据实际需要进行信息域最大封装长度选项的协商。 如果信息域长度不足1500字节,可被填充,但不是必须的。如果填充,则需通信双方的两端能辨认出有用与无用的信息,方可正常通信。 |
FCS |
2字节 |
校验域,其功能主要对PPP数据帧传输的正确性进行检测,其计算范围是除了标志域(Flag域)的其他域。 在数据帧中引入了一些传输的保证机制,会引入更多的开销,这样可能会增加应用层交互的延迟。 |
Code |
1字节 |
代码域,主要是用来标识LCP数据报文的类型。在链路建立阶段,接收方接收到LCP数据报文。当其代码域的值无效时,就会向对端发送一个LCP的代码拒绝报文(Code-Reject报文)。如果是IP报文,则不存在此域,取而代之的是IP报文内容。 常见Code值如下: · 0x01: Configure-Request · 0x02: Configure-Ack · 0x03: Configure-Nak · 0x04: Configure-Reject · 0x05: Terminate-Request · 0x06: Terminate-Ack · 0x07: Code-Reject · 0x08: Protocol-Reject · 0x09: Echo-Request · 0x0a: Echo-Replyt · 0x0b: Discard-Request · 0x0c: Reserved |
Identifier |
1字节 |
标识域,表示进行协商报文的匹配关系。标识域目的是用来匹配请求和响应报文。 一般而言,在进入链路建立阶段时,通信双方任何一端都会连续发送几个配置请求报文(Configure-Request报文)。这几个请求报文的数据域的值可能是完全一样的,只是它们的标识域不同。 通常一个配置请求报文的ID是从0x01开始逐步加1的。 当对端接收到该配置请求报文后,无论使用何种报文回应对方,但必须要求回应报文中的ID要与接收报文中的ID一致。当通信设备收到回应后就可以将该回应报文与发送时的报文进行比较来决定下一步的操作。 |
Length |
2字节 |
长度域,表示此协商报文长度,也就是该LCP报文的总字节数。它是代码域、标识域、长度域和数据域四个域长度的总和。 长度域所指示字节数之外的字节将被当作填充字节而忽略掉,而且该域的值不能超过MRU的值。 |
Data |
变长 |
数据域,所包含的是协商报文的内容。 · Type为协商选项类型。常见Type中的协商类型值: 0x01: Maximum-Receive-Unit 0x02: Async-Control-Character-Map 0x03: Authentication-Protocol 0x04: Quality-Protocol 0x05: Magic-Number 0x06: RESERVED 0x07: Protocol-Field-Compression 0x08: Address-and-Control-Field-Compression · Length为协商选项长度,它是指Data域的总长度,也就是包含Type、Length和Data。 · Data为协商的选项具体内容。 |
三、PPP协议帧示例
3.1、PPP LCP帧(Configure-Request)
Frame 1: 16 bytes on wire (128 bits), 16 bytes captured (128 bits)
Arrival Time: Apr 24, 2009 06:38:09.600000000
Epoch Time: 1240526289.600000000 seconds
[Time delta from previous captured frame: 0.000000000 seconds]
[Time delta from previous displayed frame: 0.000000000 seconds]
[Time since reference or first frame: 0.000000000 seconds]
Frame Number: 1
Frame Length: 16 bytes (128 bits)
Capture Length: 16 bytes (128 bits)
[Frame is marked: False]
[Frame is ignored: False]
[Protocols in frame: ppp:lcp]
Point-to-Point Direction: Sent (0)
Point-to-Point Protocol
Address: 0xff
Control: 0x03
Protocol: Link Control Protocol (0xc021)
[Direction: DTE->DCE (0)]
PPP Link Control Protocol
Code: Configuration Request (0x01)
Identifier: 0x01
Length: 10
Options: (6 bytes)
Async Control Character Map: 0x000a0000 (, DC1 (XON)DC3 (XOFF))
3.2、 PPP LCP帧(Configure-Reject)
Frame 1: 20 bytes on wire (160 bits), 20 bytes captured (160 bits)
Arrival Time: Apr 24, 2009 06:38:09.600000000
Epoch Time: 1240526289.600000000 seconds
[Time delta from previous captured frame: 0.000000000 seconds]
[Time delta from previous displayed frame: 0.000000000 seconds]
[Time since reference or first frame: 0.000000000 seconds]
Frame Number: 1
Frame Length: 20 bytes (160 bits)
Capture Length: 20 bytes (160 bits)
[Frame is marked: False]
[Frame is ignored: False]
[Protocols in frame: ppp:lcp]
Point-to-Point Direction: Sent (0)
Point-to-Point Protocol
Address: 0xff
Control: 0x03
Protocol: Link Control Protocol (0xc021)
[Direction: DTE->DCE (0)]
PPP Link Control Protocol
Code: Configuration Reject (0x04)
Identifier: 0x00
Length: 14
Options: (10 bytes)
Magic number: 0x43acefab
Protocol field compression
Address/control field compression
3.3、PPP LCP帧(Configure-NAK)
Frame 6: 20 bytes on wire (160 bits), 20 bytes captured (160 bits)
Arrival Time: Apr 24, 2009 06:38:09.600000000
Epoch Time: 1240526289.600000000 seconds
[Time delta from previous captured frame: 0.000000000 seconds]
[Time delta from previous displayed frame: 0.000000000 seconds]
[Time since reference or first frame: 0.000000000 seconds]
Frame Number: 6
Frame Length: 20 bytes (160 bits)
Capture Length: 20 bytes (160 bits)
[Frame is marked: False]
[Frame is ignored: False]
[Protocols in frame: ppp:lcp]
Point-to-Point Direction: Received (1)
Point-to-Point Protocol
Address: 0xff
Control: 0x03
Protocol: Link Control Protocol (0xc021)
[Direction: DCE->DTE (1)]
PPP Link Control Protocol
Code: Configuration Nak (0x03)
Identifier: 0x01
Length: 14
Options: (10 bytes)
Magic number: 0x43ace5f9
Protocol field compression
Address/control field compression
3.4、PPP LCP帧(Configure-ACK)
Frame 1: 16 bytes on wire (128 bits), 16 bytes captured (128 bits)
Arrival Time: Apr 24, 2009 06:38:09.600000000
Epoch Time: 1240526289.600000000 seconds
[Time delta from previous captured frame: 0.000000000 seconds]
[Time delta from previous displayed frame: 0.000000000 seconds]
[Time since reference or first frame: 0.000000000 seconds]
Frame Number: 1
Frame Length: 16 bytes (128 bits)
Capture Length: 16 bytes (128 bits)
[Frame is marked: False]
[Frame is ignored: False]
[Protocols in frame: ppp:lcp]
Point-to-Point Direction: Sent (0)
Point-to-Point Protocol
Address: 0xff
Control: 0x03
Protocol: Link Control Protocol (0xc021)
[Direction: DTE->DCE (0)]
PPP Link Control Protocol
Code: Configuration Ack (0x02)
Identifier: 0x01
Length: 10
Options: (6 bytes)
Async Control Character Map: 0x00000000 (None)
3.5、PPP LCP帧(Discard-Request)
Frame 1: 14 bytes on wire (112 bits), 14 bytes captured (112 bits)
Arrival Time: Apr 24, 2009 06:38:09.600000000
Epoch Time: 1240526289.600000000 seconds
[Time delta from previous captured frame: 0.000000000 seconds]
[Time delta from previous displayed frame: 0.000000000 seconds]
[Time since reference or first frame: 0.000000000 seconds]
Frame Number: 1
Frame Length: 14 bytes (112 bits)
Capture Length: 14 bytes (112 bits)
[Frame is marked: False]
[Frame is ignored: False]
[Protocols in frame: ppp:lcp]
Point-to-Point Direction: Received (1)
Point-to-Point Protocol
Address: 0xff
Control: 0x03
Protocol: Link Control Protocol (0xc021)
[Direction: DCE->DTE (1)]
PPP Link Control Protocol
Code: Discard Request (0x0b)
Identifier: 0x02
Length: 8
Magic number: 0x43acefab
3.6、PPP LCP帧(Protocol-Reject)
Frame 1: 24 bytes on wire (192 bits), 24 bytes captured (192 bits)
Arrival Time: Apr 24, 2009 06:38:09.600000000
Epoch Time: 1240526289.600000000 seconds
[Time delta from previous captured frame: 0.000000000 seconds]
[Time delta from previous displayed frame: 0.000000000 seconds]
[Time since reference or first frame: 0.000000000 seconds]
Frame Number: 1
Frame Length: 24 bytes (192 bits)
Capture Length: 24 bytes (192 bits)
[Frame is marked: False]
[Frame is ignored: False]
[Protocols in frame: ppp:lcp:ccp]
Point-to-Point Direction: Received (1)
Point-to-Point Protocol
Address: 0xff
Control: 0x03
Protocol: Link Control Protocol (0xc021)
[Direction: DCE->DTE (1)]
PPP Link Control Protocol
Code: Protocol Reject (0x08)
Identifier: 0x03
Length: 18
Rejected protocol: Compression Control Protocol (0x80fd)
Rejected packet (12 bytes)
PPP Compression Control Protocol
Code: Configuration Request (0x01)
Identifier: 0x01
Length: 12
Options: (8 bytes)
Deflate
Window: 7
Method: zlib compression (0x08)
Sequence number check method: 0
MVRCA (Magnalink)
Features: 3
Packet by Packet flag: true
History: 32
Number of contexts: 0
3.7、PPP IPCP帧(Configuration-Request)
Frame 1: 16 bytes on wire (128 bits), 16 bytes captured (128 bits)
Arrival Time: Apr 24, 2009 06:38:09.600000000
Epoch Time: 1240526289.600000000 seconds
[Time delta from previous captured frame: 0.000000000 seconds]
[Time delta from previous displayed frame: 0.000000000 seconds]
[Time since reference or first frame: 0.000000000 seconds]
Frame Number: 1
Frame Length: 16 bytes (128 bits)
Capture Length: 16 bytes (128 bits)
[Frame is marked: False]
[Frame is ignored: False]
[Protocols in frame: ppp:ipcp]
Point-to-Point Direction: Received (1)
Point-to-Point Protocol
Address: 0xff
Control: 0x03
Protocol: IP Control Protocol (0x8021)
[Direction: DCE->DTE (1)]
PPP IP Control Protocol
Code: Configuration Request (0x01)
Identifier: 0x00
Length: 10
Options: (6 bytes)
IP address: 10.28.113.85
3.8、 PPP IPCP帧(Configuration-Ack)
Frame 1: 16 bytes on wire (128 bits), 16 bytes captured (128 bits)
Arrival Time: Apr 24, 2009 06:38:09.600000000
Epoch Time: 1240526289.600000000 seconds
[Time delta from previous captured frame: 0.000000000 seconds]
[Time delta from previous displayed frame: 0.000000000 seconds]
[Time since reference or first frame: 0.000000000 seconds]
Frame Number: 1
Frame Length: 16 bytes (128 bits)
Capture Length: 16 bytes (128 bits)
[Frame is marked: False]
[Frame is ignored: False]
[Protocols in frame: ppp:ipcp]
Point-to-Point Direction: Sent (0)
Point-to-Point Protocol
Address: 0xff
Control: 0x03
Protocol: IP Control Protocol (0x8021)
[Direction: DTE->DCE (0)]
PPP IP Control Protocol
Code: Configuration Ack (0x02)
Identifier: 0x00
Length: 10
Options: (6 bytes)
IP address: 10.28.113.85
3.9、 PPP IPCP帧(Configuration-Nak)
Frame 1: 28 bytes on wire (224 bits), 28 bytes captured (224 bits)
Arrival Time: Apr 24, 2009 06:38:09.600000000
Epoch Time: 1240526289.600000000 seconds
[Time delta from previous captured frame: 0.000000000 seconds]
[Time delta from previous displayed frame: 0.000000000 seconds]
[Time since reference or first frame: 0.000000000 seconds]
Frame Number: 1
Frame Length: 28 bytes (224 bits)
Capture Length: 28 bytes (224 bits)
[Frame is marked: False]
[Frame is ignored: False]
[Protocols in frame: ppp:ipcp]
Point-to-Point Direction: Received (1)
Point-to-Point Protocol
Address: 0xff
Control: 0x03
Protocol: IP Control Protocol (0x8021)
[Direction: DCE->DTE (1)]
PPP IP Control Protocol
Code: Configuration Nak (0x03)
Identifier: 0x01
Length: 22
Options: (18 bytes)
IP address: 10.160.219.2
Primary DNS server IP address: 10.28.114.91
Secondary DNS server IP address: 10.28.122.93
3.10、PPP CCP帧(Configuration-Request)
Frame 15: 18 bytes on wire (144 bits), 18 bytes captured (144 bits)
Arrival Time: Apr 24, 2009 06:38:09.600000000
Epoch Time: 1240526289.600000000 seconds
[Time delta from previous captured frame: 0.000000000 seconds]
[Time delta from previous displayed frame: 0.000000000 seconds]
[Time since reference or first frame: 0.000000000 seconds]
Frame Number: 15
Frame Length: 18 bytes (144 bits)
Capture Length: 18 bytes (144 bits)
[Frame is marked: False]
[Frame is ignored: False]
[Protocols in frame: ppp:ccp]
Point-to-Point Direction: Sent (0)
Point-to-Point Protocol
Address: 0xff
Control: 0x03
Protocol: Compression Control Protocol (0x80fd)
[Direction: DTE->DCE (0)]
PPP Compression Control Protocol
Code: Configuration Request (0x01)
Identifier: 0x01
Length: 12
Options: (8 bytes)
Deflate
Window: 7
Method: zlib compression (0x08)
Sequence number check method: 0
MVRCA (Magnalink)
Features: 3
Packet by Packet flag: true
History: 32
Number of contexts: 0
四、PPP协议参考标准
RFC 1661 |
The Point-to-Point Protocol (PPP) |
RFC 1055 |
A NONSTANDARD FOR TRANSMISSION OF IP DATAGRAMS OVER SERIAL LINES: SLIP |
RFC 1144 |
Compressing TCP/IP headers for low-speed serial links |
RFC 1717 |
The PPP Multilink Protocol (MP) |
RFC 1332 |
The PPP Internet Protocol Control Protocol (IPCP) |
RFC 1962 |
The PPP Compression Control Protocol (CCP) |
发表评论