18.7.3 检测半打开连接
如果一方已经关闭或异常终止连接而另一方却还不知道,
我们将这样的TCP连接称为半打开的 。
任何一端的主机异常都可能导致发生这种情况。
只要不打算在半打开连接上传输数据,仍处于连接状态的一方就不会检测到
另一方已经出现异常。
node1:/root/test#tcpdump -S -i eth1 '((tcp) and (port 9) and (host 192.168.137.3))'
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth1, link-type EN10MB (Ethernet), capture size 65535 bytes
21:57:36.932363 IP node1.48328 > node2.discard: Flags [S], seq 2725563020, win 2560, options [mss 256,sackOK,TS val 105112800 ecr 0,nop,wscale 6], length 0
21:57:36.933936 IP node2.discard > node1.48328: Flags [S.], seq 2334307058, ack 2725563021, win 2560, options [mss 256,nop,nop,sackOK,nop,wscale 7], length 0
21:57:36.933985 IP node1.48328 > node2.discard: Flags [.], ack 2334307059, win 40, length 0
21:58:02.710652 IP node1.48328 > node2.discard: Flags [P.], seq 2725563021:2725563031, ack 2334307059, win 40, length 10
21:58:02.710945 IP node2.discard > node1.48328: Flags [.], ack 2725563031, win 20, length 0
重启192.168.137.3 主机:
21:59:31.865388 IP node1.48328 > node2.discard: Flags [P.], seq 2725563031:2725563045, ack 2334307059, win 40, length 14
21:59:32.068377 IP node1.48328 > node2.discard: Flags [P.], seq 2725563031:2725563045, ack 2334307059, win 40, length 14
21:59:32.474842 IP node1.48328 > node2.discard: Flags [P.], seq 2725563031:2725563045, ack 2334307059, win 40, length 14
21:59:33.286687 IP node1.48328 > node2.discard: Flags [P.], seq 2725563031:2725563045, ack 2334307059, win 40, length 14
21:59:34.911500 IP node1.48328 > node2.discard: Flags [P.], seq 2725563031:2725563045, ack 2334307059, win 40, length 14
21:59:38.160262 IP node1.48328 > node2.discard: Flags [P.], seq 2725563031:2725563045, ack 2334307059, win 40, length 14
21:59:53.165162 IP node1.48328 > node2.discard: Flags [P.], seq 2725563031:2725563045, ack 2334307059, win 40, length 14
21:59:53.168715 IP node2.discard > node1.48328: Flags [R], seq 2334307059, win 0, length 0
Last login: Mon Mar 2 21:23:24 2020 from 192.168.137.1
node1:/root#telnet 192.168.137.3 discard
Trying 192.168.137.3...
Connected to 192.168.137.3.
Escape character is '^]'.
hi there
another line
Connection closed by foreign host.
来源:CSDN
作者:zhaoyangjian724
链接:https://blog.csdn.net/zhaoyangjian724/article/details/104632665