Projects / 2025

pktlab

A reproducible packet-capture lab built from network namespaces, veth pairs, and a little tc.

active LinuxPythontcpdumptc

pktlab started as a way to stop testing packet captures on production. It builds a small, disposable network in network namespaces: two hosts, a router, a lossy link, and a capture point on each side. When the experiment is over, one command removes the whole thing.

Why

Most capture tutorials use a single host and a loopback interface. That is enough to learn the syntax, but it does not reproduce the interesting failures: a queue that builds under load, a path MTU black hole, a middlebox that rewrites options, or asymmetric loss.

A namespace lab gives you those failures on demand, without a spare switch or a maintenance window.

What it does

make lab          # create the namespaces and links
make capture      # start tcpdump on both ends
make load         # apply netem delay/loss/rate and generate traffic
make down         # remove everything

The default topology is deliberately small:

client ns ── veth ── router ns ── veth ── server ns
                         │
                    tc netem here

The router is a namespace with IP forwarding enabled. The tc rules live on its interfaces, so the capture on the client sees one side of the impairment and the capture on the server sees the other.

Status

Active, used for my own notes and for teaching. The scripts are intentionally boring: shell for setup, Python for parsing summaries, tcpdump for the capture. No agent, no daemon, no dashboard.

Notes

The lab is not a benchmark. It runs on one machine, so the CPU is shared by every namespace. Treat throughput numbers as relative, not absolute. The latency and loss behaviour is the useful part.

If you run it on a laptop, put the lab on a separate network namespace and keep the default route untouched. The make down target removes only what make lab created.