Computer Network (xxii) TCP Introduction

TCP sufficiently achieved various control functions of data transmission, retransmission control can be performed when packet loss may also be subcontracted to mess order sequence control.
As a TCP connection-oriented protocol has only confirmed when the communication terminal before the transmission data is present, it can be controlled wasteful communication traffic.
Based on these mechanisms of TCP, the IP network such connectionless communication can be realized with high reliability.

1.TCP characteristics and purpose

Through TCP checksum and sequence number, acknowledgment, retransmission control, connection management and other window control mechanisms to achieve reliable transmission.

2. acknowledgment sequence number to improve reliability

In TCP, a data transmitting side when reaching the receiving host, the receiving host returns a notification message has been received. This message is called the acknowledgment (ACK).
Normal data transmission
TCP Reliable data transmission through a positive acknowledgment response (ACK).
After the data is sent to the transmitting side waits for the end of the acknowledgment response. If there is confirmation response, indicating that data has been successfully reach the remote. On the contrary, the possibility of data loss is large.
Did not wait for the acknowledgment within a certain period of time, the sender can be considered data has been lost, and re-issued.
Even if a packet loss, to ensure that the data is still able to reach the end, to achieve reliable transmission.
Case of packet loss
Did not receive the acknowledgment does not necessarily mean that the data is lost. There may be other data has been received, but the acknowledgment returned lost in transit.
Confirmed case of loss of response
It is also possible because of some other reasons why the acknowledgment delayed arrival, the situation after the source host retransmission data before reaching will appear. As long as the source host transmits the data according to retransmission mechanism. But for the target host, this is simply a disaster. "It will again receive the same data. In order to provide reliable transmission of upper layer application, must give up duplicate packets.
To avoid this, it is necessary to introduce a species mechanism, it is possible to identify whether data has been received, and it can be determined whether the reception.
these acknowledgment processing, retransmission control and repetitive control other functions can be by the sequence number,
the sequence number of every word in order to transmit data section (8 bytes) are marked number on the number.
the receiving end of a query received data length of the TCP header in the sequence number and the data of his next be received sequence number as an acknowledgment response foldback back.
by sequence numbers and acknowledgment No, TCP enables reliable transmission.
send data

3. How to determine the retransmission timeout

Retransmission timeout means before retransmission data, that particular time to wait for the arrival of the acknowledgment interval. If more than this time not receive acknowledgment, the sender will retransmit the data.
The specific length of time retransmission timeout is how to determine:
the ideal is to find a minimum of time, and to ensure that "the acknowledgment will be able to return at this time.
However, this length of time with the different ways a packet network environment vary.
TCP requires no matter what is under the network environment must provide high performance communication, and no matter what changes in network congestion occurs, must maintain this characteristic. it will be calculated at each round-trip time and contract as a variation
to the round trip time and adding the offset, that is, the retransmission time-out is slightly larger than this value to the sum.
calculated retransmission timeout is necessary to consider the round trip time will have to consider deviation reasons :
according to the network environment different round-trip time may produce substantial swing, because fragmented packets is the result of .TCP / IP purpose is different lines to reach even be controlled also in this environment, try not to waste network traffic.
Calculate the round trip time and the retransmission timeout time lapse
in the BSD Windows and Unix systems, to 0.5 second timeout control unit, the retransmission timeout is therefore an integral multiple of 0.5 seconds
Since the first data packet does not know the round-trip time, so that the retransmission timeout is generally set to 6 seconds
data is then retransmitted if the acknowledgment is not received, the transmission is performed again. In this case, the acknowledgment waiting time will be extended to 2-fold, 4-fold exponential function.
after the data is not infinite, repeatedly retransmitted. a certain number of retransmissions, if still no acknowledgment returned will be determined that the occurrence of a network or a peer host abnormal, forcibly closed connection and notifies the application communication abnormality forcibly terminated.

4. Connection Management

TCP provides for communication with a transport connection. It means for connecting the first preparatory work before the ends of the communication between the start of data communication.
UDP is a connectionless protocol for communication, and therefore does not check whether the peer can communicate directly sent UDP packet.
TCP contrary, it prior to data communication, by sending a TCP header SYN packet as a request to establish a connection to wait for acknowledgment. If the acknowledgment from a peer, it is considered to be in data communication.
At the end of the communication will be processed (FIN packets) disconnect.
You can use TCP header field for control to manage TCP connections. A connection establishment and disconnection , the normal process of sending back and forth at least seven packets to complete. Wherein establishing a TCP connection needs to send three packages . This process is also known as " three-way handshake ."
TCP connection establishment and disconnection

5.TCP transmitting data in units of segments

While establishing a TCP connection, you can also determine the unit that sent the packet, we can also call it "the maximum message length" (MSS: Maximum Segment Size) .
Ideally, the maximum message length is exactly the IP fragmentation processing is not the maximum data length.
When large amounts of data TCP, the MSS is the size of the transmission data is divided. When retransmission is to MSS units.
MSS is when the three-way handshake is calculated between the two ends of the host. Host both ends of the connection establishment request is issued, will write the MSS option in the TCP header, tell each other the size of its own interface can adapt to the MSS. Then will choose a smaller value in use between the two.
The communication between the host and the Ethernet access FDDI access host

6. The improved speed control using a window

In a TCP segment units, each segment a first acknowledgment sent for processing, the lower the longer the round trip time of the packet communication performance.
Press the confirmation response packet
TCP introduces a window, control decrease network performance.
No longer is the acknowledgment of each segment, but when confirmed in larger units, forwarding time will be greatly shortened. That is sending host, sending unnecessary after a period of waiting for confirmation response has been, and continues to send.
Sliding window with parallel processing mode
Window size refers without waiting for the acknowledgment and may continue to transmit the maximum data.
This mechanism enables the use of a large number of buffers to multiple segments simultaneously function confirmation response through.
Sliding window mode
Even if the data within the window does not receive the acknowledgment can be sent.
Sending host must keep this part of the data in a buffer before waiting for an acknowledgment returned.
When the data sent, if duly received acknowledgment may not need to be retransmitted, the data at this time can be cleared from the buffer.
Sliding window control **: ** case of receiving the acknowledgment, the position of the sliding window to the sequence number in the acknowledgment. Such may sequentially transmit the plurality of segments simultaneously improve communication performance.

7. The window control and retransmission control

The failure to return the acknowledgment:
data has arrived for the terminal, is no further retransmission. However, when window control is not used, it does not receive the acknowledgment data will be retransmitted. The use of window control, some even lost the acknowledgment does not need retransmission.
No confirmation response will not be affected
The case of a missing segment:
the window is relatively large, the case of the missing segment, with a number of acknowledgment response will be repeated continually return appeared. And the sending host is received three times in succession with an acknowledgment, it will be a corresponding data retransmission.
This mechanism is more efficient than the previously mentioned time-out control, it is also referred to as high-speed retransmission control .
High-speed retransmission control

8. Flow Control

Flow Control: TCP provides a mechanism that allows sending end controlling the amount of data transmitted according to the actual reception capability of the receiving terminal.
Specific operations: receiving host notifies the sending host can receive their data size, then transmitting side sends data does not exceed this limit. The size limit will be referred to as window size .
The TCP header, there is a special field is used to notify the window size. The larger the value of this field, the higher the throughput of the network. Upon receiving the end face of this buffer once data overflow, the value of the window size will also be set to a smaller value notified to the transmission side, thereby controlling the amount of data sent. I.e., based on the sending host to receiving host indicating, for controlling the amount of transmission data. This will form a complete TCP flow control (flow control) .
Flow Control
Host sending end will occasionally called window probe data segment, the data segment containing only one byte of the window size to obtain the latest information.

9. Congestion Control

In general, computer networks are in a shared environment. Thus there may be because communication between other hosts such network congestion.
When the network is congested, if suddenly sent a relatively large amount of data, it is likely to lead to paralysis of the entire network.
TCP To prevent this problem, when the communication will be started by the called slow-start algorithm is the value obtained, the transmission data amount is controlled.
Slow Start
Specific actions:
1. In order to adjust the end of transmission of the data to be transmitted, defines a concept called "congestion window". Accordingly, when the slow start, the congestion window size will be set to one segment (1MSS) to send data.
2. After each receive one acknowledgment (ACK), the value of the congestion window is incremented.
3. The window size when transmitting data packets, the size of the congestion window and the receiving host notification compared, and the smaller of them in accordance with that value, which is smaller than the transmission amount of data.
Retransmission timeout mechanism is employed, then the initial value of the congestion window can be set to 1 after the slow start then corrected. It can effectively reduce the communication network congestion caused by a continuous contract at the beginning of, and also avoid the occurrence of network congestion.
With each round-trip packet congestion window will increase to 2, 4, etc. exponential function, or even lead to congestion surge in network congestion.
The slow start threshold **: ** As long as the value of the congestion window beyond this threshold, a confirmation in response, this only allows the following scaling each received congestion window:
proportion
Change the TCP window
number larger congestion window acknowledgment will increase. Congestion window size will be a linear upward trend.
When TCP communication began, and did not set the appropriate slow start threshold. But when retransmission timeout, the time will be set to half the size of the congestion window.
Duplicate confirmation response triggered by the high-speed processing and retransmission timeout retransmission mechanism is somewhat different. The former requires at least three times the acknowledgment segment to reach the other side will trigger the host, network congestion compared to the latter to be lighter.
While repeating acknowledgment for high-speed retransmission control, half the size of the slow start threshold is set to a time window size, the window size is then set to the slow start threshold size data segments +3.
Window size will directly affect the throughput when data is forwarded, under normal circumstances, the larger the window, the formation of high throughput communication.
The so-called TCP throughput characteristics is like the feeling of gradual occupation of network bandwidth.

10. Specification improve network utilization

a.Nagle algorithm

The algorithm refers to a data transmission terminal, even if there should be sent, but if this part of the data is small, then the mechanism for processing transmission is delayed.
Only data that can be sent in any of the following conditions. If the two conditions are not met, then the data is then sent temporarily to wait for some time.
Conditions 1. The data sent have received the confirmation response.
2. Conditions may be transmitted maximum segment size (MSS) of the data.
Although this algorithm can improve network utilization, but some degree of delay may occur.
When using the TCP window control systems and machinery and other fields, often closed to enable the algorithm.

b. delay confirmation response

After receiving the data is not immediately return an acknowledgment response, but the delay mechanism over time.
1. 2x data is not received until the maximum segment length is not acknowledgment (depending on the operating system, regardless of the data size may also, as long as the two received packets can immediately return a response confirmation.)
2. Under other circumstances , the maximum transmission delay of 0.5 seconds acknowledgment (many operating system is set to approximately 0.2 seconds)
no need for each data segment once acknowledgment. TCP uses the sliding window control mechanism, and therefore can be generally less acknowledgment. TCP file transfer, the vast majority once every two segment and return the acknowledgment.
Delay confirmation response

c. piggybacking

Among communication, TCP acknowledgment and receipt of data can be sent over a packet. This method is called piggybacking.
By this mechanism, it can reduce the amount of data transmission and reception.
After receiving the data return immediately if the acknowledgment can not be achieved piggybacking. But the received data to the application after the processing of generating the return data into further until the transmission request must wait until transmission of the acknowledgment.
If the delay confirmation response is not enabled can not be achieved piggybacking.
Piggybacking

11. The use of TCP application

TCP the above-described mechanism provides high-speed, reliable communication service.
If you need to apply yourself to deal with some more details on the control, use UDP protocol is a good choice.
If a large amount of data forwarding, high reliability requirements, can choose to use TCP.

Guess you like

Origin blog.csdn.net/NEUChords/article/details/91819108