28.12.2013 Views

Serial Programming - upload.wikimedia....

Serial Programming - upload.wikimedia....

Serial Programming - upload.wikimedia....

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

8 Error Correction Methods<br />

8.1 Introduction<br />

There are 3 main types of handling errors:<br />

• acknowledge or retry (ACK-NAK).<br />

• "Forward Error Correction" (FEC)<br />

• Pretend It Never Happened<br />

8.2 ACK-NAK<br />

Each packet is checked by the receiver to make sure it is "good".<br />

If it *is* good, the receiver (eventually) tells the sender that it came through OK -- it<br />

acknowledges (ACK) the packet.<br />

All versions of ACK-NAK absolutely require Two Way Communication 1 .<br />

How does the receiver know it's good ?<br />

The sender calculates a checksum or CRC for the entire packet (except for the footer), then<br />

appends it to the end of the packet (in the footer/trailer).<br />

The typical CRC is 32 bits, often a Fletcher-32 2 checksum 3 .<br />

Aside: Note that the checksum or CRC are forms of hashing, ie, irreversibly shrinking<br />

data. Checksums and CRCs are weaker algorithms than "cryptographically strong" message<br />

authentication code algorithms such as MD5 or SHA variants. Cryptographically strong<br />

algorithms can detect errors better than checksums or CRCs, but they take more time to<br />

calculate.<br />

Whenever the receiver receives a packet, the receiver calculates exactly the same checksum<br />

or CRC, then compares it to the one in the footer/trailer. If they match, the entire packet<br />

is (almost certainly) good, so the receiver sends an ACK.<br />

When there's even the slightest question that the packet has any sort of error (which could<br />

be *either* in the actual data *or* in the header *or* in the checksum bits -- there's no way<br />

1 http://en.wikibooks.org/wiki/<strong>Serial</strong>_<strong>Programming</strong>%3ABi-directional_Communication<br />

2 http://en.wikipedia.org/wiki/%20Fletcher%27s%20checksum<br />

3 http://en.wikipedia.org/wiki/%20checksum%20<br />

115

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!