Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

PPP-checksum

230 views
Skip to first unread message

Peter Kaufmann

unread,
Oct 5, 1997, 3:00:00 AM10/5/97
to

Hello
Does anyone know how to build the checksum in the PPP-protocol?
Which parts of a ppp packet must be taken in the checksum and how can I
calculate it?

Thanks
Peter Kaufmann


Tim Smith

unread,
Oct 7, 1997, 3:00:00 AM10/7/97
to

In article 01bcd1d8$ccf0b740$f5a606c2@kaufmann,
Read the applicable RFC docs...it's all there, including example source code
for encoding and decoding. One little detail that's not so clear in the text is
that the checksum gets inverted and then byte-order swapped.

Search the net for RFC1331 for starters.

-Tim


yin

unread,
Oct 8, 1997, 3:00:00 AM10/8/97
to

Peter Kaufmann wrote:
>
> Hello
> Does anyone know how to build the checksum in the PPP-protocol?
> Which parts of a ppp packet must be taken in the checksum and how can I
> calculate it?
>
> Thanks
> Peter Kaufmann
Hi Peter,

You can refer to RFC-1662 "HDLC-like Framing" for PPP FCS calculation
method. There are programs for both 16-bit and 32-bit FCS calculation.
Bear in mind that FCS covers the range from HDLC address field up to the
end of packet, i.e. the last byte of your PPP information field.

Hope this helps you.

Yin.

Steve Parkis

unread,
Oct 19, 1997, 3:00:00 AM10/19/97
to

In article <343AE4...@lukin.com.hk>, yin <y...@lukin.com.hk> wrote:
>Peter Kaufmann wrote:
>>
>> Hello
>> Does anyone know how to build the checksum in the PPP-protocol?
>Hi Peter,
>
> You can refer to RFC-1662 "HDLC-like Framing" for PPP FCS calculation
>method.

That’s the standard reference. In my view, it’s also a PITA.

Here’s what I view as a little more understandable version. It describes how
to calculate the FCS for a frame of PPP data. This does not involve a lookup
table and so on as in the reference. It incorporates all that stuff into an
algorithm that calculates the FCS on the fly. Note the FCS word stuffed into
the end of the frame is calculated over the data between the starting 7E flag
byte and the FCS word immediately preceding the ending 7E flag byte.

Please feel free to shoot holes, suggest improvements, etc. It has worked
reliably for me so far...

Steve

First, in pseudocode:

set initial fcs word value to ffffh
for each byte to be included in fcs
xor byte with low order byte of prior fcs
put result in word as low order byte, 0 as high order byte
for i = 1 to 8
shift word right 1 bit
if 1 was shifted out
xor word with 8048h
endif
end for
put high order byte of prior fcs in low order byte of 2d word
put 0 in high order byte of 2d word
xor the first and second words
store result as prior fcs for next byte
end for
xor final result with ffffh

Here’s what the meat looks like in 80X86 assembler:

fcs dw 0ffffh ;Beginning fcs value
lea di,frame ;point di at beginning of frame
loop0:
;Put high order byte of prior interim fcs into bl, low order into al,

;zeroize ah, bh
mov ax,fcs
mov bl,ah
xor ah,ah
mov bh,ah
;xor frame byte/octet with low order byte of prior interim fcs
xor al,byte ptr[di]
;shift resulting ax right 1 bit, w/ xor if low order bit
;was 1 prior to shift--repeat for total of 8 iterations
mov cx,8
loop1:
shr ax,1
jnc $+5
xor ax,8408h
loop loop1
;now xor bx with result in ax
xor bx,ax
;store result as interim fcs
mov fcs,bx
;get next byte in frame and do it all again unless end of frame marker
inc di
cmp byte ptr [di],7eh
jnz loop0
;when frame complete, xor against ffff for final fcs value
xor bx,0ffffh
mov fcs,bx


Steve

Request reply by mail in addition to post...my news server derails a lot...

0 new messages