Outils pour utilisateurs

Outils du site


tech:reseau_linux_pile_tcp_ip_rto_min_scripts

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Prochaine révision
Révision précédente
tech:reseau_linux_pile_tcp_ip_rto_min_scripts [2025/03/24 15:06] – créée - modification externe 127.0.0.1tech:reseau_linux_pile_tcp_ip_rto_min_scripts [2026/06/07 19:12] (Version actuelle) – modification externe 127.0.0.1
Ligne 1: Ligne 1:
 +<!DOCTYPE markdown>
 +{{tag>Brouillon Réseau Linux Kernel TCP RedHat SystemD Service Script Bash CA}}
 +
 +# Réseau Linux pile TCP/IP rto_min scripts
 +
 +Voir :
 +* [[Réseau Linux pile TCP/IP - TCP retransmission timeout RTO]]
 +* [[reseau_linux_pile_tcp_ip]]
 +
 +
 +Le hack ci-dessous ne semble plus utile pour RedHat 9.
 +
 +“NetworkManager now supports advmss, rto_min, and quickack route attributes”
 +https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/9/html-single/9.1_release_notes/index
 +
 +
 +`network_tcp_tune_change_mto_min.sh`
 +~~~bash
 +#! /bin/bash
 +
 +set -euo pipefail
 +
 +declare -i ALREADY_SET
 +
 +# check if file exist
 +file_exist() {
 + [ -e "$1" ]
 +}
 +
 +LINE="$(ip route show default | grep ^default)"
 +
 +if echo "$LINE" | grep -q -e rto_min; then
 + ALREADY_SET=1
 +else
 + ALREADY_SET=0
 +fi
 +
 +usage() {
 + cat <<EOF
 +SysV init script.
 +Args are : status, stop, start, restart
 +
 +EOF
 +}
 +
 +status() {
 + if [ $ALREADY_SET -eq 1 ]; then
 + echo Started
 + else
 + echo Stopped
 + fi
 + ip route show default | grep -e '^default'
 + echo
 + echo "/proc/sys/net/ipv4/tcp_thin_dupack"
 + file_exist /proc/sys/net/ipv4/tcp_thin_dupack && cat /proc/sys/net/ipv4/tcp_thin_dupack
 + echo
 + echo "/proc/sys/net/ipv4/tcp_thin_linear_timeouts"
 + cat /proc/sys/net/ipv4/tcp_thin_linear_timeouts
 +}
 +
 +start() {
 + echo "Starting..."
 + file_exist /proc/sys/net/ipv4/tcp_thin_dupack && echo 1 > /proc/sys/net/ipv4/tcp_thin_dupack
 + echo 1 > /proc/sys/net/ipv4/tcp_thin_linear_timeouts
 + if [ $ALREADY_SET -eq 0 ]; then
 + NEW_LINE="$LINE rto_min 8ms"
 + echo "ip route change $NEW_LINE"
 + echo "$NEW_LINE" | xargs ip route change 
 + else
 + echo "Already started"
 + fi
 +}
 +
 +stop() {
 + echo "Stopping..."
 + if [ $ALREADY_SET -eq 1 ]; then
 + NEW_LINE="$(echo "$LINE" | sed -e 's/ lock / /g' -e 's/rto_min [[:alnum:]]\+//')"
 + echo "ip route change $NEW_LINE"
 + echo "$NEW_LINE" | xargs ip route change 
 + else
 + echo "Already stopped"
 + fi
 +}
 +
 +case "${1:-}" in
 +start)
 + start
 + ;;
 +restart)
 + start
 + ;;
 +stop)
 + stop
 + ;;
 +status)
 + status
 + ;;
 +-h | --help)
 + usage
 + ;;
 +*)
 + usage
 + exit 1
 + ;;
 +esac
 +
 +echo .
 +~~~
 +
 +
 +`network_tcp_tune_change_mto_min.service`
 +~~~ini
 +[Unit]
 +Description=Network setting on default gateway. Change rto_min to 8ms. Don not alwaays wait 200ms to resend packet
 +Wants=network.target network-online.target
 +After=network.target network-online.target
 +
 +[Service]
 +Type=oneshot
 +# ExecStartPre=/usr/bin/sleep 5
 +ExecStart=/bin/bash /root/scripts/network_tcp_tune_change_mto_min.sh start
 +ExecStop=/bin/bash /root/scripts/network_tcp_tune_change_mto_min.sh stop
 +RemainAfterExit=yes
 +
 +[Install]
 +WantedBy=multi-user.target
 +~~~
 +
 +
 +## Mesures
 +
 +### rsync
 +
 +~~~
 +truncate -s 1G big_file.img
 +~~~
 +
 +
 +#### Avant
 +
 +~~~
 +$ rsync --compress-level=0 --progress --human-readable -v --log-file=rsync.log big_file.img target:big_file.img | grep MB
 +          1.07G 100%   76.63MB/   0:00:13 (xfr#1, to-chk=0/1)
 +          1.07G 100%   64.51MB/   0:00:15 (xfr#1, to-chk=0/1)
 +          1.07G 100%   69.04MB/   0:00:14 (xfr#1, to-chk=0/1)
 +          1.07G 100%   45.00MB/   0:00:22 (xfr#1, to-chk=0/1)
 +          1.07G 100%   44.32MB/   0:00:23 (xfr#1, to-chk=0/1)
 +          1.07G 100%  129.67MB/   0:00:07 (xfr#1, to-chk=0/1)
 +          1.07G 100%   44.98MB/   0:00:22 (xfr#1, to-chk=0/1)
 +~~~
 +
 +
 +#### Après
 +
 +~~~
 +$ rsync --compress-level=0 --progress --human-readable -v --log-file=rsync.log big_file.img target:big_file.img | grep MB
 +          1.07G 100%  110.12MB/   0:00:09 (xfr#1, to-chk=0/1)
 +          1.07G 100%  137.35MB/   0:00:07 (xfr#1, to-chk=0/1)
 +          1.07G 100%   98.45MB/   0:00:10 (xfr#1, to-chk=0/1)
 +          1.07G 100%  129.62MB/   0:00:07 (xfr#1, to-chk=0/1)
 +          1.07G 100%  110.69MB/   0:00:09 (xfr#1, to-chk=0/1)
 +          1.07G 100%  152.42MB/   0:00:06 (xfr#1, to-chk=0/1)
 +          1.07G 100%  110.20MB/   0:00:09 (xfr#1, to-chk=0/1)
 +          1.07G 100%  135.79MB/   0:00:07 (xfr#1, to-chk=0/1)
 +~~~
 +
 +
 +### Iperf
 +
 +Serveur
 +~~~bash
 +iperf3 -s -p 8080
 +~~~
 +
 +
 +#### Avant
 +
 +
 +
 +~~~
 +$ iperf3 -i 1 -P 1 -t 600 -p 8080 -c 192.168.10.10
 +Connecting to host 192.168.10.10, port 8080
 +[  4] local 192.168.10.11 port 43100 connected to 192.168.10.10 port 8080
 +[ ID] Interval           Transfer     Bandwidth       Retr  Cwnd
 +[  4]   0.00-1.00   sec  69.0 MBytes   579 Mbits/sec   19    836 KBytes
 +[  4]   1.00-2.00   sec  23.8 MBytes   199 Mbits/sec  633    652 KBytes
 +[  4]   2.00-3.00   sec  68.8 MBytes   577 Mbits/sec  894    724 KBytes
 +[  4]   3.00-4.00   sec  53.8 MBytes   451 Mbits/sec  1251    731 KBytes
 +[  4]   4.00-5.00   sec  72.5 MBytes   608 Mbits/sec  455    680 KBytes
 +[  4]   5.00-6.00   sec   158 MBytes  1.32 Gbits/sec   95    921 KBytes
 +[  4]   6.00-7.00   sec   124 MBytes  1.04 Gbits/sec   25   1.07 MBytes
 +[  4]   7.00-8.00   sec  57.5 MBytes   483 Mbits/sec  1063   1.27 MBytes
 +[  4]   8.00-9.00   sec  60.0 MBytes   503 Mbits/sec  761   1.24 MBytes
 +[  4]   9.00-10.00  sec  63.8 MBytes   535 Mbits/sec  2013   1.18 MBytes
 +[  4]  10.00-11.00  sec   124 MBytes  1.04 Gbits/sec   33   2.02 MBytes
 +~~~
 +
 +
 +
 +#### Après
 +
 +~~~
 +$ iperf3 -i 1 -P 1 -t 600 -p 8080 -c 192.168.10.10
 +Connecting to host 192.168.10.10, port 8080
 +[  4] local 192.168.10.11 port 43348 connected to 192.168.10.10 port 8080
 +[ ID] Interval           Transfer     Bandwidth       Retr  Cwnd
 +[  4]   0.00-1.00   sec   142 MBytes  1.19 Gbits/sec  612   1.11 MBytes
 +[  4]   1.00-2.00   sec   232 MBytes  1.95 Gbits/sec   26   1.51 MBytes
 +[  4]   2.00-3.00   sec   220 MBytes  1.85 Gbits/sec  2551   1.29 MBytes
 +[  4]   3.00-4.00   sec   139 MBytes  1.16 Gbits/sec  1769    459 KBytes
 +[  4]   4.00-5.00   sec   130 MBytes  1.09 Gbits/sec  1301    451 KBytes
 +[  4]   5.00-6.00   sec   125 MBytes  1.05 Gbits/sec  1541    396 KBytes
 +[  4]   6.00-7.00   sec   126 MBytes  1.06 Gbits/sec  751    448 KBytes
 +[  4]   7.00-8.00   sec   118 MBytes   986 Mbits/sec  1071    535 KBytes
 +[  4]   8.00-9.00   sec   124 MBytes  1.04 Gbits/sec  1162    518 KBytes
 +~~~
 +
 +
 +### Netcat
 +
 +Serveur
 +~~~bash
 +nc -p 8080 -lk > /dev/null
 +~~~
 +
 +
 +#### Avant
 +
 +~~~
 +$ while sleep 0.2 ; do echo -n -e "$(date --rfc-3339=seconds)\t" ; (dd if=/dev/zero bs=100000k count=1 | nc 192.168.10.10 8080) 2>&1 | awk '/copied/ { print $8 }' ; done
 +2024-01-27 11:10:31+01:00       149
 +2024-01-27 11:10:32+01:00       57.1
 +2024-01-27 11:10:34+01:00       25.6
 +2024-01-27 11:10:38+01:00       64.5
 +2024-01-27 11:10:40+01:00       62.8
 +2024-01-27 11:10:42+01:00       115
 +2024-01-27 11:10:43+01:00       215
 +2024-01-27 11:10:44+01:00       134
 +2024-01-27 11:10:45+01:00       89.8
 +2024-01-27 11:10:46+01:00       30.8
 +2024-01-27 11:10:50+01:00       58.7
 +~~~
 +
 +
 +#### Après
 +
 +~~~
 +$ while sleep 0.2 ; do echo -n -e "$(date --rfc-3339=seconds)\t" ; (dd if=/dev/zero bs=100000k count=1 | nc 192.168.10.10 8080) 2>&1 | awk '/copied/ { print $8 }' ; done
 +2024-01-27 11:11:21+01:00       164
 +2024-01-27 11:11:21+01:00       164
 +2024-01-27 11:11:22+01:00       165
 +2024-01-27 11:11:23+01:00       217
 +2024-01-27 11:11:24+01:00       229
 +2024-01-27 11:11:24+01:00       151
 +2024-01-27 11:11:25+01:00       121
 +2024-01-27 11:11:26+01:00       141
 +2024-01-27 11:11:27+01:00       118
 +2024-01-27 11:11:28+01:00       123
 +~~~
 +
 +
 +## Autres
 +
 +### quickack
 +
 +~~~bash
 +ip route change default via 10.0.0.1 quickack 1
 +~~~
 +
  

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki