ssh
や telnet
など) や小さなブロックのデータだけを取り扱うサービスに関連するパケットに高い優先度を付けることも可能です。
tc
コマンド (iproute パッケージに含まれます) を使って設定します。tc
コマンドはインターフェースがかなり複雑なので、高レベルツールを使うことを推奨します。
wondershaper
(同名のパッケージに含まれます) の主目的はネットワーク負荷とは無関係に待ち時間を最小化することです。全トラフィックをある値に制限することにより、これは実現されます。この値には帯域を飽和させるよりほんの少しだけ小さな値を設定します。
wondershaper interface download_rate upload_rate
を実行することでトラフィックが制限されます。ここで interface はたとえば eth0
または ppp0
などのインターフェース名で、download_rate および upload_rate はキロビット毎秒単位の値です。特定のインターフェースで実施されているトラフィック制限を無効化するには wondershaper remove interface
コマンドを使います。
wondershaper
をインターフェースが設定された直後に呼び出すのが最良です。これを行うには、/etc/network/interfaces
ファイルに up
と down
指示文を追加して、それぞれインターフェースが開始された後と停止される前に実行するコマンドを宣言します。以下にその例を示します。
例 10.9 /etc/network/interfaces
ファイルの修正
iface eth0 inet dhcp up /sbin/wondershaper eth0 500 100 down /sbin/wondershaper remove eth0
/etc/ppp/ip-up.d/
内に wondershaper
を呼び出すスクリプトを作成することで、接続が開始された後の可能な限り早い時期にトラフィック制御を行うように設定できます。
pfifo_fast
queue scheduler, which provides a few interesting features by itself. The priority of each processed IP packet is based on the DSCP field (Differentiated of Services Code Point) of this packet; modifying this 6-bit field is enough to take advantage of the scheduling features. Refer to https://en.wikipedia.org/wiki/Differentiated_services#Class_Selector for more information.
nft add table ip mangle nft add rule ip mangle PREROUTING tcp sport 22 counter ip dscp set 0x04 nft add rule ip mangle PREROUTING tcp dport 22 counter ip dscp set 0x04