G1.10.2 Find the Corrupted Packet

EasyImplementIcarus · browser samples / server checksReview the topic

Compute Internet checksums by hand with the end-around carry, and find the one received packet whose sum is not ffff.

Hardware context: The receiver of a serial sensor link, a network card that drops packets, and a bar-code digit reader. Compute Internet checksums by hand and find the corrupted packet.

A network card drops a few packets each hour, and nobody knows why. The capture shows four received packets, each with its checksum. Before blaming the hardware, you check the arithmetic by hand.

This is an Implement problem with no logic to write. Work out each answer and write it into the answer module, in hex for the sums and checksums. The first three constants are worked examples.

The checksum is the Internet checksum of the lesson. It is a ones'-complement sum of 16-bit words, inverted. Every carry out of bit 15 is added back at bit 0.

Signals in the Timeline

SignalWidthRole
question8input of each check
Full specification
ConstantWhat to write
SUM_AThe ones'-complement sum of 1234, f00d, beef, 0f0f (as in the lesson).
CHECK_AThe checksum of the same four words: the sum, inverted.
RECV_AThe receiver's ones'-complement sum of the four words and the checksum.
CHECK_BThe checksum of 8001, 8002, 7fff.
CHECK_CThe checksum of ffff, 0001, 1234, 4321.
CHECK_DThe checksum of a5a5, 5a5a, 0100.
RECV_3The receiver's sum over all four words of received packet 3.
BAD_PACKETThe number, 1 to 4, of the one received packet that is corrupted.
Received packetWordsChecksum
10102 0304 0506f6f3
2c0de cafe 0bad6875
37777 88c8 1111eeee
44000 4000 8000fffe

BAD_PACKET is a decimal number. Keep the module name and the constant names.

Examples

Example 1

Worked Example: The Sum
Input
the ones'-complement sum of 1234, f00d, beef, 0f0f (as in the lesson)
Output
sum_a = 0xd040

1234 + f00d is 1_0241. The carry goes back to bit 0: 0242. Adding beef and 0f0f the same way ends at d040. This constant is already filled in.

Example 2

Worked Example: The Checksum
Input
the checksum of the same four words: the sum, inverted
Output
check_a = 0x2fbf

d040 inverted is 2fbf: each hex digit d becomes f - d. This constant is already filled in.

Example 3

Worked Example: The Receiver
Input
the receiver's ones'-complement sum of the four words and the checksum
Output
recv_a = 0xffff

d040 + 2fbf is ffff, so the packet passes. This constant is already filled in.

Constraints and Contract

  • Keep the module name answer and the names of the constants.
  • Exactly one received packet is corrupted.

Hints

Hint 1

Add two words at a time. When the sum needs a seventeenth bit, drop it and add 1 at the bottom instead.

Hint 2

The checksum is the sum with every bit inverted. In hex, each digit d becomes f - d.

Hint 3

At the receiver, add the words and the checksum. A good packet gives ffff.

What the grader checks: The check reads eight constants. Each is compared with a value from a ones'-complement model in JavaScript. It cannot see how a value was found.

8 checks on Icarus · browser samples / server checks. Run the examples first, then check the full regression. Full checks use the server judge. Downloads contain public samples only. A passing result establishes the tested cases, not a proof for all possible inputs.

See all 3 steps and the final capstone

Report a problem with this page

Your code SystemVerilogSaved locally
Ln 1, Col 1Tab indents · Ctrl/⌘ + Enter runs samples
Not run yet

Worked Example: The Sum

Input
the ones'-complement sum of 1234, f00d, beef, 0f0f (as in the lesson)
Expected output
sum_a = 0xd040

1234 + f00d is 1_0241. The carry goes back to bit 0: 0242. Adding beef and 0f0f the same way ends at d040. This constant is already filled in.

Run samples executes all 3 public checks. Check all tests runs 8 checks on the server.

Icarus · browser samples / server checks