我如何取得 Ubuntu 中 TCP 連線建立時間、任何 TCP 連線的重試時間以及服務品質參數的值。
答案1
嘗試顯示目前用於 TCP 通訊的值:
sudo sysctl -ae | fgrep -i "net.ipv4.tcp"
本手冊頁中記錄了一些變數:
man 7 tcp
快速開始:
man 7 tcp | awk '/proc interfaces/,/Socket options/ {print prev; prev=$0}'
服務品質參數,可以透過以下方式顯示:
netstat -s
/sbin/ifconfig
----
tcp_retries1 (integer; default: 3; since Linux 2.2)
The number of times TCP will attempt to retransmit a packet on an established
connection normally, without the extra effort of getting the network layers
involved. Once we exceed this number of retransmits, we first have the network
layer update the route if possible before each new retransmit. The default is
the RFC specified minimum of 3.
tcp_retries2 (integer; default: 15; since Linux 2.2)
The maximum number of times a TCP packet is retransmitted in established
state before giving up. The default value is 15, which corresponds to a duration
of approximately between 13 to 30 minutes, depending on the retransmission
timeout. The RFC 1122 specified minimum limit of 100 seconds is typically deemed
too short.
如果考慮預設值 tcp_retries1=3 和 tcp_retries2=15:
- 如果傳輸資料包失敗,將嘗試 3 (tcp_retries1) 次重傳,無需額外努力。
- 3次嘗試後,網路層參與更新路由
- 最多執行 15 次嘗試 (tcp_retries2),然後停止。