GNU/Linux >> Belajar Linux >  >> Linux

Bagaimana menginterpretasikan output dari netstat -o / netstat --timers

Kolom pengatur waktu memiliki dua bidang (dari o/p Anda di atas):

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

1st field dapat memiliki nilai:
keepalive - saat timer keepalive ON untuk soket
on - saat timer transmisi ulang ON untuk soket
off - tidak satu pun di atas yang AKTIF

2nd field memiliki TIGA subbidang:

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

a =nilai timer (a=timer keepalive, saat field ke-1="keepalive"; a=timer transmisi ulang, saat field ke-1="on")
b =jumlah transmisi ulang yang telah terjadi
c =jumlah probe keepalive yang telah dikirim

Misalnya, saya membuka dua soket antara klien &server (bukan loopback). Pengaturan keepalive adalah:

KEEPALIVE_IDLETIME   30
KEEPALIVE_NUMPROBES   4
KEEPALIVE_INTVL      10

Dan saya mematikan mesin klien, jadi di sisi server saya menjalankan netstat &hasilnya adalah:

Port1:

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)

Anda dapat melihat di atas bahwa server mengirimkan EMPAT probe keepalive, masing-masing setelah 10 detik dan karena tidak mendapatkan respons apa pun, jumlah jumlah probe yang dikirim meningkat, dan setelah 4, ia terputus dari klien.

Pelabuhan 2:

Untuk koneksi ke-2, soketnya identik, kecuali, aplikasi saya di sisi server mencoba mengirim beberapa pesan setelah klien mati &sebelum keepalive kedaluwarsa:

 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)

Seperti yang Anda lihat, dalam hal ini sedikit berbeda. Ketika klien turun, server saya mulai mengirim pesan keepalive, tetapi saat masih mengirim keepalive tersebut, server saya mencoba mengirim pesan ke klien. Karena klien telah turun, server tidak bisa mendapatkan ACK dari klien, sehingga pengiriman ulang TCP dimulai dan server mencoba mengirim data lagi, setiap kali menambah jumlah pengiriman ulang (bidang ke-2) ketika waktu pengiriman ulang (ke-1 bidang) kedaluwarsa.

Semoga ini menjelaskan netstat --timer opsi dengan baik.


Angka pertama jelas merupakan penghitung waktu mundur. Bergantung pada jenis status, setelah timer habis, ia akan mencoba lagi dan mengirimkan FIN lain atau paket apa pun yang diperlukan untuk mencoba lagi. Jadi angka kedua melacak jumlah percobaan ulang. Perhatikan bahwa pengatur waktu bertambah karena TCP memiliki pengatur waktu mundur jika ada kondisi lalu lintas. Timer mundur menghindari percobaan ulang yang terlalu sering. Setiap kegagalan menghasilkan kemunduran yang semakin besar. Backoff bisa berupa pertumbuhan eksponensial atau linier, tergantung pada tumpukan TCP. Saya belum tahu untuk apa angka 3 itu. Selalu nol di layar saya.


Linux
  1. Crontab Log:Cara Mencatat Keluaran Skrip Cron Saya

  2. Bagaimana cara menambahkan output ke file?

  3. Bagaimana saya mengontrol output daya di port USB di Linux?

  1. Bagaimana cara Menyimpan output SHOW PROCESSLIST ke dalam file di MySQL?

  2. Python - Supervisor cara mencatat keluaran standar -

  3. Bagaimana cara menyalin output terminal?

  1. Bagaimana Mengurutkan Du Output Berdasarkan Ukuran?

  2. Bagaimana Menyoroti Kata Dalam Output "kucing"??

  3. Bagaimana Mencetak Output Multiline Pada Baris Yang Sama?