Squid で帯域制限

遅い回線のエミュレーションをしたかったので、Squid で帯域制限をやってみた。
以前にも同じようなことを FreeBSD で bridge + dummynet でやったのだが、今回はお手軽に Squid のみで。

dummynet だと IP レベルで制限をかけるので遅延もエミュレーションできる (遅い回線で遅延を大きくするとか) が、Squid はダウンロード帯域のみの制限になるので、厳密さはちょっと落ちるはず。

squid.conf に以下のように記述。64, 128, 256, 512, 1024kbps の制限を port 別にかけて、クライアントから Proxy にその port を指定してやる。

http_port 10064
http_port 10128
http_port 10256
http_port 10512
http_port 11024

acl 64kbps   myport 10064
acl 128kbps  myport 10128
acl 256kbps  myport 10256
acl 512kbps  myport 10512
acl 1024kbps myport 11024

delay_pools 5

delay_class 1 1
delay_access 1 allow 64kbps all
delay_parameters 1 8000/8000

delay_class 2 1
delay_access 2 allow 128kbps all
delay_parameters 2 16000/16000

delay_class 3 1
delay_access 3 allow 256kbps all
delay_parameters 3 32000/32000

delay_class 4 1
delay_access 4 allow 512kbps all
delay_parameters 4 64000/64000

delay_class 5 1
delay_access 5 allow 1024kbps all
delay_parameters 5 128000/128000