Link layer之PPP
2015-01-16 12:30
204 查看
3.4 Point-to-Point Protocol(PPP)
它有三个组件:一个封装上层协议的方法
Link Control Protocol(LCP):负责链接的建立和断开。
Network Control Protocol(NCP):负责配置不同网络层的选项。
3.4.1 PPP Operaton
数据包交互过程如下:1、PPP首先发送LCP packets来建立连接和测试连接。
2、发起连接的一端需要进入认证阶段(该阶段是可选的)
3、然后PPP会发送NCP数据包来配置多个network layer protocols(网络层协议)
4、一旦配置完成,network-layer packets就可以在该PPP上传输了。
5、LCP负责断开PPP连接。
3.4.2 PPP frame
1、Flag用于定界frames,固定为“01111110”
2、Address:固定设为“11111111”
3、Control:固定为“00000011”
4、Protocol:指明上层协议,是IP or IPX,默认是16bits,可以通过LCP来协商成8bits
5、Information:最大长度默认为1500bytes
6、FCS:使用CRC,默认为16bits,通过LCP协商可扩展成32bits。重传机制由上层协议维护,如TCP。
Remark:PPP没有Flow Control,也没有Medium Access Control。
3.4.3 IPCP
IPCP是NCP的一种,在建立PPP连接并认证成功之后,用于配置IP protocol over PPP。IPCP的配置项有:IP-Compression-Protocol, and IP-Address。
在IPCP的协商之后,IP packets就可以被封装在PPP中,协议号为0x0021
3.4.4 PPP Drivers
在Linux中,PPP的实现只要由2部分构成:data-plane PPP Driver and control-plane PPP daemon(PPPd)。PPP driver负责建立网络接口并传递数据包。PPPd负责认证、协商。PPP driver由PPP generic layer和PPP channel driver构成。
在linux中有asynchronous and synchronous PPP drivers (对应 ppp_async.c and ppp_synctty.c under the drivers/net directory)。至于到底使用同步还是异步的PPP channel driver取决于您使用的物理卡是同步还是异步。
PPP driver所关联的I/O函数指针定义在tty_ldisc_ops 结构中。
Packet Transmission
要发送的packets被传送到ppp_start_xmit()中,在该函数中,数据包被封装上PPP header,然后将数据包入队到发送队列xq中(see the ppp_file structure in ppp_generic.c )。最后,ppp_start_xmit() 调用 ppp_xmit_process(),该函数将packets出xq队列,然后调用ppp_send_frame()来处理packets,如header compression,之后,ppp_send_frame()会调用ppp_async_send()(异步) , or ppp_sync_send()(同步)来发送数据包。
Packet Reception
不论是同步还是异步的driver将接收的数据包发送给ppp_input(),该函数将packets加入到接收队列rq中。最后,PPPd将从/dev/ppp中读取该packets。
3.4.5 PPPOE
PPPOE就是PPP协议被ETHERNET封装。它一共有两个stages:the Discovery stage and the PPP Session stage。Discovery stage有如下4步:
1、station会广播初始化frame,来得到AC(就是PPP的server)的mac address。
2、一些AC用mac address作为回应。
3、Station会选择一个AC,并向他发送Session-Request frame。
4、该AC生成PPPOE的session id,然后返回一个包含session id的确认帧。
PPP session stage跟PPP的数据交互过程相同,参见3.4.1
[此为原创,转载请标明出处,谢谢!]
相关文章推荐
- 蓝牙BLE LINK LAYER剖析(一) -- status and channel
- PPP Multilink协议
- [BLE--Link Layer]物理信道
- 蓝牙BLE LINK LAYER剖析(二) -- PDU
- 全面了解PPP Multilink
- (链路捆绑)关于PPP Multilink协议的配置
- 关于PPP Multilink协议的配置
- 动画黄金搭档:CADisplayLink & CAShapeLayer
- [BLE--Link Layer]Link层控制之连接参数请求
- What are the different Ethernet frame formats? (Ethernet Data Link Layer)
- 网络高可用性之浮动静态路由、备份接口、Multilink ppp
- [BLE--Link Layer]空中包格式(待续)
- [BLE--Link Layer]物理信道
- Computer Network --- Data Link Layer
- Link Layer Discovery Protocol
- Link layer之device driver
- [BLE--Link Layer]Link Layer状态及其之间的切换
- [BLE--Link Layer]Link层控制之连接更新过程
- (notes)physical and direct link layer
- Link Layer Discovery Protocol (LLDP, IEEE 802.1AB)