What to do
1) Use Cyclic Redundancy Check (CRC) as error detection strategy. We use the CRC code provided by Michael Barr in the link below:
- Note the CRC in our frame is calculated based on the first seven members of a frame. Because six of them are not char-type, we need to first convert them into six 4-byte char arraies. For how to convert a 32-bit integer into 4-byte char array, please check the link below. (Note that enum is actually integer-type.) http://stackoverflow.com/questions/3784263/converting-an-int-into-a-4-byte-char-array-c. !!!
Phase 3 Goal
Based on the code of phase 2, add additional functionality. Before sending frame to server, the sender calculates CRC, and upon the receiver receives the frame, it calculates the CRC and compare it with the CRC in the receiving frame. If they don't match, print the event (in this phase, we don't insert any error).
Useful resources
How to define enumeration in C?
enum in C.
typedef in C.
Implement Cyclic Redundancy Check in C
Understanding CRC
What is C-preprocessor (Wiki)
The C Preprocessor
No comments:
Post a Comment