Point to Point Protocol (PPP)

 

Point to Point Protocol (PPP)

 


(RFC 1661)
Point to Point Protocol (PPP) protocol is utilized to establish a connection between 
your PC and your ISP (Internet Service Provider). PPP is used on two points-connection only
usually modem to modem. This protocol accomplishes a few main tasks:

Checks the condition of the phone line.
Checks your password.
Provides your computer with an IP address valid for the duration of connection.
Establishes the configuration of packets (packet size, compression, etc).
Acknowledge one part that the other is closing the connection.


PPP operates by sending Request packets and waiting for Acknowledge packets that either accept, reject
or try to change the request.

Various protocols are utilized to accomplish different tasks which together form the PPP.

Link Control Protocol (LCP) checks among other things the condition of the line by sending a
large (4 byte-hex) randomly chosen number (Magic Number) which needs to be returned by the
receiving part.

Password Authentication Protocol (PAP) or Challenged Authentication Protocol (CHAP) checks the
password either sent in clear (PAP) or encrypted (CHAP).

Internet Protocol Control Protocol (IPCP) is utilized to assign an IP address to the PC, to
determine if compression will be used and to setup the configuration of the packets
encapsulated within PPP frames.
PPP PACKET FORMAT
 (example):

The fields are transmitted from left to right.

+----------+----------+----------+----------+---------------+----------+----------
| Flag | Address | Control | Protocol | Information | FCS | Flag |
| 0x7E | 0xFF | 0x03 | 16 bits | * | 16 bits | 0x7E |
+----------+----------+----------+----------+---------------+----------+----------

Here is a typical example of a PPP packet:

7E FF 7D 23 C0 21 7D 21 7D 22 7D 20 7D 38 7D 21 7D 24 7D 25 DC 7D 22 7D 26 7D 20 7D 20
7D 20 7D 20 7D 25 7D 26 29 23 BE 84 7D 27 7D 22 7D 28 7D 22 DF 7D 30 7E

Packet content:

Start 7E
Address FF 03 FF 7D 23
Protocol (LCP) C0 21
Code (CONFREQ) 01 7D 21
Id 01 7D 21
Length 00 18 7D 20 7D 38
Type, Length, MRU 01 04 05 DC 7D 21 7D 24 7D 25 DC
Type, Length, ACCM 02 06 00 00 00 00 7D 22 7D 26 7D 20 7D 20 7D 20 7D 20
Type, Length, MAGIC 05 06 29 23 BE 84 7D 25 7D 26 29 23 BE 84
Type, Length, PFC 07 02 7D 27 7D 22
Type, Length, ACFC 08 02 7D 28 7D 22
FCS DF 10 DF 7D 30
Stop 7E

7E is the flag sequence.
7D is the escape sequence (any octet that follows is added 0x20).

 

FCS CALCULATION




FCS (Frame Check Sequence)is calculated over the entire PPP packet, not including
the start and stop flags (0x7E). For a transmitted packet the calculation is performed
prior to the addition of the 0x7D escape sequences to the octets lower then 0x20.
For a received packet the calculation is performed after eliminating the 0x7D escape
sequences and subtracting 0x20 from the octets marked by the escape sequences.

In the example code,
u16 buff[] is an array containing all octets in the packet with the
FCS octets made equal to zero.
u16 fcs_start is the position of the first octet in the packet
u16 fcs_stop is the position of the last octet in the packet

/*
**************************** fcs_calc *********************
Function: fcs_calc
Description: frame check sequence (fcs) calculation.
**************************************************************
*/
typedef unsigned short u16

u16 short fcs_calc(u16 fcs_start, u16 fcs_stop, u16 buff[])
{
#define P 0x8408
#define fcsinit 0xFFFF

static u16 fcstab[256];
u16 fcs;
u16 b, v;
u16 i;
u16 MSB_fcs, LSB_fcs;

for (b=0; ; ){
v = b;
for (i = 8; i--; )
v = v & 1 ? (v >> 1) ^ P : v >> 1;
fcstab[b] = v & 0xFFFF;
if (++b == 256)
break;
}

fcs = fcsinit;
for (i=fcs_start; i<fcs_stop; i++)
fcs = (fcs >> 8) ^ fcstab[(fcs ^ buff[i]) & 0xFF];
fcs ^= 0xFFFF;

LSB_fcs = ((fcs >> 8) & 0xFF);
MSB_fcs = fcs & 0xFF;

return(MSB_fcs, LSB_fcs);
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值