HTTP protocol implementation method based on hybrid TCP-UDP

Source: Internet
Author: User
Tags http redirect

Abstract:Currently, all applications used for web page access are based on the HTTP application protocol, while the lower layer uses the Transmission Control Protocol (TCP) [1] as the transmission protocol. However, TCP is not suitable for short sessions, that is, only a small amount of data is exchanged. Because the overhead of establishing and revoking TCP links is required even for short sessions. In the design of the browser for PDA (Personal Digital Assistant), a method of hybrid TCP-UDP transmission protocol is proposed based on the characteristics of high latency and narrow bandwidth of wireless network. In this method, UDP [2] is used as the transport layer protocol for short sessions, and TCP is used as the transport layer protocol for transmission of a large amount of data. In this way, short sessions can avoid additional TCP overhead, while long sessions can be reliably transmitted and congested By TCP.

Keywords:TCP UDP HTTP PDA

Introduction

Hypertext Transfer Protocol (HTTP) is currently the most important way to exchange information over the Internet. The HTTP protocol is based on the request/response model. First, the customer establishes a TCP link with the server and sends a request to the server. The request contains the request method, Uri, Protocol version, and related mime (Multipurpose Internet Mail Extensions) style message. The server responds to a status line, contains the Protocol version of the message, a success or failure code, and related mime-style messages (including server information, resource entity information, and possible resource content ). Figure 1 shows a simple model for HTTP implementation. HTTP/1.0 [3] creates a new TCP link for each HTTP Request/response, therefore, a page containing HTML content and images requires multiple short-term TCP links. Three handshakes are required for the establishment of a TCP link. In addition, TCP takes an additional loop connection time (RTT) to get the appropriate transmission speed ). The establishment of each link requires such regular overhead, but does not carry actual useful data, but only ensures the reliability of the link, therefore, HTTP/1.1 [4] proposes the implementation of sustainable links. HTTP/1.1 will only establish a TCP link once and repeatedly use it to transmit a series of request/response messages, thus reducing the number of connection establishment times and regular link overhead.

Continuous links reduce the time required to establish each TCP link. However, a idle TCP link requires a socket and the corresponding storage buffer. The minimum length of a socket buffer must be greater than the maximum length of a TCP packet, that is, 64 KB. Many implementations will pre-allocate some buffers when the link is established. The number of available sockets is limited. Many BSD-based operating systems have a default maximum number of connections that can be opened at the same time.

The Application of PDA for wireless handheld devices (such as browsers) [5] features: ① because the page is made for handheld devices, generally 1 K ~ 2 K bytes, relatively small; ② at present, the bandwidth of the wireless communication network is very narrow, and the bandwidth of the GSM data channel is only 9.6 K. Currently, most web page access uses HTTP and TCP as the lower-layer transmission control protocol. However, unfortunately, TCP is not suitable for short sessions. It is different from the current use of a single TCP transmission protocol for data transmission. This paper proposes a dynamic selection of Transport Layer Protocol (TCP and UDP) to improve page retrieval latency, network congestion, and server load.

This hybrid TCP-UDP method combines the advantages of two aspects: first, for the case of less data transmission, it will use UDP as the transport layer protocol, this avoids the overhead of multiple handshakes of TCP links. In addition, when more data transmission is required, it uses reliable TCP protocol with reordering and congestion control as the transport layer protocol. The implementation of hybrid TCP-UDP only needs to change the application layer, and the core code of the operating system does not need to be changed. The disadvantage of UDP protocol only lies in that a complex control protocol similar to TCP needs to be established at the application layer to achieve re-sorting and congestion control to ensure the reliability of transmission.

1 back scene

HTTP is a request/response protocol. The client application can obtain the required data from the server by providing a URL. HTTP can be used to access various types of resources, including text, graphics, audio and video, executable files, and database query results.

Figure 2 illustrates Packet Exchange between the client and the server after the client initiates an http get request. In the figure, only two data packets are useful (that is, they carry data): one is an http get request and the other is an HTTP response. The rest are the data packets that TCP uses for handshaking. Redirection is often used to reduce the load on Web servers. In this way, the redirection response packet sent from the server is a short packet. Using TCP as the transmission protocol requires at least 7 packets, while using UDP requires only 2 packets.

2 sets

We use the hybrid transport layer [6] method, that is, UDP is used for a small amount of data transmission links, while TCP is used for a large number of data transmission links as the transport layer protocol. In this way, the overhead of TCP handshakes is avoided for short links, while the advantages of TCP can still be obtained for long links, such as timeout retransmission, congestion control, and error recovery mechanism. In this method, the client first tries to use UDP as the transport layer protocol. If the requested url udp is not suitable, the TCP link is used again. This method provides the following guarantees:

◇ If the initial UDP packet is lost, the TCP relink will be used without any impact.

◇ If the linked server does not use the implementation mechanism of the hybrid transport layer, the client will use TCP to re-link.

Figure 3 shows the mixed TCP and UDP implementation algorithms. An HTTP client using a hybrid algorithm first uses UDP as the transport layer protocol to send an http get request and start the timeout timer.

When the server processes a request sent from the client, it can choose from the following two points:

① If the response data is small enough (for example, it can be put into a data packet), the server will send back the response using UDP. Such as small web pages or HTTP redirect responses.

② If the response data is large and cannot be put into a UDP packet, the server requires the client to use TCP to retry. This can be solved by adding an HTTP header field such as tcpretr.

On the client, the following three situations occur:

◇ The client receives a response from the server. If the response contains the required HTTP response, the client processes the data. If the server requires a client retry, the client uses TCP as the transport layer to retry.

◇ If the server does not process the HTTP packet transmitted through UDP, the client will receive an ICMP error message (the destination address cannot be reached/The Protocol cannot be reached ). In this case, the client will use TCP to retry.

◇ If the timer times out, the client should use TCP to retry.

Figure 4 shows the packet exchange between the client and the server when the timer times out. This timeout mechanism provides reliability and compatibility with servers that do not use a hybrid TCP-UDP method.

Figure 5 illustrates the packet exchange between the client and the server when the server requires the client to resend the request using TCP.

3. Knot

The hybrid TCP-UDP method improves three aspects involved in HTTP transmission: client, server, and network.

◇ For the client, the three-way handshake time introduced due to TCP can be avoided, thus reducing the browsing delay time.

◇ For servers, the number of TCP links required is reduced, which reduces the load on servers caused by the establishment, maintenance, and revocation of TCP links.

◇ For the network, the reduction of TCP Control data packets reduces network congestion.

 

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.