Skip to content

umaumax/netlim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

netlim

This is a bandwidth limiting tool for TCP network communication.

how to install

cargo install --git https://github.com/umaumax/netlim

how to check

wget

# mac
mkfile -v 100m 100m
# linux
fallocate -l 100m 100m

# server
python3 -m http.server 22222

# bandwidth limiter
cargo run -- --src=0.0.0.0:11111 --dst=localhost:22222

# client
wget localhost:11111/100m

iperf3

# server
iperf3 -s

# client
netlim --src 0.0.0.0:5201 --dst $server_ip_addr:5201 --out 1MB --in 1MB

iperf3 -c localhost -p 5201

alternative command

ssh -g -N -L 5201:localhost:5201 $server_ip_addr -o ProxyCommand='pv -cN out -L 1024K | nc %h %p | pv -cN in -L 1024K'

how to use

# with debug logs
cargo run -- --src=0.0.0.0:11111 --dst=localhost:22222 --verbose

help

netlim 0.1.0

USAGE:
    netlim [FLAGS] [OPTIONS]

FLAGS:
    -h, --help       Prints help information
        --unshare    unshare bandwidth limit flag
    -V, --version    Prints version information
        --verbose    verbose flag

OPTIONS:
        --dst <dst-socket>                  dst socket [default: localhost:22222]
        --in <inbound-bandwidth-limit>      inbound bandwidth limit [Byte] [default: 1MB]
        --out <outbound-bandwidth-limit>    outbound bandwidth limit [Byte] [default: 1MB]
        --src <src-socket>                  src socket [default: 0.0.0.0:11111]

figure

flowchart LR
    client -- "send to src socket (outbound)" --> netlim -- "response (inbound)" --> client
    server -- "response (inbound)" --> netlim -- "send to dst socket (outbound)" --> server
Loading

NOTE

  • tikv/async-speed-limit: Asynchronously speed-limiting multiple byte streams
    • これは非同期ランタイムのtokioではなく、futures向けであるが、futures-utilのcompatモジュールを利用すると利用できるらしいが、うまくいかない
  • inboundやoutboundのデータ量に応じて、それぞれ指定の時間までsleepする仕組みで帯域制限を行うことで実現
  • デフォルトオプションでは各コネクションで帯域制限を共有する
    • ただし、コネクション毎のスケジューリングはtokio依存である
    • ワークスティーリングスケジューラであるらしいが、実際に実行すると、特定のコネクションのみがずっと実行されるケースが確認された
    • コネクション毎に独立して帯域制限するオプションあり(--unshare)

About

No description or website provided.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages