WO2011057525A1 - Http server based on packet processing and data processing method thereof - Google Patents

Http server based on packet processing and data processing method thereof Download PDF

Info

Publication number
WO2011057525A1
WO2011057525A1 PCT/CN2010/077486 CN2010077486W WO2011057525A1 WO 2011057525 A1 WO2011057525 A1 WO 2011057525A1 CN 2010077486 W CN2010077486 W CN 2010077486W WO 2011057525 A1 WO2011057525 A1 WO 2011057525A1
Authority
WO
WIPO (PCT)
Prior art keywords
data
http server
packet
data packet
network card
Prior art date
Application number
PCT/CN2010/077486
Other languages
French (fr)
Chinese (zh)
Inventor
张富春
Original Assignee
腾讯科技(深圳)有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 腾讯科技(深圳)有限公司 filed Critical 腾讯科技(深圳)有限公司
Publication of WO2011057525A1 publication Critical patent/WO2011057525A1/en

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/02Protocols based on web technology, e.g. hypertext transfer protocol [HTTP]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/16Implementation or adaptation of Internet protocol [IP], of transmission control protocol [TCP] or of user datagram protocol [UDP]
    • H04L69/161Implementation details of TCP/IP or UDP/IP stack architecture; Specification of modified or new header fields

Definitions

  • the present invention relates to the field of network technologies, and in particular, to an HTTP server based on packet processing and a data processing method thereof.
  • Hypertext Transfer Protocol ('HTTP') is a transport protocol for transferring hypertext from a web server to a local browser.
  • the current HTTP server is based on the Transmission Control Protocol (Transmission Control). Protocol, abbreviated as 'TCP', as shown in FIG. 3, the specific process of the HTTP server processing the data packet sent by the client is: the data packet sent by the client to the HTTP server is first processed by the network card driver.
  • 'TCP' Transmission Control Protocol
  • the network data frame is restored to an IP data packet; then the network card driver delivers the IP data packet to the protocol stack of the kernel, and the protocol stack parses the data packet, and when the TCP data packet is parsed, the serial number check and sort operations are performed, Ensure the reliability of TCP transmission; after the protocol stack is processed, the TCP socket of the application layer receives the message and parses it on the data content of the TCP protocol to obtain the HTTP data and enter the relevant logic processing of HTTP.
  • the above HTTP server processes the data packets sent by the client through layer layer resolution, layer-by-layer copying, and the processing logic is very complicated. Therefore, the number of connections supported by the HTTP server is very limited. For some small data volumes and applications that need to frequently interact with the server, when the current HTTP server faces a large number of requests from the client, the protocol stack consumes a large amount of system resources, so performance low.
  • the invention provides an HTTP server based on packet processing, which uses raw sockets to process data packets of a communication port.
  • the HTTP server receives the data sent by the client, and copies the data to the memory buffer of the application layer in a memory mapping manner after being processed by the network card driver.
  • the network card driver can be used to convert the received network data frame into an IP data packet.
  • the HTTP server constructs an IP data packet at the application layer, and sends the IP data packet to the IP protocol stack, and the IP data packet is sent to the network card driver by the IP protocol stack, and the network card driver processes the IP data packet and sends it to the client.
  • the network card driver can be used to convert IP data packets into network data frames.
  • the invention also provides an HTTP server data processing method, comprising: the HTTP server processing the data packet of the communication port by using the original socket.
  • the step of the HTTP server processing the data packet of the communication port by using the original socket may include:
  • the HTTP server receives the data sent by the client, and copies the data to the memory buffer of the application layer in a memory mapping manner after being processed by the network card driver.
  • the step of the network card driving process may specifically be: the network card driver converts the received network data frame into an IP data packet.
  • the step of processing, by the HTTP server, the data packet of the communication port by using the original socket may further include:
  • the HTTP server constructs an IP data packet at the application layer, and sends the IP data packet to the IP protocol stack, and the IP data packet is sent to the network card driver by the IP protocol stack, and the network card driver processes the IP data packet and sends it to the client.
  • the step of processing the IP data packet by the network card driver may specifically be: the network card driver converts the IP data packet into a network data frame.
  • An HTTP server based on packet processing comprising: a network card driver, receiving a data packet; a memory buffer copying the data packet processed by the network card driver in a memory mapping manner; and an HTTP server, using the original socket pair data The package is processed.
  • the network card driver converts the received network data frame into an IP data packet.
  • the packet processing-based HTTP server further includes an IP protocol stack; the HTTP server constructs an IP data packet at an application layer, and sends the IP data packet to an IP protocol stack, and the IP protocol stack transmits IP data.
  • the packet is sent to the network card driver, and the network card driver processes the IP data packet and sends it to the client.
  • the network card driver is configured to convert IP data packets into network data frames.
  • the above-mentioned packet processing-based HTTP server and its data processing method process the data packet of the communication port by using the original socket, and when the HTTP server receives the data sent by the client, it is not necessary to hand the data to the protocol stack, but directly
  • the data is copied to the memory buffer of the application layer in a memory-mapped manner, and the HTTP server can directly use the data, and does not need to go through other processing of the socket, thereby reducing a large part of system resource consumption.
  • the data packet Since the data processing of the HTTP server is implemented on the IP protocol level, the data packet does not enter the TCP protocol stack, thereby improving the response speed of the HTTP server, enabling the HTTP server to process the massive data request of the client; on the other hand, the HTTP server returns
  • the IP data packet is directly constructed by the application layer, and the IP data packet is sent to the IP protocol stack, and then sent by the IP protocol stack to the network card driver, because the performance of the data transmission of the original socket is much higher than that.
  • TCP sockets are sent for data, which also improves performance.
  • FIG. 1 is a schematic diagram of a client interacting with an HTTP server in an embodiment
  • FIG. 2 is a schematic diagram of an HTTP server data processing method in an embodiment
  • FIG. 3 is a schematic diagram of a prior art HTTP server data processing method.
  • the communication mode is a request-response mode.
  • the client sends a SYN packet to the HTTP server
  • the HTTP server sends a SYN+ACK packet to the client
  • the client sends a packet with the content GET to the HTTP server
  • the HTTP server returns a packet with a content of 200 OK to the client;
  • the SYN packet is a handshake packet
  • the ACK is a response packet
  • the FIN is an end packet.
  • the above steps (1) to (3) are typical TCP three-way handshake procedures
  • the GET packet is a request packet of the HTTP protocol, 200.
  • OK is the content package returned by the HTTP server to the client.
  • the first communication between the client and the HTTP server includes three data packets (SYN packets, ACK packets, and GET packets) sent by the client to the HTTP server and two data packets (ACK+SYN) that the HTTP server responds to the client.
  • Handshake reply packet and ACK+FIN with content of 200 OK's business-related response package).
  • the packet processing-based HTTP server processes the data packets of the communication port using the original socket.
  • the communication port here is the default port 80.
  • the original socket is a different network communication method than the TCP socket. It can collect the data packets of the link layer. Because the link layer is the IP protocol layer, IP. Above the protocol layer is the TCP protocol layer, and the original socket is the lowest level application programming interface (Application The Programming Interface (referred to as 'API') is therefore able to collect packets from all layers.
  • 'API' Application The Programming Interface
  • the packet processing-based HTTP server of the present invention includes: a network card driver, an IP protocol stack, a memory buffer, and an HTTP server;
  • the network card driver receives the data packet, and converts the received network data frame into an IP data packet and converts the IP data packet into a network data frame;
  • the memory buffer copies the data packet processed by the network card driver in a memory mapping manner
  • HTTP The server uses the original socket to process the data packet, constructs an IP data packet in the application layer, and sends the IP data packet to the IP protocol stack, and the IP protocol stack sends the IP data packet to the network card driver, and the network card driver drives the IP data packet. After processing, send it to the client.
  • the process of processing the data packet of the communication port by using the original socket by the HTTP server includes a process of receiving data sent by the client and a process of returning data to the client.
  • the process of the HTTP server receiving the data sent by the client is as follows: (1) The client sends data to the network card driver.
  • the network card driver receives the network data frame transmitted by the client through the network; (2) the network card driver converts the received network data frame into an IP data packet; and (3) the network card driver processes the obtained IP data packet into a memory mapped The way to copy the data to the memory buffer of the application layer. After IP packets are copied into memory, the HTTP server can use these packets directly without having to go through other socket processing.
  • the HTTP server responds to the client as follows: (1) The HTTP server constructs an IP packet at the application layer and sends the IP packet to the IP protocol stack; (2) The IP protocol stack sends the IP packet to NIC driver; (3) NIC driver to process IP packets. Specifically, the network card driver converts IP data packets into network data frames. (4) The network card driver sends the network data frame to the client through the network.
  • the above-described packet processing-based HTTP server and its data processing method are widely applicable to HTTP applications having a large number of requests and a very small amount of data transmission per request and response because of the high number of connections that can be supported.
  • statistics server such as counters on online advertising
  • chat server such as HTTP-based two-person chat or chat room
  • verification code server such as generating complex captcha pictures
  • avatar image server such as processing GZIP compressed Images smaller than 1460 bytes
  • other HTTP applications with less than 1460 bytes of request and response content are widely applicable to HTTP applications having a large number of requests and a very small amount of data transmission per request and response because of the high number of connections that can be supported.
  • chat server such as HTTP-based two-person chat or chat room
  • verification code server such as generating complex captcha pictures
  • avatar image server such as processing GZIP compressed Images smaller than 1460 bytes
  • other HTTP applications with less than 1460 bytes of request and response content such as processing GZIP compressed Images smaller than 1460 bytes

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer Security & Cryptography (AREA)
  • Computer And Data Communications (AREA)

Abstract

A Hyper Text Transfer Protocol (HTTP) server based on packet processing and the data processing method thereof are provided by the present invention. Said HTTP server processes the data packets on the communication ports with raw sockets, wherein, the HTTP server receives the data sent from a client, the network card driver processes said data, and the HTTP server copies the data to the memory buffer by the way of memory mapping; when sending data, the HTTP server constructs IP data packets on the application layer, and sends said IP data packets to an IP protocol stack. The IP protocol stack sends the IP data packets to the network card driver. The network card driver processes the IP data packets and sends them to the client. The HTTP server based on packet processing and the data processing method thereof provided by the present invention can support the mass data requests of the client, and have a better processing performance.

Description

基于包处理的HTTP服务器及其数据处理方法HTTP server based on packet processing and data processing method thereof
技术领域 Technical field
本发明涉及网络技术领域,更具体地说,涉及一种基于包处理的HTTP服务器及其数据处理方法。 The present invention relates to the field of network technologies, and in particular, to an HTTP server based on packet processing and a data processing method thereof.
背景技术Background technique
超文本传输协议(Hypertext Transfer Protocol,简称'HTTP ' )是用于从万维网服务器传输超文本到本地浏览器的传送协议。目前的HTTP服务器都是基于传输控制协议(Transmission Control Protocol,简称'TCP')之上实现的,如图3所示,该HTTP服务器处理客户端发送来的数据包的具体过程是:客户端发送到HTTP服务器的数据包首先由网卡驱动进行处理,将网络数据帧还原为IP数据包;然后网卡驱动将IP数据包交给内核的协议栈处理,协议栈对数据包进行解析,解析得到TCP数据包时则进行序列号核对、排序等操作,以确保TCP传输的可靠性;协议栈处理好后,应用层的TCP套接字则收到消息,在TCP协议的数据内容之上再进行解析,得到HTTP数据后进入HTTP的相关逻辑处理。  Hypertext Transfer Protocol ('HTTP') ) is a transport protocol for transferring hypertext from a web server to a local browser. The current HTTP server is based on the Transmission Control Protocol (Transmission Control). Protocol, abbreviated as 'TCP', as shown in FIG. 3, the specific process of the HTTP server processing the data packet sent by the client is: the data packet sent by the client to the HTTP server is first processed by the network card driver. The network data frame is restored to an IP data packet; then the network card driver delivers the IP data packet to the protocol stack of the kernel, and the protocol stack parses the data packet, and when the TCP data packet is parsed, the serial number check and sort operations are performed, Ensure the reliability of TCP transmission; after the protocol stack is processed, the TCP socket of the application layer receives the message and parses it on the data content of the TCP protocol to obtain the HTTP data and enter the relevant logic processing of HTTP.
上述HTTP服务器处理客户端发送来的数据包需经过层层解析,层层拷贝,处理逻辑十分复杂。因而,HTTP服务器支持的连接数非常有限,对于一些小数据量且需要频繁与服务器交互的应用场景,目前的HTTP服务器面对客户端的海量请求时,协议栈会消耗很大的系统资源,因此性能低下。 The above HTTP server processes the data packets sent by the client through layer layer resolution, layer-by-layer copying, and the processing logic is very complicated. Therefore, the number of connections supported by the HTTP server is very limited. For some small data volumes and applications that need to frequently interact with the server, when the current HTTP server faces a large number of requests from the client, the protocol stack consumes a large amount of system resources, so performance low.
发明内容Summary of the invention
基于此,有必要提供一种基于包处理的HTTP服务器,能处理客户端的海量数据请求且处理性能更好。 Based on this, it is necessary to provide a packet processing-based HTTP server that can handle massive data requests from clients and has better processing performance.
此外,还有必要提供一种HTTP服务器数据处理方法,能处理客户端的海量数据请求且处理性能更好。 In addition, it is necessary to provide an HTTP server data processing method that can handle massive data requests from clients and has better processing performance.
本发明提供了一种基于包处理的HTTP服务器,采用原始套接字对通讯端口的数据包进行处理。 The invention provides an HTTP server based on packet processing, which uses raw sockets to process data packets of a communication port.
优选地,HTTP服务器接收客户端发送的数据,经网卡驱动处理后以内存映射的方式将数据拷贝到应用层的内存缓冲区中。Preferably, the HTTP server receives the data sent by the client, and copies the data to the memory buffer of the application layer in a memory mapping manner after being processed by the network card driver.
进一步优选地,网卡驱动可用于将接收到的网络数据帧转换为IP数据包。 Further preferably, the network card driver can be used to convert the received network data frame into an IP data packet.
优选地, HTTP服务器在应用层构造IP数据包,并将IP数据包发送给IP协议栈,由IP协议栈将IP数据包发送给网卡驱动,网卡驱动对IP数据包进行处理后发送给客户端。 Preferably, The HTTP server constructs an IP data packet at the application layer, and sends the IP data packet to the IP protocol stack, and the IP data packet is sent to the network card driver by the IP protocol stack, and the network card driver processes the IP data packet and sends it to the client.
进一步优选地,网卡驱动可用于将IP数据包转换为网络数据帧。 Further preferably, the network card driver can be used to convert IP data packets into network data frames.
本发明还提供了一种HTTP服务器数据处理方法,包括:所述HTTP服务器采用原始套接字对通讯端口的数据包进行处理。 The invention also provides an HTTP server data processing method, comprising: the HTTP server processing the data packet of the communication port by using the original socket.
优选地,HTTP服务器采用原始套接字对通讯端口的数据包进行处理的步骤可包括: HTTP服务器接收客户端发送的数据,经网卡驱动处理后以内存映射的方式将数据拷贝到应用层的内存缓冲区中。 Preferably, the step of the HTTP server processing the data packet of the communication port by using the original socket may include: The HTTP server receives the data sent by the client, and copies the data to the memory buffer of the application layer in a memory mapping manner after being processed by the network card driver.
进一步优选地,网卡驱动处理的步骤具体可以是:网卡驱动将接收到的网络数据帧转换为IP数据包。 Further preferably, the step of the network card driving process may specifically be: the network card driver converts the received network data frame into an IP data packet.
优选地,HTTP服务器采用原始套接字对通讯端口的数据包进行处理的步骤还可包括: HTTP服务器在应用层构造IP数据包,并将IP数据包发送给IP协议栈,由IP协议栈将IP数据包发送给网卡驱动,网卡驱动对IP数据包进行处理后发送给客户端。 Preferably, the step of processing, by the HTTP server, the data packet of the communication port by using the original socket may further include: The HTTP server constructs an IP data packet at the application layer, and sends the IP data packet to the IP protocol stack, and the IP data packet is sent to the network card driver by the IP protocol stack, and the network card driver processes the IP data packet and sends it to the client.
进一步优选地,网卡驱动对IP数据包进行处理的步骤具体可是:网卡驱动将IP数据包转换为网络数据帧。 Further preferably, the step of processing the IP data packet by the network card driver may specifically be: the network card driver converts the IP data packet into a network data frame.
一种基于包处理的HTTP服务器,包括:网卡驱动,接收数据包;内存缓冲区,以内存映射的方式拷贝经所述网卡驱动处理后的数据包;以及HTTP服务器,采用原始套接字对数据包进行处理。 An HTTP server based on packet processing, comprising: a network card driver, receiving a data packet; a memory buffer copying the data packet processed by the network card driver in a memory mapping manner; and an HTTP server, using the original socket pair data The package is processed.
优选地,所述网卡驱动将接收到的网络数据帧转换为IP数据包。 Preferably, the network card driver converts the received network data frame into an IP data packet.
优选地,所述的基于包处理的HTTP服务器进一步包括IP协议栈;所述HTTP服务器在应用层构造IP数据包,并将所述IP数据包发送给IP协议栈,由IP协议栈将IP数据包发送给网卡驱动,所述网卡驱动对IP数据包进行处理后发送给客户端。 Preferably, the packet processing-based HTTP server further includes an IP protocol stack; the HTTP server constructs an IP data packet at an application layer, and sends the IP data packet to an IP protocol stack, and the IP protocol stack transmits IP data. The packet is sent to the network card driver, and the network card driver processes the IP data packet and sends it to the client.
进一步优选地,所述网卡驱动用于将IP数据包转换为网络数据帧。 Further preferably, the network card driver is configured to convert IP data packets into network data frames.
上述基于包处理的HTTP服务器及其数据处理方法,通过采用原始套接字对通讯端口的数据包进行处理,在HTTP服务器接收客户端发送的数据时,无需将数据交给协议栈,而是直接以内存映射的方式将数据拷贝到应用层的内存缓冲区中,HTTP服务器则可直接使用这些数据,不需要再经过套接字的其它处理,减少了很大部分的系统资源消耗。由于是在IP协议的层面上实现HTTP服务器的数据处理,数据包未进入TCP协议栈,因此提高了HTTP服务器的响应速度,使HTTP服务器能处理客户端的海量数据请求;另一方面,HTTP服务器返回数据给客户端时,直接由应用层构造好IP数据包,将IP数据包发送给IP协议栈,再由IP协议栈发送给网卡驱动,由于原始套接字的数据包发送的性能远高于TCP套接字的数据发送,因此也提高了性能。 The above-mentioned packet processing-based HTTP server and its data processing method process the data packet of the communication port by using the original socket, and when the HTTP server receives the data sent by the client, it is not necessary to hand the data to the protocol stack, but directly The data is copied to the memory buffer of the application layer in a memory-mapped manner, and the HTTP server can directly use the data, and does not need to go through other processing of the socket, thereby reducing a large part of system resource consumption. Since the data processing of the HTTP server is implemented on the IP protocol level, the data packet does not enter the TCP protocol stack, thereby improving the response speed of the HTTP server, enabling the HTTP server to process the massive data request of the client; on the other hand, the HTTP server returns When the data is sent to the client, the IP data packet is directly constructed by the application layer, and the IP data packet is sent to the IP protocol stack, and then sent by the IP protocol stack to the network card driver, because the performance of the data transmission of the original socket is much higher than that. TCP sockets are sent for data, which also improves performance.
附图说明DRAWINGS
图1是一个实施例中客户端与HTTP服务器进行交互的示意图; 1 is a schematic diagram of a client interacting with an HTTP server in an embodiment;
图2是一个实施例中HTTP服务器数据处理方法的原理图; 2 is a schematic diagram of an HTTP server data processing method in an embodiment;
图3是现有技术中HTTP服务器数据处理方法的原理图。 3 is a schematic diagram of a prior art HTTP server data processing method.
具体实施方式detailed description
由于HTTP协议的通讯过程一般都是短连接,通讯模式上是请求-响应模式。参照图1,客户端与HTTP服务器之间的一次交互过程如下: Since the communication process of the HTTP protocol is generally a short connection, the communication mode is a request-response mode. Referring to Figure 1, an interaction process between the client and the HTTP server is as follows:
(1)客户端发送SYN包给HTTP服务器; (1) The client sends a SYN packet to the HTTP server;
(2)HTTP服务器发送SYN+ACK包给客户端; (2) The HTTP server sends a SYN+ACK packet to the client;
(3)客户端发送ACK包给HTTP服务器; (3) The client sends an ACK packet to the HTTP server;
(4)客户端发送内容为GET的包给HTTP服务器; (4) The client sends a packet with the content GET to the HTTP server;
(5)HTTP服务器返回内容为200 OK的包给客户端; (5) The HTTP server returns a packet with a content of 200 OK to the client;
(6)数据发送完成后关闭连接。 (6) Close the connection after the data transmission is completed.
其中,SYN包是握手包,ACK是应答包,FIN是结束包,上述步骤(1)至(3)是典型的TCP三次握手过程;而GET包是HTTP协议的请求包,200 OK是HTTP服务器返回给客户端的内容包。由上述内容可知,客户端与HTTP服务器的一次通讯包括:客户端发送给HTTP服务器的三次数据包(SYN包、ACK包和GET包)和HTTP服务器响应给客户端的两次数据包(ACK+SYN的握手应答包和ACK+FIN且内容为200 OK的与业务相关的应答包)。 The SYN packet is a handshake packet, the ACK is a response packet, and the FIN is an end packet. The above steps (1) to (3) are typical TCP three-way handshake procedures; and the GET packet is a request packet of the HTTP protocol, 200. OK is the content package returned by the HTTP server to the client. It can be seen from the above that the first communication between the client and the HTTP server includes three data packets (SYN packets, ACK packets, and GET packets) sent by the client to the HTTP server and two data packets (ACK+SYN) that the HTTP server responds to the client. Handshake reply packet and ACK+FIN with content of 200 OK's business-related response package).
在一个实施方式中,本发明提供的基于包处理的HTTP服务器采用原始套接字对通讯端口的数据包进行处理。这里的通讯端口为默认的80端口,原始套接字是与TCP套接字不同的一种网络通信方式,其能够采集链路层的数据包,由于链路层之上是IP协议层,IP协议层之上是TCP协议层,而原始套接字是最底层的应用程序编程接口(Application Programming Interface,简称'API'),因此能够采集所有层的数据包。 In one embodiment, the packet processing-based HTTP server provided by the present invention processes the data packets of the communication port using the original socket. The communication port here is the default port 80. The original socket is a different network communication method than the TCP socket. It can collect the data packets of the link layer. Because the link layer is the IP protocol layer, IP. Above the protocol layer is the TCP protocol layer, and the original socket is the lowest level application programming interface (Application The Programming Interface (referred to as 'API') is therefore able to collect packets from all layers.
参见图2,本发明的基于包处理的HTTP服务器包括:网卡驱动、IP协议栈、内存缓冲区和HTTP服务器; Referring to FIG. 2, the packet processing-based HTTP server of the present invention includes: a network card driver, an IP protocol stack, a memory buffer, and an HTTP server;
网卡驱动接收数据包,并将接收到的网络数据帧转换为IP数据包以及将IP数据包转换为网络数据帧; The network card driver receives the data packet, and converts the received network data frame into an IP data packet and converts the IP data packet into a network data frame;
内存缓冲区以内存映射的方式拷贝经网卡驱动处理后的数据包; The memory buffer copies the data packet processed by the network card driver in a memory mapping manner;
HTTP 服务器采用原始套接字对数据包进行处理,在应用层构造IP数据包,并将IP数据包发送给IP协议栈,由IP协议栈将IP数据包发送给网卡驱动,网卡驱动对IP数据包进行处理后发送给客户端。 HTTP The server uses the original socket to process the data packet, constructs an IP data packet in the application layer, and sends the IP data packet to the IP protocol stack, and the IP protocol stack sends the IP data packet to the network card driver, and the network card driver drives the IP data packet. After processing, send it to the client.
在一个实施方式中,如图2所示,HTTP服务器采用原始套接字对通讯端口的数据包进行处理的过程包括接收客户端发送的数据的处理过程及返回数据至客户端的处理过程。其中,HTTP服务器接收客户端发送的数据的过程如下:(1)客户端发送数据至网卡驱动。网卡驱动接收的是客户端通过网络传送过来的网络数据帧;(2)网卡驱动将接收到的网络数据帧转换为IP数据包;(3)网卡驱动将处理得到的IP数据包以内存映射的方式将数据拷贝到应用层的内存缓冲区中。IP数据包复制到内存中后,HTTP服务器则可以直接使用这些数据包,而无需再经过套接字的其它处理过程。 In one embodiment, as shown in FIG. 2, the process of processing the data packet of the communication port by using the original socket by the HTTP server includes a process of receiving data sent by the client and a process of returning data to the client. The process of the HTTP server receiving the data sent by the client is as follows: (1) The client sends data to the network card driver. The network card driver receives the network data frame transmitted by the client through the network; (2) the network card driver converts the received network data frame into an IP data packet; and (3) the network card driver processes the obtained IP data packet into a memory mapped The way to copy the data to the memory buffer of the application layer. After IP packets are copied into memory, the HTTP server can use these packets directly without having to go through other socket processing.
如图2所示,HTTP服务器响应客户端的过程如下:(1)HTTP服务器在应用层构造IP数据包,并将IP数据包发送给IP协议栈;(2)IP协议栈将IP数据包发送给网卡驱动;(3)网卡驱动对IP数据包进行处理。具体地,网卡驱动是将IP数据包转换为网络数据帧。(4)网卡驱动将网络数据帧通过网络发送到客户端。 As shown in Figure 2, the HTTP server responds to the client as follows: (1) The HTTP server constructs an IP packet at the application layer and sends the IP packet to the IP protocol stack; (2) The IP protocol stack sends the IP packet to NIC driver; (3) NIC driver to process IP packets. Specifically, the network card driver converts IP data packets into network data frames. (4) The network card driver sends the network data frame to the client through the network.
上述基于包处理的HTTP服务器及其数据处理方法,数据在处理的过程中只需要复制一次,而不需要层层复制,因此数据处理的流程减少了,对于应用程序而言,接收数据的流程也更简单,其能支持的连接数将更高。由于HTTP服务器的数据处理过程是在IP协议的层面上实现,数据包未进入TCP协议栈,因此HTTP服务器的响应速度更快,且对服务器的消耗更小。另外,上述基于包处理的HTTP服务器由于绕过了TCP协议栈,因此服务器端并不需要保存客户端和服务器的连接状态,当客户端发起针对TCP协议栈的攻击时,对该基于包处理的HTTP服务器并不适用,因此能有效抵制恶意的SYN FLOOD或慢连接。 In the above-mentioned packet processing-based HTTP server and its data processing method, data only needs to be copied once in the process of processing, and no layer-level copying is required, so the flow of data processing is reduced, and for the application, the process of receiving data is also Simpler, the number of connections it can support will be higher. Since the data processing process of the HTTP server is implemented at the level of the IP protocol, the data packet does not enter the TCP protocol stack, so the response speed of the HTTP server is faster and the consumption of the server is smaller. In addition, since the above-mentioned packet processing-based HTTP server bypasses the TCP protocol stack, the server side does not need to save the connection state between the client and the server. When the client initiates an attack against the TCP protocol stack, the packet processing is performed. HTTP server is not applicable, so it can effectively resist malicious SYN FLOOD or slow connection.
上述基于包处理的HTTP服务器及其数据处理方法,由于可支持的连接数很高,可广泛应用于具有海量请求数且每次请求和响应的数据传输量非常小的HTTP应用。例如:统计服务器(如网络广告上的计数器)、聊天服务器(如基于HTTP的双人聊天或者聊天室)、验证码服务器(如生成复杂的验证码图片)、头像图片服务器(如处理GZIP压缩后的小于1460字节的图片)、以及其它请求和响应内容小于1460字节的HTTP应用。 The above-described packet processing-based HTTP server and its data processing method are widely applicable to HTTP applications having a large number of requests and a very small amount of data transmission per request and response because of the high number of connections that can be supported. For example: statistics server (such as counters on online advertising), chat server (such as HTTP-based two-person chat or chat room), verification code server (such as generating complex captcha pictures), avatar image server (such as processing GZIP compressed Images smaller than 1460 bytes), and other HTTP applications with less than 1460 bytes of request and response content.
以上所述仅为本发明的较佳实施例而已,并不用以限制本发明,凡在本发明的精神和原则之内所作的任何修改、等同替换和改进等,均应包含在本发明的保护范围之内。 The above is only the preferred embodiment of the present invention, and is not intended to limit the present invention. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the protection of the present invention. Within the scope.

Claims (14)

  1. 一种基于包处理的HTTP服务器,其特征在于,所述HTTP服务器采用原始套接字对通讯端口的数据包进行处理。  An HTTP server based on packet processing, characterized in that the HTTP server processes the data packet of the communication port by using the original socket.
  2. 根据权利要求1所述的基于包处理的HTTP服务器,其特征在于,所述HTTP服务器接收客户端发送的数据,经网卡驱动处理后以内存映射的方式将数据拷贝到应用层的内存缓冲区中。 The packet processing-based HTTP server according to claim 1, wherein the HTTP server receives the data sent by the client, and copies the data to the memory buffer of the application layer in a memory mapping manner after being processed by the network card driver. .
  3. 根据权利要求2所述的基于包处理的HTTP服务器,其特征在于,所述网卡驱动用于将接收到的网络数据帧转换为IP数据包。 The packet processing based HTTP server of claim 2, wherein the network card driver is configured to convert the received network data frame into an IP data packet.
  4. 根据权利要求1至3中任一项所述的基于包处理的HTTP服务器,其特征在于,所述HTTP服务器在应用层构造IP数据包,并将所述IP数据包发送给IP协议栈,由IP协议栈将IP数据包发送给网卡驱动,所述网卡驱动对IP数据包进行处理后发送给客户端。 The packet processing-based HTTP server according to any one of claims 1 to 3, wherein the HTTP server constructs an IP data packet at an application layer, and transmits the IP data packet to an IP protocol stack, The IP protocol stack sends the IP data packet to the network card driver, and the network card driver processes the IP data packet and sends it to the client.
  5. 根据权利要求4所述的基于包处理的HTTP服务器,其特征在于,所述网卡驱动用于将IP数据包转换为网络数据帧。 The packet processing-based HTTP server according to claim 4, wherein the network card driver is configured to convert an IP data packet into a network data frame.
  6. 一种HTTP服务器数据处理方法,其特征在于,所述方法包括:An HTTP server data processing method, the method comprising:
    所述HTTP服务器采用原始套接字对通讯端口的数据包进行处理。The HTTP server processes the data packets of the communication port using the original socket.
  7. 根据权利要求6所述的HTTP服务器数据处理方法,其特征在于,所述HTTP服务器采用原始套接字对通讯端口的数据包进行处理的步骤包括:The HTTP server data processing method according to claim 6, wherein the step of processing, by the HTTP server, the data packet of the communication port by using the original socket comprises:
    所述HTTP服务器接收客户端发送的数据,经网卡驱动处理后以内存映射的方式将数据拷贝到应用层的内存缓冲区中。The HTTP server receives the data sent by the client, and copies the data to the memory buffer of the application layer in a memory mapping manner after being processed by the network card driver.
  8. 根据权利要求7所述的HTTP服务器数据处理方法,其特征在于,所述网卡驱动处理的步骤具体是:所述网卡驱动将接收到的网络数据帧转换为IP数据包。 The HTTP server data processing method according to claim 7, wherein the step of the network card driving process is specifically: the network card driver converts the received network data frame into an IP data packet.
  9. 根据权利要求6至8中任一项所述的 HTTP服务器数据处理方法,其特征在于,所述HTTP服务器采用原始套接字对通讯端口的数据包进行处理的步骤还包括:A method according to any one of claims 6 to 8 The HTTP server data processing method is characterized in that: the step of processing, by the HTTP server, the original socket to process the data packet of the communication port further includes:
    所述HTTP服务器在应用层构造IP数据包,并将所述IP数据包发送给IP协议栈,由IP协议栈将IP数据包发送给网卡驱动,所述网卡驱动对IP数据包进行处理后发送给客户端。The HTTP server constructs an IP data packet at the application layer, and sends the IP data packet to the IP protocol stack, and the IP data packet sends the IP data packet to the network card driver, and the network card driver processes the IP data packet and sends the IP data packet. To the client.
  10. 根据权利要求9所述的HTTP服务器数据处理方法,其特征在于,所述网卡驱动对IP数据包进行处理的步骤具体是:所述网卡驱动将IP数据包转换为网络数据帧。 The HTTP server data processing method according to claim 9, wherein the step of processing the IP data packet by the network card driver is specifically: the network card driver converts the IP data packet into a network data frame.
  11. 一种基于包处理的HTTP服务器,其特征在于,包括:An HTTP server based on packet processing, characterized in that it comprises:
    网卡驱动, 接收数据包;Network card driver, receiving data packets;
    内存缓冲区,以内存映射的方式拷贝经所述网卡驱动处理后的数据包;a memory buffer that copies the data packet processed by the network card driver in a memory mapped manner;
    以及HTTP 服务器,采用原始套接字对数据包进行处理。And an HTTP server that processes the packet with raw sockets.
  12. 根据权利要求11所述的基于包处理的HTTP服务器,其特征在于,所述网卡驱动将接收到的网络数据帧转换为IP数据包。 The packet processing-based HTTP server according to claim 11, wherein said network card driver converts the received network data frame into an IP data packet.
  13. 根据权利要求11或12所述的基于包处理的HTTP服务器,其特征在于,进一步包括IP协议栈;所述HTTP服务器在应用层构造IP数据包,并将所述IP数据包发送给IP协议栈,由IP协议栈将IP数据包发送给网卡驱动,所述网卡驱动对IP数据包进行处理后发送给客户端。 The packet processing-based HTTP server according to claim 11 or 12, further comprising an IP protocol stack; the HTTP server constructs an IP data packet at an application layer, and transmits the IP data packet to an IP protocol stack The IP data packet is sent by the IP protocol stack to the network card driver, and the network card driver processes the IP data packet and sends it to the client.
  14. 根据权利要求13所述的基于包处理的HTTP服务器,其特征在于,所述网卡驱动用于将IP数据包转换为网络数据帧。 The packet processing based HTTP server of claim 13, wherein the network card driver is configured to convert an IP data packet into a network data frame.
PCT/CN2010/077486 2009-11-10 2010-09-29 Http server based on packet processing and data processing method thereof WO2011057525A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN200910193804.7A CN102055774B (en) 2009-11-10 2009-11-10 Based on http server and the data processing method thereof of bag process
CN200910193804.7 2009-11-10

Publications (1)

Publication Number Publication Date
WO2011057525A1 true WO2011057525A1 (en) 2011-05-19

Family

ID=43959700

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2010/077486 WO2011057525A1 (en) 2009-11-10 2010-09-29 Http server based on packet processing and data processing method thereof

Country Status (2)

Country Link
CN (1) CN102055774B (en)
WO (1) WO2011057525A1 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109194747A (en) * 2018-09-10 2019-01-11 四川长虹电器股份有限公司 Traffic mirroring method and system under cloud environment

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102202094A (en) * 2011-05-13 2011-09-28 中兴通讯股份有限公司 Method and device for processing service request based on HTTP (hyper text transfer protocol)
CN102685243B (en) * 2012-05-22 2015-03-04 清华大学 Realizing method of light-weight TCP (Transmission Control Protocol)/IP (Internet Protocol) stack
CN102984025B (en) * 2012-11-23 2015-09-30 华为技术有限公司 The method of testing of gateway device virtual tunnel performance, Apparatus and system
KR102244824B1 (en) 2014-08-28 2021-04-27 삼성전자주식회사 Electronic apparatus and method for ip network service
CN106706657A (en) * 2015-11-17 2017-05-24 北大方正集团有限公司 On-line detection system and method based on ink jet printing

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1435773A (en) * 2002-01-29 2003-08-13 深圳市中兴通讯股份有限公司上海第二研究所 Virtual network card system based on multiple processors and communication method thereof
US7313600B1 (en) * 2000-11-30 2007-12-25 Cisco Technology, Inc. Arrangement for emulating an unlimited number of IP devices without assignment of IP addresses

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7313600B1 (en) * 2000-11-30 2007-12-25 Cisco Technology, Inc. Arrangement for emulating an unlimited number of IP devices without assignment of IP addresses
CN1435773A (en) * 2002-01-29 2003-08-13 深圳市中兴通讯股份有限公司上海第二研究所 Virtual network card system based on multiple processors and communication method thereof

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
ZHANG WEI CHENG ET AL.: "The Application of Raw Socket Programming in Embedded Internet Communication Protocol.", APPLICATION RESEARCH OF COMPUTERS., vol. 2002, no. 10, December 2002 (2002-12-01), pages 29 - 30, 74 *

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109194747A (en) * 2018-09-10 2019-01-11 四川长虹电器股份有限公司 Traffic mirroring method and system under cloud environment

Also Published As

Publication number Publication date
CN102055774B (en) 2015-09-16
CN102055774A (en) 2011-05-11

Similar Documents

Publication Publication Date Title
US8458280B2 (en) Apparatus and method for packet transmission over a high speed network supporting remote direct memory access operations
US7716731B2 (en) Method for dynamically tunneling over an unreliable protocol or a reliable protocol, based on network conditions
US7817634B2 (en) Network with a constrained usage model supporting remote direct memory access
TWI677222B (en) Connection establishment method and device applied to server load balancing
KR100255501B1 (en) Improving session and transport layer proxies via tcp glue
US7761588B2 (en) System and article of manufacture for enabling communication between nodes
JP4903270B2 (en) How to remove redundant connections
US7966380B2 (en) Method, system, and program for forwarding messages between nodes
WO2011057525A1 (en) Http server based on packet processing and data processing method thereof
US20060031518A1 (en) Method and apparatus for transparent negotiations
US20070025374A1 (en) TCP normalization engine
US20080304481A1 (en) System and Method of Offloading Protocol Functions
Natarajan et al. SCTP: An innovative transport layer protocol for the web
AU2007320794A1 (en) Selective session interception method
JP6444988B2 (en) Communication system using HTTP
JP2017118545A5 (en)
KR20050026881A (en) Method and computer program product for multiple offload of network state objects with support for failover events
US20150288763A1 (en) Remote asymmetric tcp connection offload over rdma
CN105791239B (en) A kind of TCP go-between processing method
JP3988475B2 (en) Transmitting apparatus, receiving apparatus and methods thereof
CN111314447B (en) Proxy server and method for processing access request thereof
CN101064671A (en) Method for processing P2P technique based network video signal
CN100423513C (en) Merging method with TCP connection
Dalessandro et al. AcceleratingWeb Protocols Using RDMA
JP2010153944A (en) Communication system, receiver, transmitter and communication method

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 10829489

Country of ref document: EP

Kind code of ref document: A1

WWE Wipo information: entry into national phase

Ref document number: 3286/CHENP/2012

Country of ref document: IN

NENP Non-entry into the national phase

Ref country code: DE

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 10/10/2012)

122 Ep: pct application non-entry in european phase

Ref document number: 10829489

Country of ref document: EP

Kind code of ref document: A1