使用 ipfw 模拟 URL 的延迟

使用 ipfw 模拟 URL 的延迟

如何模拟单个 URL 的延迟?

我尝试通过添加 ipfw 规则来模拟单个 URL 的延迟。

sudo ipfw add pipe 1 ip  from  myurl.com to any
#(response of running above command) 00100 pipe 1 ip from any to any
sudo ipfw add pipe 1 ip  from  any to myurl.com
#(response of running above command) 00200 pipe 2 ip from any to any


sudo   ipfw pipe 1 config delay 10000ms bw 1Kbit/s
sudo   ipfw pipe 2 config delay 10000ms bw 1Kbit/s

然而,上述规则引入了全部URL,而不仅仅是 myurl.com

我是否遗漏了某些内容而导致 myurl.com 出现延迟

答案1

#!/bin/sh
# latency.sh    

oif="em0" # just the interface looking to the outer space

# let's create two seperate pipes
ipfw pipe 1 config delay 10000ms bw 1Kbit/s
ipfw pipe 2 config delay 10000ms bw 1Kbit/s

# let's pipe some traffic
# going in...
ipfw add 1000 pipe 1 all from myurl.com to any in via $oif
# and out...
ipfw add 1001 pipe 2 all from any to myurl.com out via $oif
# that's all 

# sudo ./latency.sh

相关内容