[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-81893":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":15,"subscribersCount":15,"size":15,"stars1d":16,"stars7d":16,"stars30d":13,"stars90d":15,"forks30d":15,"starsTrendScore":17,"compositeScore":18,"rankGlobal":10,"rankLanguage":10,"license":19,"archived":20,"fork":20,"defaultBranch":21,"hasWiki":22,"hasPages":20,"topics":23,"createdAt":10,"pushedAt":10,"updatedAt":32,"readmeContent":33,"aiSummary":34,"trendingCount":15,"starSnapshotCount":15,"syncStatus":16,"lastSyncTime":35,"discoverSource":36},81893,"networking-from-scratch","TanayK07\u002Fnetworking-from-scratch","TanayK07","Build the network stack from raw bytes. 289 hands-on lessons in C and Python — from Ethernet frames to TLS 1.3","https:\u002F\u002Fnetworkingfromscratch.vercel.app\u002F",null,"C",43,3,1,0,2,6,47.11,"MIT License",false,"main",true,[24,25,26,27,28,29,30,31],"c","learn-networking","linux","networking","systems-programming","tcp","tcp-ip","udp","2026-06-12 04:01:35","\u003Cdiv align=\"center\">\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:\u002F\u002Fimg.shields.io\u002Fgithub\u002Fstars\u002FTanayK07\u002Fnetworking-from-scratch?style=flat-square&color=00897B)](https:\u002F\u002Fgithub.com\u002FTanayK07\u002Fnetworking-from-scratch\u002Fstargazers)\n[![License: MIT](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Flicense-MIT-blue?style=flat-square)](LICENSE)\n[![Lessons](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Flessons-289-teal?style=flat-square)](https:\u002F\u002Fnetworkingfromscratch.vercel.app\u002Fcatalog.html)\n[![Phases](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Fphases-15-orange?style=flat-square)](https:\u002F\u002Fnetworkingfromscratch.vercel.app\u002Froadmap.html)\n[![C](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FC-00599C?style=flat-square&logo=c&logoColor=white)](phases\u002F)\n[![Python](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FPython-3776AB?style=flat-square&logo=python&logoColor=white)](phases\u002F)\n\n[Website](https:\u002F\u002Fnetworkingfromscratch.vercel.app) · [Catalog](https:\u002F\u002Fnetworkingfromscratch.vercel.app\u002Fcatalog.html) · [Roadmap](https:\u002F\u002Fnetworkingfromscratch.vercel.app\u002Froadmap.html) · [Glossary](https:\u002F\u002Fnetworkingfromscratch.vercel.app\u002Fglossary.html) · [Discussions](https:\u002F\u002Fgithub.com\u002FTanayK07\u002Fnetworking-from-scratch\u002Fdiscussions)\n\n\u003C\u002Fdiv>\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\u002FIP stack** on a Linux TUN\u002FTAP device that can `curl` a real HTTPS site (saminiir's *Let's code a TCP\u002FIP 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\u002F4789.\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`\u002F`unpack`, `asyncio`, `pytest`.\n- **CS fundamentals** — binary\u002Fhex, 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\u002FTAP, eBPF, and namespace lessons require root.\n\nSee [`docs\u002Fprereqs.md`](docs\u002Fprereqs.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:\u002F\u002Fgithub.com\u002FTanayK07\u002Fnetworking-from-scratch.git\ncd networking-from-scratch\n\n# Set up an Ubuntu 24.04 VM with all dependencies (recommended)\n.\u002Ftools\u002Fsetup-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\u002F01-bits-and-wires\u002F02-bits-bytes-endianness test\n\n# Or jump to the link layer\nmake -C phases\u002F02-link-layer\u002F03-raw-sockets-on-linux-afpacket\nsudo .\u002Fphases\u002F02-link-layer\u002F03-raw-sockets-on-linux-afpacket\u002Fsniff eth0\n```\n\n---\n\n## Curriculum at a glance\n\n```\nP1   Bits & Wires             ─┐\nP2   Link Layer                ├── FOUNDATIONS\nP3   Network Layer             │\nP4   Transport (UDP\u002FTCP\u002FQUIC) ─┘\nP5   Sockets & I\u002FO             ─┐\nP6   Application Protocols      │── PROTOCOLS\nP7   TLS & Secure Transport    ─┘\nP8   Userspace TCP\u002FIP Stack    ── CAPSTONE I\nP9   Linux Kernel Internals   ─┐\nP10  eBPF, XDP, Kernel Bypass  ├── KERNEL & PERF\nP11  Performance & Observability┘\nP12  Routing: BGP, OSPF        ─┐\nP13  Overlays & Container Net   ├── MODERN INFRA\nP14  Service Mesh & Cloud-Native┘\nP15  BONUS: DDS & Robotics\n```\n\n| Phase | Title | Lessons | Capstone |\n|------:|-------|--------:|----------|\n| P1  | Bits & 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 & I\u002FO Models                  | 16 | A 10k-connection HTTP\u002F1.0 server (epoll) |\n| P6  | Application Protocols                 | 28 | An HTTP CONNECT proxy supporting HTTP\u002F1.1, \u002F2, \u002F3 |\n| P7  | TLS & Secure Transport                | 16 | A minimal HTTPS server using your TLS 1.3 |\n| P8  | Userspace TCP\u002FIP 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 & 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 & Container Networking       | 16 | A bridge CNI plugin in Python |\n| P14 | Service Mesh & 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\u002Findex.md`](docs\u002Findex.md) for the full lesson list with descriptions.\n\n---\n\n## Repository layout\n\n```\nnetworking-from-scratch\u002F\n├── README.md                        # this file\n├── LICENSE                          # MIT\n├── CONTRIBUTING.md\n├── CODE_OF_CONDUCT.md\n├── docs\u002F\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\u002F                        # cached copies of canonical RFCs\n├── common\u002F\n│   ├── c\u002F                           # shared C helpers (checksum, CRC, TUN, log)\n│   └── python\u002Fnfs\u002F                  # shared Python helpers (packet, pcap, runner)\n├── phases\u002F\n│   ├── 01-bits-and-wires\u002F\n│   │   ├── README.md\n│   │   ├── 01-what-is-a-network\u002F\n│   │   ├── 02-bits-bytes-endianness\u002F\n│   │   │   ├── README.md            # the lesson (theory, code, exercises)\n│   │   │   ├── htonl.c\n│   │   │   ├── htonl.h\n│   │   │   ├── Makefile\n│   │   │   └── tests\u002F\n│   │   ├── 08-errors-and-crcs\u002F\n│   │   └── ...\n│   ├── 02-link-layer\u002F\n│   ├── ...\n│   └── 15-dds-robotics-bonus\u002F\n├── tools\u002F\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\u002F\n│   └── workflows\u002F                   # 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 \u002F 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\u002Flint-curriculum.py`) rejects PRs that omit any of these sections. See [`docs\u002Fstyle-guide.md`](docs\u002Fstyle-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\u002F01-bits-and-wires\u002F02-bits-bytes-endianness\u002F)** — reimplements `htonl`\u002F`ntohl` from scratch, verifies bit-for-bit agreement with the kernel's. (C)\n- **[P2.06 — ARP request \u002F reply](phases\u002F02-link-layer\u002F06-arp-request-reply\u002F)** — 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\u002F03-network-layer\u002F02-internet-checksum\u002F)** — 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\u002Flint-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:\u002F\u002Fnetworkingfromscratch.vercel.app\u002Fcatalog.html), fork, write it following [`docs\u002Fstyle-guide.md`](docs\u002Fstyle-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:\u002F\u002Fnetworkingfromscratch.vercel.app).\n\nIf you want to help write lessons, the [project board](https:\u002F\u002Fgithub.com\u002FTanayK07\u002Fnetworking-from-scratch\u002Fprojects\u002F1) 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\u002FIP stack*](https:\u002F\u002Fwww.saminiir.com\u002Flets-code-tcp-ip-stack-1-ethernet-arp\u002F)** — the reference for how to teach a TCP\u002FIP stack from scratch.\n- **[Beej's Guide to Network Programming](https:\u002F\u002Fbeej.us\u002Fguide\u002Fbgnet\u002F)** — the canonical introduction to the Berkeley sockets API.\n- **[*TCP\u002FIP Illustrated*](https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FTCP\u002FIP_Illustrated) by W. Richard Stevens** — the canonical reference for protocol implementation details.\n- **[*The Illustrated TLS 1.3 Connection*](https:\u002F\u002Ftls13.xargs.org\u002F)** — the byte-level TLS 1.3 walkthrough we shamelessly model on.\n- **[packagecloud's Linux network stack tutorials](https:\u002F\u002Fblog.packagecloud.io\u002Fmonitoring-tuning-linux-networking-stack-receiving-data\u002F)** — the receive-path bible.\n- **[*AI Engineering from Scratch*](https:\u002F\u002Faiengineeringfromscratch.com\u002F)** — the structural template for this curriculum.\n- **The build-your-own-X repos**, especially [danistefanovic\u002Fbuild-your-own-x](https:\u002F\u002Fgithub.com\u002Fdanistefanovic\u002Fbuild-your-own-x) and [practical-tutorials\u002Fproject-based-learning](https:\u002F\u002Fgithub.com\u002Fpractical-tutorials\u002Fproject-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","Networking from Scratch 是一个教育性质的项目，旨在从零开始构建网络协议栈。它通过289个动手实践课程，使用C和Python语言，覆盖了从以太网帧到TLS 1.3的广泛内容。项目的核心功能包括手动实现TCP\u002FIP堆栈、TLS 1.3协议解析、编写内核模块以及开发CNI插件等。技术特点上，强调从原始字节出发，不依赖任何框架，直到用户自己构建出最小版本。适合对计算机网络底层原理感兴趣的开发者或学生，在实际操作中加深理解。","2026-06-11 04:07:05","CREATED_QUERY"]