End-to-end protocol

Source: Internet
Author: User

End-to-end protocol chapter fifth

The previous chapters examined the host-to-host packet delivery service to the communication channel between the steering process to the process, which is the task of the Transport Layer () in the network architecture, and transport because it supports communication between endpoint applications, the Transport layer protocol is sometimes referred to as an end-to-end ( end to end ) protocol.

The Internet provides best-effort ( best-effort ) services to meet the advanced services required by the application, and different transport layer protocols are used for different algorithm combinations. There are 4 representative types: A simple asynchronous multi-channel decomposition service, a reliable byte stream service, a request/response service, and a service for real-time applications.

5.1 Simple multi-channel decomposition protocol (UDP)

Perhaps the simplest transport protocol is to extend the host-to-host delivery service of the downlevel network to the process-to-process communication service. It is possible to run multiple processes on any host, so the laundry needs to add at least one multi-way decomposition capability so that multiple processes on each host can share the network. In addition, the transport Protocol no longer adds any additional functionality to the services provided by the downlevel network. The internet provides a User Datagram Protocol ( User Datagram Protocol ), which is such a transport protocol.

It is important to note that the address form of the identity destination process (which can be identified directly between processes using the process identifiers given by the operating system pid , but not to many different systems), UDP uses an abstract locator with a appellation port port , which enables the process to recognize each other indirectly. The basic idea is that the source process sends a message to the port and the destination process receives the message from the port. < host, port > a multi-path decomposition key that forms the UDP protocol.

How do I know the process port number to each other? The policy is that the server process receives messages on a well-known port well-known port , that is, the well-known port has only one. Sometimes, well-known ports are just the starting point for communication: The client and server use this port to agree and follow up on another port to release well-known ports for use by other client processes.

Generally speaking, a port is implemented by a message queue, and when a message arrives, the protocol adds the message to the end of the queue, and if the queue is full, the message is discarded. There is no flow control mechanism for sending a slow sending speed.

Although UDP does not implement traffic control or reliable/orderly transmission, it does more than simply decompose the message into an application process, but does more work to ensure the correctness of the message by verifying the checksum portion of the header.

5.2 Reliable byte stream transmission Control Protocol

TCP can guarantee reliable, orderly byte stream transmission, it is a full-duplex protocol, that is, each TCP connection directly a pair of byte stream, a byte stream in each direction, he also has the flow control mechanism, in addition, like UDP, TCP supports the multi-channel decomposition mechanism. In addition, TCP implements a highly-tuned congestion control mechanism, which is designed to control the speed at which the TCP sender sends data, and is not intended to prevent the sender from exceeding the receiver's ability to send out the data, but to prevent the emitted party from exceeding the capacity of the network.

The difference between flow control and congestion control traffic control prevents the data emitted by the sender from exceeding the receiver's receiving capacity, and congestion control prevents excessive data injection into the network and causes the switch or link to overload. So flow control is an end-to-end problem, and congestion control is the problem of how the host interacts with the network.

5.2.1 End-to-end issues

The core of TCP is the sliding window algorithm. Because TCP runs across the internet rather than on a point-to-page link, there are many important differences. One of the events that occurred during the connection establishment phase was the creation of a shared state between the two parties that enabled the sliding window algorithm to start running. The disconnection phase is necessary because only then the host knows it is the time to release the state.

The difference between a TCP connection and a point link connection
    1. The sliding window algorithm described in chapter two runs on a physical link that is always connected to two computers, but TCP still supports logical connections between processes running on any two computers in the Internet.
    2. Although a physical link to connect two identical computers has a fixed RTT, TCP connections are likely to have very different round-trip latencies.
    3. Grouping may be reordered over the Internet, which is not possible on a point-to-time link, because a packet sent first in a link must first reach the other end.
    4. Computers that connect to point-to-point links are often designed to support such links. Flow control issues
    5. Because the sender of a direct link cannot send data at a rate that is beyond the link bandwidth, and only one host injects data to the link, it cannot possibly be unaware of link congestion. But TCP doesn't know.

In TCP, the lower IP network is considered unreliable, and the transitive message is wrongly ordered, and TCP provides a reliable/orderly transfer using the sliding window algorithm on an end-to-end basis.

5.2.2 Message Segment Format

TCP is a byte-oriented protocol, which means that the sending direction is a TCP connection that writes bytes, and the receiver reads bytes from the TCP connection.

In fact, the TCP on the source host collects bytes that are delivered by the sending process, stores it in a buffer, accumulates enough, puts it together into a suitably sized grouping, and then sends it to the peer entity on the destination host. TCP on the destination host stores the contents of this packet in a receive buffer, and the receiving process reads bytes from this buffer when it is idle.

establishment and termination of 5.2.3 connections

Note that although the connection is established as an asymmetric activity (one party performs a passive open while the other side executes the active open), the disconnection of the connection is a symmetric activity (each party must close the connection independently). So it's possible that one of the parties has finished closing the connection, which means it no longer has data, but the other side still keeps the other half of the two-way connection open and the data continues to occur.

Three-time handshake

The algorithm used by TCP to establish and terminate the connection is called a "three-time Handshake" ( three-way handshake ), which means that three messages are exchanged between the client and the server.

The idea of the algorithm is that the two sides need to agree on a number of parameters, when a TCP connection is opened, the parameters are the starting sequence numbers that both parties intend to use for their respective byte streams. First, the client (the active party) sends a message segment to the server (the passive party), declares the initial sequence number () that it will use, and the Flags = SYN,SequenceNum=x server responds with a message segment to confirm the client's ordinal number (), Flags = ACK,Ack= x+1 declares its own initial sequence number ( Flags=SYN,SequenceNum=y ), and finally, The client responds with a third message segment, confirming the server's ordinal number ( Flags = ACK,Ack=y+1 ). The confirmation ordinal of each paragraph is higher than the one sent for the first time because the Acknowledgment field actually indicates "the next ordinal you want to receive", thereby implicitly confirming all the preceding sequence numbers. The first two segments use a timer, and if you do not receive the desired response, the message segment is re-transmitted.

The TCP specification requires that each of the connected parties randomly select an initial sequence number to prevent the two instances of the same connection from reusing the same sequence number too quickly, that is, it is still possible to have a data segment of the previous connection instance interfering with the subsequent connection instance.

State transitions

Initially, the closed client actively opens and sends a SYN signal, the client enters SYN_SENT , the server side is passive open into the LISTEN state, and then when the server receives the client sent SYN , enters the SYN_RCVD state and sends the SYN+ACK message segment response, When this segment arrives at the client, it causes the client to enter the ESTABLISHED state and sends an ACK segment to the server, and when the packet arrives, the server is transferred to ESTABLISHED . This concludes the state transition of the three-time handshake.

5.2.4 Sliding window again discussion

The TCP window algorithm serves three purposes

    1. Ensure reliable data transfer
    2. Ensure the orderly delivery of data
    3. Enhanced traffic control between sender and receiver.

TCP differs from the previous algorithm in that it increases the flow control function, in particular that TCP does not use a fixed-size sliding window, but rather is notified (by the receiving direction sender advertise ) of its window size. This is done through the TCP header AdvertisedWindow field. The receiver AdvertisedWindow chooses an appropriate value based on the amount of memory allocated to the connection for caching data.

Reliable and orderly transmission

The sender's TCP maintains a send buffer, which is used to store data that has been emitted but not acknowledged and written by the sending application but not emitted. On the receiver side, TCP maintains a receive buffer, storing the data that arrives in the wrong sequence and those that arrive in the correct order but the application process is not readable.

The sender buffer maintains 3 pointers, LastByteAcked LastByteWrittenLastByteSent

Similarly, the receiver Buffer maintains 3 pointers, LastByteRead NextByteExpectedLastByteRcvd

Flow control

The buffer has a finite size. The receiver can control the sender's sending rate by notifying the sender of a window that is not much more than the amount of data he can store. TCP only sends a message segment response when it receives a message segment, and the response contains the Acknowledgment AdvertisedWindow most recent value of the field, even though the two values have not changed since the last time it was sent. The problem is this, when the window is 0, the sender is not allowed to send any data, it means that it can not be found at some point in the future Notification window is no longer 0. The receiver's TCP does not spontaneously send packets that do not contain data, and he sends them only in response to a message segment that arrives. TCP handles this situation as follows, and when the window is 0 o'clock, the sender still insists on sending a 1-byte message segment.

The reason the sender periodically sends the probe segment is that TCP is designed to make the receiver as simple as possible, that is, he responds only to the segment of the message sent from the sender, and it never initiates any activity. We call it the Smart sender/Clumsy receiver ( smart sender/dumb receiver ) rule.

5.2.5 Triggering transmission

TCP has three mechanisms to trigger the transmission of a message segment.

    1. TCP maintains a variable, called the maximum Packet length (MSS), once TCP is collected from the sending process to the MSS bytes, it sends a message segment, usually the MSS is set to TCP can send and does not cause the local IP segment of the maximum packet length, that is, MSS is set to the MTU of the directly connected network minus the size of the header of TCP and IP.
    2. The sending process explicitly requires TCP to send a segment of a message, especially TCP supports push operations, and the send process calls this operation to enable TCP to send all unsent bytes in the buffer,
    3. The timer is activated, and the resulting message segment contains all the bytes in the current buffer that need to be sent out.
fool window Symptoms

Blindly using any of the available Windows policies can lead to situations that are now known as the Fool window symptoms. All the questions are back: When does the sender decide when to transmit a message segment?

NagleThe algorithm introduces a perfect self-timing ( self-clocking ) scheme, the idea is that as long as TCP sends out the data, the sender will eventually receive an ACK, which can be regarded as the active timer, triggering the transmission of more data. Nagleprovides a simple uniform rule for deciding when to transfer data: If the window size permits, you can emit a full-loaded segment of the message. If there is currently no segment in transit, a tabloid segment can be issued immediately, but if there is a transmitted segment, the sender must wait for an ACK to arrive before transmitting the next segment.

5.2.6 Self-adaptive retransmission

Because TCP guarantees reliable data transfer, all packets are re-transmitted if the ACK is not received within a certain time frame. TCP sets this timeout to the RTT function at both ends of the connection it expects. Choosing a suitable time-out value is not easy. To deal with this problem, TCP uses a self-adapting retransmission mechanism.

Primitive algorithm

Maintain the average operating value of a RTT and calculate the timeout value as a function of this RTT.

Karn/partridge algorithm

The original algorithm has an obvious flaw, the problem is that the ACK does not actually confirm the transmission, it actually confirms the receipt of the data, cannot determine whether the received ACK is for the first segment of the message or the second re-sent segment. The workaround is quite simple, when TCP retransmissions a segment, stops calculating the sample value of the RTT, which is measured only once for the packet segment. At the same time, a small trimming is made to the TCP retransmission mechanism. Each time the TCP retransmission is set, it sets the next timeout value to twice times the last time.

End-to-end protocol

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.