リモート サーバーの応答が遅い場合に、外部 JavaScript の読み込みがページにどのように影響するかをテストしたいと思います。
特定のサイトの接続を遅くできるツールを探しましたが、ネットワーク全体を遅くするツール、または Mac 用に存在しないツールしか見つかりませんでした (ここやここなど) 。
そのようなツールはありますか?
Detours App for Macを使用すると、特定のホストを自分のローカル Web サーバーにリダイレクトできます。次に、サーバーから (curl などを介して) リソースを取得し、一定時間スリープしてから、応答を返すことができます。
簡単な方法ではありませんが、IPTABLES (unix ip-router) を TC (トラフィック制御) と組み合わせて使用できますか? 端末の bash スクリプトがどのように機能するかを知らない場合、これは非常に広範囲に及びますが、適切な解決策を得るには端末が 100% 必要になります。
これがうまくいかない場合は、より簡単な方法を試してください: http://lartc.org/howto/lartc.ratelimit.single.html
これをたとえばホームフォルダーに保存し、bwm.shと呼びます
#!/bin/bash
# through this interface
IF=$1
# on this HOST
HOST=$2
# get the IP from HOST
HOSTIP="`nslookup $HOST|grep Address|grep -v "#"|cut -d " " -f2`"
# with this rate
your_rate=$3
# defaults /sbin/tc
TC="`whereis tc | sed 's/[^\ ]*.\([^\ ]*\).*/\1/'`"
# defaults /sbin/iptables
IPTABLES="`whereis iptables | sed 's/[^\ ]*.\([^\ ]*\).*/\1/'`"
#some number
PRIO="123"
# you create a new rule in the mangle table
IPT="$IPTABLES -t mangle"
echo "Program locations found: iptables: $IPTABLES and tc: $TC"
echo "down-rating bandwidth\n on $HOST\n to $your_rate whilst marking packages that origins\n from $HOSTIP\n with $PRIO on interface\n named $IF"
echo -n "starting setup.."
# apply custom filter
$IPT -N myfilter
# add it to the POSTROUTING chain
$IPT -A POSTROUTING -j myfilter
# if conntrack is used - restore a mark and allow the packets, which already have been marked, through - no need to check again
$IPT -A myfilter -p tcp -j CONNMARK --restore-mark
$IPT -A myfilter -m mark --mark $PRIO -j ACCEPT
# add to it your matching rule
$IPT -A myfilter -p tcp -s $HOSTIP -j MARK --set-mark $PRIO
# conntrack it optionally, so not every packet has to be rematched
$IPT -A myfilter -j CONNMARK --save-mark
# use that mark in a tc filter rule
echo qdisc add
$TC qdisc add dev $IF root handle 1: htb default 30
echo class add
$TC class add dev $IF parent 1: classid 1:1 htb rate $your_rate # <<<<<<<< fill in rate
echo sfq add
# add an SFQ qdisc to the end - to which you then attach the actual filter
$TC qdisc add dev $IF parent 1:1 sfq perturb 10
echo filter add
$TC filter add dev $IF parent 1:1 prio 1 handle $PRIO fw flowid 1:1
echo "done"
ターミナルウィンドウを開き、ルート権限を取得します
ファインダー>ターミナル>オープン、ユーザーホームに移動してスーパーユーザーに入ります
cd; su
ルートパスワードを入力してください
インターフェイス、ホスト名、レート パラメータを使用してプログラムを開始する
sh bwm.sh IF HOST RATE