四次挥手的原因

四次挥手

  • 原因:
    TCP inactive 的 四个条件 (双方都要满足)

    1. receive fin (inbound end)
    2. send fin (outbound end)
    3. fin is acked (the peer receive the fin, otherwise need to retransmit fin)
    4. the remote peer statisfy #1 through #3
  • inactive 的方式

    1. 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

    2. 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
  • summary

    • before send fin, receive fin, no need to linger, passive
    • otherwise need to linger
posted @ 2023-08-16 21:34  chumoath  阅读(11)  评论(0)    收藏  举报