计算机网络——基础知识(一)

1. 为什么 socket 在应用层和传输层之间提供接口而不在其他层之间提供呢?#


从类比操作系统和各自关注的细节两方面回答

2.TCP 握手和挥手以及数据传输的过程?#

Socket网络编程

3. TCP 四次挥手中,为什么主动关闭的一方最后要处于 TIME_WAIT 状态?同时为什么 TIME_WAIT 状态要维持 2MSL 呢?#

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

4. TCP 如何区分不同的连接?#

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.

5. 并发服务器的连接情况?#

Socket网络编程

6. 常见因特网应用所用的协议#

Socket网络编程

本作品采用《CC 协议》,转载必须注明作者和本文链接