Serial Programming - upload.wikimedia....
Serial Programming - upload.wikimedia....
Serial Programming - upload.wikimedia....
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Error Correction Methods<br />
for the receiver to tell), the receiver discards it completely and (in most cases) pretends it<br />
never saw it.<br />
If it's not good, the sender sends it again.<br />
How does the sender know it wasn't good ?<br />
It never got the ACK. (So either the packet was corrupted, *or* the ACK was corrupted --<br />
there's no way for the sender to know).<br />
"Stop-and-wait ARQ"<br />
The simplest version of ACK-NAK is "Stop-and-wait ARQ".<br />
The sender sends a packet, then waits a little for an ACK. As soon as it gets the ACK, it<br />
immediately sends the next packet. If the sender doesn't hear the ACK in time, it starts<br />
over from the beginning, sending the same packet again, until it does get an ACK.<br />
The receiver waits for a packet. If the packet passes all the error-detection tests perfectly,<br />
the receiver transmits an ACK (acknowledgment) to the sender.<br />
Subtleties: If the receiver receives the packet perfectly, but the ACK message is delayed too<br />
long, then the transmitter sends another copy of the message (a "communication echo").<br />
Imagine the packet contained the message "deduct $11,000 from Fred's account.". When the<br />
receiver gets this second copy of the packet, what should it do? Certainly it should send an<br />
ACK (otherwise the transmitter will keep trying to send this packet over and over). Either<br />
or both of the following problems could occur:<br />
• The delayed first ACK could hit the transmitter after it transmits the second copy of<br />
the message, so it transmits the next packet. Then the second ACK hits the transmitter,<br />
tricking the transmitter into thinking that "next packet" has been successfully received,<br />
when it hasn't.<br />
• When the receiver gets 2 identical consecutive packets saying "deduct $11,000 from Fred's<br />
account", are these 2 legitimate independent transactions, and so it should deduct $22,000<br />
from Fred's account? Or is it really just 1 transaction, with a bit of echo, and so should<br />
deduct a total of only $11,000 from Fred's account?<br />
Both of these problems can be solved by adding a "sequence number". The transmitter<br />
keeps a count of how many independent packets it has transmitted to that receiver, and<br />
puts that sequence number in the header of each packet. But when it re-transmits a packet,<br />
it re-transmits that same identical packet with that same identical sequence number. Also,<br />
the receiver, rather than sending a generic "ACK" message, specifies which particular packet<br />
it is responding to by putting its sequence number in the ACK message. When there is a<br />
communication echo, the receiver sees the same sequence number, so ACKs that sequence<br />
number (again) but then discards and ignores the extra, redundant copy of a packet it<br />
already received. When the transmitter is sending a new packet that merely happens to<br />
contain the same data, the receiver sees a different sequence number, so it ACKs that new<br />
sequence number, and takes another $11,000 out of Fred's account. Poor Fred.<br />
116