TCP article

TCP

In order to provide reliable data transmission, TCP depends on many underlying principle, comprising: an error detection, retransmission, delayed acknowledgment timer, and head number and acknowledgment number fields

1512814-02ea13c7a7d8b6dd.png
1559025245343.png

1. TCP connection

TCP is a connection-oriented protocol, because the data transmission starts before an application process to another, the two processes must first mutual "handshake" that is, they must send each other some initial segment (segment) is used to confirm the establishment of reliable data transmission parameters, as part of establishing a TCP connection, the two sides will be connected to initialize many TCP connections associated TCP state variables.

TCP connection can provide full-duplex service (full-duplex service). If the process A and the process B a host on another host has a TCP connection, then the application layer data may flow from the process A to the process B, while the application layer data flow may be to process B from process A.

TCP is a connection point to point (point-to-point), which is a sender and a receiver. It is referred to as "multicast" data transmission is done from a sender to a plurality of receivers in a transmission operation. It is impossible for TCP, TCP is for just two, three too many.

1512814-535e636de6983d61.png
1559029698967.png

让我们来考虑从客户端进程向服务端进程发送数据。客户端进程通过套接字传递数据流,如图3.28所示,TCP将此数据定向到连接的发送缓冲区,该缓冲区是在三次握手期间初始化的缓冲区之一。 TCP将不时地从发送缓冲区中获取数据块并将数据传递到网络层。可以获取的并且放置在一个段中的最大数据量受 MSS(maximum segment size)的限制。 通常通过首先确定本地发送主机可以发送的最大链路层帧的长度(maximum transmission unit, MTU)来设置 MSS,然后设置MSS以确保TCP报文段(当封装在IP数据报中时)加上TCP / IP报头长度(通常为40个字节)能够装进单个链路层帧。 以太网和PPP链路层协议都具有1,500字节的MSS。 还有一种方法来发现路径MTU--可以在源到目的地的所有链路上发送的最大链路层帧[RFC 1191] - 并根据路径MTU值设置MSS。 请注意,MSS是段中应用层数据的最大数量,而不是包含标头的TCP报文段的最大大小。 (这个术语令人困惑,但我们必须忍受它,因为它根深蒂固。

TCP将客户端的每个数据块与TCP报文段头部配对,从而组从一个TCP报文段。TCP连接的双方都有自己发送缓冲区和接收缓冲区。

我们从这个讨论中看到,TCP连接由缓冲区,变量和到一个主机中的进程的套接字连接,以及另一组缓冲区,变量和到另一个主机中的进程的套接字连接组成。

2. TCP报文段的结构

TCP报文段由多个头部字段和一个数据字段组成,数据字段包含了一块应用层数据,上文提到过, MSS 限制了报文段的数据字段的最大大小。

1512814-684ce3ce951515b2.png
1559031830150.png

3. 往返时间(RTT)估计和超时

In the realization of the timeout / retransmission when the mechanism has many subtle problems. Perhaps the most obvious problem is the length (the length of timeout intervals) time-out interval. It is clear that overtime is often greater than the round trip time Yingge connection (RTT), the message is from a period of time until confirmation is sent from.

RTT estimate

Most TCP implementations are not measured SampleRTT to segment each transmission, but a measurement only once SampleRTT. That, at any point in time, but only one for the sent message paragraphs currently unconfirmed estimates SampleRTT, so get about a new value SampleRTT in each RTT. In addition, TCP segment is never calculated SampleRTT retransmitted; it has been transmitted once only measuring SampleRTT segment.

The recommended value of x is 0.125 (ie, 1/8) [RFC 6298]

Note EstimatedRTT is a weighted average of SampleRTT

RTT fluctuations

Recommended value is 0.25 x

Set up and manage retransmission timeout interval

TimeoutInterval recommended initial value is 1 [RFC 6298]

4. reliable data transmission

  • Doubling the time-out interval
  • Fast retransmission (three duplicate ACK)
  • GBN and SR

5. TCP flow control

Adjusting the transmission rate of the sender

  • Receive Buffer
  • Receive Window rwnd

6. TCP Connection Management

7. TCP Congestion Control

  • Slow Start
  • Congestion Avoidance
  • Fast Recovery
  • Aind

Guess you like

Origin blog.csdn.net/weixin_34277853/article/details/90784949