{"id":50309581,"url":"https://github.com/TanayK07/networking-from-scratch","last_synced_at":"2026-06-14T11:00:32.048Z","repository":{"id":357084381,"uuid":"1235288399","full_name":"TanayK07/networking-from-scratch","owner":"TanayK07","description":"Build the network stack from raw bytes. 289 hands-on lessons in C and Python — from Ethernet frames to TLS 1.3","archived":false,"fork":false,"pushed_at":"2026-05-24T10:05:54.000Z","size":6851,"stargazers_count":28,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-05-24T12:10:39.931Z","etag":null,"topics":["c","learn-networking","linux","networking","systems-programming","tcp","tcp-ip","udp"],"latest_commit_sha":null,"homepage":"https://networkingfromscratch.vercel.app/","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TanayK07.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-05-11T07:22:06.000Z","updated_at":"2026-05-24T11:38:20.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/TanayK07/networking-from-scratch","commit_stats":null,"previous_names":["tanayk07/networking-from-scratch"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/TanayK07/networking-from-scratch","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TanayK07%2Fnetworking-from-scratch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TanayK07%2Fnetworking-from-scratch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TanayK07%2Fnetworking-from-scratch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TanayK07%2Fnetworking-from-scratch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TanayK07","download_url":"https://codeload.github.com/TanayK07/networking-from-scratch/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TanayK07%2Fnetworking-from-scratch/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34318525,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-14T02:00:07.365Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c","learn-networking","linux","networking","systems-programming","tcp","tcp-ip","udp"],"created_at":"2026-05-28T20:00:31.626Z","updated_at":"2026-06-14T11:00:31.983Z","avatar_url":"https://github.com/TanayK07.png","language":"C","funding_links":[],"categories":["Tutorials"],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n# Networking from Scratch\n\n**Build the network stack — bits, frames, packets, TCP, TLS, kernel modules, eBPF, CNI plugins, and a real DDS implementation — from raw bytes, in C and Python.**\n\n[![GitHub stars](https://img.shields.io/github/stars/TanayK07/networking-from-scratch?style=flat-square\u0026color=00897B)](https://github.com/TanayK07/networking-from-scratch/stargazers)\n[![License: MIT](https://img.shields.io/badge/license-MIT-blue?style=flat-square)](LICENSE)\n[![Lessons](https://img.shields.io/badge/lessons-289-teal?style=flat-square)](https://networkingfromscratch.vercel.app/catalog.html)\n[![Phases](https://img.shields.io/badge/phases-15-orange?style=flat-square)](https://networkingfromscratch.vercel.app/roadmap.html)\n[![C](https://img.shields.io/badge/C-00599C?style=flat-square\u0026logo=c\u0026logoColor=white)](phases/)\n[![Python](https://img.shields.io/badge/Python-3776AB?style=flat-square\u0026logo=python\u0026logoColor=white)](phases/)\n\n[Website](https://networkingfromscratch.vercel.app) · [Catalog](https://networkingfromscratch.vercel.app/catalog.html) · [Roadmap](https://networkingfromscratch.vercel.app/roadmap.html) · [Glossary](https://networkingfromscratch.vercel.app/glossary.html) · [Discussions](https://github.com/TanayK07/networking-from-scratch/discussions)\n\n\u003c/div\u003e\n\n---\n\n## What you'll build\n\nBy the time you finish this curriculum you will have:\n\n- Hand-rolled an **Ethernet frame**, computed its FCS, and injected it through a raw socket.\n- Built a **userspace TCP/IP stack** on a Linux TUN/TAP device that can `curl` a real HTTPS site (saminiir's *Let's code a TCP/IP stack*, rebuilt and extended with SACK, window scaling, and CUBIC).\n- Implemented **TLS 1.3** from `ClientHello` to `Finished` against `cloudflare.com`, parsing every byte the way `tls13.xargs.org` does.\n- Written a **loadable kernel module** that hooks into Netfilter to log every packet's 5-tuple.\n- Loaded a small **XDP program** that drops a SYN flood at line rate.\n- Built a **CNI plugin** in Python that creates veth pairs and attaches Pods to a bridge.\n- Stood up a **two-host VXLAN overlay** on UDP/4789.\n- Shipped a tiny **DDS publisher** that interoperates over the wire with Eclipse Cyclone DDS.\n\nEverything from raw bytes. No frameworks until you've built a minimal version yourself.\n\n---\n\n## Prerequisites\n\nYou should arrive with:\n\n- **C, intermediate level** — pointers, structs, bit fields, `memcpy`, `malloc`, function pointers.\n- **Python 3, intermediate level** — `bytes` vs `str`, `struct.pack`/`unpack`, `asyncio`, `pytest`.\n- **CS fundamentals** — binary/hex, two's complement, endianness, basic data structures.\n- **Linux command line** — `ip`, `ss`, `tcpdump`, `make`, reading `man 2` pages.\n- **A Linux box you can break.** Most kernel-module, TUN/TAP, eBPF, and namespace lessons require root.\n\nSee [`docs/prereqs.md`](docs/prereqs.md) for the full breakdown and a setup script for an Ubuntu 24.04 VM.\n\n---\n\n## Quickstart\n\n```bash\ngit clone https://github.com/TanayK07/networking-from-scratch.git\ncd networking-from-scratch\n\n# Set up an Ubuntu 24.04 VM with all dependencies (recommended)\n./tools/setup-vm.sh\n\n# Or install dependencies on your existing machine (use a VM you don't mind breaking)\nsudo apt install -y build-essential gcc clang make python3 python3-pip \\\n    libbpf-dev linux-headers-$(uname -r) linux-tools-$(uname -r) \\\n    libsodium-dev libssl-dev iproute2 tcpdump iperf3 wireshark-common\n\n# Run your first lesson\nmake -C phases/01-bits-and-wires/02-bits-bytes-endianness test\n\n# Or jump to the link layer\nmake -C phases/02-link-layer/03-raw-sockets-on-linux-afpacket\nsudo ./phases/02-link-layer/03-raw-sockets-on-linux-afpacket/sniff eth0\n```\n\n---\n\n## Curriculum at a glance\n\n```\nP1   Bits \u0026 Wires             ─┐\nP2   Link Layer                ├── FOUNDATIONS\nP3   Network Layer             │\nP4   Transport (UDP/TCP/QUIC) ─┘\nP5   Sockets \u0026 I/O             ─┐\nP6   Application Protocols      │── PROTOCOLS\nP7   TLS \u0026 Secure Transport    ─┘\nP8   Userspace TCP/IP Stack    ── CAPSTONE I\nP9   Linux Kernel Internals   ─┐\nP10  eBPF, XDP, Kernel Bypass  ├── KERNEL \u0026 PERF\nP11  Performance \u0026 Observability┘\nP12  Routing: BGP, OSPF        ─┐\nP13  Overlays \u0026 Container Net   ├── MODERN INFRA\nP14  Service Mesh \u0026 Cloud-Native┘\nP15  BONUS: DDS \u0026 Robotics\n```\n\n| Phase | Title | Lessons | Capstone |\n|------:|-------|--------:|----------|\n| P1  | Bits \u0026 Wires                          | 12 | A virtual wire with framing + CRC + retransmit |\n| P2  | Link Layer                            | 18 | A tiny L2 switch with MAC learning |\n| P3  | Network Layer                         | 22 | A userspace IP router on TUN devices |\n| P4  | Transport: UDP, TCP, QUIC             | 40 | End-to-end TCP over TUN, fetching `example.com` |\n| P5  | Sockets \u0026 I/O Models                  | 16 | A 10k-connection HTTP/1.0 server (epoll) |\n| P6  | Application Protocols                 | 28 | An HTTP CONNECT proxy supporting HTTP/1.1, /2, /3 |\n| P7  | TLS \u0026 Secure Transport                | 16 | A minimal HTTPS server using your TLS 1.3 |\n| P8  | Userspace TCP/IP Stack                | 12 | `lvl-ip-rebuilt` — a working stack on TUN |\n| P9  | Linux Kernel Internals                | 24 | An LKM that injects 1% packet loss |\n| P10 | eBPF, XDP, Kernel Bypass              | 18 | An XDP DDoS scrubber + AF_XDP packet generator |\n| P11 | Performance \u0026 Observability           | 14 | A `tcpdump`+eBPF+Grafana observability stack |\n| P12 | Routing: BGP, OSPF                    | 16 | A BGP route reflector + OSPF area-0 simulator |\n| P13 | Overlays \u0026 Container Networking       | 16 | A bridge CNI plugin in Python |\n| P14 | Service Mesh \u0026 Cloud-Native           | 12 | A 200-line L7 proxy with mTLS |\n| P15 | BONUS: DDS, RTPS, Robotics Middleware | 25 | A DDS publisher interoperating with Cyclone DDS |\n| **Total** | |  **289** | |\n\nSee [`docs/index.md`](docs/index.md) for the full lesson list with descriptions.\n\n---\n\n## Repository layout\n\n```\nnetworking-from-scratch/\n├── README.md                        # this file\n├── LICENSE                          # MIT\n├── CONTRIBUTING.md\n├── CODE_OF_CONDUCT.md\n├── docs/\n│   ├── index.md                     # full curriculum\n│   ├── prereqs.md                   # setup and prerequisites\n│   ├── style-guide.md               # how to write a lesson\n│   ├── glossary.md\n│   └── rfcs/                        # cached copies of canonical RFCs\n├── common/\n│   ├── c/                           # shared C helpers (checksum, CRC, TUN, log)\n│   └── python/nfs/                  # shared Python helpers (packet, pcap, runner)\n├── phases/\n│   ├── 01-bits-and-wires/\n│   │   ├── README.md\n│   │   ├── 01-what-is-a-network/\n│   │   ├── 02-bits-bytes-endianness/\n│   │   │   ├── README.md            # the lesson (theory, code, exercises)\n│   │   │   ├── htonl.c\n│   │   │   ├── htonl.h\n│   │   │   ├── Makefile\n│   │   │   └── tests/\n│   │   ├── 08-errors-and-crcs/\n│   │   └── ...\n│   ├── 02-link-layer/\n│   ├── ...\n│   └── 15-dds-robotics-bonus/\n├── tools/\n│   ├── new-lesson.py                # scaffold a new lesson directory\n│   ├── lint-curriculum.py           # check every lesson has the 6 sections\n│   └── setup-vm.sh                  # provision an Ubuntu 24.04 VM\n├── .github/\n│   └── workflows/                   # CI: C build, Python tests, LKMs, eBPF, docs\n├── Makefile                         # top-level: builds everything\n└── tox.ini                          # Python test orchestration\n```\n\n---\n\n## How a lesson is structured\n\nEvery lesson `README.md` has the same six sections, in this order:\n\n```\n# NN. Lesson Title\n\n## 1. Problem        — concrete, observable problem this lesson solves\n## 2. Theory         — plain-prose explanation, with diagrams\n## 3. Math / Spec    — the formal definition (algorithm, RFC quote, equation)\n## 4. Code           — annotated walkthrough of the implementation\n## 5. Tests          — unit, property, interop, fuzz\n## 6. Exercises      — 5–10 graded exercises with ★ difficulty markers\n```\n\nThe lint script (`tools/lint-curriculum.py`) rejects PRs that omit any of these sections. See [`docs/style-guide.md`](docs/style-guide.md) for the full convention.\n\n---\n\n## Sample lesson — see them in action\n\nThree sample lessons are fully written to demonstrate the format:\n\n- **[P1.02 — Bits, bytes, and endianness](phases/01-bits-and-wires/02-bits-bytes-endianness/)** — reimplements `htonl`/`ntohl` from scratch, verifies bit-for-bit agreement with the kernel's. (C)\n- **[P2.06 — ARP request / reply](phases/02-link-layer/06-arp-request-reply/)** — responds to ARP requests for a virtual MAC; the kernel's `arp` table populates with our fake. (C)\n- **[P3.02 — The Internet checksum (RFC 1071)](phases/03-network-layer/02-internet-checksum/)** — byte-by-byte and incremental-update implementations, with property tests. (C)\n\nEach one is a working, tested, runnable example of how every other lesson should look.\n\n---\n\n## Building everything\n\n```bash\n# Top-level Makefile delegates to every per-lesson Makefile\nmake build      # build all C lessons\nmake test       # run all C and Python tests\nmake clean      # clean all artifacts\n\n# Python tests via tox\ntox             # runs pytest, ruff, mypy\n\n# Lint the curriculum structure\npython3 tools/lint-curriculum.py\n```\n\n---\n\n## Contributing\n\nWe want this curriculum to be the canonical answer to \"how do I really learn networking?\"\n\nUseful contributions:\n\n1. **Write a lesson.** Pick any planned lesson from the [catalog](https://networkingfromscratch.vercel.app/catalog.html), fork, write it following [`docs/style-guide.md`](docs/style-guide.md), open a PR.\n2. **Add a test.** Existing lessons are improved by more property tests, fuzz harnesses, and interop checks.\n3. **Fix a bug.** Code, prose, links — open a PR.\n4. **Translate.** We accept lesson translations as separate folders (`README.es.md`, etc.).\n\nSee [`CONTRIBUTING.md`](CONTRIBUTING.md) for the full guide.\n\n---\n\n## Status\n\nThis is a curriculum-in-progress. The structure, sample lessons, and three reference implementations (P1.02, P2.06, P3.02) are complete; ~286 lessons are still planned. See the live progress on [the website](https://networkingfromscratch.vercel.app).\n\nIf you want to help write lessons, the [project board](https://github.com/TanayK07/networking-from-scratch/projects/1) shows what's claimed and what's open.\n\n---\n\n## Inspirations\n\nThis project would not exist without prior work:\n\n- **[saminiir's *Let's code a TCP/IP stack*](https://www.saminiir.com/lets-code-tcp-ip-stack-1-ethernet-arp/)** — the reference for how to teach a TCP/IP stack from scratch.\n- **[Beej's Guide to Network Programming](https://beej.us/guide/bgnet/)** — the canonical introduction to the Berkeley sockets API.\n- **[*TCP/IP Illustrated*](https://en.wikipedia.org/wiki/TCP/IP_Illustrated) by W. Richard Stevens** — the canonical reference for protocol implementation details.\n- **[*The Illustrated TLS 1.3 Connection*](https://tls13.xargs.org/)** — the byte-level TLS 1.3 walkthrough we shamelessly model on.\n- **[packagecloud's Linux network stack tutorials](https://blog.packagecloud.io/monitoring-tuning-linux-networking-stack-receiving-data/)** — the receive-path bible.\n- **[*AI Engineering from Scratch*](https://aiengineeringfromscratch.com/)** — the structural template for this curriculum.\n- **The build-your-own-X repos**, especially [danistefanovic/build-your-own-x](https://github.com/danistefanovic/build-your-own-x) and [practical-tutorials/project-based-learning](https://github.com/practical-tutorials/project-based-learning).\n\n---\n\n## License\n\n[MIT](LICENSE).\n\nThe curriculum text, sample code, and supporting tools are all MIT-licensed. Use them however you want — just keep the attribution.\n\n---\n\n© 2026 · open source · free forever\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FTanayK07%2Fnetworking-from-scratch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FTanayK07%2Fnetworking-from-scratch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FTanayK07%2Fnetworking-from-scratch/lists"}