Let’s Get Technical
Figure 4. The three-bit shift register used to create a CRC check sequence.
acknowledgement messages —
allows us to exchange data reliably.
Checksums are also used to verify
the contents of a file or EPROM or
the contents of a line of text in a file
used for downloading. For example,
here is a text file encoded using
Intel’s Hex record format:
Figure 5. TCP header details.
F
o
r
E
l
e
c
t
r
o
n
i
c
s
Email, we want to know that these
operations are successful. This
guarantees that images and other
web page content — as well as Email
text and binary attachments — are
received without error. Perhaps a
better expression would be
transferred without error.
If we receive some information
and it has been corrupted, we simply
ask for it to be retransmitted. This is
the beauty of the TCP (Transmission
Control Protocol) transport protocol
within the TCP/IP suite of network
protocols. TCP is a connection-oriented protocol where a session is
set up between the transmitter and
receiver (a client computer and a
server computer).
NUTS & VOLTS
E
v
e
r
y
t
h
i
n
g
Reliable exchanges of informa-tion are made possible through the
use of acknowledgement messages
sent back and forth between the
transmitter and receiver. Figure 5
shows the various fields of the TCP
protocol header. The header is a
block of information contained in a
network message that provides
important information to the
application processing the message.
One of the fields in the TCP
header is the checksum field. This
field stores a 16-bit number that is
generated by adding all of the values
represented by the TCP data together,
ignoring any carries out of the 16th
bit position. The 1s complement of
the final sum is saved as the
checksum. For example, if the sum
was the 3C85 hexadecimal, the 1s
complement checksum would be
C37A hex.
When a TCP message is
received, its checksum is recomputed
by adding all of the received data
plus the checksum. Typically, the result
must equal the 0000 hexadecimal (2s
complement checksum) or the FFFF
hex (1s complement checksum). If
the checksum does not match, a
message is sent back to the transmitter
indicating that the data must be
resent.
The checksum — together with
:10200000310028D303DB03E680CA0520DB0
3E6109A
:0E201000C20320DB03E60F47D303DB03E68
0A9
:10201E00CA1A20DB03E610CA0320DB03D30
317170B
:0C202E001717E6F0B04FCD0E02C30320E0
:00000001FF
The last byte on each line (9A on
the first line, FF on the last) is the 2s
complement checksum byte. If you
add all the bytes on each line together,
you should always end up with 00.
Whether we use hardware or
software, protecting our data is
becoming more and more important.
It is worth the time spent investigating
these, and other, techniques for error
detection and correction. NV
About the Author
James Antonakos is a Professor in the
Departments of Electrical Engineering
Technology and Computer Studies at
Broome Community College. He has over 28
years of experience designing digital and
analog circuitry and developing software. He
is also the author of numerous textbooks on
microprocessors, programming, and
microcomputer systems. You may reach him
at antonakos_j@sunybroome.edu or visit his
website at www.sunybroome.edu/
~antonakos_j
18
JULY 2004