Master the fundamental concepts of network stack fundamentals through this focused micro-challenge.
You have read the whole brief, and the concepts above stay free on every task. Writing and running the code needs a plan.
Three hints are available for this task, revealed one at a time inside the code workspace so you can struggle productively before seeing them.
Every task includes starter code, theory, and hidden tests so you can implement and verify locally in the browser.
How it worksEthernet is the dominant link-layer technology for LANs. The Ethernet II header is 14 bytes before the payload begins. For example, bytes 12-13 hold the EtherType: 0x0800 means IPv4, 0x0806 means ARP.
A typical frame on the wire:
ff:ff:ff:ff:ff:ff for broadcastaa:bb:cc:dd:ee:ffFrame size constraints: minimum 64 bytes, maximum 1518 bytes including FCS. Payloads shorter than 46 bytes get padded.
To parse a captured frame manually:
0x8100)This task requires you to parse a simulated Ethernet frame byte array. You will use this exact 14-byte header layout in every tcpdump capture and when you build ARP requests with raw sockets later in the track. Switches forward frames based on the destination MAC you extract here, and VLAN-tagged frames with EtherType 0x8100 shift the IP payload start past byte 14.
Write a C program that parses an Ethernet II frame supplied on stdin as whitespace-separated hex bytes (a single hex token also works since %2x resumes at the next nibble).
Parse the 14-byte header: destination MAC (bytes 0-5), source MAC (bytes 6-11), EtherType (bytes 12-13, big-endian). If the EtherType is 0x8100 the frame carries an 802.1Q VLAN tag: the next two bytes are the TCI, followed by the real EtherType, and the header is 18 bytes long.
Print one key=value line each for: dst and src as colon-separated lowercase hex pairs, ethertype as 0x%04x, header_len (14 or 18), and payload_len (total input bytes minus header_len). For VLAN frames also print vlan_tci as 0x%04x and inner_ethertype.