trickleコマンドで特定のコマンドのネットワーク帯域を絞る

ストリーミングビデオを見ているときに他の通信を行うとビデオの画質が止まってしまいストレスです.ローカルにダウンロード出来るものはダウンロードしてから再生することでストレスなく視聴可能ですがそれができないものやライブだとできません.
アプリケーションによっては帯域を絞るオプションがありますがそれがないものは不便.今回 trickle というツールを使って特定のプログラムの帯域を絞ってみました.

今回Raspberry Pi OS bookworm armhf環境でパッケージから導入しました.

$ sudo apt install trickle
$ trickle -h
Usage: trickle [-hvVs] [-d <rate>] [-u <rate>] [-w <length>] [-t <seconds>]
               [-l <length>] [-n <path>] command ...
        -h           Help (this)
        -v           Increase verbosity level
        -V           Print trickle version
        -s           Run trickle in standalone mode independent of trickled
        -d <rate>    Set maximum cumulative download rate to <rate> KB/s
        -u <rate>    Set maximum cumulative upload rate to <rate> KB/s
        -w <length>  Set window length to <length> KB
        -t <seconds> Set default smoothing time to <seconds> s
        -l <length>  Set default smoothing length to <length> KB
        -n <path>    Use trickled socket name <path>
        -L <ms>      Set latency to <ms> milliseconds
        -P <path>    Preload the specified .so instead of the default one

wgetには帯域を絞るオプションがあります( --limit-rate )がお手軽なのでまずはこれで試します.
ここでは -s でデーモンを使わずアドホックに利用します.
-d 30 とダウンロードを 30KB/s に制限したのが効いているようでそれに近い速度になっています.

$ trickle -s -d 30 wget https://mirrors.edge.kernel.org/qubes/iso/Qubes-R4.2.3-x86_64.iso -O /dev/null
   :
/dev/null               0%[                       ]   2.63M  31.3KB/s    eta 2d 9h

次に帯域制限がなさそうなRaspberryPiのKernelを新しくするコマンドで試します.はじめsudoコマンドの前にtrickleを置くと効きませんでした.sudoの後ろにtrickleを置くことで帯域制限できました.でも今回は接続が切れてしまいました.程々にしないと駄目みたいですね.もしくはcontinueやretryを使うよう書き換える.

$ sudo trickle -s -d 30 rpi-update
   :
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
 15  144M   15 22.9M    0     0  28070      0  1:29:44  0:14:17  1:15:27 30009
curl: (56) Recv failure: Connection reset by peer

アプリケーションごとの帯域制限のオプションは覚えきれないし毎回オプションを調べるのは面倒.でもtrickleだけなら覚えられそうです.

環境
$ dpkg-query -W trickle wget curl
curl    8.5.0-2~bpo12+1
trickle 1.07-12
wget    1.21.3-1+b1
$ lsb_release -dr
No LSB modules are available.
Description:    Raspbian GNU/Linux 12 (bookworm)
Release:        12
$ arch
armv7l
$ grep ^Model /proc/cpuinfo
Model           : Raspberry Pi 3 Model B Rev 1.2

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

To respond on your own website, enter the URL of your response which should contain a link to this post's permalink URL. Your response will then appear (possibly after moderation) on this page. Want to update or remove your response? Update or delete your post and re-enter your post's URL again. (Find out more about Webmentions.)