MIT course, CS144, Week 2,Transport Layer

In summary, TCP provides in-order, reliable delivery of a stream of bytes between application processes.

  • TCP is a specific example of transportation layer protocols. Other
    protocols include UDP, ICMP and the like.
  • TCP的end-to-end, byte-stream通信是大多数(几乎95%)application所需要的,所以它的覆盖率很广。

TCP在两个端(两个transport layer)之间建立一个two-way communication,通过一个state machine.

MIT course, CS144, Week 2,Transport Layer
两个application之间传送的Bytestream,通过被tear down为一个个TCP segments被传送。传到的TCP segments有时需要发送好几次直到对方回复ACK确认收到。收到的TCP segments会改变顺序以对应原先的顺序(The TCP layer re-sequence them to the correct order using the sequence number) 。

当A B其中一方决定停止connection,进行tear down, 然后状态机就可以 clean up states
MIT course, CS144, Week 2,Transport Layer
Data+ 指B在接收到A的停止传输信号后,可能还有data要传回给A。最终,B会传一个Fin给A结束通信。

MIT course, CS144, Week 2,Transport Layer

  1. flow-control可以防止两个端点由于速度不匹配而产生的over-flow。如果B速度太慢,它会告诉A自己的缓冲区(buffer)还可以接受多少信息,如果为0了,那么A会等待B。

Congestion control比较复杂,它对网络进行优化。
MIT course, CS144, Week 2,Transport Layer

MIT course, CS144, Week 2,Transport Layer
Destination port,端口编号。Refer to IANA for more information of the definition of port numbers (e.g. 22 for ssh, 23 for smtp). Port指定a specific application the host should establish a connection with.

Sequence number是以第一个byte为基准的, offset by the initial sequence number。

Ack Sequence # 表示等待传输的下一个byte的number(next expected byte)。E.g., 751表示在750包括750)之前的所有byte“我”都已经收到
Initial sequence number to prevent overlap with previous connection with same ID. 也就是说,每建立一个tcp connection都会随机产生一个initial sequence number,避免之前用同一对端口传送过的信息仍在回荡继而被收到。

MIT course, CS144, Week 2,Transport Layer

左边的Web client(假设为Chorme)sends the data to TCP layer(假设connection已经被建立)。