idofront / TrafficPlayer

TrafficPlayer is a Linux application to recreate network traffic. It replays pcap files to simulate conditions. Users can specify a NIC for better control. TrafficPlayer allows speed adjustment, offering flexibility in testing behaviors. It is ideal for evaluating network performance and reliability.
MIT License
1 stars 0 forks source link

throughput モードの精度が悪い #7

Closed idofront closed 4 days ago

idofront commented 1 week ago

throughput モードで高速化させると期待する速度がでない.

「thread_sleep の計算は正しいがオーバヘッドでずれているのか」「そもそも計算が間違っているのか」不明だが,精度が悪すぎて使い物にならない.

せめて 100Mbps でそれなりの精度を出してくれたら良かったが 40Mbps 程度しかでない.

$ sudo ./build/TrafficPlayer --log-level info -i lo -p ~/Downloads/dns.cap --report-interval 1 --repeat 0 throughput 100 | grep Throughput
[2024-11-25 00:23:23.357] [info] Throughput: 100 Mbps
[2024-11-25 00:23:23.358] [info] Mode: Throughput
[2024-11-25 00:23:24.400] [info] [Report] Total: 4882836 bytes, Throughput: 38714.260 Kbps, 49621.407 packets/s
[2024-11-25 00:23:25.400] [info] [Report] Total: 5042722 bytes, Throughput: 40382.158 Kbps, 51755.756 packets/s
[2024-11-25 00:23:26.398] [info] [Report] Total: 4854731 bytes, Throughput: 38954.712 Kbps, 49928.786 packets/s
[2024-11-25 00:23:27.399] [info] [Report] Total: 4919999 bytes, Throughput: 39359.992 Kbps, 50449.000 packets/s
[2024-11-25 00:23:28.399] [info] [Report] Total: 4843840 bytes, Throughput: 38750.720 Kbps, 49667.000 packets/s

NIC の問題の可能性も否定できないが,ループバックで動作させて 100Mbps もでないとなるとプログラム側の問題を疑わざるを得ない.

idofront commented 1 week ago

アルゴリズムを SpeedScale にあわせて実装したが改善しなかった.
// 遅くなったがおそらくもともとの実装が間違っていた?

$ sudo ./build/TrafficPlayer --log-level info -i lo -p ~/Downloads/dns.cap --report-interval 1 --repeat 0 throughput 100 | grep Throughput
[2024-11-25 00:59:55.415] [info] Throughput: 100 Mbps
[2024-11-25 00:59:55.415] [info] Mode: Throughput
[2024-11-25 00:59:56.451] [info] [Report] Total: 3870638 bytes, Throughput: 30719.349 Kbps, 39373.016 packets/s
[2024-11-25 00:59:57.451] [info] [Report] Total: 3861804 bytes, Throughput: 30894.432 Kbps, 39598.000 packets/s
[2024-11-25 00:59:58.451] [info] [Report] Total: 3813474 bytes, Throughput: 30538.330 Kbps, 39141.141 packets/s

昔,各種 sleep 系の関数の精度を調べたさい数 msec 〜数十 usec 程度だった気がする.それを考えると,現状の sleep の使いかたではこれ以上の精度向上は望めない気がする.
// 確か 0 を指定すると途端に nsec くらいで応答がかえってきていたので,これ以上に早くなるのは wait の計算結果が 0 (もしくはマイナス) になるれコードがあるからだろう.

idofront commented 4 days ago

8 で対応

100Mbps 程度まで流せるようになった.

$ sudo ./build/TrafficPlayer --log-level info -i lo -p ~/Downloads/dns.cap --report-interval 1 --repeat 0 throughput 100 | grep Throughput
[2024-11-29 00:14:15.901] [info] Throughput: 100 Mbps
[2024-11-29 00:14:15.901] [info] Mode: Throughput
[2024-11-29 00:14:16.958] [info] [Report] Total: 12757106 bytes, Throughput: 99957.736 Kbps, 128115.573 packets/s
[2024-11-29 00:14:17.959] [info] [Report] Total: 12369360 bytes, Throughput: 99053.934 Kbps, 126959.960 packets/s
[2024-11-29 00:14:18.957] [info] [Report] Total: 12586680 bytes, Throughput: 100996.429 Kbps, 129445.336 packets/s
[2024-11-29 00:14:19.957] [info] [Report] Total: 12523779 bytes, Throughput: 100290.523 Kbps, 128545.546 packets/s
[2024-11-29 00:14:20.958] [info] [Report] Total: 12436443 bytes, Throughput: 99491.544 Kbps, 127517.000 packets/s
[2024-11-29 00:14:21.956] [info] [Report] Total: 12560082 bytes, Throughput: 100783.005 Kbps, 129174.524 packets/s

今後の課題は以下 2 点