Thanks
Peter Kaufmann
Search the net for RFC1331 for starters.
-Tim
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.
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...