Build your own TCP/IP Stack
A user-space network stack on a Linux TAP device: Ethernet, ARP, IPv4, ICMP and finally TCP.
- Advanced
- About 30–60 h
- 4 checkpoints
- 2 tutorials · C
Pick a tutorial, then check yourself at each checkpoint. Work in any language you like.
Choose a tutorialWhy build it
Writing the stack turns packet captures from noise into a story. You will see why handshakes, sequence numbers and retransmissions exist.
Before you start: Needs Linux with root to create a TAP device (a VM is fine).
You will be able to
- Read and write raw Ethernet frames on a TAP device.
- Answer ARP requests and ICMP echo (ping).
- Implement the TCP state machine for connection setup and teardown.
- Debug a protocol implementation with Wireshark or tcpdump.
Skills it exercises
- TCP & UDP
- Packet Capture & Analysis
- Networking Basics
- Ethernet Switching & VLANs
- IPv4 Addressing & Subnetting
Recommended on Network Engineer.
How you know you are there
Work in any language. Each checkpoint ends with something you can run or observe, so you can check it yourself.
- Checkpoint 1Self-check
Frames
Done when: Your program reads Ethernet frames from a TAP interface and prints their source, destination and EtherType.
- Checkpoint 2Self-check
ARP and ping
Done when:
arpingandpingfrom the host to your stack's address get replies, with checksums verified in Wireshark. - Checkpoint 3Self-check
TCP handshake
Done when:
ncon the host completes a three-way handshake with your stack, and the capture shows correct sequence and acknowledgement numbers. - Checkpoint 4Self-check
Data and teardown
Done when: curl gets a response from a tiny HTTP server running on your stack, and the connection closes cleanly with FIN and ACK.
Stretch goals
- Retransmission with timeouts.
- Flow control with the receive window.
- UDP and a tiny DNS client on top.
Step-by-step guides
Pick one in a language you know (tutorial languages: C). They open on the author’s site.
- C
Let's code a TCP/IP stack(external site)
C, five parts on a TAP device: Ethernet and ARP, IPv4 and ICMP, TCP basics, the handshake, retransmission.
- C
Beej's Guide to Network Programming(external site)
C: the sockets API that applications use on top of a stack like yours. Useful for writing the test programs.
Where to go next
- Build your own VPN
Advanced · 15–30 h
Practice builds are self-paced: Tech Atlas does not track them or count them as evidence. To show a skill, take its knowledge check from the skill page.
Tutorials come from codecrafters-io/build-your-own-x (CC0, snapshot of 2026-07-14, commit aa17439; links checked on 2026-10-19). Each tutorial belongs to its author and keeps its own licence; Tech Atlas links to it and does not host it. Briefs, checkpoints and the mapping to skills are Tech Atlas editorial drafts.