0
1

More than 3 years have passed since last update.

tcコマンドによるパケットロスおよび遅延

Last updated at Posted at 2020-06-07

tcコマンドによるパケットロスおよび遅延

Virtual Boxを用いて、tcコマンドによるパケットロスおよび遅延を実践する。

準備

VMを3つ(Ethernet Bridge、PC1、PC2)用意

構成図は次のとおり。
構成図.PNG

Virtual Box設定

Ethernet Bridge VM

設定.PNG
ネットワークアダプタを2つ作る。1つは内部ネットワークintnet1、もう一つは内部ネットワークintnet2。プロミスキャスモードですべて許可。

PC1 VM

ネットワークアダプタ、内部ネットワークintnet1。

PC2 VM

ネットワークアダプタ、内部ネットワークintnet2。

Ethernet Bridgeの設定

起動時にBridgeが自動的に作成されるよう、/etc/network/interfacesを次のように記述。

root@live:~# cat /etc/network/interfaces
auto eth0
iface eth0 inet static
  address 0.0.0.0
auto eth1
iface eth1 inet static
  address 0.0.0.0

auto br0
iface br0 inet static
  address 0.0.0.0
  bridge_ports eth0 eth1
  bridge_stp on

PC1およびPC2の設定

ここでは、PC2に固定IPアドレスを割り当て、DHCPサーバーを起動。PC1はDHCPサーバーからIPアドレスを取得するように設定した。詳細略。

実験

設定前の状況は次のとおり。

root@live:~# tc qdisc show dev eth1
qdisc pfifo_fast 0: root refcnt 2 bands 3 priomap  1 2 2 2 1 2 0 0 1 1 1 1 1 1 1 1

このときのpingの結果は次のとおり。
正常.PNG
正常。

パケットロス

30%のパケットロスをBridgeのeth1に発生させる。

root@live:~# tc qdisc add dev eth1 root netem drop 30%
root@live:~# tc qdisc show dev eth1
qdisc netem 8002: root refcnt 2 limit 1000 loss 30%

このときのpingの結果は次のとおり。
30%Loss.PNG
24%ロス。回数を増やせば限りなく30%に近づくであろう。

遅延

50msの遅延をBridgeのeth1に発生させる。

root@live:~# tc qdisc add dev eth1 root netem delay 50ms
root@live:~# tc qdisc show dev eth1
qdisc netem 8005: root refcnt 2 limit 1000 delay 50.0ms

このときのpingの結果は次のとおり。
50msDelay.PNG
正常時は約2msのターンアラウンドタイムであったが、この結果では約52msとなっている。

設定解除

次のコマンドにより設定を解除できる。

root@live:~# tc qdisc del dev eth1 root
root@live:~# tc qdisc show dev eth1
qdisc pfifo_fast 0: root refcnt 2 bands 3 priomap  1 2 2 2 1 2 0 0 1 1 1 1 1 1 1 1

参考にしたサイト

こちら

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1