Diagram TCP/IP sixth TCP and UDP note 6.1 The role of the transport layer

Source: Internet
Author: User


Plot? Tcp / ip? Sixth chapter? TCP vs. UDP? Note 6.1 The role of the transport layer

?

The transport layer must indicate this specific program, in order to achieve this function, use the port number of such an identification code. Depending on the port number, it is possible to identify specific programs that are all processed by the application layer on the transport layer.

?

6.1.1 Transport Layer Definition

6.1.2 Communication Processing

?

6.1.32 Transport Layer protocols TCP and UDP

TCP is a connection-oriented, reliable streaming protocol. A flow is an uninterrupted data structure that you can imagine as a water flow in a drain pipe.

UDP is a packet protocol that does not have reliability. Minor processing will be given to the upper application to complete. In the case of UDP, although you can ensure that the message size is sent, there is no guarantee that the message will arrive.

?

6.1.4 TCP and UDP distinction

TCP is used in situations where the transport layer is required to achieve reliability transmission. It can provide reliable transmission for applications because it is oriented to a connected, sequential control, and re-transmit control mechanism.

UDP is mainly used for communication or broadcast communication which has higher requirements for high-speed transmission and real-time. IP telephony, if TCP is used, if data loss is to be re-sent, but this does not smooth the transmission of the voice of the caller, will result in the inability to make a full length of communication. With UDP, it does not perform a re-send process. Thus there will be no significant delay in the arrival of sound problems.

The application uses a class library provided by the operating system when using TCP or UDP.

When using TCP or UDP communication, the socket (socket) API is widely used.

?

6.2 Port Number

?

6.2.1 Port Number Definition

6.2.2 identify applications based on port number

6.2.3 Communication recognition by IP address, port number, protocol number

6.2.4 How to determine the port number

6.2.5 Port number and protocol

The port number is determined by the Transport layer protocol that it uses. Therefore, different transport layer protocols can use the same port number. For example, TCP uses the same port number as UDP, but uses different purposes. This is because the processing on the port number is based on the difference between each transport protocol.

6.3 UDP

6.4 TCP

Characteristics and purpose of 6.4.1 TCP

TCP transmits reliability through mechanisms such as inspection and serial number, acknowledgment response, retransmission control, connection management, and window control.

6.4.2 improves reliability with serial number and confirmation response

In TCP, the receiving host returns a notification that a message has been received when the data on the sending side arrives at the receiving host. This message is called a confirmation answer (ACK).

?

6.4.3 How to determine the re-send timeout

6.4.4 Connection Management

You can use the TCP header to control the fields to manage TCP connections. A connection is established and disconnected, and the normal process requires at least 7 packets to be sent back and forth to complete.

?

6.4.5 TCP sends data in segments

While establishing a TCP connection, you can also determine the unit of the sending packet, or the maximum message length (Mss:maximum Segment Size).

MSS is calculated between two hosts at the end of the three-time handshake. At both ends of the host when making a connection request, the TCP header will be written to the MSS option, tell the other side of the interface can adapt to the MSS size. It then chooses a smaller value between the two to put into use.

6.4.6 using window control to increase speed

TCP takes 1 segments, one for each segment, to process the acknowledgment response. There is a disadvantage to such a transmission mode. That is, the longer the package's round-trip time, the lower the communication performance.

To solve this problem, TCP introduces the concept of Windows. It also controls the degradation of network performance, even in the case of long round-trip times.

The forwarding time will be significantly shortened when confirming that the answer is no longer in each segment, but in larger units. The sending segment host does not have to wait for a confirmation reply after sending a segment, but continues to send.

Window size refers to the maximum number of data that can continue to be sent without waiting for a confirmation answer.

This mechanism enables the use of a large number of buffers, through the simultaneous confirmation of multiple segments of the function.

The data you can see from the window is missing from the transmission, so the sending segment does not receive a confirmation reply, and this situation also needs to be resent. To do this, the sending host must retain this portion of the data in the buffer until the acknowledgment answer is returned.

When you receive a confirmation answer, slide the window to the location of the serial number in the confirmation answer. This enables sequential simultaneous sending of multiple segments to improve communication performance. This mechanism is also known as sliding window control.

?

6.4.7 window control and heavy-hair control

In the Use of window control, what if a segment is lost?

First consider the case where the acknowledgment response could not be returned. In this case, the data has reached the peer, and it does not need to be re-sent. However, when no window control is used, the data that has not received a confirmation reply will be re-sent. With window control, some acknowledgment responses do not need to be re-sent even if they are lost.

Second, consider the case where a packet segment is missing.

?

6.4.8 Flow Control

The sending side sends the data according to its own actual situation.

TCP provides a mechanism that allows the sending side to control the amount of data sent based on the actual acceptance of the receiving end. This is known as flow control.

The specific operation is that the receiving host notifies the sending host that it can accept the size of the data, and the sending side sends no more than that limit. The size limit is called the window size.

In the TCP header, there is a dedicated field to inform the window size. The receiving host notifies the sender of the size of the buffer that it can accept by placing it in this field. The larger the value of this field, the higher the throughput of the network.

However, once the buffer of the receiver is faced with data overflow, the window size value will be set to a smaller value to notify the sender, thus controlling the amount of data sent. In other words, the sending side will control the amount of data sent based on the instructions received from the host. This also forms the complete TCP control flow. (Flow control).

?

6.4.9 Congestion Control

With TCP window control, sending and receiving hosts can send a large number of packets continuously even if they no longer send acknowledgment responses in a single data segment. However, if a large amount of data is sent at the beginning of the communication, other problems may also arise.

In general, the computer network is in a shared environment, if there are other hosts communication between the network congestion, in the event of network congestion, if suddenly send a large amount of data, it is possible to make the network paralyzed.

TCP in order to prevent this problem, at the beginning of the communication will be a slow-start algorithm derived from the value, the amount of data sent to control.

First, in order to adjust the sending end of the data to be sent two, define a concept called congestion window. So when the slow boot, the size of the congestion window is set to 1 data segments to send data, and then every time you receive a confirmation acknowledgment ack, The value of the congestion window is added 1. When sending a packet, the size of the congested window is compared with the window size of the receiving host notification, and the amount of data that is smaller than it is sent, according to the relatively small value.

However, with each round of the package, the Congestion window will also be 1, 2, 4 and other exponential function of the increase of viscosity, congestion and even caused the congestion of the network. To prevent these, the concept of a slow-start threshold is introduced. As long as the value of the congestion window exceeds this threshold, only the congestion window is allowed to be enlarged at the following rate for each acknowledgment reply:

?

When the TCP communication starts, the corresponding slow-start threshold is not set. Instead, it is set to half of the congestion window when the time-out is re-issued.

6.4.10 specification for improving network utilization

Nagle algorithm

TCP often uses an algorithm called Nagle in order to improve the utilization of the network.

The algorithm refers to the sending side even if there is the data that should be sent, but if this part of the data is very small, then a processing mechanism for delay sending. Specifically, data can be sent only in one of the following conditions. If none of the two conditions are met, wait for a period of time before the data is sent.

The sent data has received a confirmation reply.

The maximum segment length can be sent when the data is MSS.

?

Depending on the algorithm, network utilization can be increased, but some degree of latency may occur. For this reason, when TCP is used in the window system and in the field of machine control, the algorithm is often turned off.

?

Delay Acknowledgement Response

When a receiver receives a notification from this small window, it will send the data to him as the limit, thereby reducing the utilization of the network. To this end, a method is introduced, that is, the receipt of data does not immediately return to confirm the answer, but delay a period of mechanism.

?

In a TCP file transfer, the overwhelming majority is that each data returns a confirmation reply.

?

?

Piggyback response

Depending on the application layer protocol, the sent message arrives at the peer and is processed by the peer, returning a receipt.

These application protocols use the same connection for data exchange. Even with the HTTP protocol using WWW, this is the case from the 1.1 release.

In such communication, the acknowledgment and receipt data of TCP can be sent through a packet. This method is called a piggyback response. This mechanism can reduce the amount of data sent and received.

?

?

6.4.11 applications that use TCP

TCP uses a variety of control mechanisms. Even the more complex control mechanisms that are not mentioned in this book are used. TCP uses these mechanisms to provide high-speed, reliable communication services.

?

Using the UDP protocol is a good choice if you need to apply yourself to handle some more detailed controls. You can choose to use TCP if the amount of forwarding is high and the reliability requirements are higher. Both TCP and UDP have the same length, and they should be appropriately selected when designing and developing applications, with the characteristics of their respective agreements.

?

6.6 UDP Header Format

?

6.7 TCP Header Format

?

Control bits:

Cwr:congestion window reduced?

The CWR logo and the following ECE logo are used for the IP header of the ECN field. The ECE flag bit 1 o'clock notifies the other party that the congestion window has been narrowed.

ECE Ecn-echo

?

The ECE symbol indicates Ecn-echo. 1 will notify the communication party, from the other side of the network is congested. In the IP header where the packet was received, the ECN in the TCP header is set to 1 in a 1 o'clock.

URG Urgent flag?

Indicates that there is data in the package that needs urgent processing. For data that requires urgent processing, it is explained in the following emergency pointers.

ACK Acknowledgement flag?

This bit is 1 o'clock, confirming that the answered field becomes valid. TCP Specifies that the bit must be set to 1 in addition to the SYN packet when the connection was initially established.

PSH push flag?

This bit is 1 o'clock, which means that the received data needs to be passed to the upper application protocol immediately. PSH is 0 o'clock, it does not need to be transmitted immediately but first cached.

RST Reset Flag?

A bit of 1 indicates that an exception in the TCP connection must be forced to disconnect.

?

SYN Synchronize flag?

Used to establish a connection. A SYN of 1 indicates that you want to establish a connection and set the initial value of the sequence number in the field of its serial number.

FIN? Fin flag?

This bit is 1 o'clock, indicating that no more data will be sent in the future and want to disconnect. The TCP segment with FIN position 1 can be exchanged between the hosts on both sides of the communication when the communication ends when the connection is expected to be disconnected.

?

Window size?

?

Diagram TCP/IP sixth TCP and UDP note 6.1 The role of the transport layer

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.