Comcast網(wǎng)絡(luò)問題模擬工具
Comcast 是一個(gè)用來(lái)模擬各種常用的網(wǎng)絡(luò)問題的工具,例如延遲、帶寬限制以及丟包等等問題。
Comcast 使用可移植的方式封裝了各種系統(tǒng)工具,例如 ipfw 和 pfctl 來(lái)注入網(wǎng)絡(luò)通信失敗問題。
安裝
$ go get github.com/tylertreat/comcast
使用
在 Linux 中 Comcast 支持很多選項(xiàng),包括設(shè)備、延遲、目標(biāo)、默認(rèn)帶寬、丟包、協(xié)議和端口等。
$ 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.
