Verification #46 · 2026-11-08 · solve before · Medium · about 12 min

The flag that's never set

packet in pkt.sv randomizes a packet that is either a control packet (no payload, len == 0) or a data packet (len in 1..1500). The flag is_ctrl picks which.

Both kinds are supposed to come up often, so a test built on this generator exercises control packets as well as data. But when you randomize many packets and count them, almost every one is a data packet — control packets turn up perhaps once in a thousand, even though nothing forbids them.

The length rule itself is correct: control packets always have len == 0 and data packets always land in 1..1500. Make control packets appear a healthy fraction of the time. Fix pkt.sv.

Write and run your answer in the browser. The hidden tests check it, and it’s free.