四次挥手的原因
四次挥手
-
原因:
TCP inactive 的 四个条件 (双方都要满足)- receive fin (inbound end)
- send fin (outbound end)
- fin is acked (the peer receive the fin, otherwise need to retransmit fin)
- the remote peer statisfy #1 through #3
-
inactive 的方式
-
active close => the last one is send
-
need to linger to avoid releasing the port number
-
send fin actively => #2
-
receive ack => #3 (the remote peer's #1)
-
receive fin => #1 (the remote peer's #2)
- send ack => for statisfy #4 (the remote peer's #3) -
need to linger to make sure that the remote peer's #3
-
namely reponse to the fin that is retranmited by the remote peer -
bacause ack is not retransmited, and it is possibly dropped -
need to linger to assure the segment for this connection to be cleaned
-
-
passive close => the last one is receive
- local statisfy #1 #2 #3 #4
- receive fin => #1 (the remote peer's #2)
- send ack + fin => #2
- receive ack => #3 (the remote peer's #1,#3)
- only if receive this ack, means that the first fin's ack must be receive by the remote peer, becase the second fin must have the ack for the first fin
- local statisfy #1 #2 #3 #4
-
-
summary
- before send fin, receive fin, no need to linger, passive
- otherwise need to linger

浙公网安备 33010602011771号