Checksum Implementation Program

Verified

Added on  2019/09/19

|2
|448
|166
Homework Assignment
AI Summary
This assignment requires the implementation of a checksum method, which involves two parts: calculating the checksum at the sender and verifying it at the receiver. The sender's part takes four 16-bit binary data inputs and calculates a 16-bit checksum by adding the data in pairs, handling carry-overs, and taking the one's complement of the final sum. The receiver's part takes the same four 16-bit data inputs along with the 16-bit checksum and verifies the data integrity by adding all the data and the checksum. If the result is all zeros, the data is not corrupted; otherwise, the data is corrupted. The assignment provides a detailed example of the checksum calculation process.
Document Page
BONUS ASSIGNMENT
Write a program to implement the checksum method.
The implementation has two parts:
a. Calculating the checksum at the sender
b. Verifying the checksum at the receiver
Calculating the checksum at the sender
Inputs: 4 data each consisting of 16-bit (binary)
Output: Checksum of 16-bit (binary)
Example:
http://mathforum.org/library/drmath/view/54379.html
For example, suppose we have the following data. I separate the
data into groups of 4 bits only for readability.
1000 0110 0101 1110
1010 1100 0110 0000
0111 0001 0010 1010
1000 0001 1011 0101
First, we add the 16-bit values 2 at a time:
1000 0110 0101 1110 First 16-bit value
+ 1010 1100 0110 0000 Second 16-bit value
---------------------
1 0011 0010 1011 1110 Produced a carry-out, which gets added
+ \----------------> 1 back into LSb
---------------------
0011 0010 1011 1111
+ 0111 0001 0010 1010 Third 16-bit value
---------------------
0 1010 0011 1110 1001 No carry to swing around (**)
+ 1000 0001 1011 0101 Fourth 16-bit value
---------------------
1 0010 0101 1001 1110 Produced a carry-out, which gets added
+ \----------------> 1 back into LSb
---------------------
0010 0101 1001 1111 Our "one's complement sum"
(**) Note that we could "swing around" the carry-out of 0, but adding
0 back into the LSb has no effect on the sum. (But technically, that's
what the checksum generator does.)
Then we have to take the one's complement of the sum. We do this by
simply inverting all the bits in the final result from above:
0010 0101 1001 1111 Our "one's complement sum"
1101 1010 0110 0000 The "one's complement"
Therefore, the checksum generated from the given data would be
Page 1 of 2
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
1101 1010 0110 0000.
Verifying the checksum at the receiver
Inputs: 4 data each is consisting of 16-bit and their 16-bit checksum
Output: Checksum for 4 data each is consisting of 16-bit and their 16-bit
checksum
If checksum is equal to 0s, your data is not corrupted
If checksum is not equal 0s, your data is corrupted
Page 2 of 2
chevron_up_icon
1 out of 2
circle_padding
hide_on_mobile
zoom_out_icon
[object Object]