如何在ubuntu 14中获取TCP连接建立时间、重试时间的值

如何在ubuntu 14中获取TCP连接建立时间、重试时间的值

如何获取 TCP 连接建立时间的值、任何 TCP 连接的重试时间以及 Ubuntu 中的服务质量参数。

答案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),然后停止。

相关内容