这篇文章有待改进,内容还有比较多的内容需要补全。想要了解的建议直接移步reference。
The blog is to be continued.

layer

UDP

  • 保证正确性(cksum)
  • 不保证顺序
  • 不保证送达
  • 资源占用少
  • 包头短
  • 无状态(无连接)

TCP

Logic

transfer control

  • retransmission

    • fast retransmission due to 3 Acknowledgement Duplicates:
    • timeout
  • time adjustment: when accept each packet

problem

  • 为什么建立要3次,断开要4次?
    • 建立:确保client端开启。
    • 关闭: 当收到对方的FIN报文时,仅仅表示对方不再发送数据了但是还能接收数据,己方也未必全部数据都发送给对方了,所以己方可以立即close,也可以发送一些数据给对方后,再发送FIN报文给对方来表示同意现在关闭连接,因此,己方ACK和FIN一般都会分开发送。
  • 为什么TIME_WAIT状态需要经过2MSL(最大报文段生存时间)才能返回到CLOSE状态?
    • 保证TCP协议的全双工连接能够可靠关闭
    • 保证这次连接的重复数据段从网络中消失

transfer - Sliding windows

  • 目的:凭借小范围的乱序提升性能,减少阻塞时间, 速度控制

sender

  • Sent and Acknowledged:这些数据表示已经发送成功并已经被确认的数据,比如图中的前31个bytes,这些数据其实的位置是在窗口之外了,因为窗口内顺序最低的被确认之后,要移除窗口,实际上是窗口进行合拢,同时打开接收新的带发送的数据
  • Send But Not Yet Acknowledged:这部分数据称为发送但没有被确认,数据被发送出去,没有收到接收端的ACK,认为并没有完成发送,这个属于窗口内的数据。
  • Not Sent,Recipient Ready to Receive:这部分是尽快发送的数据,这部分数据已经被加载到缓存中,也就是窗口中了,等待发送,其实这个窗口是完全有接收方告知的,接收方告知还是能够接受这些包,所以发送方需要尽快的发送这些包
  • Not Sent,Recipient Not Ready to Receive: 这些数据属于未发送,同时接收端也不允许发送的,因为这些数据已经超出了发送端所接收的范围

receiver

  • Received and ACK Not Send to Process:这部分数据属于接收了数据但是还没有被上层的应用程序接收,也是被缓存在窗口内
  • Received Not ACK: 已经接收并,但是还没有回复ACK,这些包可能输属于Delay ACK的范畴了
  • Not Received:有空位,还没有被接收的数据。

Congestion Control

  • Congestion Avoidance Phase : additive increment
  • Congestion Detection Phase : multiplicative decrement
    • by Retransmission due to Timeout
    • Retransmission due to 3 Acknowledgement Duplicates

The above default congestion is loss-based congestion control, which is designed for stable network and small buffer.
There are another congestion control(BBR) which works for long-distance network and larger buffer, like cross-nation communication(e.g. VPN proxy).
BBR considers how fast the network is delivering data. For a given network connection, it uses recent measurements of the network’s delivery rate and round-trip time to build an explicit model that includes both the maximum recent bandwidth available to that connection, and its minimum recent round-trip delay.
https://cloud.google.com/blog/products/networking/tcp-bbr-congestion-control-comes-to-gcp-your-internet-just-got-faster

Reference