如何解释netstat -o / netstat --timers的输出


16

netstat -o 包括输出中的一些计时器信息,但我还没有找到输出的解释 Timer 任何地方的列
任何人都能解释一下或指出解释吗?

这就是netstat -o的输出看起来像(在Ubuntu 8.04上)。

Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       Timer
tcp        0      0 192.168.22.1:443        111.111.11.210:5804     ESTABLISHEDkeepalive (6176.47/0/0)
tcp        0      0 192.168.22.1:443        192.168.22.253:48379    TIME_WAIT  timewait (36.57/0/0)
tcp        0    924 192.168.22.1:47763      10.9.169.60:443         ESTABLISHEDon (0.34/0/0)
tcp        0      0 192.168.22.1:443        192.168.111.99:4059     ESTABLISHEDkeepalive (6963.60/0/0)
tcp        0      0 192.168.22.1:443        192.168.111.74:1729     ESTABLISHEDkeepalive (1393.60/0/0)
tcp        0      0 192.168.56.1:42204      10.9.169.60:443         ESTABLISHEDoff (0.00/0/0)
tcp        0      0 192.168.56.1:42207      10.9.169.60:443         ESTABLISHEDoff (0.00/0/0)
tcp        0    940 192.168.22.1:42186      10.9.169.60:443         ESTABLISHEDon (0.28/0/0)
tcp        0      0 192.168.22.1:443        192.168.22.253:48367    TIME_WAIT  timewait (31.57/0/0)
tcp        0      0 192.168.22.1:42234      10.9.169.60:443         ESTABLISHEDoff (0.00/0/0)
tcp        0      0 192.168.22.1:42209      10.9.169.60:443         ESTABLISHEDoff (0.00/0/0)

Answers:


6

第一个数字显然是倒数计时器。根据状态类型,一旦计时器超时,它将重试并发送另一个FIN或任何需要的数据包再试一次。所以第二个数字跟踪重试次数。请注意,计时器会增加,因为TCP具有退避计时器,以防出现流量情况。退避定时器避免了过度频繁的重试。每次失败都会导致越来越大的退避。退避可以是指数增长或线性,取决于TCP堆栈。我还没弄明白这个数字是为了什么。我的显示器始终为零。


27

计时器列有两个字段(来自上面的o / p):

keepalive (6176.47/0/0)  
<1st field> <2nd field>

1st field 可以有价值:
keepalive - 当套接字的keepalive定时器为ON时
on - 当套接字的重传定时器为ON时
off - 以上都不是ON

2nd field 有三个子字段:

(6176.47/0/0) -> (a/b/c)

a =定时器值(a = keepalive定时器,当1st field =“keepalive”时; a =重传定时器,当1st field =“on”时)
b =已发生的重新传输次数
c =已发送的keepalive探测器的数量

例如,我在客户端和客户端之间打开了两个插槽。服务器(不是环回)。 keepalive设置为:

KEEPALIVE_IDLETIME   30
KEEPALIVE_NUMPROBES   4
KEEPALIVE_INTVL      10

我关闭了客户机,所以在服务器端我运行了一个netstat&amp;输出是:

端口1:

netstat -c --timer | grep "192.0.0.1:43245             192.0.68.1:49742"

tcp        0      0 192.0.0.1:43245             192.0.68.1:49742            ESTABLISHED keepalive (1.92/0/0)
tcp        0      0 192.0.0.1:43245             192.0.68.1:49742            ESTABLISHED keepalive (0.71/0/0)
tcp        0      0 192.0.0.1:43245             192.0.68.1:49742            ESTABLISHED keepalive (9.46/0/1)
tcp        0      0 192.0.0.1:43245             192.0.68.1:49742            ESTABLISHED keepalive (8.30/0/1)
tcp        0      0 192.0.0.1:43245             192.0.68.1:49742            ESTABLISHED keepalive (7.14/0/1)
tcp        0      0 192.0.0.1:43245             192.0.68.1:49742            ESTABLISHED keepalive (5.98/0/1)
tcp        0      0 192.0.0.1:43245             192.0.68.1:49742            ESTABLISHED keepalive (4.82/0/1)
tcp        0      0 192.0.0.1:43245             192.0.68.1:49742            ESTABLISHED keepalive (3.66/0/1)
tcp        0      0 192.0.0.1:43245             192.0.68.1:49742            ESTABLISHED keepalive (2.50/0/1)
tcp        0      0 192.0.0.1:43245             192.0.68.1:49742            ESTABLISHED keepalive (1.33/0/1)
tcp        0      0 192.0.0.1:43245             192.0.68.1:49742            ESTABLISHED keepalive (0.17/0/1)
tcp        0      0 192.0.0.1:43245             192.0.68.1:49742            ESTABLISHED keepalive (9.01/0/2)
tcp        0      0 192.0.0.1:43245             192.0.68.1:49742            ESTABLISHED keepalive (7.75/0/2)
tcp        0      0 192.0.0.1:43245             192.0.68.1:49742            ESTABLISHED keepalive (6.47/0/2)
tcp        0      0 192.0.0.1:43245             192.0.68.1:49742            ESTABLISHED keepalive (5.29/0/2)
tcp        0      0 192.0.0.1:43245             192.0.68.1:49742            ESTABLISHED keepalive (4.08/0/2)
tcp        0      0 192.0.0.1:43245             192.0.68.1:49742            ESTABLISHED keepalive (2.89/0/2)
tcp        0      0 192.0.0.1:43245             192.0.68.1:49742            ESTABLISHED keepalive (1.73/0/2)
tcp        0      0 192.0.0.1:43245             192.0.68.1:49742            ESTABLISHED keepalive (0.54/0/2)
tcp        0      0 192.0.0.1:43245             192.0.68.1:49742            ESTABLISHED keepalive (9.38/0/3)
tcp        0      0 192.0.0.1:43245             192.0.68.1:49742            ESTABLISHED keepalive (8.23/0/3)
tcp        0      0 192.0.0.1:43245             192.0.68.1:49742            ESTABLISHED keepalive (7.08/0/3)
tcp        0      0 192.0.0.1:43245             192.0.68.1:49742            ESTABLISHED keepalive (5.93/0/3)                                                                                                                               
tcp        0      0 192.0.0.1:43245             192.0.68.1:49742            ESTABLISHED keepalive (4.76/0/3)
tcp        0      0 192.0.0.1:43245             192.0.68.1:49742            ESTABLISHED keepalive (3.62/0/3)
tcp        0      0 192.0.0.1:43245             192.0.68.1:49742            ESTABLISHED keepalive (2.48/0/3)
tcp        0      0 192.0.0.1:43245             192.0.68.1:49742            ESTABLISHED keepalive (1.32/0/3)
tcp        0      0 192.0.0.1:43245             192.0.68.1:49742            ESTABLISHED keepalive (0.13/0/3)
tcp        0      0 192.0.0.1:43245             192.0.68.1:49742            ESTABLISHED keepalive (8.98/0/4)
tcp        0      0 192.0.0.1:43245             192.0.68.1:49742            ESTABLISHED keepalive (7.78/0/4)
tcp        0      0 192.0.0.1:43245             192.0.68.1:49742            ESTABLISHED keepalive (6.62/0/4)
tcp        0      0 192.0.0.1:43245             192.0.68.1:49742            ESTABLISHED keepalive (5.45/0/4)
tcp        0      0 192.0.0.1:43245             192.0.68.1:49742            ESTABLISHED keepalive (4.29/0/4)
tcp        0      0 192.0.0.1:43245             192.0.68.1:49742            ESTABLISHED keepalive (3.14/0/4)
tcp        0      0 192.0.0.1:43245             192.0.68.1:49742            ESTABLISHED keepalive (1.99/0/4)
tcp        0      0 192.0.0.1:43245             192.0.68.1:49742            ESTABLISHED keepalive (0.85/0/4)

您可以看到上面的服务器发送了4个keepalive探测器,每个探测器在10秒后发现并且由于没有得到任何响应,探测器发送的数量会增加,而在4之后,它会断开与客户端的连接。

端口2:

对于第二个连接,套接字是相同的,除了,我在服务器端的应用程序试图在客户端关闭后发送一些消息&amp;在keepalive过期之前:

 netstat -c --timer | grep "192.0.0.1:36483             192.0.68.1:43881"

tcp        0      0 192.0.0.1:36483             192.0.68.1:43881            ESTABLISHED keepalive (8.18/0/1)
tcp        0      0 192.0.0.1:36483             192.0.68.1:43881            ESTABLISHED keepalive (7.00/0/1)
tcp        0      0 192.0.0.1:36483             192.0.68.1:43881            ESTABLISHED keepalive (5.86/0/1)
tcp        0      0 192.0.0.1:36483             192.0.68.1:43881            ESTABLISHED keepalive (4.71/0/1)
tcp        0      0 192.0.0.1:36483             192.0.68.1:43881            ESTABLISHED keepalive (3.55/0/1)
tcp        0      0 192.0.0.1:36483             192.0.68.1:43881            ESTABLISHED keepalive (2.40/0/1)                                                                                                                               
tcp        0      0 192.0.0.1:36483             192.0.68.1:43881            ESTABLISHED keepalive (1.21/0/1)
tcp        0      0 192.0.0.1:36483             192.0.68.1:43881            ESTABLISHED keepalive (0.05/0/1)
tcp        0      0 192.0.0.1:36483             192.0.68.1:43881            ESTABLISHED keepalive (8.91/0/2)
tcp        0      0 192.0.0.1:36483             192.0.68.1:43881            ESTABLISHED keepalive (7.75/0/2)
tcp        0      0 192.0.0.1:36483             192.0.68.1:43881            ESTABLISHED keepalive (6.56/0/2)
tcp        0      0 192.0.0.1:36483             192.0.68.1:43881            ESTABLISHED keepalive (5.39/0/2)
tcp        0      0 192.0.0.1:36483             192.0.68.1:43881            ESTABLISHED keepalive (4.14/0/2)
tcp        0    210 192.0.0.1:36483             192.0.68.1:43881            ESTABLISHED on (0.21/2/2)  // <---- retransmission timer kicks in
tcp        0    210 192.0.0.1:36483             192.0.68.1:43881            ESTABLISHED on (0.68/3/2)
tcp        0    210 192.0.0.1:36483             192.0.68.1:43881            ESTABLISHED on (2.74/4/2)
tcp        0    210 192.0.0.1:36483             192.0.68.1:43881            ESTABLISHED on (1.59/4/2)
tcp        0    210 192.0.0.1:36483             192.0.68.1:43881            ESTABLISHED on (0.43/4/2)
tcp        0    210 192.0.0.1:36483             192.0.68.1:43881            ESTABLISHED on (2.28/5/2)
tcp        0    210 192.0.0.1:36483             192.0.68.1:43881            ESTABLISHED on (1.11/5/2)
tcp        0    210 192.0.0.1:36483             192.0.68.1:43881            ESTABLISHED on (2.95/6/2)

. . . . . 

tcp        0    210 192.0.0.1:36483             192.0.68.1:43881            ESTABLISHED on (0.65/249/2)
tcp        0    210 192.0.0.1:36483             192.0.68.1:43881            ESTABLISHED on (2.58/250/2)
tcp        0    210 192.0.0.1:36483             192.0.68.1:43881            ESTABLISHED on (1.48/250/2)
tcp        0    210 192.0.0.1:36483             192.0.68.1:43881            ESTABLISHED on (0.36/250/2)
tcp        0    210 192.0.0.1:36483             192.0.68.1:43881            ESTABLISHED on (2.26/251/2)
tcp        0    210 192.0.0.1:36483             192.0.68.1:43881            ESTABLISHED on (1.15/251/2)
tcp        0    210 192.0.0.1:36483             192.0.68.1:43881            ESTABLISHED on (3.01/252/2)
tcp        0    210 192.0.0.1:36483             192.0.68.1:43881            ESTABLISHED on (1.92/252/2)
tcp        0    210 192.0.0.1:36483             192.0.68.1:43881            ESTABLISHED on (0.84/252/2)
tcp        0    210 192.0.0.1:36483             192.0.68.1:43881            ESTABLISHED on (2.72/253/2)
tcp        0    210 192.0.0.1:36483             192.0.68.1:43881            ESTABLISHED on (1.64/253/2)
tcp        0    210 192.0.0.1:36483             192.0.68.1:43881            ESTABLISHED on (0.55/253/2)
tcp        0    210 192.0.0.1:36483             192.0.68.1:43881            ESTABLISHED on (2.47/254/2)
tcp        0    210 192.0.0.1:36483             192.0.68.1:43881            ESTABLISHED on (1.39/254/2)                                                                                                                                    
tcp        0    210 192.0.0.1:36483             192.0.68.1:43881            ESTABLISHED on (0.31/254/2)
tcp        0    210 192.0.0.1:36483             192.0.68.1:43881            ESTABLISHED on (2.19/255/2)
tcp        0    210 192.0.0.1:36483             192.0.68.1:43881            ESTABLISHED on (1.12/255/2)

正如您所看到的,在这种情况下,事情会有所不同。当客户端出现故障时,我的服务器开始发送keepalive消息,但是当它仍在发送这些keepalive时,我的服务器试图向客户端发送消息。由于客户端已关闭,服务器无法从客户端获取任何ACK,因此TCP重新启动并且服务器再次尝试发送数据,每次在重新传输计时器(第1个字段)时递增重新传输计数(第1个字段)字段)已过期。

希望这能解释一下 netstat --timer 选择好。


你好。如果你打开了 连接,为什么netstat显示这么多条目?
Marco Marsala

1
'-c'标志使其每秒连续打印此信息。
brokenfoot

0

第一场: timewait/keepalive

从最后一个数据传输到下一个TCP keepalive探测器的时间(以秒为单位)。

默认情况下,此操作从7200开始,每次发送更多数据时再次重置。如果该值较低,例如。 4000秒,这意味着一些保持活动的连接在很长一段时间内挂起或什么都不做。

与内部代理或其他内部进程的连接可能会挂起更长时间,但这不应该发生在基于Web的连接上。


2
为了避免在Linux上出现混淆:计时器可见 netstat -o 但它永远不会重置,它会计数到0,然后检查数据是否已发送。如果没有它会发送一个数据包,否则如果将计算剩余时间并重新开始。这样它就不需要更改正在运行的计时器。
eckes
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.