1. TCP 是面向连接的、可靠的、基于字节流的传输层通信协议。
    TCP初步

TCP初步
TCP初步

连接

Connections:
The reliability and flow control mechanisms described above require that TCPs initialize and maintain certain status information for each data stream.
The combination of this information, including sockets, sequence numbers, and window sizes, is called a connection.

TCP初步
建立一个 TCP 连接需要客户端与服务器端达成以上三个信息的共识。

Socket:由 IP 地址和端口号组成
***:用来解决乱序问题等
窗口大小:用来做流量控制

TCP 四元组可以唯一的确定一个连接,源地址、源端口、目的地址、目的端口。

源地址和目的地址的字段(32位)是在 IP 头部中,作用是通过 IP 协议发送报文给对方主机。

源端口和目的端口的字段(16位)是在 TCP 头部中,作用是告诉 TCP 协议应该把报文发给哪个进程。

UDP 不提供复杂的控制机制,利用 IP 提供面向无连接的通信服务。

  1. 建立TCP连接

TCP 是面向连接的协议,使用 TCP 必须先建立连接,建立连接是通过三次握手实现的。

TCP初步
三次握手的原因:
避免历史连接
同步双方的初始***
减少双方不必要的资源开销

The principal reason for the three-way handshake is to prevent old duplicate connection initiations from causing confusion.

如果是历史连接(***过期或超时),则第三次握手发送的报文是 RST 报文,不再是ACK以此来中止历史连接。

  1. 断开TCP连接

TCP 断开连接是通过四次挥手的方式实现的。双方都可以主动断开连接,断开连接后主机中的资源将被释放。
TCP初步

相关文章:

  • 2021-10-06
  • 2021-04-18
  • 2021-09-01
  • 2022-12-23
  • 2021-11-10
  • 2021-11-15
  • 2021-08-13
  • 2021-06-25
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-06-04
  • 2022-12-23
  • 2022-01-06
  • 2021-09-22
  • 2021-06-22
相关资源
相似解决方案