Build a TCP/IP Stack from Scratch · Module 00
What You'll Build (Scope)
What You'll Build
Over the next modules, you'll create a fully working network stack that runs entirely in user space — inside a Docker container — and can talk to real software like ping, curl, and web browsers.
At a High Level
Your stack will be able to:
Layer 2 (Data Link)
- Send and receive Ethernet frames through a TAP device
- Parse source/destination MAC addresses and Ethertype fields
Layer 3 (Network)
- Resolve IP addresses using ARP and maintain an ARP cache
- Handle IPv4 packets: parse headers, compute checksums, route packets, and forward traffic
- Reply to ICMP Echo Requests (ping) and generate ICMP error messages
Layer 4 (Transport)
- Exchange UDP datagrams, enough to implement simple services like a DNS resolver
- Establish and manage TCP connections: perform the three-way handshake, send and acknowledge data, and close connections properly
Application Layer
- Provide a lightweight sockets API (
bind,listen,send,recv) so user programs inside your container can use your stack instead of the system one - Run real applications on top of it — first a simple echo server, then a minimal HTTP server that can serve a web page through your own TCP/IP layers
The Lab Environment
In the lab, your container will act as a host or router.
It will receive raw Ethernet frames on its tap0 interface, process them through your stack, and send responses back out the same interface.
From another container (the client), you'll run ordinary tools like:
ping 10.10.0.1
curl http://10.10.0.1:8080/And watch those requests travel through every layer of code you've written — from Ethernet all the way up to HTTP.
The Complete Journey
Client (curl) → Ethernet → IP → TCP → HTTP → Your Web Server
↓ ↓ ↓ ↓
[Your Code Handles Every Step]
By the end, you'll have a compact but complete model of how real operating systems move data across networks.