gitmyhub

comcast

Go ★ 11k updated 1y ago

Simulating shitty network connections so you can build better systems.

A command-line tool that deliberately degrades your network connection to simulate real-world conditions like packet loss, added latency, and bandwidth caps so you can test how your app handles them.

Goiptablestcipfwpfctlsetup: easycomplexity 2/5

Comcast is a command-line tool for deliberately degrading your network connection in controlled ways so you can test how your software behaves under poor conditions. The name is a joke referencing the ISP, not an affiliation with it. The idea is that network failures are not always dramatic outages; more often they are slow connections, occasional dropped packets, or added latency, and these subtle problems are worth testing for.

The tool works by wrapping the network control utilities that already exist on your operating system. On Linux it uses iptables and tc, which are built-in tools for managing network traffic rules. On macOS and BSD systems it uses ipfw or pfctl, depending on the OS version. Comcast just provides a simpler command to configure those tools without having to write the commands by hand.

You run it from the terminal, passing flags for the conditions you want to simulate. You can set added latency in milliseconds, cap the bandwidth in kilobits per second, and specify a percentage of packets to randomly drop. You can also narrow the conditions to specific IP addresses, protocols (TCP, UDP, ICMP), or port numbers, so only traffic to a particular service is affected. Running comcast --stop removes the rules and restores normal network behavior.

The README includes a reference table of real-world network profiles with suggested values for conditions like 3G mobile, DSL, dial-up, WiFi, and even Starlink, so you can replicate recognizable scenarios rather than guessing at numbers.

The project is written in Go and installable with a single go install command. For users who prefer not to run a wrapper script, the README also shows the underlying iptables and ipfw commands directly, so you can run them yourself.

Where it fits