Linux查看tcp连接的keepalive情况

netstat -o --wide

输出类似如下:

Proto Recv-Q Send-Q Local Address           Foreign Address         State       Timer
tcp        0      0 rz-tutor-primary-advert1-test:23507 10.11.43.151:6030       ESTABLISHED off (0.00/0/0)
tcp        0      0 rz-tutor-primary-advert1-test:5708 10.11.62.106:4505       ESTABLISHED keepalive (30.57/0/0)
tcp        0      0 rz-tutor-primary-advert1-test:41374 10.11.43.152:8433       ESTABLISHED off (0.00/0/0)
tcp        0     36 rz-tutor-primary-advert1-test:ssh 10.1.61.13:51199        ESTABLISHED on (0.20/0/0)
tcp        0      0 rz-tutor-primary-advert1-test:60114 10.11.43.156:8433       ESTABLISHED off (0.00/0/0)
tcp        0      0 rz-tutor-primary-advert1-test:41372 10.11.43.152:8433       ESTABLISHED off (0.00/0/0)
tcp        0      0 rz-tutor-primary-advert1-test:46736 10.11.43.157:8433       ESTABLISHED off (0.00/0/0)
tcp        0      0 rz-tutor-primary-advert1-test:9176 10.11.52.155:8433       ESTABLISHED off (0.00/0/0)
tcp6       0      0 10.9.66.112:21666       10.11.61.58:commplex-main ESTABLISHED keepalive (678.75/0/0)
tcp6       0      0 10.9.66.112:22724       10.9.62.84:commplex-main ESTABLISHED keepalive (1014.62/0/0)
tcp6       0      0 10.9.66.112:16519       10.9.62.137:commplex-main ESTABLISHED keepalive (1051.48/0/0)
tcp6       0      0 10.9.66.112:synapse-nhttp 10.9.63.73:commplex-main ESTABLISHED keepalive (65.88/0/0)
tcp6       0      0 10.9.66.112:8162        10.9.61.173:commplex-main ESTABLISHED keepalive (867.16/0/0)
tcp6       0      0 10.9.66.112:17109       10.9.68.192:commplex-main ESTABLISHED keepalive (719.70/0/0)

我们重点关注State和Timer字端:

State字端的可能值:

  • keepalive (长连接等待检查计时)
  • on 重发
  • off 没有时间计时
  •  timewait (当代关闭了)

Timer里有三个值,假设a/b/c:

  • a 当state是on表示重发时间,state是timewait时表示等待计时,state是keepalive时表示计时时间
  • b 已经产生的重发次数
  • c 已经发送的检测包次数

 

Leave a Reply

Your email address will not be published.