結論として

結論として

帯域幅を制限し、tc確認結果を使用しようとしていますiperf。これが私が始めた方法です。

# iperf -c 192.168.2.1
------------------------------------------------------------
Client connecting to 192.168.2.1, TCP port 5001
TCP window size: 23.5 KByte (default)
------------------------------------------------------------
[  3] local 192.168.2.7 port 35213 connected with 192.168.2.1 port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0-10.0 sec   830 MBytes   696 Mbits/sec

両方のインスタンスはイーサネット経由で直接接続されます。

htb qdisc次に、帯域幅を1Mbit / sに制限する基本クラスを設定します。

# tc qdisc add dev bond0 root handle 1: htb default 12
# tc class add dev bond0 parent 1: classid 1:12 htb rate 1mbit

しかし、私は期待しているものを得ません。

# iperf -c 192.168.2.1
------------------------------------------------------------
Client connecting to 192.168.2.1, TCP port 5001
TCP window size: 23.5 KByte (default)
------------------------------------------------------------
[  3] local 192.168.2.7 port 35217 connected with 192.168.2.1 port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0-12.8 sec   768 KBytes   491 Kbits/sec

速度を2倍にすると、測定された帯域幅は変わりません。私は何を見逃していますか?測定された帯域幅がパラメータの1 mbitに対応しないのはなぜですかrate?帯域幅を特定の速度に制限するには、どのパラメータを設定する必要がありますか?

しかし、ページでは、これを行うにはこれを選択する必要があるとman言います。tbfqdisc

トークンバケットフィルタは、トラフィックを正確に設定された速度に減らすのに適しています。大きな帯域幅にうまく拡張されます。

tbfパラメータrateburstlimit| latency)が必要です。だから私は次のことを試しましたが、合計burstlimit| latency)が利用可能な帯域幅にどのような影響を与えるのかわかりません。

# tc qdisc add dev bond0 root tbf rate 1mbit limit 10k burst 10k

私が測定した帯域幅は113Kbits / secでした。値を追加すると、状況が大きく変化することがわかるまで、これらのパラメータを使用しても大幅に変わりませんでしたmtu

# tc qdisc add dev bond0 root tbf rate 1mbit limit 10k burst 10k mtu 5000

測定された帯域幅は1.00Mbits /秒です。

帯域幅を特定の速度に制限するには、どのパラメータを設定する必要がありますか?

htbこれにはキュールールを使用する必要がありますか?tbf

編集する:

これらのリソースに基づいていくつかのテストを行いました。

次の設定を試しました。

本物のマシンで

/etc/network/interfaces:

auto lo
iface lo inet loopback

auto br0
iface br0 inet dhcp
bridge_ports eth0

測定方法iperf

# tc qdisc add dev eth0 root handle 1: htb default 12
# tc class add dev eth0 parent 1: classid 1:12 htb rate 1mbit
# iperf -c 192.168.2.1
------------------------------------------------------------
Client connecting to 192.168.2.1, TCP port 5001
TCP window size: 23.5 KByte (default)
------------------------------------------------------------
[  3] local 192.168.2.4 port 51804 connected with 192.168.2.1 port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0-11.9 sec  1.62 MBytes  1.14 Mbits/sec

そして、iperfサーバーは異なる帯域幅を計算します。

[  4] local 192.168.2.1 port 5001 connected with 192.168.2.4 port 51804
[  4]  0.0-13.7 sec  1.62 MBytes   993 Kbits/sec

バインドされていない仮想マシンで

/etc/network/interfaces:

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp

測定方法iperf

# tc qdisc add dev eth0 root handle 1: htb default 12
# tc class add dev eth0 parent 1: classid 1:12 htb rate 1mbit
# iperf -c 192.168.2.1
------------------------------------------------------------
Client connecting to 192.168.2.1, TCP port 5001
TCP window size: 23.5 KByte (default)
------------------------------------------------------------
[  3] local 192.168.2.7 port 34347 connected with 192.168.2.1 port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0-11.3 sec  1.62 MBytes  1.21 Mbits/sec

そして、iperfサーバーは異なる帯域幅を計算します。

[  4] local 192.168.2.1 port 5001 connected with 192.168.2.7 port 34347
[  4]  0.0-14.0 sec  1.62 MBytes   972 Kbits/sec

ボンディングを含むVM(eth0に設定されたtc)

/etc/network/interfaces:

auto lo
iface lo inet loopback

auto eth0
allow-bond0 eth0
iface eth0 inet manual
    bond-master bond0
    bond-primary eth0 eth1

auto eth1
allow-bond0 eth1
iface eth1 inet manual
    bond-master bond0
    bond-primary eth0 eth1

auto bond0
iface bond0 inet dhcp
    bond-slaves none
    bond-mode 1
#    bond-arp-interval 250
#    bond-arp-ip-target 192.168.2.1
#    bond-arp-validate 3

測定方法iperf

# tc qdisc add dev eth0 root handle 1: htb default 12
# tc class add dev eth0 parent 1: classid 1:12 htb rate 1mbit
# iperf -c 192.168.2.1
------------------------------------------------------------
Client connecting to 192.168.2.1, TCP port 5001
TCP window size: 23.5 KByte (default)
------------------------------------------------------------
[  3] local 192.168.2.9 port 49054 connected with 192.168.2.1 port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0-11.9 sec  1.62 MBytes  1.14 Mbits/sec

そして、iperfサーバーは異なる帯域幅を計算します。

[  4] local 192.168.2.1 port 5001 connected with 192.168.2.9 port 49054
[  4]  0.0-14.0 sec  1.62 MBytes   972 Kbits/sec

ボンディングを含むVM(bond0に設定されたtc)

/etc/network/interfaces:

auto lo
iface lo inet loopback

auto eth0
allow-bond0 eth0
iface eth0 inet manual
    bond-master bond0
    bond-primary eth0 eth1

auto eth1
allow-bond0 eth1
iface eth1 inet manual
    bond-master bond0
    bond-primary eth0 eth1

auto bond0
iface bond0 inet dhcp
    bond-slaves none
    bond-mode 1
#    bond-arp-interval 250
#    bond-arp-ip-target 192.168.2.1
#    bond-arp-validate 3

測定方法iperf

# tc qdisc add dev bond0 root handle 1: htb default 12
# tc class add dev bond0 parent 1: classid 1:12 htb rate 1mbit
# iperf -c 192.168.2.1
------------------------------------------------------------
Client connecting to 192.168.2.1, TCP port 5001
TCP window size: 23.5 KByte (default)
------------------------------------------------------------
[  3] local 192.168.2.9 port 49055 connected with 192.168.2.1 port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0-13.3 sec   768 KBytes   475 Kbits/sec

そして、iperfサーバーは異なる帯域幅を計算します。

[  4] local 192.168.2.1 port 5001 connected with 192.168.2.9 port 49055
[  4]  0.0-14.1 sec   768 KBytes   446 Kbits/sec

eth1バインディングから(手動インターフェイス)を削除しても結果は変わりません。

結論として

交通制御結合されたインターフェイスでは機能しないか、少なくとも期待どおりに機能しません。もう少し調べてみましょう。

回避策として、以下を追加できます。キューの規律ボンドに属するインターフェイスに直接接続します。

ベストアンサー1

tcがどのように機能するかわからない場合でも、tcを監視してパケットフローを確認できますか?私のスクリプトを使用してtcを監視することができ、高い権限を持つ端末でそれを実行する必要があります。 wlan0 を別のインターフェースに変更することができ、grep と awk も必要です。

      #!/bin/sh
      INTERVAL=15
      while sleep $INTERVAL
      do
             /usr/sbin/tc -s -d class show dev wlan0

             uptime
             more /proc/meminfo | grep MemFree | grep -v grep
             echo cache-name num-active-objs total-objs obj-size
             SKBUFF=`more /proc/slabinfo | grep skbuff | grep -v grep | awk 
             '{print $2} {print $3} {print $4}'`

             echo skbuff_head_cache: $SKBUFF
      done

おすすめ記事