1. COMMUNICATION ERROR DETECTION
AND CORRECTION
DATA COMMUNICATION ERRORS
F Data communication errors are undesirable changes
in the bit pattern of data that occur after the data goes
from the internal PC data bus enroute to an external
device or computer.
F They can appear at any point along a communication
link.
F Data communication errors can produce catastrophic
results if not quickly detected and corrected.
REDUNDANCY ERROR-DETECTION TECHNIQUES
F To detect and correct communications errors, a sender
must provide a receiver with information that allows
the receiver to verify proper receipt of information or
data.
F This additional information is called error checking
data or redundancy data.
F The sender must use a mathematical technique to
calculate this error checking data based on the bit
stream of information it will send.
Communication Error Detection and Correction 1
2. ERROR-DETECTION TECHNIQUES
F Parity Checking
This technique is primarily for detecting errors when
the number of information bits is small and the
probability of an error being present is small.
Two Kinds of Parity Checking:
1. Even Parity. The number of 1’s in a word
should be even.
Example:
A = 1000001
B = 1000010 In ASCII
C = 1000011
Applying the parity bit:
A = 0 1000001
B = 0 1000010
C = 1 1000011
Communication Error Detection and Correction 2
3. 2. Odd Parity. The number of 1’s in a word
should be odd.
Example:
A = 1000001
B = 1000010 In ASCII
C = 1000011
Applying the parity bit:
A = 1 1000001
B = 1 1000010
C = 0 1000011
Take note the parity checking can only detect any odd
number of digit corruptions
Communication Error Detection and Correction 3
4. F Block Sum Checking
Parity checking is done on a per block basis.
Example: Transmit DATACOM
D = 1000100 C = 1000011
A = 1000001 O = 1001111
T = 1010100 M = 1001101
(odd)
1 1 0 0 0 1 0 0 D
1 1 0 0 0 0 0 1 A
0 1 0 1 0 1 0 0 T
1 1 0 0 0 0 0 1 A
Traverse (Row)
Parity Bits 0 1 0 0 0 0 1 1 C
0 1 0 0 1 1 1 1 O
1 1 0 0 1 1 0 1 M
0 1 0 1 0 0 0 1 (even)
Longitudinal (Column)
Parity Bits
Communication Error Detection and Correction 4
5. F Polynomial Codes
In using polynomial codes, a single set of check digits
referred to as the frame check sequence or cyclic
redundancy check is generated or computed for each
frame.
Polynomial codes are based upon treating bit strings as
representations of polynomials with coefficients of 0
and 1 only.
A k-bit string or frame is regarded as the coefficient
list for a polynomial with k terms, ranging from Xk-1 to
X0. The MSB is the coefficient of Xk-1 while the LSB
is the coefficient of X0.
Example:
110001 - 6 bits (represents a 6-term polynomial)
M(X) = 1ŸX5 + 1ŸX4 + 0ŸX3 + 0ŸX2 + 0ŸX1 + 1ŸX0
= X5 + X4 + X0
= X5 + X4 + 1
Degree of 110001 = 5
(highest exponent)
Communication Error Detection and Correction 5
6. In using the polynomial code, the sender and receiver
agree upon a generator polynomial G(X) in advanced.
Algorithm for computing the FCS:
1. Let r be the degree of G(X). Append r zero bits
to the low-order end of the message frame M(X),
so it now contains m + r bits where m is the
number of bits in M(X).
The resulting frame will be called M ’(X).
2. Divide the bit string corresponding to G(X) into
the bit string corresponding to M‘(X) using
modulo 2 arithmetic.
Modulo 2 Arithmetic (XOR)
Examples:
10011011 00110011
+ 11001010 - 11001101
01010001 11111110
3. Subtract the remainder (which is always r or
fewer bits) from M’(X) using modulo 2
subtraction. The result is the checksummed
frame to be transmitted T(X).
Communication Error Detection and Correction 6
8. To compute for T(X):
11010110110000
- 1110
11010110111110 = Frame to be
Transmitted, T(X)
When the receiver gets the transmitted frame
T(X), it tries dividing it by G(X). If there is a
remainder, there has been a transmission error.
Some Points Regarding Polynomial Codes:
1. T(X) is exactly divisible (modulo 2) by G(X).
In any division problem, if the remainder is
subtracted from the dividend, what is left over is
divisible by the divisor.
Example:
M’ = 11
G = 5
Remainder of M’ / G = 1
T = 11 -1 = 10 Exactly divisible
by G
Communication Error Detection and Correction 8
9. 2. Assume that a transmission error occurs so that
instead of the polynomial for the transmitted
message T(X) arriving, T(X) + E(X) arrives.
Those errors that happen to correspond to
polynomials containing G(X) as a factor will slip
by unnoticed, but all other errors will be caught.
Example:
T(X) = 11010110111110
E(X) = 10011
T(X) + E(X) = 11010110101101
If the receiver tries to divide this
by G(X), there will be no
remainder (error was not
detected).
Communication Error Detection and Correction 9
10. An important characteristic of the polynomial code
method is that all burst of errors with fewer terms or
bits than the generator polynomial are detected.
Standards in CRC (For Generator Polynomial)
1. CRC - 12
X12 + X11 + X3 + X2 + X + 1
2. CRC - 16
X16 + X15 + X2 + 1
3. CRC - CCITT
X16 + X12 + X5 + 1
4. CRC - 32
X32 + X26 + X23 + X22 + X16 + X12 +
X11 + X10 + X8 + X7 + X5 + X4 +
X2 + X + 1
Communication Error Detection and Correction 10
11. ERROR-CORRECTION TECHNIQUES
F Error-correction techniques allow the receiver to
determine which bit or bits is/are erroneous thereby
allowing it to make the necessary corrections.
F One popular error-correction technique uses the
Hamming codes.
F In using Hamming codes, the bits of the message to be
transmitted are numbered consecutively, starting with
bit 1 at the left end.
The bits of the message that will be transmitted are
therefore numbered as:
b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 . . .
Those bits that are powers of 2 (b1, b2, b4, b8, etc.) are
the check bits (the exact values of which will be
computed) while the rest of the bits (b3, b4, b5, b6, b7,
b9, etc.) are the data bits.
Each check bit forces the parity of some collection of
bits, including itself, to be even (or odd). A bit may be
included in several parity computations.
Communication Error Detection and Correction 11
12. To determine which check bits the data bit in position
k contributes to, rewrite k as a sum of powers of two.
Example:
11 = 1 + 2 + 8
This means that b11 is checked by b1,
b2, and b8.
F Case Study: Transmit the byte 1101101
The actual bits that will be transmitted are:
b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11
1 1 0 1 1 0 1
The values of the check bits b1, b2, b4, and b8 will
have to be computed.
b3 is checked by bits b1 and b2.
b5 is checked by bits b1 and b4.
b6 is checked by bits b2 and b4.
b7 is checked by bits b1, b2 and b4.
b9 is checked by bits b1 and b8.
b10 is checked by bits b2 and b8.
b11 is checked by bits b1, b2 and b8.
Communication Error Detection and Correction 12
13. Summarizing which data bits are checked by a
certain check bit:
b1 checks data bits b3, b5, b7, b9, b11
b2 checks data bits b3, b6, b7, b10, b11
b4 checks data bits b5, b6, b7
b8 checks data bits b9, b10, b11
By using the values of the data bits and by
assuming that even parity is used, the values of
the check bits are computed as:
b1 = 1
b2 = 1
b4 = 0
b8 = 0
The actual bits that will be transmitted are
therefore:
b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11
1 1 1 0 1 0 1 0 1 0 1
Communication Error Detection and Correction 13
14. F Correcting Errors
Assume that the transmitted code is:
1 1 1 0 1 0 1 0 1 0 1
However, due to impulse noise, b9 was corrupted.
The received message is therefore:
1 1 1 0 1 0 1 0 0 0 1
The receiver checks for parity errors as follows:
1st group: b1, b3, b5, b7, b9, b11
1 1 1 1 0 1
2nd group: b2, b3, b6, b7, b10, b11
1 1 0 1 0 1
3rd group: b4, b5, b6, b7
0 1 0 1
4th group: b8, b9, b10, b11
0 0 0 1
There is a parity error in groups 1 and 4. By method
of elimination, the erroneous bit cannot be b4, b5, b6,
b7, b8, b10, and b11 since all of these bits are present in
groups 2 and 3 and yet there these groups do not
indicate any error. Therefore, the erroneous bit is b9.
Communication Error Detection and Correction 14
15. ERROR CONTROL IN FILE TRANSMISSION
F A simple but time-consuming technique of transferring
files with the assurance of file integrity is to transfer
the entire file at least twice.
If the files are not identical, there is no way of
knowing which file contains errors. In this case, the
entire file must be retransmitted again.
F To make the process of file transfer error detection
and correction a manageable task, the file is divided
into smaller units called packets as it moves from one
computer to another.
F These packets include error-detection information
(such as CRC) that enables the receiving computer to
determine the presence of communication-induced
errors. If the receiver receives an error-free packet, it
sends an acknowledgement (ACK) to the sender.
F The sender waits for an ACK after every packet it
sends. Only when an acknowledgement has been
received is the next packet sent. If a packet contains
errors, then the receiver will send a negative
acknowledgement (NAK) to the sender. The sender
will then retransmit that particular packet.
F This protocol is known as the Stop-and-Wait ARQ
(Automatic Repeat Request) protocol since the
transmitter has to stop and wait for the receiver to
formulate and send a response.
Communication Error Detection and Correction 15
16. THE STOP-AND-WAIT ARQ PROTOCOL
F Error control in the Stop-and-Wait ARQ protocol is
implemented simply: anytime an error is detected in an
exchange, a negative acknowledgement (NAK) is
returned and the specified packets are retransmitted.
F An error is implied as a damaged packet, a lost packet,
or a lost acknowledgement.
F For retransmission to work, the following features are
necessary:
1. The sending device keeps a copy of the last
packet transmitted until it receives an
acknowledgement for that packet. Keeping a
copy allows the sender to retransmit lost or
damaged packets until they are received
correctly.
2. For identification purposes, both data packets and
ACK packets are numbered alternately 0 and 1.
A data 0 packet is acknowledged by an ACK 1
packet indicating that the receiver has gotten data
0 and is now expecting data 1.
3. If an error is discovered in a data packet, a NAK
packet is returned. NAK frames, which are not
numbered, tell the sender to retransmit the last
packet sent.
Communication Error Detection and Correction 16
17. 4. The sending device is equipped with a timer. If
an expected acknowledgement is not received
within the allotted time period (time out), the
sender assumes that the last data frame was lost
in transit and sends it again.
F Damaged Packets
When a packet is discovered by the receiver to contain
an error, it returns a NAK packet and the sender
retransmits the last packet.
Sender Receiver
Data 0
ACK 1
Data 1
ACK 0
Data 0 error in
NAK packet 0
Data 0
ACK 1
Communication Error Detection and Correction 17
18. F Lost Packet
The sender is equipped with a timer that starts every
time a data packet is transmitted. If the packet never
makes it to the receiver, the receiver can never
acknowledge it, positively or negatively. The sending
device waits for an ACK or a NAK frame until its
timer goes off, at which point it tries again. It
retransmits the last frame, restarts its timer, and waits
for an acknowledgement.
Sender Receiver
Data 0 lost
time out
period
Data 0
ACK 1
Communication Error Detection and Correction 18
19. F Lost Acknowledgement
In this case, the data packet has made it to the receiver
and has been found to be either acceptable or not
acceptable. But the ACK or NAK packet returned by
the receiver is lost in transit. The sending device waits
until its timer goes off, then retransmits the data
packet. The receiver checks the number of the new
data packet. If the lost packet was a NAK, the
receiver accepts the new copy and returns an
appropriate ACK (assuming the copy arrives
undamaged). If the lost frame was an ACK, the
receiver recognizes the new copy as a duplicate,
acknowledges its receipt, then discards it and waits for
the next packet.
Sender Receiver
Data 0
time out lost ACK 1
period
Data 0
ACK 1
Communication Error Detection and Correction 19
20. F This stop-and-wait file transfer protocol is a half-
duplex protocol because it allows the transmission to
flow in only one direction at a time.
F The advantage of stop-and-wait is simplicity: each
packet is checked and acknowledged before the next
frame is sent.
The disadvantage is inefficiency: stop-and-wait is
slow. If the distance between devices is long, the time
spent waiting for ACKs between each packet can add
significantly to the total transmission time.
F A different approach is to allow a transmitter to send
many packets before needing an acknowledgement.
The receiver acknowledges only some of the packets,
using a single ACK to confirm the receipt of multiple
data packets. This is known as the sliding window
protocol.
Communication Error Detection and Correction 20
21. THE SLIDING WINDOW PROTOCOL
F The sliding window refers to imaginary boxes at both
sender and receiver. This window can hold packets at
either end and provides the upper limit on the number
of packets that can be transmitted before requiring an
acknowledgement. Packets may be acknowledged at
any point without waiting for the window to fill up and
may be transmitted as long as the window is not yet
full.
F To keep track of which packets have been transmitted
and which received, sliding window introduces an
identification scheme based on the size of the window.
The packets are numbered modulo-n, which means
they are numbered 0 to n - 1.
For example , if n = 8, the packets are numbered 0, 1,
2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, …The size of
the window is n – 1 (in this case, 7). In other words,
the window cannot cover the whole module (8
packets): it covers one packet less.
F When the receiver sends an ACK, it includes the
number of the next packet it expects to receive. In
other words, to acknowledge the receipt of a string of
packets ending in packet 4, the receiver sends an ACK
with the number 5. When the sender sees an ACK
with the number 5, it knows that all packets up
through number 4 have been received.
Communication Error Detection and Correction 21
22. F The window can hold n – 1 packets at either end:
therefore, a maximum of n – 1 packets may be sent
before an acknowledgement is required.
Window
6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5
F The Sender Window
At the beginning of the transmission, the sender’s
window contains n – 1 packets. As the packets are
sent out, the left boundary of the window moves
inward, shrinking the size of the window. Given a
window of size w, if three packets have been
transmitted since the last acknowledgement, then the
number of packets left in the window is w – 3. Once
an ACK arrives, the window expands to allow in a
number of new packets equal to the number of packets
acknowledged by that ACK.
Sender Window
0 1 2 3 4 5 6 7 0 1 2 3 4
Direction Direction
This wall moves to the This wall moves to the
right when a packet is right when an ACK is
sent received
Communication Error Detection and Correction 22
23. Given a window of size 7, if packets 0 through 4 have
been sent and no acknowledgement has been received,
the sender’s window contains two packets (numbers 5
and 6).
Now if an ACK numbered 4 is received, four packets
(0 through 3) are known to have arrived undamaged
and the sender’s window expands to include the next
four frames in the buffer. At this point, the sender’s
window contains six packets (numbers 5, 6, 7, 0, 1, 2).
If the received ACK had been numbered 2 instead of
4, the sender’s window would have expanded by only
two packets, to contain a total of four.
F The Receiver Window
At the beginning of transmission, the receiver window
contains not n – 1 packets but n – 1 spaces for
packets. As new frames come in, the size of the
receiver window shrinks. The receiver window
therefore represents not the number of frames
received but the number of frames that may still be
received before an ACK must be sent.
Given a window of size w, if three packets are
received without an acknowledgement being returned,
the number of spaces in the window is w – 3.
As soon as an acknowledgement is sent, the window
expands to include spaces for a number of packets
equal to the number of packets acknowledged.
Communication Error Detection and Correction 23
24. Receiver Window
0 1 2 3 4 5 6 7 0 1 2 3 4
Direction Direction
This wall moves to the This wall moves to the
right when a packet is right when an ACK is
received sent
In the given figure, the window contains spaces for
seven packets, meaning that seven packets may be
received before an ACK must be sent.
With the arrival of the first packet, the receiving
window shrinks, moving the boundary from space 0 to
1. The window has shrunk by one, so the receiver
may now accept six packets before it is required to
send an ACK. If frames 0 through 3 have arrived but
have not been acknowledged, the window still
contains three packet spaces.
As each ACK is sent out, the receiving window
expands to include as many new placeholders as newly
acknowledged packets. The window expands to
include a number of new packet spaces equal to the
number of the most recently acknowledged packet
minus the number of the previously acknowledged
packet.
Communication Error Detection and Correction 24
25. In a seven-packet window, if the prior ACK was for
packet 2 and the current ACK is for frame 5, the
window expands to by three (5 – 2). If the prior ACK
was for packet 3 and the current ACK is for frame 1,
the window expands to by six (1 + 8 – 3).
F Example of a simple transmission that uses sliding
window protocol:
Sender Receiver
0 1 2 3 4 5 6 7 0 1 2 3 4 0 1 2 3 4 5 6 7 0 1 2 3 4
Data 0
0 1 2 3 4 5 6 7 0 1 2 3 4 0 1 2 3 4 5 6 7 0 1 2 3 4
Data 1
0 1 2 3 4 5 6 7 0 1 2 3 4 0 1 2 3 4 5 6 7 0 1 2 3 4
ACK 2
0 1 2 3 4 5 6 7 0 1 2 3 4 0 1 2 3 4 5 6 7 0 1 2 3 4
Data 2
0 1 2 3 4 5 6 7 0 1 2 3 4 0 1 2 3 4 5 6 7 0 1 2 3 4
ACK 3
0 1 2 3 4 5 6 7 0 1 2 3 4 0 1 2 3 4 5 6 7 0 1 2 3 4
Data 3
0 1 2 3 4 5 6 7 0 1 2 3 4 0 1 2 3 4 5 6 7 0 1 2 3 4
Data 4
0 1 2 3 4 5 6 7 0 1 2 3 4 0 1 2 3 4 5 6 7 0 1 2 3 4
Data 5
0 1 2 3 4 5 6 7 0 1 2 3 4 0 1 2 3 4 5 6 7 0 1 2 3 4
ACK 6
0 1 2 3 4 5 6 7 0 1 2 3 4 0 1 2 3 4 5 6 7 0 1 2 3 4
Communication Error Detection and Correction 25
26. The given figure shows a sample transmission that uses
sliding window flow control with a window of seven
frames. In this example, all frames arrive undamaged.
As will be shown later, if errors are found in the
received frames, or if one or more frames are lost in
transit, the process will become more complex.
At the beginning of the transmission, both sender and
receiver windows are fully expanded to include seven
frames (seven transmittable frames in the sender
window, seven placeholder frames in the receiver
window). The frames within the windows are
numbered 0 through 7 and are part of a larger data
buffer, 13 of which are shown.
F In the sliding window method of flow control, the size
of the window is one less than the modulo range so
that there is no ambiguity in the acknowledgement of
the received frames. Assume that the frame sequence
numbers are modulo-8 and the window size is also 8.
Now imagine that frame 0 is sent and ACK 1 is
received. The sender expands its window and sends
frame 1, 2, 3, 4, 5, 6, 7, and 0. If it now receives an
ACK 1 again, it is not sure if this is a duplicate of the
previous ACK 1 (duplicated by the network) or a new
ACK 1 confirming the most recently sent eight frames.
But if the window size is 7 (instead of 8), this scenario
could not happen.
Communication Error Detection and Correction 26
27. SLIDING WINDOW ARQ
F Among the several popular mechanisms for continuous
transmission error control, two protocols are the most
popular: Go-Back-n ARQ and Selective-Reject ARQ,
both based on the sliding window flow control.
F To extend sliding window to cover retransmission of
lost or damaged frames, three features are added to the
basic flow control mechanism:
1. The sending device keeps copies of all
transmitted frames until they have been
acknowledged.
2. In addition to ACK frames, the receiver has the
option of returning a NAK frame if the data have
been received damaged. Because sliding window
is a continuous transmission mechanism, both
ACK and NAK frames must be numbered for
identification. Unlike ACK frames, NAK frames
carry the number of the damaged frame itself.
Every damaged frame must be negatively
acknowledged individually.
If data frames 4 and 5 are received damaged,
both NAK 4 and NAK 5 must be returned.
However, a NAK 4 tells the sender that all frames
received before frame 4 have arrived intact.
Communication Error Detection and Correction 27
28. 3. Like stop-and-wait ARQ, the sending device in
sliding window ARQ is equipped with a timer to
enable it to handle lost acknowledgements. The
sliding window ARQ, n – 1 frames (the size of the
window) may be sent before the
acknowledgement must be received. If n – 1
frames are awaiting acknowledgement, the sender
starts a timer and waits before sending any more.
If the allotted time has run out with no
acknowledgement, the sender assumes that the
frames were not received and retransmits one or
all of the frames depending on the protocol.
F Go-Back-n ARQ
In the sliding window go-back-n ARQ method, if one
frame is lost or damaged, all frames sent since the last
frame acknowledged are retransmitted.
Damaged Frame
Suppose that frames 0, 1, 2, and 3 have been
transmitted but the first acknowledgement received is
a NAK 3. Remember that a NAK means two things:
(1) a positive acknowledgement of all frames received
prior to the damaged frame and (2) a negative
acknowledgement of the frame indicated. If the first
acknowledgement is a NAK 3, it means that data
frames 0, 1, and 2 were all received in good shape.
Only frame 3 must be resent.
Communication Error Detection and Correction 28
29. As soon as the receiver discovers an error, it stops
accepting subsequent frames until the damaged frame
has been replaced correctly.
Example of Go-Back-n (damaged data frame):
Sender Receiver
Data 0
Data 1
Data 2
Data 3
ACK 3 Error, Discarded
Data 4
Discarded
NAK 3
Data 5
Discarded
Resent
Data 3
Resent
Data 4
Resent
Data 5
.
.
.
Communication Error Detection and Correction 29
30. Lost Data Frame
Sliding window protocols require that data frames be
transmitted sequentially. If one or more frames are
become lost in transit, the next frame to arrive at the
receiver will be out of sequence. The receiver checks
the identifying number on each frame, discovers that
one or more have been skipped, and returns the NAK
for the first missing frame. A NAK frame does not
indicate whether the frame has been lost or damaged,
just that it needs to be resent. The sending device then
retransmits the frame indicated by the NAK, as well as
any frames that it had transmitted after the lost one.
Lost Acknowledgement
The sender is not expecting to receive an ACK frame
for every data frame it sends. It cannot use the
absence of sequential ACK numbers to identify lost
ACK or NAK frames. Instead it uses a timer. The
sending device can send as many frames as the
window allows before waiting for an
acknowledgement. Once the limit has been reached or
the sender has no more frames to send, it must wait. If
an acknowledgement has not been received within a
certain time limit, the sender retransmits every frame
transmitted since the last ACK.
Communication Error Detection and Correction 30
31. Example of Go-Back-n (lost data frame):
Sender Receiver
Data 0
Data 1
Data 2
Lost
Data 3
Discarded
NAK 2
Data 4
Discarded
Resent
Data 2
Resent
Data 3
Resent
Data 4
.
.
.
Communication Error Detection and Correction 31
32. Example of Go-Back-n (lost ACK):
Sender Receiver
Data 0
Data 1
Time Out
Data 2
Lost ACK 3
Data 0
Data 1
Data 2
.
.
.
Communication Error Detection and Correction 32
33. F Selective-Reject ARQ
In selective-reject ARQ, only the specific damaged or
lost frame is retransmitted. If a frame is corrupted in
transit, a NAK is returned and the frame is resent out
of sequence.
To make such selectivity possible, a selective-reject
ARQ system differs from a go-back-n ARQ system in
the following ways:
1. The receiving device must contain sorting logic to
enable it to reorder frames received out of
sequence. It must also be able to store frames
received after a NAK has been sent until the
damaged frame has been replaced.
2. The sending device must contain a searching
mechanism that allows it to find and select only
the requested frame for retransmission.
3. A buffer in the receiver must keep all previously
received frames on hold until all retransmissions
have been sorted and any duplicate frames have
been identified and discarded.
4. To aid selectivity, ACK numbers, like NAK
numbers, must refer to the frame received (or
lost) instead of the next frame expected.
5. This complexity requires a smaller window size
than is needed by the go-back-n method if it is to
work efficiently. It is recommended that the
window size be less than or equal to (n + 1) / 2,
where n – 1 is the go-back-n window size.
Communication Error Detection and Correction 33
34. Damaged Frame
Example of Selective-Reject (damaged data
frame):
Sender Receiver
Data 0
Data 1
Data 2
Error in Frame 2
Data 3
Data 4 NAK 2
Data 5
Resent
Data 2
.
.
.
Communication Error Detection and Correction 34
35. In the given example, frames 0 and 1 are received but
are not acknowledged. Data 2 arrives and is found to
contain an error, so NAK 2 is returned. Like NAK
frames in go-back-n, a NAK here both acknowledges
the intact receipt of any previously unacknowledged
data frames and indicates an error in the current
frame.
NAK 2 tells the sender that data 0 and data 1 have
been accepted, but that data 2 must be resent. The
receiver in the selective-reject system continues to
accept new frames while waiting for an error to be
corrected.
However, because an ACK implies the successful
receipt not only of the specific frame but all of the
previous frames, frames received after the error frame
cannot be acknowledged until the damaged frames
have been retransmitted.
In the example, the receiver accepts data 3, 4, and 5
while waiting for a new copy of data 2. When the new
data 2 arrives, an ACK 5 can be returned,
acknowledging the new data 2 and the original frames
3, 4, and 5. Quite a bit of logic is required by the
receiver to sort out-of-sequence retransmissions and to
keep track of which frames are still missing and which
have yet to be acknowledged.
Communication Error Detection and Correction 35
36. Lost Frames
Although frames can be accepted out of sequence,
they cannot be acknowledged out of sequence. If a
frame is lost, the next frame will arrive out of
sequence. When the receiver tries to reorder the
existing frame to include it, it will discover the
discrepancy and return a NAK. Of course, the
receiver will recognize the omission only if other
frames follow. If the lost frame was the last of the
transmission, the receiver does nothing and the sender
treats the silence like a lost acknowledgement.
Lost Acknowledgement
Lost ACK and NAK framers are treated by selective-
reject ARQ just as they are by go-back-n ARQ. When
the sending device reaches either the capacity of its
window or the end of its transmission, it sets a timer.
If no acknowledgement arrives in the time allotted, the
sender retransmits all of the frames that remain
unacknowledged. In most cases, the receiver will
recognize any duplications and discard them.
F Comparison between Go-Back-n and Selective-Reject
Because of the complexity of the sorting and storage
required by the receiver, and the extra logic needed by
the sender to select specific frames for retransmission,
selective-reject ARQ is expensive and not often used.
Communication Error Detection and Correction 36
37. ASYNCHRONOUS FILE-TRANSFER PROTOCOLS
F XMODEM Protocol
Packet Format:
SOH PKT # PKT # COMPL DATA CHECKSUM
SOH - Start of Header or Start
of Packet (00000001)
PKT # - Sequential Packet
Number (8 bits)
PKT # COMPL - Complement of PKT #
Examples:
00000001 11111110
00000010 11111101
00000011 11111100
DATA - 128 bytes of data
CHECKSUM - error-detection byte
(sum of the ASCII value
of all 128 bytes, modulo
255)
Communication Error Detection and Correction 37
38. Protocol Operation:
1. Receiver sends a NAK character (00010101) to
signal the transmitter to start transmitting the file.
2. Transmitter transmits a packet.
3. Receiver receives the packet and checks for
errors.
If packet is error-free, receiver transmits an ACK
character (00000110) to inform the transmitter to
start transmitting the next packet.
Otherwise, receiver transmits a NAK character to
inform the transmitter to retransmit the previous
packet.
4. It transmitter receives an ACK, it transmits the
next packet. If transmitter receives a NAK, it
retransmits the previous packet.
5. Steps 3 and 4 are repeated until there are no more
packets to transmit.
6. Transmitter transmits an EOT character
(00000100) to inform the receiver that there are
no more packets to be retransmitted.
7. Receiver sends a final ACK character.
Communication Error Detection and Correction 38
39. Some Points Regarding the XMODEM Protocol:
1. XMODEM can transmit a CAN character
(00011000) or ^X to abort a file transfer.
2. XMODEM considers more than 10 attempts to
resend the data packet a fatal error and aborts the
file transfer.
3. The error-detection scheme used by XMODEM is
not so reliable.
4. An ACK (00000110) can be accidentally changed
(due to communication errors) to a NAK
(00010101) causing the transmitter to
unnecessarily retransmit the previous data packet.
5. If an ACK is changed to any other character, the
transmitter will not know when to send the next
sequential packet.
6. An ACK or NAK can become a CAN character
thus aborting the file transfer. The file transfer
has to be restarted from the beginning.
7. XMODEM is ideal for low-speed transfer through
high-quality transmission lines.
Communication Error Detection and Correction 39
41. F YMODEM Protocol
The YMODEM protocol is similar to XMODEM
except:
1. YMODEM uses 1024-byte data blocks instead of
128 (less overhead). If the line is not good,
YMODEM automatically decreases the data
block length to 128 bytes to reduce the number of
bytes that have to be retransmitted each time the
protocol detects an error.
Under worst of conditions, YMODEM’s
performance equals that of XMODEM.
2. YMODEM must receive two sequential CAN
characters before it abnormally terminates a file
transfer.
3. YMODEM uses the CRC error-detection
technique.
4. YMODEM transmits file-related information to
the receiving computer. It transmits the filename,
time, date, and size of the file in the first block.
Communication Error Detection and Correction 41
42. F ZMODEM Protocol
1. ZMODEM can resume a file transfer at any point
that a communication link fails.
2. Before a file transfer starts, ZMODEM checks to
see if the file exists on the local disk.
3. ZMODEM can perform data compression to
reduce the time required to move the file.
4. ZMODEM uses CRC-32 which provides better
error-detection than most protocols.
5. ZMODEM uses the sliding window technique.
Communication Error Detection and Correction 42
43. F Kermit Protocol
Packet Format:
MARK PKT LENGTH PKT # PKT TYPE DATA CHECK
MARK - Start of packet
PKT LENGTH - Number of bytes that
follow this field
PKT # - Packet Sequence
Number
PKT TYPE - Packet Type: Data,
ACK, NAK, Send-
Initiate, Break Signal,
File Header, End of File,
Error
DATA - 7- or 8-bit data
CHECK - 6-bit checksum, 12-bit
checksum, or CRC-
CCITT
Communication Error Detection and Correction 43
44. Features of Kermit:
1. Kermit uses full packets with error checking for
both data and ACK/NAK response data.
2. Kermit performs feature negotiation each time it
transmits a file.
This takes place through the exchange
of send-initiate packets.
During the send-initiate process, two
Kermits compare features and select
the ones both ends of the link can
support.
This allows any kermit implementation
to communicate with any other kermit
implementation.
3. Kermit uses control character conversion.
4. Kermit can use 7-bit or 8-bit characters.
5. Kermit can choose which error-detection
technique to use.
6. Kermit has file group transfer capability. It can
move groups of files without interruption.
7. Other special capabilities: file attribute transfer,
data compression, sliding windows.
Communication Error Detection and Correction 44