如何解釋 netstat -o / netstat --timers 的輸出

如何解釋 netstat -o / netstat --timers 的輸出

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)

答案1

第一個數字顯然是倒數計時器。根據狀態類型,一旦計時器逾時,它將重試並發送另一個 FIN 或任何需要的資料包以重試。所以第二個數字記錄重試次數。請注意,計時器會增加,因為 TCP 具有退避計時器,以防出現流量狀況。退避計時器可以避免過於頻繁的重試。每次失敗都會導致越來越大的退避。退避可以是指數成長或線性成長,取決於 TCP 堆疊。我還沒搞清楚這個3數字是做什麼用的。我的顯示器上始終為零。

答案2

計時器列有兩個欄位(來自上面的 o/p):

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

可以1st field有以下值:
keepalive- 當套接字的保活定時器為 ON 時
on- 當套接字的重傳定時器為 ON 時
off- 以上皆不為 ON

2nd field有三個子字段:

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

a=計時器值(a=保活計時器,當第一個字段=“keepalive”時;a=重傳計時器,當第一個字段=“on”時)
b=已發生的重傳次數
c=已發送的保活探測次數

例如,我在客戶端和伺服器之間打開了兩個套接字(不是環回)。保活設定為:

KEEPALIVE_IDLETIME   30
KEEPALIVE_NUMPROBES   4
KEEPALIVE_INTVL      10

我關閉了客戶端計算機,因此在伺服器端我運行了 netstat,輸出為:

連接埠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)

您可以在上面看到伺服器發送了四個保活探針,每個探針在10 秒後發送,並且由於沒有收到任何回應,因此發送的探針數量增加,在4 個之後,它與客戶端斷開連線。

埠2:

對於第二個連接,套接字是相同的,除了我在伺服器端的應用程式試圖在客戶端關閉後和保持活動過期之前發送一些訊息:

 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)

正如您所看到的,在這種情況下情況有些不同。當客戶端發生故障時,我的伺服器開始發送保活訊息,但當它仍在發送這些保活訊息時,我的伺服器嘗試向客戶端發送訊息。由於客戶端已宕機,伺服器無法從客戶端獲得任何ACK,因此TCP 重傳開始,伺服器嘗試再次發送數據,每次重傳計時器(第1 個欄位)時,增加重傳計數(第2個欄位)。

希望這netstat --timer能很好地解釋這個選項。

答案3

第一個字段:timewait/keepalive

從最後一次資料傳輸到發送下一個 TCP keepalive 探測的時間(以秒為單位)。

預設情況下,該時間從 7200 秒開始,並在每次發送更多資料時再次重設。如果該值較低,例如。 4000秒,這意味著一些保活連接長時間掛起或不執行任何操作。

與內部代理或其他內部程序的連線可能會掛起更長時間,但基於 Web 的連線不應發生這種情況。

相關內容