計算機網路——基礎知識(一)

it_was發表於2020-10-03


從類比作業系統和各自關注的細節兩方面回答

Socket網路程式設計

There are two reasons for the TIME_WAIT state:

  1. To implement TCP’s full-duplex connection termination reliably
  2. To allow old duplicate segments to expire in the network

TCP must prevent old duplicates from a connection from reappearing at some later time and being misinterpreted as belonging to a new incarnation of the same connection. To
do this, TCP will not initiate a new incarnation of a connection that is currently in the TIME_WAIT state. Since the duration of the TIME_WAIT state is twice the MSL, this allows MSL seconds for a packet in one direction to be lost, and another MSL seconds for the reply to be lost. By enforcing this rule, we are guaranteed that when we successfully establish a TCP connection, all old duplicates from previous incarnations of the connection have expired in the network

The socket pair for a TCP connection is the four-tuple that defines the two endpoints of the connection: the local IP address, local port, foreign IP address, and foreign port.

Socket網路程式設計

Socket網路程式設計

本作品採用《CC 協議》,轉載必須註明作者和本文連結

相關文章