Link layer之PPP

来源:互联网 发布:淘宝网进入卖家中心 编辑:程序博客网 时间:2024/06/13 09:47

3.4 Point-to-Point Protocol(PPP)

它有三个组件:

一个封装上层协议的方法

Link Control ProtocolLCP):负责链接的建立和断开。

Network Control ProtocolNCP):负责配置不同网络层的选项。

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

 

RemarkPPP没有Flow Control,也没有Medium Access Control

3.4.3 IPCP

IPCPNCP的一种,在建立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 daemonPPPd)。PPP driver负责建立网络接口并传递数据包。PPPd负责认证、协商。

PPP driverPPP generic layerPPP 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(),该函数将packetsxq队列,然后调用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封装。它一共有两个stagesthe Discovery stage and the PPP Session stage

Discovery stage有如下4步:

1、station会广播初始化frame,来得到AC(就是PPPserver)的mac address

2、一些ACmac address作为回应。

3、Station会选择一个AC,并向他发送Session-Request frame

4、该AC生成PPPOEsession id,然后返回一个包含session id的确认帧。

 

PPP session stagePPP的数据交互过程相同,参见3.4.1


                                                                             [此为原创,转载请标明出处,谢谢!]


0 0
原创粉丝点击