Verification #16 · 2026-10-09 · Polymorphism · Easy · about 10 min
The tag that never reaches the wire
packet.sv has two kinds of packet. A packet goes on the wire as dst followed by its payload. A tagged_packet extends it with one more byte, tag, sent right after dst.
The driver takes every packet through a packet handle, whatever kind it really is, and calls:
pack(), which returns the bytes to put on the wire, in order.length(), which returns how many bytes that is.
Both must describe the object the handle points to. Today a tagged_packet handed to the driver goes out without its tag, and reports a length one byte short.
Fix packet.sv. The same must hold for any class that later extends packet or tagged_packet with its own pack() and length(). Run sends three packets through the driver.
Write and run your answer in the browser. The hidden tests check it, and it’s free.