Master the fundamental concepts of network stack fundamentals through this focused micro-challenge.
TCP provides reliable, ordered byte streams. The minimum header is 20 bytes. For example, a SYN segment to port 443 might have source port 54321, destination port 443, sequence number 1000, and flags SYN+ACK encoded in byte 13.
80 and 49152Common flag combinations:
The data-offset nibble determines where TCP options end and payload begins. Misreading it desyncs every byte after the header. A data offset of 5 means 20 bytes with no options; 6 means 24 bytes with 4 bytes of options.
This task asks you to parse a simulated TCP segment and print ports, sequence numbers, flags, and window size. nmap's SYN scan crafts and reads exactly these fields to fingerprint open ports without completing a handshake.
Write a C program that parses a simulated TCP segment byte array. Print the source port, destination port, sequence number, acknowledgment number, flags, and window size.
Requirements:
Three hints are available for this task, revealed one at a time inside the code workspace so you can struggle productively before seeing them.
All starter code and reference implementations are available for your local setup.
View on Github