Master the fundamental concepts of tcp/ip from scratch through this focused micro-challenge.
TUN and TAP are virtual kernel interfaces that let user-space programs inject and read raw packets. TUN works at layer 3 (IP packets to 10.0.0.1 with no Ethernet header). TAP works at layer 2 (full Ethernet frames with MAC addresses and EtherType 0x0800).
cLoading…
Flags:
IFF_TUN: layer 3, IP packets onlyIFF_TAP: layer 2, Ethernet framesIFF_NO_PI: skip the 4-byte packet info headerRead and write the fd like a file: read(fd, buf, 1500) returns an IP packet; write(fd, buf, len) injects one into the kernel routing table.
This task asks you to set up a TUN interface and demonstrate packet I/O. This is the same kernel interface that lets you build and test a user-space TCP stack without touching kernel code. WireGuard creates a TUN device to intercept IP packets bound for 10.0.0.0/24 before encrypting and tunneling them over UDP to a peer endpoint.
Implement a program that sets up a TUN interface and demonstrates packet I/O.
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