Simulating shitty network connections so you can build better systems.

Overview

Comcast

Testing distributed systems under hard failures like network partitions and instance termination is critical, but it's also important we test them under less catastrophic conditions because this is what they most often experience. Comcast is a tool designed to simulate common network problems like latency, bandwidth restrictions, and dropped/reordered/corrupted packets.

It works by wrapping up some system tools in a portable(ish) way. On BSD-derived systems such as OSX, we use tools like ipfw and pfctl to inject failure. On Linux, we use iptables and tc. Comcast is merely a thin wrapper around these controls. Windows support may be possible with wipfw or even the native network stack, but this has not yet been implemented in Comcast and may be at a later date.

Installation

$ go get github.com/tylertreat/comcast

Usage

On Linux, Comcast supports several options: device, latency, target/default bandwidth, packet loss, protocol, and port number.

$ comcast --device=eth0 --latency=250 --target-bw=1000 --default-bw=1000000 --packet-loss=10% --target-addr=8.8.8.8,10.0.0.0/24 --target-proto=tcp,udp,icmp --target-port=80,22,1000:2000

On OSX, Comcast will check for pfctl support (as of Yosemite), which supports the same options as above. If pfctl is not available, it will use ipfw instead, which supports device, latency, target bandwidth, and packet-loss options.

On BSD (with ipfw), Comcast currently supports only: device, latency, target bandwidth, and packet loss.

$ comcast --device=eth0 --latency=250 --target-bw=1000 --packet-loss=10%

This will add 250ms of latency, limit bandwidth to 1Mbps, and drop 10% of packets to the targetted (on Linux) destination addresses using the specified protocols on the specified port numbers (slow lane). The default bandwidth specified will apply to all egress traffic (fast lane). To turn this off, run the following:

$ comcast --stop

By default, comcast will determine the system commands to execute, log them to stdout, and execute them. The --dry-run flag will skip execution.

I don't trust you, this code sucks, I hate Go, etc.

If you don't like running code that executes shell commands for you (despite it being open source, so you can read it and change the code) or want finer-grained control, you can run them directly instead. Read the man pages on these things for more details.

Linux

On Linux, you can use iptables to drop incoming and outgoing packets.

$ iptables -A INPUT -m statistic --mode random --probability 0.1 -j DROP
$ iptables -A OUTPUT -m statistic --mode random --probability 0.1 -j DROP

Alternatively, you can use tc which supports some additional options.

$ tc qdisc add dev eth0 root netem delay 50ms 20ms distribution normal
$ tc qdisc change dev eth0 root netem reorder 0.02 duplicate 0.05 corrupt 0.01

To reset:

$ tc qdisc del dev eth0 root netem

BSD/OSX

To shape traffic in BSD-derived systems, create an ipfw pipe and configure it. You can control incoming and outgoing traffic separately for any specific host or network.

$ ipfw add 1 pipe 1 ip from me to any
$ ipfw add 2 pipe 1 ip from any to me
$ ipfw pipe 1 config delay 500ms bw 1Mbit/s plr 0.1

To reset:

$ ipfw delete 1

Note: ipfw was removed in OSX Yosemite in favor of pfctl.

Network Condition Profiles

Here's a list of network conditions with values that you can plug into Comcast. Please add any more that you may come across.

Name Latency Bandwidth Packet-loss
GPRS (good) 500 50 2
EDGE (good) 300 250 1.5
3G/HSDPA (good) 250 750 1.5
DIAL-UP (good) 185 40 2
DSL (poor) 70 2000 2
DSL (good) 40 8000 0.5
WIFI (good) 40 30000 0.2
Satellite 1500 - 0.2
Comments
  • Legal fund

    Legal fund

    Is there a place where we can donate to your legal fund when they hulk smash over the use of their mark? Your tool seems too useful and functional to claim parody although obviously I'm no lawyer.

    opened by jgowdy 10
  • Added target addresses/ports/protocols for Linux.

    Added target addresses/ports/protocols for Linux.

    -Added --dry-run to not commit any changes -Can specify the default bandwidth limit of non-targetted connections with --default-bw (fast-lanes) Will add support for also affecting latency/packet loss for default connections at a later date. -Mac/BSD using ipfw not yet supported for target addresses/ports/protocols -Mac/BSD must use --target-bw now instead of --bandwidth

    opened by ghost 8
  • Feature Request - Throttle traffic based on domain.

    Feature Request - Throttle traffic based on domain. "Fast Lane/Slow Lanes"

    The documentation didn't appear to state that using this will, by default, make requests to YouTube and Netflix slower, seems like a critical missing feature.

    It would be pretty cool if you could spec a bandwidth restriction per domain though, or based on other packet criteria. Though I totally understand if delving that deep into networking black magic is outside the scope of this project.

    opened by thorsummoner 8
  • Comcast not working in OSX 10.10.1

    Comcast not working in OSX 10.10.1

    Hi guys, I just tried to setup Comcast on a MAC OS X 10.10.1 machine, resulting in the following message: "I don't support your version of OSX". Is there a way to get it working? Maybe by changing some codelines and building it by myself?

    opened by dsilhavy 6
  • Unclear about units of packet-loss

    Unclear about units of packet-loss

    The README file indicates that --packet-loss=0.1 corresponds to 10% packet loss, but then further down lists profiles that would seem to include 150% or 200% packet loss. The code seems to indicate that 0.1 would actually mean 0.1%, not 10%.

    opened by ghost 6
  • Added manpage

    Added manpage

    Added a shitty manpage (I don't even know how to create manages I had to Google it and this is what I came up with) to simulate shitty customer service. Fixes tylertreat/Comcast#1

    opened by ryankearney 5
  • added a table of simulated network conditions to the markdown

    added a table of simulated network conditions to the markdown

    I added a guide table with network condition values to plug into Comcast. I think it will be useful. Hopefully more people with real multi-network experience can add some more profiles.

    J

    opened by jujhars13 5
  • failed to stop packet controls

    failed to stop packet controls

    used example comcast --device=eth0 --latency=250 --bandwidth=1000 --packet-loss=0.1

    attempting to stop failed.

    root@Desktop:~# comcast --mode stop sudo tc qdisc show | grep "netem" sudo tc qdisc del dev eth0 root netem Failed to stop packet controls

    opened by sigmonsays 5
  • codebeat badge

    codebeat badge

    Is it fine to add codebeat badge to README?

    codebeat is automated code review tool for Swift,Ruby,Go & Python that helps get instant feedback on code quality.

    "Quick wins" suggested by codebeat could be a nice candidate for a pull request and help other developers become contributors.

    FYI. To be fully open and honest. I'm co-founder of codebeat.

    opened by korzonek 4
  • Mac OSX Yosemite+ support via pfctl and dnctl

    Mac OSX Yosemite+ support via pfctl and dnctl

    Adds support for Mac OSX Yosemite via the pfctl and dnctl commands. As part of the implementation, I've removed the check for OSX version and instead replaced it with tests for the 2 known firewall implementations (namely pfctl and ipfw).

    If this makes it in, we may want to consider updating the OSX stanza in the README.

    Nice little project, btw :ok_hand: (although the name has less effect over here in Australia).

    opened by mefellows 4
  • Add ipv6 destination support on Linux

    Add ipv6 destination support on Linux

    Now it's possible to specify IPv6 address as a destination using the --ipv6 command line option:

    comcast --packet-loss=20% --ipv6 --target-addr=2001:db8::1 --target-proto=tcp --target-port=80
    
    opened by roman-kashitsyn 4
  • sudo tc qdisc show | grep

    sudo tc qdisc show | grep "netem" It looks like the packet rules are already setup

    Hello! I am actually having several issues. I am currently running Ubuntu 20.04.4 LTS for context.

    1. The go install github.com/tylertreat/comcast@latest installation command isn't working for me; I needed to git pull the comcast repository, and then go build comcast.go and go install in order for the comcast command to work in my terminal. I am having to build and install each time I restart my terminal.
    2. I simply can't get the comcast command to work properly; for example running comcast --device=<device name> --latency=2000 prints sudo tc qdisc show | grep "netem" It looks like the packet rules are already setup and then comcast --stop prints Failed to stop packet controls.

    Any advice on fixing either of these things or getting comcast working would be greatly appreciated.

    opened by JasonRWilson00 1
  • eBPF support?

    eBPF support?

    Any interest for a PR to add eBPF functionality? I was imagining a tutorial "Mediacom" Docker container baked out of a simple config file that gave it not only bad network connections - but also problematic filesystem calls in a designated directory like /tmp/mediacom .

    opened by chadbrewbaker 1
  • Allow injecting

    Allow injecting "data cap is full" messages into packages

    Comcast, in the real world, does deep packet inspection to find HTTP packages, and injects a "you've reached your data cap" message.

    screenshot of such a message

    It would be useful to have this option for testing available as well (and maybe even multiple such messages from multiple ISPs, used at random)

    opened by justjanne 0
  • Probablistically dropping outbound traffic is a poor simulation of packet loss.

    Probablistically dropping outbound traffic is a poor simulation of packet loss.

    The kernel sends the client an eperm when tc or iptables drops a packet. In real packet loss, the client wouldn't be made immediately aware that the packet didn't reach its destination. The process I'm testing responds to eperm by closing down the socket and trying again on a new socket.

    See https://www.spinics.net/lists/netfilter/msg42592.html.

    I worked around this by rerouting the packet to a port, 9999, which hopefully isn't used - this solution probably isn't ideal here.

    That said, if the intention is to run these scripts on a machine acting as a router then this isn't an issue.

    opened by kportertx 0
  • network latency on specific port is invalid

    network latency on specific port is invalid

    when I use this command

    ./comcast --device=eth0 --latency=5000 --target-proto=tcp,udp,icmp --target-addr=10.215.45.5
    

    it is useful.but if i add --target-port=9999 like

    ./comcast --device=eth0 --latency=5000 --target-proto=tcp,udp,icmp --target-addr=10.215.45.5 --target-port=9999
    

    it doesn’t work .

    system CentOS release 6.9 (Final) Comcast version 1.0.0

    opened by zhqqqy 0
Releases(v1.0.1)
Owner
Tyler Treat
Interested in messaging middleware, distributed systems, and cloud infrastructure.
Tyler Treat
LINE 4.1k Dec 31, 2022
Intra is an experimental tool that allows you to test new DNS-over-HTTPS services that encrypt domain name lookups and prevent manipulation by your network

Intra Intra is an experimental tool that allows you to test new DNS-over-HTTPS services that encrypt domain name lookups and prevent manipulation by y

Jigsaw 1.2k Jan 1, 2023
A High Performance Network ( TCP/IP ) Library

Chronicle-Network About A High Performance Network library Purpose This library is designed to be lower latency and support higher throughputs by empl

Chronicle Software : Open Source 231 Dec 31, 2022
Netty project - an event-driven asynchronous network application framework

Netty Project Netty is an asynchronous event-driven network application framework for rapid development of maintainable high performance protocol serv

The Netty Project 30.5k Jan 3, 2023
Lunar Network SoupPvP gamemode replica

SoupPvP Lunar Network SoupPvP gamemode replica Disclaimer This is a work-in-progress, for that reason, a lot of features and essential parts of Lunar'

Elb1to 64 Nov 30, 2022
Magician is an asynchronous non-blocking network protocol analysis package, supports TCP, UDP protocol, built-in Http, WebSocket decoder

An asynchronous non-blocking network protocol analysis package Project Description Magician is an asynchronous non-blocking network protocol analysis

贝克街的天才 103 Nov 30, 2022
JNetcat : a tool to debug network issues or simulate servers

JNetcat A tool to easily debug or monitor traffic on TCP/UDP and simulate a server or client No need of telnet anymore to test for a remote connection

io-panic 3 Jul 26, 2022
Apache MINA is a network application framework which helps users

Apache MINA is a network application framework which helps users develop high performance and high scalability network applications easily

The Apache Software Foundation 846 Dec 20, 2022
A network core plugin for the Spigot which best Experience for Minecraft Servers.

tCore The core plugin for Spigot. (Supports 1.8.8<=) 大規模サーバー、ネットワーク等の中核となるプラグインです。プロトコルバージョン 1.8 未満での動作は確認していません。かなりの量のソースになりますが、様々な機能が実装されています。中身自体は過

null 6 Oct 13, 2022
VelocityControl is a BungeeControl-fork plugin enabling ChatControl Red to connect with your Velocity network.

VelocityControl is a BungeeControl-fork plugin enabling ChatControl Red to connect with your Velocity network.

Matej Pacan 10 Oct 24, 2022
CustomRPC - a tool that allows you to change your discord rich presence (RPC) to a custom one

CustomRPC is a tool that allows you to change your discord rich presence (RPC) to a custom one. It also allows creating sentence sequences

null 2 May 3, 2022
Operating Systems - Concepts of computer operating systems including concurrency, memory management, file systems, multitasking, performance analysis, and security. Offered spring only.

Nachos for Java README Welcome to Nachos for Java. We believe that working in Java rather than C++ will greatly simplify the development process by p

Sabir Kirpal 1 Nov 28, 2021
Create your Java crypto trading bot in minutes. Our Spring boot starter takes care of exchange connections, accounts, orders, trades, and positions so you can focus on building your strategies.

Quick Start | Documentation | Discord | Twitter Create and run your java crypto trading bot in minutes Our Spring boot starter takes care of exchange

Cassandre 442 Jan 3, 2023
Netflix, Inc. 23.1k Jan 5, 2023
This is a Meme repo for fixed & Cleaned source of 'Better'Bungeecord but its not realy better code is trash!

#Fucking cleaned by CryCodes Disclaimer: Based of MD_5's Bungeecord (Fork of "BetterBungee") | I am not the owner of the code This repo is just for fu

Rooks 3 Jan 2, 2022
Jetserver is a high speed nio socket based multiplayer java game server written using Netty and Mike Rettig's Jetlang.It is specifically tuned for network based multiplayer games and supports TCP and UDP network protocols.

Note New version of Jetserver is called Nadron and is in a new netty 4 branch of this same repo. JetServer is a java nio based server specifically des

Abraham Menacherry 1.2k Dec 14, 2022
A Network Observer which would provide maximum details about the network to the administrator on their screen without knowing to their users.

Smart-Network-Observer-With-Energy-Framework A Network Observer which would provide maximum details about the network to the administrator on their sc

Shrutika Ambre 5 Jul 15, 2022
Chaos engineering tool for simulating real-world distributed system failures

Proxy for simulating real-world distributed system failures to improve resilience in your applications. Introduction Muxy is a proxy that mucks with y

Matt Fellows 811 Dec 25, 2022
Logisim-evolution is educational software for designing and simulating digital logic circuits

Branch master: Branch develop: Logisim-evolution Table of contents Features Requirements Downloads Nightly builds (unstable) Pictures of Logisim-evolu

null 3k Jan 4, 2023