Skip to content

Commit afa93c7

Browse files
authored
Merge pull request #6 from ngrok/joelhans/lesson-00-and-diary
add diary+lesson 00: Two Pis, connected—can they just... talk?
2 parents 9cffdf9 + 8b50968 commit afa93c7

27 files changed

Lines changed: 1836 additions & 15 deletions

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
# Python bytecode (from running the tools/* scripts)
22
__pycache__/
33
*.py[cod]
4+
5+
# macOS
6+
.DS_Store

AGENTS.md

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# Agent guide
2+
3+
This repo teaches networking by pairing story, runnable lessons, and Raspberry
4+
Pi image tooling. If you are a coding agent asked to guide someone through it,
5+
act as a tutor and lab operator: explain what each command is proving, run only
6+
the mode that matches the user's environment, and stop for physical actions.
7+
8+
## Start here
9+
10+
Read these in order before making changes or walking a user through the lab:
11+
12+
1. `README.md` for the project shape and phases.
13+
2. `diaries/00_two-pis-one-cable.md` for the story behind lesson 00.
14+
3. `lessons/00/README.md` for the hands-on run path.
15+
4. `lessons/00/manifest.json` for the machine-readable lesson beats, expected
16+
observations, and recovery commands.
17+
18+
Use `rg --files` to inspect the repo. The `.context/` directory is private
19+
workspace scratch space; do not assume external users or future agents can see
20+
it.
21+
22+
## Teaching modes
23+
24+
- Read-only tutoring: use the diary, lesson README, and manifest to explain the
25+
lesson without running commands. This works from any machine.
26+
- Virtual lab: run lesson 00 in Linux with network namespaces. This is the best
27+
mode when there is no hardware. From `lessons/00`, use
28+
`sudo env NO_COLOR=1 ./scripts/run.sh --virtual`.
29+
- Hardware lab: drive two real Pis over SSH. Confirm the user has two nodes
30+
flashed with `image/`, an Ethernet cable between their `eth0` ports, and SSH
31+
access over Wi-Fi before running scripts.
32+
33+
## Commands and safety
34+
35+
Lesson 00 scripts live in `lessons/00/scripts/`.
36+
37+
- `./scripts/check.sh --hardware` checks SSH access, required tools, sudo
38+
readiness, and whether `eth0` already has lesson state.
39+
- `sudo ./scripts/check.sh --virtual` checks the Linux namespace lab
40+
prerequisites.
41+
- `./scripts/run.sh` walks the hardware lesson over SSH.
42+
- `sudo ./scripts/run.sh --virtual` creates, runs, and tears down the namespace
43+
lab.
44+
- `./scripts/reset.sh` deletes the lesson's `eth` NetworkManager profile on
45+
both hardware nodes, returning `eth0` to a blank lab wire.
46+
- `sudo ./scripts/virtual/lab-down.sh` removes the virtual namespaces if a
47+
virtual run is interrupted.
48+
49+
Do not run hardware scripts without confirming `A_HOST` and `B_HOST`; they
50+
default to `pi@pi-foo-01.local` and `pi@pi-foo-02.local`. Do not run image build
51+
or flashing commands unless explicitly asked; those can take a long time and can
52+
write to disks if misused.
53+
54+
When scripting or capturing output for another agent, prefer:
55+
56+
```bash
57+
NO_COLOR=1 ./scripts/<step>.sh
58+
```
59+
60+
The scripts pause only when stdin is a terminal, so noninteractive runs continue
61+
through prompts automatically. Hardware runs may still need SSH and sudo access.
62+
63+
## Human handoffs
64+
65+
Stop and ask the user to perform physical work when the lesson requires it:
66+
67+
- Unplug or seat the Ethernet cable.
68+
- Check link lights.
69+
- Flash or move microSD cards.
70+
- Confirm the correct SD card device before any `dd` command.
71+
72+
The agent can interpret output and troubleshoot, but it cannot verify physical
73+
state directly.
74+
75+
## Expected lesson 00 arc
76+
77+
The lesson answers three questions:
78+
79+
- Layer 1: a real cable changes `eth0` from `NO-CARRIER` / `DOWN` to
80+
`LOWER_UP` / `UP`, with speed and duplex negotiated.
81+
- Layer 2: the link emits frames immediately, including IPv6 neighbor discovery,
82+
multicast listener reports, router solicitation, and on real Pis often mDNS
83+
and DHCP discovery.
84+
- Layer 3: `ping 10.10.0.2` fails until both ends receive IPv4 identities on
85+
`eth0`; then ARP maps the typed IP address to the peer's MAC address.
86+
87+
If the virtual lab is unavailable on macOS or Windows, tell the user to run it
88+
inside a Linux VM or use read-only tutoring mode.

README.md

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,25 @@ Networking is one of the most global and durable technologies you'll ever touch.
77
Its fundamentals are going nowhere, and when you make all those invisible layers
88
of the internet visible and intuitive to you, you become a better developer.
99

10+
Everything here is meant to be **reproduced**. The bill of materials, the OS
11+
image tooling, and the lesson scripts all live in this repo so you can build
12+
your own little internet and follow along.
13+
1014
_And have some fun along the way._
1115

1216
## How I'm rolling out the little internet
1317

14-
We start with a single network, then two networks, and then a working facsimile
15-
of the internet you know and love. Each phase comes with lessons as technical
16-
write-ups ([ngrok blog](https://ngrok.com/blog)), YouTube videos
17-
([ngrok @ YouTube](https://www.youtube.com/@ngrokHQ)), and follow-along scripts
18-
in this repo.
18+
I'm going from single network, then two networks, and then a working facsimile
19+
of the internet you know and love.
20+
21+
As I go, I'll write [diaries](./diaries/) that track questions I'm asking about
22+
the little internet and the paths I've taken to unpuzzle and understand them.
23+
Each of those gets a hands-on [lesson](./lessons) you can run yourself. I'll
24+
also peel off particularly tasty deep-dives on different protocols over to the
25+
[ngrok blog](https://ngrok.com/blog) and
26+
[YouTube](https://www.youtube.com/@ngrokHQ).
1927

20-
Each phase includes just enough hardware to make the next set of ideas tangible.
28+
Here's the whole big picture:
2129

2230
- **Phase 1: a network.** Two Pis and a managed switch. How do devices on the
2331
same network find and talk to each other? _ARP, MAC addresses, broadcast
@@ -30,16 +38,18 @@ Each phase includes just enough hardware to make the next set of ideas tangible.
3038
advertise their reachability to one another. _Autonomous systems, BGP, path
3139
selection, convergence_, plus side quests like DNS, TLS, and Pi-hole.
3240

33-
## Want to build your own?
41+
## Want to build your own little internet?
3442

3543
1. Gather the hardware. See [`BOM.md`](./BOM.md) for the full parts list by
3644
phase.
3745
2. Download a prebuilt image from [Releases](../../releases), or build your own.
3846
Either way, see [`image/`](./image/) for getting the Raspberry Pi OS image
3947
(built with [pi-gen](https://github.com/RPi-Distro/pi-gen)) and flashing it
4048
to your microSD cards.
41-
3. Follow the lessons. (Coming soon. Start with lesson 00, "why can't these two
42-
Pis just talk to each other?")
49+
3. Follow the lessons. Start with [`lesson 00`](./lessons/00/), "two Pis, one
50+
cable: can they just talk?"
51+
4. Read the diaries for the story behind it all. They're the running build log
52+
of putting this together, in the order each piece came to life.
4353

4454
## Repo layout
4555

@@ -49,10 +59,22 @@ Each phase includes just enough hardware to make the next set of ideas tangible.
4959
├── BOM.md Bill of materials — every part, by phase, with vendors.
5060
├── image/ pi-gen config that builds the Raspberry Pi OS image the
5161
│ nodes run, plus instructions for building and flashing it.
52-
└── lessons/ (coming soon) One directory per lesson: an explainer, the
53-
scripts to run it yourself, and recorded packet captures.
62+
├── diaries/ Running build log of how the network came together, one
63+
│ prose file per session, in the order things happened.
64+
├── lessons/ One directory per lesson: an explainer, the scripts to run
65+
│ it yourself, and recorded packet captures. Start with
66+
│ lessons/00.
67+
└── AGENTS.md Guidance for coding agents that teach or operate the labs.
5468
```
5569

70+
## Using a coding agent
71+
72+
Coding agents can teach from the docs, run the Linux virtual lab, or drive real
73+
Pis over SSH while you handle the cable and hardware. Point them at
74+
[`AGENTS.md`](./AGENTS.md) first; lesson 00 also has a machine-readable
75+
[`manifest.json`](./lessons/00/manifest.json) with beats, commands, expected
76+
observations, and recovery steps.
77+
5678
## Contributing
5779

5880
Want to help? Open an issue or email me at joel@ngrok.com.

0 commit comments

Comments
 (0)