Comcast - 网络问题模拟工具


Apache
跨平台
Google Go

软件简介

Comcast 是一个用来模拟各种常用的网络问题的工具,例如延迟、带宽限制以及丢包等等问题。

Comcast 使用可移植的方式封装了各种系统工具,例如 ipfw 和 pfctl 来注入网络通信失败问题。

安装

$ go get github.com/tylertreat/comcast

使用

在 Linux 中 Comcast 支持很多选项,包括设备、延迟、目标、默认带宽、丢包、协议和端口等。

$ 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.