text
stringlengths
0
99.6k
which: <SOH> = 01 hex <blk #> =
binary number, starts at 01 increments
by 1, and wraps 0FFH to 00H (not to
01) <255-blk #> = ones complement of
blk #. <CRC hi> = byte containing the
8 hi order coefficients of the CRC.
<CRC lo> = byte containing the 8 lo
order coefficients of the CRC.
9. CRC CALCULATION
---- 9A. FORMAL DEFINITION OF THE CRC
CALCULATION To calculate the 16 bit
CRC the message bits are considered to
be the coefficients of a polynomial.
This message polynomial is first
multiplied by X^16 and then divided by
the generator polynomial (X^16 + X^12 +
X^5 + 1) using modulo two arithemetic.
The remainder left after the division
is the desired CRC. Since a message
block in the Modem Protocol is 128
bytes or 1024 bits, the message
polynomial will be of order X^1023.
The hi order bit of the first byte of
the message block is the coefficient of
X^1023 in the message polynomial.
The lo order bit of the last byte of
the message block is the coefficient
of X^0 in the message polynomial.
---- 9B. EXAMPLE OF CRC CALCULATION
WRITTEN IN C /* This function
calculates the CRC used by the "Modem
Protocol". The first argument is a
pointer to the message block. The
second argument is the number of bytes
in the message block. The message
block used by the Modem Protocol
contains 128 bytes. The function
return value is an integer which
contains the CRC. The lo order 16
bits of this integer are the
coefficients of the CRC. The lo order
bit is the lo order coefficient of the
CRC. */ int calcrc(ptr, count) char
*ptr; int count; int crc, i;
crc = 0; while(--count >= 0)
crc = crc ^ (int)*ptr++ << 8;
for(i = 0; i < 8; ++i)
if(crc & 0x8000) crc
= crc << 1 ^ 0x1021; else
crc = crc << 1;
return (crc & 0xFFFF);
10. FILE LEVEL PROTOCOL, CHANGES FOR
COMPATIBILITY
---- 10A. COMMON TO BOTH SENDER AND
RECEIVER: The only change to the
File Level Protocol for the CRC option
is the initial handshake which is used
to determine if both the sending and
the receiving programs support the CRC
mode. All Modem Programs should
support the checksum mode for
compatibility with older versions.
A receiving program that wishes to
receive in CRC mode implements the
mode setting handshake by sending a <C>
in place of the initial <NAK>. If the
sending program supports CRC mode it
will recognize the <C> and will set
itself into CRC mode, and respond by
sending the first block as if a <NAK>
had been received. If the sending
program does not support CRC mode it
will not respond to the <C> at all.
After the receiver has sent the <C> it
will wait up to 3 seconds for the
<SOH> that starts the first block. If
it receives a <SOH> within 3 seconds
it will assume the sender supports CRC
mode and will proceed with the file
exchange in CRC mode. If no <SOH> is
received within 3 seconds the receiver
will switch to checksum mode, send a
<NAK>, and proceed in checksum mode.
If the receiver wishes to use checksum
mode it should send an initial <NAK>
and the sending program should respond
to the <NAK> as defined in the
original Modem Protocol. After the
mode has been set by the initial <C> or
<NAK> the protocol follows the
original Modem Protocol and is
identical whether the checksum or CRC
is being used.
---- 10B. RECEIVE PROGRAM CONSIDERATIONS: