WO2015113435A1 - 基于并行协议栈实例的数据包处理方法和装置 - Google Patents

基于并行协议栈实例的数据包处理方法和装置 Download PDF

Info

Publication number
WO2015113435A1
WO2015113435A1 PCT/CN2014/091614 CN2014091614W WO2015113435A1 WO 2015113435 A1 WO2015113435 A1 WO 2015113435A1 CN 2014091614 W CN2014091614 W CN 2014091614W WO 2015113435 A1 WO2015113435 A1 WO 2015113435A1
Authority
WO
WIPO (PCT)
Prior art keywords
protocol stack
stack instance
protocol
data packet
target socket
Prior art date
Application number
PCT/CN2014/091614
Other languages
English (en)
French (fr)
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 华为技术有限公司
Priority to JP2016549111A priority Critical patent/JP6359111B2/ja
Priority to EP14880468.5A priority patent/EP3091706B1/en
Publication of WO2015113435A1 publication Critical patent/WO2015113435A1/zh
Priority to US15/222,753 priority patent/US10069947B2/en

Links

Images

Classifications

    • 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
    • H04L69/162Implementation details of TCP/IP or UDP/IP stack architecture; Specification of modified or new header fields involving adaptations of sockets based mechanisms
    • 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/30Definitions, standards or architectural aspects of layered protocol stacks

Definitions

  • the present invention relates to communication technologies, and in particular, to a data packet processing method and apparatus based on an example of a parallel protocol stack.
  • a parallel protocol stack instance includes at least two protocol stack instances, each protocol stack instance running on a virtual CPU (VCPU) of the CPU, using a socket associated with the exclusive protocol stack instance The way to avoid the competition between the above multi-protocol stack instances.
  • VCPU virtual CPU
  • each protocol stack instance may perform protocol processing on the data packets in parallel by using a socket associated with the protocol stack instance.
  • the application specifies the association relationship between the socket and the protocol stack instance when instructing to create the socket required for the foregoing protocol processing, so that only the associated protocol stack instance specified by the APP occupies the socket pair data.
  • the packet is processed by the protocol.
  • the instance of the protocol stack to which the network card diverts the data packet is different from the protocol stack instance associated with the socket specified by the APP, the instance of the protocol stack specified by the APP conflicts with the protocol stack instance specified by the network card. In the case, the packet cannot be processed by the protocol.
  • an embodiment of the present invention provides a data packet processing method and apparatus based on an example of a parallel protocol stack.
  • the first aspect provides a packet processing method based on a parallel protocol stack instance, where the parallel protocol stack instance includes at least a first protocol stack instance and a second protocol stack instance, and the method includes: utilizing the first protocol The stack instance feeds the data packet that the network card offloads to the first protocol stack instance. Performing a low-level protocol processing; determining a target socket socket required for performing processing of the upper layer protocol on the data packet processed by the lower layer protocol; determining, according to the target socket, a second protocol stack instance associated with the target socket Performing, by using the target socket and the second protocol stack instance, the upper layer protocol processing on the data packet processed by the low layer protocol; wherein the low layer protocol processing and the upper layer protocol processing jointly complete the The complete protocol processing of the data packet.
  • the determining, according to the target socket, the second protocol stack instance associated with the target socket including: according to the target socket and the location in the affinity map Determining an affinity between each protocol stack instance included in the parallel protocol stack instance, determining the second protocol stack instance associated with the target socket; between the target socket and each of the protocol stack instances
  • the affinity is used to indicate the number of data packets that need to be processed by the upper layer protocol by using the target socket in the data packet that the network card has been offloaded to each protocol stack instance.
  • the target socket and the parallel protocol stack instance included in the affinity map are included
  • the affinity between the protocol stack instances, before determining the second protocol stack instance associated with the target socket further includes: updating the pro according to the number of the data packets processed by the lower layer protocol And the affinity between the target socket and the first protocol stack instance recorded in the sex map.
  • the method further includes: determining whether n ⁇ A is greater than B, where A is the target socket and the first Affinity between protocol stack instances, B is the affinity between the target socket and the associated protocol stack instance recorded in the affinity map, n is a preset coefficient; An affinity between the target socket in the sex map and each protocol stack instance included in the parallel protocol stack instance, determining the second protocol stack instance associated with the target socket, including: if n ⁇ A Not greater than B, determining an instance of the protocol stack associated with the target socket recorded in the affinity map as the second protocol stack instance associated with the target socket.
  • the target socket and the parallel protocol stack instance included in the affinity map are included Affinity between the protocol stack instances, determining the second protocol stack instance associated with the target socket, further comprising: if n ⁇ A is greater than B, determining the first protocol stack instance as And the second protocol stack instance associated with the target socket, and updating the protocol stack instance associated with the target socket recorded in the affinity map to the first protocol stack instance.
  • the determining, by using the target socket socket required for performing upper layer protocol processing on the data packet processed by the low layer protocol includes: in a socket table Performing a search to obtain the target socket required for performing upper layer protocol processing on the data packet processed by the lower layer protocol.
  • the performing, by using the target socket and the second protocol stack instance, performing the upper layer protocol processing on the data packet processed by the low layer protocol includes: adding, by the lower layer protocol, the data packet to an underlying data receiving queue of the target socket; and when the linked list is associated according to the protocol stack instance corresponding to the second protocol stack instance, polling the And performing the upper layer protocol processing on the data packet in the bottom data receiving queue by using the second protocol stack instance; the protocol stack instance association list corresponding to the second protocol stack instance is used to indicate The second protocol stack instance has a socket of an association relationship.
  • the method further includes: utilizing The parent protocol stack instance of each protocol stack instance included in the parallel protocol stack instance creates the target socket that has no association relationship with each protocol stack instance; the parent protocol stack instance is that the application APP adopts random The mode or parameter specification mode or load balancing mode is selected.
  • the method further includes: receiving a first data packet sent by the application APP, and determining a required protocol for performing the protocol processing on the first data packet. Determining a target socket; determining the second association associated with the target socket The stack instance is configured to perform protocol processing on the first data packet by using the target socket and the second protocol stack instance.
  • the second aspect provides a packet processing method based on a parallel protocol stack instance, where the parallel protocol stack instance includes at least a first protocol stack instance and a second protocol stack instance, where the method includes: receiving an application APP a data packet; determining a target socket socket required for protocol processing of the first data packet; determining, according to an association relationship between the target socket and the second protocol stack instance, the first node associated with the target socket
  • the second protocol stack is configured to perform protocol processing on the first data packet by using the target socket and the second protocol stack instance; wherein, the association relationship between the target socket and the second protocol stack instance is Determining, when the first protocol stack instance and the second protocol stack instance perform protocol processing on the second data packet, the first protocol stack instance performs low-level protocol processing on the second data packet, where the second protocol The stack instance performs upper layer protocol processing on the second data packet, where the lower layer protocol processing and the upper layer protocol processing together complete a complete protocol for the second data packet .
  • the performing, by using the target socket and the second protocol stack instance, performing protocol processing on the first data packet including: using the first data packet Adding to the APP data sending queue of the target socket; when the APP data sending queue of the target socket is polled according to the protocol stack instance associated with the second protocol stack instance, the target socket and the target socket are used.
  • the second protocol stack instance performs low-level protocol processing and upper layer protocol processing on the first data packet in the APP data sending queue respectively; the protocol stack instance association linked list corresponding to the second protocol stack instance is used to indicate The second protocol stack instance has a socket of an association relationship.
  • the determining, according to the association relationship between the target socket and the second protocol stack instance, the second protocol stack instance associated with the target socket including: according to affinity And determining, by the sex map, whether the target socket has an associated protocol stack instance; the affinity map is used to record a protocol stack instance associated with the target socket; and if the target socket has an associated protocol stack instance, determining The protocol stack instance associated with the target socket is the second protocol stack instance.
  • the method further includes: if the target socket does not have an associated protocol stack instance, the control message is Adding to the receiving queue of the parent protocol stack instance of the target socket; the parent protocol stack instance of the target socket is a protocol stack instance for creating the target socket; The message is used to perform protocol processing on the first data packet; when the control message in the receive queue of the parent protocol stack instance is polled, the control message is parsed to obtain the first a data packet; performing protocol processing on the first data packet by using the parent protocol stack instance; and updating a protocol stack instance associated with the target socket recorded in the affinity map to the parent protocol stack instance.
  • the determining a target socket socket required for performing protocol processing on the first data packet includes: performing a retrieval in a socket table, and determining a protocol required for performing protocol processing on the first data packet The target socket.
  • the method before determining the target socket socket required for performing protocol processing on the first data packet, further includes: using the parent protocol stack instance, creating the target socket that has no association relationship with each protocol stack instance included in the parallel protocol stack instance, where the parent protocol stack instance is that the APP adopts a random manner or The parameter specification mode or load balancing mode is selected in each of the protocol stack instances.
  • the method further includes: adding the first data packet processed by the protocol to the network card
  • the sending queue is configured to enable the network card to send the first data packet after the protocol processing.
  • a third aspect provides a packet processing apparatus based on a parallel protocol stack instance, where the parallel protocol stack instance includes at least a first protocol stack instance and a second protocol stack instance, and the apparatus includes: a low layer processing module, configured to: Determining, by the first protocol stack instance, the data packet that is offloaded by the network card to the first protocol stack instance, and the first determining module, configured to determine, by using the low-layer protocol, the data packet
  • the upper layer protocol is configured to process the required target socket socket;
  • the second determining module is configured to determine, according to the target socket, a second protocol stack instance associated with the target socket; and an upper layer processing module, configured to use the target socket And performing, by the second protocol stack instance, the upper layer protocol processing on the data packet processed by the low layer protocol; wherein the low layer protocol processing module and the upper layer protocol processing module jointly complete the data packet Complete protocol processing.
  • the second determining module is specifically configured to use, between the target socket included in the affinity map and each protocol stack instance included in the parallel protocol stack instance. Affinity, determining the second protocol stack instance associated with the target socket; affinity between the target socket and each of the protocol stack instances is used to indicate the network card to each of In the data packet that has been offloaded by the protocol stack instance, the number of data packets that need to be processed by the upper layer protocol by using the target socket is required.
  • the device further includes: an update module, configured to process the data according to the low layer protocol The number of packets is updated to update the affinity between the target socket and the first protocol stack instance described in the affinity map.
  • the device further includes: a determining module, configured to determine whether n ⁇ A is greater than B, where For the affinity between the target socket and the first protocol stack instance, B is the affinity between the target socket and the associated protocol stack instance recorded in the affinity map, where n is a second determining module, comprising: a first determining unit, configured to determine, if n ⁇ A is not greater than B, an instance of a protocol stack associated with the target socket recorded in the affinity map As the second protocol stack instance associated with the target socket.
  • the second determining module further includes: a second determining unit, configured to: if n ⁇ A is greater than B And determining, by the first protocol stack instance, the second protocol stack instance associated with the target socket, and updating the protocol stack instance associated with the target socket recorded in the affinity map to The first protocol stack instance is described.
  • the first determining module is specifically configured to perform a search in the socket table, and obtain an upper layer protocol processing process on the data packet processed by the low layer protocol.
  • the target socket required.
  • the upper layer processing module includes: a queue unit, configured to add the data packet processed by the low layer protocol to the target The lower layer data receiving queue of the socket; the upper layer processing unit is configured to use the second protocol stack instance pair when polling the target socket according to the protocol stack instance association list corresponding to the second protocol stack instance The data packet in the underlying data receiving queue is processed by the upper layer protocol; the protocol stack instance association list corresponding to the second protocol stack instance is used to indicate a socket that has an association relationship with the second protocol stack instance.
  • the device further includes: a creating module, configured to use one of the protocol stack instances included in the protocol stack instance included in the parallel protocol stack instance, The target socket is not associated with each protocol stack instance; the parent protocol stack instance is selected by the application APP in a random manner, a parameter specification manner, or a load balancing manner.
  • the device further includes: a receiving module, configured to receive a first data packet sent by the application APP, where the first determining module is further used Determining the target socket socket required for protocol processing of the first data packet; the second determining module is further configured to determine the target required for protocol processing of the first data packet After the socket socket, the second protocol stack instance associated with the target socket is determined; a protocol processing module is configured to perform the first data packet by using the target socket and the second protocol stack instance Protocol processing.
  • a fourth aspect is to provide a data packet processing apparatus based on a parallel protocol stack instance, where the parallel protocol stack instance includes at least a first protocol stack instance and a second protocol stack instance, and the apparatus includes: a receiving module, configured to receive a first data packet sent by the application, a first determining module, configured to determine a target socket socket required for protocol processing of the first data packet, and a second determining module, configured to use the target socket and the first Determining, by the second protocol stack instance, the second protocol stack instance associated with the target socket; the first processing module, configured to use the target socket and the second protocol stack instance, to perform the first The data packet is subjected to protocol processing; wherein the association between the target socket and the second protocol stack instance is determined when the first protocol stack instance and the second protocol stack instance perform protocol processing on the second data packet The first protocol stack instance performs low layer protocol processing on the second data packet, and the second protocol stack instance pairs the second data packet Performing upper layer protocol processing, the low layer protocol processing and the upper layer protocol processing together complete complete protocol processing on the
  • the first processing module includes: a queue unit, configured to add the first data packet to an APP data sending queue of the target socket; And when the APP data sending queue of the target socket is polled according to the protocol stack instance association list corresponding to the second protocol stack instance, using the target socket and the second protocol stack instance to The first data packet in the APP data sending queue is respectively subjected to low layer protocol processing and upper layer protocol processing; the protocol stack instance association list corresponding to the second protocol stack instance is used to indicate that the second protocol stack instance has an association relationship with the second protocol stack instance. Socket.
  • the second determining module includes: a determining unit, configured to determine, according to the affinity map, whether the target socket has an associated protocol stack instance;
  • the sufficiency map is used to record the protocol stack instance associated with the target socket, and the determining unit is configured to determine, if the target socket has an associated protocol stack instance, the protocol stack instance associated with the target socket is The second protocol stack instance is described.
  • the device further includes: a queue module, configured to: if the target socket does not have an associated protocol stack For example, the control message is added to the receive queue of the parent protocol stack instance of the target socket; the parent protocol stack instance of the target socket is a protocol stack instance for creating the target socket; the control message is used for Instructing to perform protocol processing on the first data packet; the parsing module is configured to parse the control message when the control message in the receive queue of the parent protocol stack instance is polled, to obtain the a data packet; a second processing module, configured to perform protocol processing on the first data packet by using the parent protocol stack instance; and an update module, configured to associate the target socket recorded in the affinity map The protocol stack instance is updated to the parent stack instance.
  • a queue module configured to: if the target socket does not have an associated protocol stack For example, the control message is added to the receive queue of the parent protocol stack instance of the target socket; the parent protocol stack instance of the target socket is a protocol stack instance for creating the target socket; the control message is used for Instruct
  • the first determining module is specifically configured to perform a retrieval in the socket table, and determine the target socket required for performing protocol processing on the first data packet.
  • the device further includes: a creating module, by using the parent protocol stack instance, creating and None of the protocol stack instances included in the parallel protocol stack instance have the associated relationship Socket, the parent protocol stack instance is selected by the APP in a random manner or a parameter specification manner or a load balancing manner in the protocol stack instances.
  • the device further includes: a sending module, configured to add the first data packet processed by the protocol to a sending queue of the network card, so that the network card sends the first after the protocol processing data pack.
  • the method and the device provided by the embodiment of the present invention perform low-level protocol processing on a data packet that is offloaded to the first protocol stack instance by using the first protocol stack instance, and determine a target required for performing upper-layer protocol processing on the data packet processed by the low-layer protocol.
  • the associated second protocol stack instance is determined by the target socket, and the target protocol and the second protocol stack instance are used to perform upper layer protocol processing on the data packet processed by the lower layer protocol, because the protocol processing is completed by different protocol stacks respectively.
  • the lower layer protocol processing part and the upper layer protocol processing part determine the second protocol stack instance that is processed by the upper layer protocol through the target socket, thereby solving the problem that the protocol stack instance specified by the APP conflicts with the protocol stack instance specified by the network card.
  • FIG. 1 is a schematic flowchart of a data packet processing method based on an example of a parallel protocol stack according to an embodiment of the present invention
  • FIG. 2 is a schematic flowchart of another method for processing a data packet based on an example of a parallel protocol stack according to an embodiment of the present invention
  • FIG. 3 is a schematic flowchart of a data packet processing method based on an example of a parallel protocol stack according to another embodiment of the present invention.
  • FIG. 4 is a schematic flowchart of another method for processing a data packet based on an example of a parallel protocol stack according to another embodiment of the present invention.
  • FIG. 5 is a packet processing device based on an example of a parallel protocol stack according to an embodiment of the present invention. Schematic diagram of the structure
  • FIG. 6 is a schematic structural diagram of another data packet processing apparatus based on an example of a parallel protocol stack according to an embodiment of the present invention.
  • FIG. 7 is a schematic structural diagram of a data packet processing apparatus based on an example of a parallel protocol stack according to another embodiment of the present invention.
  • FIG. 8 is a schematic structural diagram of another data packet processing apparatus based on an example of a parallel protocol stack according to another embodiment of the present invention.
  • FIG. 9 is a schematic structural diagram of a data packet processing apparatus based on an example of a parallel protocol stack according to another embodiment of the present invention.
  • FIG. 10 is a schematic structural diagram of another data packet processing apparatus based on an example of a parallel protocol stack according to another embodiment of the present invention.
  • FIG. 1 is a schematic flowchart of a data packet processing method based on a parallel protocol stack instance according to an embodiment of the present invention.
  • the method provided in this embodiment is performed by a parallel protocol stack instance, and the parallel protocol stack instance includes at least a first
  • the protocol stack instance and the second protocol stack instance, as shown in Figure 1, include:
  • the network card includes multiple physical queues, and the data packet that is offloaded to the first protocol stack instance is obtained from the physical queue corresponding to the first protocol stack instance, and the data packet is processed by the first protocol stack instance.
  • the low-level protocol processing can be handled by the three layers and below specified in the Open System Interconnect (OSI).
  • OSI Open System Interconnect
  • the search is performed in the socket table to obtain a target socket required for performing upper layer protocol processing on the data packet.
  • the upper layer protocol may be processed by four layers and above specified in the OSI, and the socket table is used to record the correspondence between the hash value of the data packet and the socket, and the hash value may be a quintuple of the data packet.
  • the information can be retrieved in the socket table according to the hash value of the data packet, and the target socket required for the upper layer protocol processing of the data packet is obtained.
  • one of the protocol stack instances is used to initially establish a parent protocol stack instance of the target socket, and the target socket that has no association relationship with each protocol stack instance is created, for example, the target socket is created in the memory.
  • the shared area, the parent protocol stack instance is selected by the APP in a random manner or a parameter designation manner or a load balancing manner. Determining a second protocol stack instance from each protocol stack instance according to an affinity between each protocol stack instance included in the parallel protocol stack instance and the target socket, or using a load balancing policy, or randomly Establishing an association relationship between the target socket and the second protocol stack instance.
  • the affinity between the protocol stack instance and the target socket is used to indicate the total number of data packets that need to be processed by the upper layer protocol by using the target socket in the data packet that the network card has been offloaded to the protocol stack instance.
  • the low layer protocol processing and the upper layer protocol processing together complete complete protocol processing on the data packet, for example, the underlying protocol processing completes the protocol processing of the third layer and below specified in the OSI of the data packet, and the upper layer protocol processing
  • the four-layer and above protocol processing specified in the OSI is completed, and the low-layer protocol processing and the upper layer protocol processing together complete the seven-layer protocol processing specified in the OSI of the data packet.
  • the data packet processed by the lower layer protocol is added to the bottom data receiving queue of the target socket, and when the target socket is associated according to the protocol stack instance corresponding to the second protocol stack instance, the The second protocol stack instance performs upper layer protocol processing on the data packet in the bottom data receiving queue to obtain user data carried by the data packet.
  • the protocol stack instance association list corresponding to the second protocol stack instance is used to indicate a socket that has an association relationship with the second protocol stack instance.
  • the data packet processing method based on the parallel protocol stack instance may be further configured to receive the first data packet sent by the APP, and then determine to perform protocol negotiation on the first data packet. Determining the target socket socket required, and determining the second protocol stack instance associated with the target socket, and then using the target socket and the second protocol stack instance to the first data The package is processed by the protocol.
  • the first protocol stack instance is used to perform low-level protocol processing on the data packet that is offloaded to the first protocol stack instance, and the target socket required for the upper layer protocol processing of the data packet processed by the lower layer protocol is determined, and the target is passed.
  • the socket determines the associated second protocol stack instance, and uses the target socket and the second protocol stack instance to perform upper layer protocol processing on the data packet processed by the lower layer protocol, because the lower layer protocol processing in the protocol processing is completed by different protocol stacks respectively.
  • the part and the upper layer protocol processing part determine the second protocol stack instance that is processed by the upper layer protocol through the target socket, thereby solving the problem that the protocol package instance specified by the APP conflicts with the protocol stack instance specified by the network card, and the protocol cannot be processed by the protocol.
  • FIG. 2 is a schematic flowchart of another method for processing a data packet based on a parallel protocol stack according to an embodiment of the present invention.
  • the method provided in this embodiment is performed by a parallel protocol stack instance, as shown in FIG. 2, and includes:
  • each physical queue in the network card has a corresponding relationship with each protocol stack instance in the parallel protocol stack, and may be a one-to-one correspondence between the physical queue and the protocol stack instance, or multiple physical queues corresponding to one protocol stack instance. This is not limited.
  • the NIC adds the data packet that is offloaded to the first protocol stack instance to the physical queue corresponding to the first protocol stack instance, and the first protocol stack obtains the data packet from the physical queue.
  • the first protocol stack instance is used to perform low-level protocol processing on the data packet, for example, the three-layer protocol and the following protocol specified in the OSI.
  • the search is performed in the socket table to obtain a target socket required for performing upper layer protocol processing on the data packet.
  • the upper layer protocol can be processed by four layers and above specified in the OSI.
  • the affinity between the protocol stack instance and the target socket is used to indicate the total number of data packets that need to be processed by the upper layer protocol by using the target socket in the data packet that the network card has been offloaded to the protocol stack instance. For a socket, multiple connections may occur, and traffic of multiple connections may be split to multiple protocol stack instances. If the configuration needs to handle socket a by protocol stack instance A, then protocol stack instance B needs to receive socket a processing. After the data packet, it needs to be forwarded to the protocol stack instance A for processing. If the configuration is directly processed by the protocol stack instance B, the socket a can be directly obtained from the cache cache, and the protocol stack instance is obviously selected. B handles socket a more efficiently.
  • the socket a and the protocol stack instance B have data affinity, so that the traffic of the socket a is preferentially distributed to the protocol stack instance B for processing. That is, the protocol stack instance with the most affinity with a socket is selected to process the socket, so that the maximum traffic does not need to be forwarded, and the efficiency is maximized.
  • the affinity map of the target socket is used to record the affinity of each protocol stack instance in the parallel protocol stack with the target socket, the associated protocol stack instance currently associated with the target socket, the parent protocol stack instance of the target socket, and the target socket.
  • the preset coefficients include an affinity array, an identifier of the associated protocol stack instance, an identifier of the parent protocol stack instance, and a preset coefficient.
  • the affinity array is used to indicate the affinity of each protocol stack instance in the parallel protocol stack to the target socket.
  • the first protocol stack instance performs low-level protocol processing on the data packet, the number of data packets processed by the low-level protocol obtained by the statistics is increased, and the number of statistics obtained is increased to the affinity of the affinity map.
  • the first protocol stack instance is in affinity with the target socket.
  • the affinity of the first protocol stack instance and the target socket is X in the affinity array of the affinity map, and the number of data packets processed by the lower layer protocol obtained by the statistics is Y, the update is performed.
  • n ⁇ A is greater than B. If yes, perform 206-207, otherwise perform 208-209.
  • A is the affinity between the target socket and the first protocol stack instance
  • B is the affinity between the target socket and the currently associated protocol stack instance
  • n is a preset coefficient
  • n The value ranges from a positive number. In general, the value of n is a positive number that is not greater than 1.
  • n may be greater than 1; the associated protocol stack instance is a protocol stack currently associated with the target socket as recorded in the affinity map example.
  • n ⁇ A is greater than B, record the first protocol stack instance as an association protocol stack instance in the affinity map, and establish a relationship between the first protocol stack instance and the target socket. connection relation.
  • n ⁇ A is greater than B, it is required to replace the associated protocol stack in the affinity map with the first protocol stack, and establish an association relationship between the first protocol stack instance and the target socket.
  • the first protocol stack instance continues to perform upper layer protocol processing on the data packet processed by the low layer protocol, obtains user data carried by the data packet, and adds the user data to the application receiving queue of the target socket, when the APP polls The user data is obtained from the queue when the queue is in use.
  • n ⁇ A is not greater than B, determine that the protocol stack instance currently associated with the target socket is the second protocol stack instance associated with the target socket.
  • the user data is transmitted to the APP.
  • the data packet processed by the low layer protocol is added to an underlying data receiving queue of the target socket.
  • the second protocol stack instance is used to perform an upper layer protocol on the data packet in the bottom data receiving queue. Processing; the protocol stack instance association list corresponding to the second protocol stack instance is used to indicate a socket that has an association relationship with the second protocol stack instance.
  • the low layer protocol processing and the upper layer protocol processing together complete the complete protocol processing of the data packet
  • the underlying protocol processing completes the protocol processing of the three layers and the following specified in the OSI of the data packet
  • the upper layer protocol The processing completes the four-layer and above protocol processing specified in the OSI
  • the low-level protocol processing and the upper layer protocol processing together complete the seven-layer protocol processing specified in the OSI of the data packet.
  • the first protocol stack instance is used to perform low-level protocol processing on the data packet that is offloaded to the first protocol stack instance, and the upper layer protocol processing is performed on the data packet processed by the low-layer protocol.
  • the associated second protocol stack instance is determined by the target socket, and the target protocol and the second protocol stack instance are used to perform upper layer protocol processing on the data packet processed by the lower layer protocol, because different protocol stacks are adopted.
  • the lower layer protocol processing part and the upper layer protocol processing part in the protocol processing are respectively completed, and the second protocol stack instance processed by the upper layer protocol is determined by the target socket, thereby solving the conflict between the protocol stack instance specified by the APP and the protocol stack instance specified by the network card.
  • the technical problem caused by the inability to protocolize the packet.
  • FIG. 3 is a schematic flowchart of a data packet processing method based on a parallel protocol stack instance according to another embodiment of the present invention.
  • the method provided in this embodiment is performed by a parallel protocol stack instance, and the parallel protocol stack instance includes at least a first
  • the protocol stack instance and the second protocol stack instance, as shown in FIG. 3, include:
  • the search is performed in the socket table to obtain a target socket required for performing protocol processing on the first data packet.
  • the target socket is an instance of a parent protocol stack in each protocol stack instance selected by the APP in a random manner or a parameter specification manner or a load balancing manner, and the instance created by the parent protocol stack instance does not exist with each protocol stack instance.
  • the socket of the association is an instance of a parent protocol stack in each protocol stack instance selected by the APP in a random manner or a parameter specification manner or a load balancing manner, and the instance created by the parent protocol stack instance does not exist with each protocol stack instance.
  • the association between the target socket and the second protocol stack instance is determined when the first protocol stack instance and the second protocol stack instance perform protocol processing on the second data packet, where the first protocol stack is The instance performs low-level protocol processing on the second data packet, where the second protocol stack instance performs upper layer protocol processing on the second data packet, and the low-level protocol processing and the upper layer protocol processing jointly complete the second Complete protocol processing of the packet.
  • the lower layer protocol processing and the upper layer protocol processing together complete the complete protocol processing of the data packet, for example, the underlying protocol processing completes the protocol processing of the three layers and the following specified in the OSI of the data packet, and the upper layer protocol processing is completed.
  • the four-layer and above protocol processing specified in the OSI, the low-level protocol processing and the upper layer protocol processing together complete the seven-layer protocol processing specified in the OSI of the data packet.
  • the first protocol stack instance is used to perform low-level protocol processing on the data packet that is offloaded to the first protocol stack instance, and the target socket required for the upper layer protocol processing of the data packet processed by the lower layer protocol is determined, and the target is passed.
  • the socket determines the associated second protocol stack instance, and uses the target socket and the second protocol stack instance to perform upper layer protocol processing on the data packet processed by the lower layer protocol, because the lower layer protocol processing in the protocol processing is completed by different protocol stacks respectively.
  • the part and the upper layer protocol processing part determine the second protocol stack instance that is processed by the upper layer protocol through the target socket, thereby solving the problem that the protocol package instance specified by the APP conflicts with the protocol stack instance specified by the network card, and the protocol cannot be processed by the protocol.
  • FIG. 4 is a schematic flowchart of another method for processing a data packet based on a parallel protocol stack according to another embodiment of the present invention.
  • the method provided by this embodiment is performed by a parallel protocol stack instance, and the parallel protocol stack instance includes at least a A protocol stack instance and a second protocol stack instance, as shown in FIG. 4, include:
  • the method includes: using a parent protocol stack instance of the parallel protocol stack instance to initially establish the target socket, and creating a target socket that has no association relationship with each protocol stack instance included in the parallel protocol stack instance, where the parent The protocol stack instance is selected by the APP in a random manner or a parameter designation manner or a load balancing manner in each protocol stack instance included in the foregoing parallel protocol stack instance.
  • the affinity map is used to record the protocol stack instance currently associated with the target socket, and the associated protocol stack instance recorded in the affinity map is an instance of the protocol stack currently associated with the target socket.
  • the association relationship is determined from each protocol stack instance according to the affinity between each protocol stack instance included in the parallel protocol stack instance and the target socket, and then the target socket and the second protocol are established. The relationship between stack instances.
  • the affinity between the protocol stack instance and the target socket is used to indicate the total number of data packets that need to be processed by the upper layer protocol by using the target socket in the data packet that the network card has been offloaded to the protocol stack instance.
  • the target socket has an associated protocol stack instance, add the first data packet to an APP data sending queue of the target socket.
  • the target socket includes an APP data sending queue, an APP data receiving queue, and an underlying data receiving queue.
  • the APP data sending queue is used to store the data packets sent by the APP
  • the APP data receiving queue is used to store the data packets sent to the APP
  • the bottom data receiving queue is used to store the data packets split by the network card.
  • the first data in the APP data sending queue is used by using the target socket and the second protocol stack instance.
  • the packet performs low-level protocol processing and upper layer protocol processing, respectively.
  • the protocol stack instance association list corresponding to the second protocol stack instance is used to indicate a socket that has an association relationship with the second protocol stack instance.
  • the lower layer protocol processing and the upper layer protocol processing together complete the complete protocol processing of the data packet, for example, the underlying protocol processing completes the protocol processing of the three layers and the following specified in the OSI of the data packet, and the upper layer protocol processing is completed.
  • the four-layer and above protocol processing specified in the OSI, the low-level protocol processing and the upper layer protocol processing together complete the seven-layer protocol processing specified in the OSI of the data packet.
  • the target socket does not have an associated protocol stack instance, add a control message to a receive queue of the target protocol stack instance of the target socket.
  • the parent protocol stack instance of the target socket is an instance of a protocol stack for creating the target socket, and the control message is used to indicate protocol processing on the first data packet.
  • the receive queue of the parent stack instance is used to store data packets or control messages that need to be processed by the parent stack.
  • the receiving queue of each protocol stack is polled.
  • the control message is taken out from the queue, and the control message is parsed to obtain the first data packet.
  • the target socket determines the associated second protocol stack instance, and uses the target socket and the second protocol stack instance to perform upper layer protocol processing on the data packet processed by the low layer protocol to obtain user data, and the protocol processing is completed by using different protocol stacks respectively.
  • the lower layer protocol processing part and the upper layer protocol processing part determine the second protocol stack instance that is processed by the upper layer protocol through the target socket, thereby solving the problem that the protocol stack instance specified by the APP conflicts with the protocol stack instance specified by the network card.
  • FIG. 5 is a schematic structural diagram of a data packet processing apparatus based on an example of a parallel protocol stack according to an embodiment of the present invention.
  • the parallel protocol stack instance includes at least a first protocol stack instance and a second protocol stack instance, as shown in FIG. 5 .
  • the method includes a low-level processing module 51, a first determining module 52, a second determining module 55, and an upper processing module 53.
  • the low-level processing module 51 is configured to perform low-level protocol processing on the data packet that the network card offloads to the first protocol stack instance by using the first protocol stack instance.
  • the first determining module 52 is connected to the lower layer processing module 51, and is configured to determine a target socket socket required for performing upper layer protocol processing on the data packet processed by the lower layer protocol.
  • the first determining module 52 is specifically configured to perform a search in the socket table, and determine a target socket required for performing upper layer protocol processing on the data packet.
  • the second determining module 55 is connected to the first determining module 52, and is configured to determine, according to the target socket, a second protocol stack instance associated with the target socket.
  • the second determining module 55 is specifically configured to determine, according to the affinity between the target socket in the affinity map and each protocol stack instance included in the parallel protocol stack instance, to determine the target socket.
  • the second protocol stack instance; the affinity between the target socket and each of the protocol stack instances is used to indicate that the network card is diverted to the data packet of each protocol stack instance, and needs to be utilized.
  • the upper layer processing module 53 is connected to the second determining module 55, configured to perform upper layer protocol processing on the data packet processed by the low layer protocol by using the target socket and the second protocol stack instance associated with the target socket. .
  • the lower layer protocol processing module 51 and the upper layer protocol processing module 53 jointly complete the number According to the complete protocol of the package.
  • the lower layer protocol processing and the upper layer protocol processing together complete the complete protocol processing of the data packet, for example, the underlying protocol processing completes the protocol processing of the three layers and the following specified in the OSI of the data packet, and the upper layer protocol processing is completed.
  • the four-layer and above protocol processing specified in the OSI, the low-level protocol processing and the upper layer protocol processing together complete the seven-layer protocol processing specified in the OSI of the data packet.
  • the upper layer processing module 53 is configured to add the data packet processed by the low layer protocol to an underlying data receiving queue of the target socket; and associate with a protocol stack instance corresponding to the second protocol stack instance. a linked list, when the target socket is polled, performing, by using the second protocol stack instance, the upper layer protocol processing on the data packet in the bottom data receiving queue; the protocol stack corresponding to the second protocol stack instance The instance association list is used to indicate a socket having an association relationship with the second protocol stack instance.
  • the first protocol stack instance is used to perform low-level protocol processing on the data packet that is offloaded to the first protocol stack instance, and the target socket required for the upper layer protocol processing of the data packet processed by the lower layer protocol is determined, and the target is passed.
  • the socket determines the associated second protocol stack instance, and uses the target socket and the second protocol stack instance to perform upper layer protocol processing on the data packet processed by the lower layer protocol, because the lower layer protocol processing in the protocol processing is completed by different protocol stacks respectively.
  • the part and the upper layer protocol processing part determine the second protocol stack instance that is processed by the upper layer protocol through the target socket, thereby solving the problem that the protocol package instance specified by the APP conflicts with the protocol stack instance specified by the network card, and the protocol cannot be processed by the protocol.
  • FIG. 6 is a schematic structural diagram of another data packet processing apparatus based on an example of a parallel protocol stack according to an embodiment of the present invention.
  • the parallel protocol stack instance includes at least a first protocol stack instance and a second protocol stack instance, as shown in FIG. 6 .
  • the data packet processing apparatus based on the parallel protocol stack instance in this embodiment further includes:
  • the creating module 54 is connected to the first determining module 52, and is configured to create a node that has no association relationship with each protocol stack instance by using one of the protocol stack instances included in the parallel protocol stack instance.
  • the target socket is configured to create a node that has no association relationship with each protocol stack instance by using one of the protocol stack instances included in the parallel protocol stack instance.
  • the parent protocol stack instance is selected by the APP in a random manner or a parameter designation manner or a load balancing manner.
  • the data packet processing apparatus based on the parallel protocol stack instance further includes:
  • the update module 57 is connected to the first determining module 52 for processing according to the lower layer protocol
  • the number of subsequent data packets updates the affinity between the target socket and the first protocol stack instance described in the affinity map.
  • the determining module 58 is connected to the updating module 57 and the second determining module 55, and is configured to determine whether n ⁇ A is greater than B, where A is an affinity between the target socket and the first protocol stack instance, B
  • n is a preset coefficient, n takes a positive number, and the value of the specific n can refer to running a parallel protocol stack instance.
  • the processing performance of the CPU if the processing performance of the CPU is excellent, n can be correspondingly smaller, and vice versa, the value of n is larger; the instance of the associated protocol stack recorded in the affinity map is the protocol stack instance currently associated with the target socket. .
  • the second determining module 55 further includes a first determining unit 551 and a second determining unit 552.
  • a first determining unit 551, configured to determine, as n ⁇ A is not greater than B, a protocol stack instance associated with the target socket recorded in the affinity map as the second protocol associated with the target socket Stack instance.
  • a second determining unit 552 configured to determine the first protocol stack instance as the second protocol stack instance associated with the target socket if n ⁇ A is greater than B, and in the affinity map The recorded protocol stack associated with the target socket is updated to the first protocol stack instance.
  • the upper layer processing module 53 includes:
  • the queue unit 531 is configured to add the data packet processed by the lower layer protocol to an underlying data receiving queue of the target socket.
  • the upper layer processing unit 532 is connected to the queue unit 531, and configured to use the second protocol stack instance to perform the rounding when the target socket is polled according to the protocol stack instance associated with the second protocol stack instance.
  • the data packet in the underlying data receiving queue is processed by the upper layer protocol; the protocol stack instance association list corresponding to the second protocol stack instance is used to indicate a socket that has an association relationship with the second protocol stack instance.
  • the packet processing device based on the parallel protocol stack instance may be disposed on the parallel protocol stack.
  • the low-level processing module 51, the first determining module 52, the second determining module 55, the updating module 57, and the determining module 58 may be disposed in the first protocol stack instance; the queue in the upper processing module 53
  • the unit 531 can be disposed in the first protocol stack instance, and the upper layer processing unit 532 in the upper layer processing module 53 can be disposed in the second protocol stack instance.
  • the data packet processing apparatus based on the parallel protocol stack instance further includes: a receiving module 61. And a protocol processing module 62.
  • the receiving module 61 is connected to the first determining module 52, and configured to receive the first data packet sent by the application APP.
  • the first determining module 52 is further configured to determine the target socket socket required for protocol processing of the first data packet.
  • the second determining module 55 is further configured to determine the second protocol stack instance associated with the target socket after determining the target socket socket required for protocol processing of the first data packet.
  • the protocol processing module 62 is connected to the second determining module 55, and is configured to perform protocol processing on the first data packet by using the target socket and the second protocol stack instance.
  • the lower layer protocol processing and the upper layer protocol processing together complete the complete protocol processing of the data packet, for example, the underlying protocol processing completes the protocol processing of the three layers and the following specified in the OSI of the data packet, and the upper layer protocol processing is completed.
  • the four-layer and above protocol processing specified in the OSI, the low-level protocol processing and the upper layer protocol processing together complete the seven-layer protocol processing specified in the OSI of the data packet.
  • the functional modules of the data packet processing apparatus of the parallel protocol stack example provided in this embodiment may be used to execute the data packet processing method flow of the parallel protocol stack instance shown in FIG. 1 and FIG. 2, and the specific working principle is not described herein. Description of method embodiments.
  • the first protocol stack instance is used to perform low-level protocol processing on the data packet that is offloaded to the first protocol stack instance, and the target socket required for the upper layer protocol processing of the data packet processed by the lower layer protocol is determined, and the target is passed.
  • the socket determines the associated second protocol stack instance, and uses the target socket and the second protocol stack instance to perform upper layer protocol processing on the data packet processed by the lower layer protocol, because the lower layer protocol processing in the protocol processing is completed by different protocol stacks respectively.
  • the part and the upper layer protocol processing part determine the second protocol stack instance that is processed by the upper layer protocol through the target socket, thereby solving the problem that the protocol package instance specified by the APP conflicts with the protocol stack instance specified by the network card, and the protocol cannot be processed by the protocol.
  • FIG. 7 is a schematic structural diagram of a data packet processing apparatus based on an example of a parallel protocol stack according to another embodiment of the present invention.
  • the parallel protocol stack instance includes at least a first protocol stack instance and a second protocol stack instance, as shown in FIG. 7 .
  • the method includes: a receiving module 71, a first determining module 72, a first processing module 73, and a second determining module 70.
  • the receiving module 71 is configured to receive the first data packet sent by the application APP.
  • the first determining module 72 is connected to the receiving module 71 and configured to determine a target socket socket required for protocol processing of the first data packet.
  • the first determining module 72 is specifically configured to perform a search in the socket table to obtain a target socket required for performing protocol processing on the first data packet.
  • the second determining module 70 is connected to the first determining module 72, and is configured to determine, according to the association relationship between the target socket and the second protocol stack instance, a second protocol stack instance associated with the target socket.
  • the first processing module 73 is connected to the second determining module 70, and is configured to perform protocol processing on the first data packet by using the target socket and the second protocol stack instance.
  • the association between the target socket and the second protocol stack instance is determined when the first protocol stack instance and the second protocol stack instance perform protocol processing on the second data packet, where the first protocol stack is The instance performs low-level protocol processing on the second data packet, where the second protocol stack instance performs upper layer protocol processing on the second data packet, and the low-level protocol processing and the upper layer protocol processing jointly complete the second Complete protocol processing of the packet.
  • the lower layer protocol processing and the upper layer protocol processing together complete the complete protocol processing of the data packet, for example, the underlying protocol processing completes the protocol processing of the three layers and the following specified in the OSI of the data packet, and the upper layer protocol processing is completed.
  • the four-layer and above protocol processing specified in the OSI, the low-level protocol processing and the upper layer protocol processing together complete the seven-layer protocol processing specified in the OSI of the data packet.
  • the first protocol stack instance is used to perform low-level protocol processing on the data packet that is offloaded to the first protocol stack instance, and the target socket required for the upper layer protocol processing of the data packet processed by the lower layer protocol is determined, and the target is passed.
  • the socket determines the associated second protocol stack instance, and uses the target socket and the second protocol stack instance to perform upper layer protocol processing on the data packet processed by the lower layer protocol, because the lower layer protocol processing in the protocol processing is completed by different protocol stacks respectively.
  • the part and the upper layer protocol processing part determine the second protocol stack instance that is processed by the upper layer protocol through the target socket, thereby solving the problem that the protocol package instance specified by the APP conflicts with the protocol stack instance specified by the network card, and the protocol cannot be processed by the protocol.
  • FIG. 8 is a schematic structural diagram of another apparatus for processing a data packet based on a parallel protocol stack according to another embodiment of the present invention.
  • the parallel protocol stack instance includes at least a first protocol stack instance and a second protocol stack instance, as shown in FIG. 8 .
  • the second determining module 70 in the packet processing device based on the parallel protocol stack instance in the embodiment further includes:
  • the determining unit 701 is configured to determine, according to the affinity map, whether the target socket exists Associated protocol stack instance.
  • the affinity map is used to record the protocol stack instance currently associated with the target socket, and the associated protocol stack instance in the affinity map is used to indicate the protocol stack instance currently associated with the target socket.
  • the determining unit 702 is connected to the determining unit 701, and is configured to: if the target socket has an associated protocol stack instance, determine that the protocol stack instance associated with the target socket is the second protocol stack instance.
  • the first processing module 73 includes a queue unit 731 and a processing unit 732.
  • the queue unit 731 is configured to add the first data packet to the APP data sending queue of the target socket.
  • the processing unit 732 is connected to the queue unit 731, and is configured to use the target socket and the office when the APP data sending queue of the target socket is polled according to the protocol stack instance association list corresponding to the second protocol stack instance.
  • the second protocol stack instance performs low-level protocol processing and upper layer protocol processing on the first data packet in the APP data sending queue respectively; the protocol stack instance association linked list corresponding to the second protocol stack instance is used to indicate The socket in which the second protocol stack instance has an association relationship.
  • the data packet processing apparatus based on the parallel protocol stack instance further includes: a creation module 78, a queue module 75, a parsing module 76, a second processing module 77, and an update module 80.
  • the creating module 78 is connected to the first determining module 72, and is configured to use the parent protocol stack instance to create the target socket that has no association relationship with each protocol stack instance included in the parallel protocol stack instance.
  • the parent protocol stack instance is selected by the APP in a random manner or a parameter specification manner or a load balancing manner in each protocol stack instance.
  • the queue module 75 is connected to the first determining module 72, and is configured to add a control message to the receiving queue of the parent protocol stack instance of the target socket if the target socket does not have an associated protocol stack instance; the target The parent protocol stack instance of the socket is a protocol stack instance for creating the target socket; the control message is used to indicate protocol processing on the first data packet.
  • the parsing module 76 is connected to the queue module 75, and configured to parse the control message to obtain the first data packet when polling the control message in the receiving queue of the parent protocol stack instance.
  • the second processing module 77 is connected to the parsing module 76 for performing protocol processing on the first data packet by using the parent protocol stack instance.
  • the lower layer protocol processing and the upper layer protocol processing together complete the complete protocol processing of the data packet, for example, the underlying protocol processing completes the protocol processing of the three layers and the following specified in the OSI of the data packet, and the upper layer protocol processing is completed.
  • the four-layer and above protocol processing specified in the OSI, the low-level protocol processing and the upper layer protocol processing together complete the seven-layer protocol processing specified in the OSI of the data packet. That is to say, the network layer corresponding to the upper layer protocol processing is higher than the network layer corresponding to the low layer protocol processing.
  • the update module 74 is connected to the second processing module 77, and is configured to update the protocol stack instance associated with the target socket recorded in the affinity map to the parent protocol stack instance.
  • the data packet processing apparatus based on the parallel protocol stack instance further includes:
  • the sending module 79 is connected to the second processing module 77 and the first processing module 73, and configured to add the first data packet processed by the protocol to the sending queue of the network card, so that the network card sends the protocol processed A packet of data.
  • the functional modules of the data packet processing apparatus of the parallel protocol stack example provided in this embodiment may be used to execute the data packet processing method flow of the parallel protocol stack example shown in FIG. 3 and FIG. 4, and the specific working principle is not described herein. Description of method embodiments.
  • the first protocol stack instance is used to perform low-level protocol processing on the data packet that is offloaded to the first protocol stack instance, and the target socket required for the upper layer protocol processing of the data packet processed by the lower layer protocol is determined, and the target is passed.
  • the socket determines the associated second protocol stack instance, and uses the target socket and the second protocol stack instance to perform upper layer protocol processing on the data packet processed by the lower layer protocol, because the lower layer protocol processing in the protocol processing is completed by different protocol stacks respectively.
  • the part and the upper layer protocol processing part determine the second protocol stack instance that is processed by the upper layer protocol through the target socket, thereby solving the problem that the protocol package instance specified by the APP conflicts with the protocol stack instance specified by the network card, and the protocol cannot be processed by the protocol.
  • FIG. 9 is a schematic structural diagram of a data packet processing apparatus based on an example of a parallel protocol stack according to another embodiment of the present invention.
  • the apparatus in this embodiment may include: a memory 81, a communication interface 82, and processing. 83.
  • the memory 81 is configured to store a program.
  • the program may include program code, and the program code includes computer operation instructions.
  • the memory 81 may include a high speed RAM memory and may also include a non-volatile memory such as at least one disk storage. Device.
  • the communication interface 82 is configured to receive a data packet that is offloaded to the first protocol stack instance.
  • the processor 83 is configured to execute a program stored in the memory 81, configured to: perform low-level protocol processing on the data packet that is offloaded by the network card to the first protocol stack instance by using the first protocol stack instance;
  • the data packet processed by the lower layer protocol performs a target socket socket required for upper layer protocol processing; according to the target socket, determines a second protocol stack instance associated with the target socket; using the target socket and the The second protocol stack instance performs the upper layer protocol processing on the data packet processed by the low layer protocol; wherein the low layer protocol processing and the upper layer protocol processing together complete complete protocol processing on the data packet.
  • the processor 83 is specifically configured to: use one of the protocol stack instances to initially establish a target protocol stack instance, and create the target socket that has no association relationship with each protocol stack instance, where the parent The protocol stack instance is selected by the APP in a random manner or a parameter designation manner or a load balancing manner; the first protocol stack instance is used to perform low-level protocol processing on the data packet that is offloaded to the first protocol stack instance, and the low-layer protocol processing is determined.
  • the subsequent data packet performs a target socket socket required for upper layer protocol processing; according to the affinity between each protocol stack instance included in the parallel protocol stack instance and the target socket, from each protocol stack instance, Determining a second protocol stack instance; the affinity between the protocol stack instance and the target socket is used to indicate that the network card has been offloaded to the protocol stack instance, and the target socket is required to perform upper layer protocol processing.
  • the total number of data packets establishing an association relationship between the target socket and the second protocol stack instance. And using the target socket and the second protocol stack instance associated with the target socket to perform upper layer protocol processing on the data packet processed by the low layer protocol to obtain user data.
  • the lower layer protocol processing and the upper layer protocol processing together complete the complete protocol processing of the data packet, for example, the underlying protocol processing completes the protocol processing of the three layers and the following specified in the OSI of the data packet, and the upper layer protocol processing is completed.
  • the four-layer and above protocol processing specified in the OSI, the low-level protocol processing and the upper layer protocol processing together complete the seven-layer protocol processing specified in the OSI of the data packet.
  • the functional modules of the data packet processing apparatus of the parallel protocol stack example provided in this embodiment may be used to execute the data packet processing method flow of the parallel protocol stack instance shown in FIG. 1 and FIG. 2, and the specific working principle is not described herein. Description of method embodiments.
  • the data that is offloaded to the first protocol stack instance is used by using the first protocol stack instance.
  • the packet performs low-level protocol processing, determines the target socket required for the upper layer protocol processing of the data packet processed by the lower layer protocol, determines the associated second protocol stack instance through the target socket, and uses the target socket and the second protocol stack instance to lower the layer.
  • the data packet processed by the protocol is processed by the upper layer protocol. Since the lower layer protocol processing part and the upper layer protocol processing part in the protocol processing are respectively completed by different protocol stacks, the second protocol stack instance for performing the upper layer protocol processing is determined by the target socket. Therefore, the technical problem that the protocol cannot be processed by the protocol due to the conflict between the protocol stack instance specified by the APP and the protocol stack instance specified by the network card is solved.
  • FIG. 10 is a schematic structural diagram of another apparatus for processing a data packet based on a parallel protocol stack according to another embodiment of the present invention.
  • the apparatus in this embodiment may include: a memory 91, a communication interface 92, and Processor 93.
  • the memory 91 is configured to store a program.
  • the program may include program code, and the program code includes computer operation instructions.
  • the memory 91 may include a high speed RAM memory and may also include a non-volatile memory such as at least one disk memory.
  • the communication interface 92 is configured to receive the first data packet sent by the APP.
  • the processor 93 is configured to execute a program stored in the memory 91, configured to: receive a first data packet sent by the application APP, and determine a target socket socket required for protocol processing of the first data packet; An association between the target socket and the second protocol stack instance, determining the second protocol stack instance associated with the target socket; using the target socket and the second protocol stack instance, performing the first data packet a protocol processing, where the association relationship between the target socket and the second protocol stack instance is determined when the first protocol stack instance and the second protocol stack instance perform protocol processing on the second data packet, where The first protocol stack instance performs low-level protocol processing on the second data packet, and the second protocol stack instance performs upper layer protocol processing on the second data packet, where the lower layer protocol processing and the upper layer protocol processing are completed together Complete protocol processing of the second data packet.
  • the processor 93 is specifically configured to determine, according to the affinity map, whether the target socket has an associated protocol stack instance, and if the target socket has an associated protocol stack instance, determine the association with the target socket.
  • the second protocol stack instance performs protocol processing on the first data packet by using the target socket and the second protocol stack instance, for example, adding the first data packet to the APP data sending queue of the target socket,
  • the linked list is associated with the protocol stack corresponding to the second protocol stack instance, and the APP data sending queue of the target socket is polled
  • the second protocol stack instance has a target socket of the association relationship.
  • the control message is added to the receive queue of the target protocol stack instance of the target socket; the parent protocol stack instance of the target socket is used to create the target socket.
  • the control stack message is used to indicate that the first data packet is subjected to protocol processing; when the control message in the receive queue is polled, the control message is parsed to obtain the a first data packet; performing protocol processing on the first data packet by using the parent protocol stack instance.
  • the lower layer protocol processing and the upper layer protocol processing together complete the complete protocol processing of the data packet, for example, the underlying protocol processing completes the protocol processing of the three layers and the following specified in the OSI of the data packet, and the upper layer protocol processing is completed.
  • the four-layer and above protocol processing specified in the OSI, the low-level protocol processing and the upper layer protocol processing together complete the seven-layer protocol processing specified in the OSI of the data packet.
  • the communication interface 92 is further configured to add the first data packet processed by the protocol to a sending queue of the network card, so that the network card sends the first data packet after the protocol processing.
  • the functional modules of the data packet processing apparatus of the parallel protocol stack example provided in this embodiment may be used to execute the data packet processing method flow of the parallel protocol stack example shown in FIG. 3 and FIG. 4, and the specific working principle is not described herein. Description of method embodiments.
  • the first protocol stack instance is used to perform low-level protocol processing on the data packet that is offloaded to the first protocol stack instance, and the target socket required for the upper layer protocol processing of the data packet processed by the lower layer protocol is determined, and the target is passed.
  • the socket determines the associated second protocol stack instance, and uses the target socket and the second protocol stack instance to perform upper layer protocol processing on the data packet processed by the lower layer protocol, because the lower layer protocol processing in the protocol processing is completed by different protocol stacks respectively.
  • the part and the upper layer protocol processing part determine the second protocol stack instance that is processed by the upper layer protocol through the target socket, thereby solving the problem that the protocol package instance specified by the APP conflicts with the protocol stack instance specified by the network card, and the protocol cannot be processed by the protocol.
  • the aforementioned program can be stored in a computer readable storage medium.
  • the program when executed, performs the steps including the foregoing method embodiments; and the foregoing storage medium includes: ROM, RAM, disk, or optical disk, etc., which can be stored.
  • the medium of the program code includes: ROM, RAM, disk, or optical disk, etc., which can be stored.

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Communication Control (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

本发明提供一种基于并行协议栈实例的数据包处理方法和装置,利用第一协议栈实例对向该第一协议栈实例分流的数据包进行低层协议处理,确定对低层协议处理后的数据包进行上层协议处理所需的目标socket之后,通过目标socket确定关联的第二协议栈实例,利用目标socket和第二协议栈实例,对低层协议处理后的数据包进行上层协议处理,由于采用了由不同的协议栈分别完成协议处理中的低层协议处理部分和上层协议处理部分,通过目标socket确定进行上层协议处理的第二协议栈实例,从而解决了由于APP指定的协议栈实例与网卡指定的协议栈实例冲突所导致的无法对数据包进行协议处理的技术问题。

Description

基于并行协议栈实例的数据包处理方法和装置 技术领域
本发明涉及通信技术,尤其涉及一种基于并行协议栈实例的数据包处理方法和装置。
背景技术
随着云计算的快速发展,对协议栈实例的处理能力提出了更高的要求。目前,通常采用多个协议栈实例共享套接字(socket)的方式,因此存在多协议栈实例之间对socket的竞争问题,进而提出了在中央处理器(central processing unit,CPU)的多核架构下并行协议栈实例,该并行协议栈实例包括至少两个协议栈实例,每个协议栈实例运行在CPU的一个虚拟中央处理器(virtual CPU,VCPU)上,采用独占协议栈实例所关联的socket的方式从而避免上述多协议栈实例之间对socket的竞争问题。当网卡根据分流策略,向各协议栈实例分流数据包时,各协议栈实例可利用与该协议栈实例关联的socket对数据包并行进行协议处理。
但是应用(Application,APP)在指示创建进行上述协议处理所需的socket时,指定了socket与协议栈实例之间的关联关系,从而仅可由APP指定的相关联的协议栈实例占用该socket对数据包进行协议处理,当网卡将数据包所分流到的协议栈实例,与该APP指定的socket相关联的协议栈实例不同时,即出现了APP指定的协议栈实例与网卡指定的协议栈实例冲突的情况,无法对数据包进行协议处理。
发明内容
为解决现有技术的问题,本发明实施例提供一种基于并行协议栈实例的数据包处理方法和装置。
第一方面是提供一种基于并行协议栈实例的数据包处理方法,所述并行协议栈实例中至少包括第一协议栈实例和第二协议栈实例,所述方法包括:利用所述第一协议栈实例对网卡向所述第一协议栈实例分流的所述数据包进 行低层协议处理;确定对所述低层协议处理后的所述数据包进行上层协议处理所需的目标套接字socket;根据所述目标socket,确定与所述目标socket关联的第二协议栈实例;利用所述目标socket和所述第二协议栈实例对所述低层协议处理后的所述数据包进行所述上层协议处理;其中,所述低层协议处理和所述上层协议处理共同完成对所述数据包的完整协议处理。
在第一方面的第一种可能的实现方式中,所述根据所述目标socket,确定与所述目标socket关联的第二协议栈实例,包括:根据亲和性图谱中所述目标socket与所述并行协议栈实例包含的每个协议栈实例之间的亲和性,确定与所述目标socket关联的所述第二协议栈实例;所述目标socket与所述每个协议栈实例之间的亲和性用于指示所述网卡向所述每个协议栈实例已分流的数据包中,需要利用所述目标socket进行上层协议处理的数据包数量。
结合第一方面的第一种可能的实现方式,在第一方面的第二种可能的实现方式中,所述根据亲和性图谱中所述目标socket与所述并行协议栈实例包含的每个协议栈实例之间的亲和性,确定与所述目标socket关联的所述第二协议栈实例之前,还包括:根据所述低层协议处理后的所述数据包的个数,更新所述亲和性图谱中所记载的所述目标socket与所述第一协议栈实例之间的亲和性。
结合第一方面的第二种可能的实现方式,在第一方面的第三种可能的实现方式中,所述根据所述低层协议处理后的所述数据包的个数,更新所述亲和性图谱中所记载的所述目标socket与所述第一协议栈实例之间的亲和性之后,还包括:判断n×A是否大于B,其中,A为所述目标socket与所述第一协议栈实例之间的亲和性,B为所述亲和性图谱中记载的所述目标socket与关联的协议栈实例之间的亲和性,n为预设系数;则所述根据亲和性图谱中所述目标socket与所述并行协议栈实例包含的每个协议栈实例之间的亲和性,确定与所述目标socket关联的所述第二协议栈实例,包括:若n×A不大于B,则确定将所述亲和性图谱中记载的所述目标socket关联的协议栈实例作为与所述目标socket关联的所述第二协议栈实例。
结合第一方面的第三种可能的实现方式,在第一方面的第四种可能的实现方式中,所述根据亲和性图谱中所述目标socket与所述并行协议栈实例包含的每个协议栈实例之间的亲和性,确定与所述目标socket关联的所述第二协议栈实例,还包括:若n×A大于B,则将所述第一协议栈实例确定为与 所述目标socket关联的所述第二协议栈实例,并将所述亲和性图谱中记载的所述目标socket关联的协议栈实例更新为所述第一协议栈实例。
结合第一方面、第一方面的第一种可能的实现方式、第一方面的第二种可能的实现方式、第一方面的第三种可能的实现方式和第一方面的第四种可能的实现方式,在第一方面的第五种可能的实现方式中,所述确定对所述低层协议处理后的所述数据包进行上层协议处理所需的目标套接字socket,包括:在socket表中进行检索,获得对所述低层协议处理后的所述数据包进行上层协议处理所需的所述目标socket。
结合第一方面、第一方面的第一种可能的实现方式、第一方面的第二种可能的实现方式、第一方面的第三种可能的实现方式和第一方面的第四种可能的实现方式,在第一方面的第六种可能的实现方式中,所述利用所述目标socket和所述第二协议栈实例对所述低层协议处理后的所述数据包进行所述上层协议处理,包括:将所述低层协议处理后的所述数据包加入到所述目标socket的底层数据接收队列中;当根据所述第二协议栈实例对应的协议栈实例关联链表,轮询到所述目标socket时,利用所述第二协议栈实例对所述底层数据接收队列中的所述数据包进行所述上层协议处理;所述第二协议栈实例对应的协议栈实例关联链表用于指示与所述第二协议栈实例存在关联关系的socket。
结合第一方面、第一方面的第一种可能的实现方式、第一方面的第二种可能的实现方式、第一方面的第三种可能的实现方式和第一方面的第四种可能的实现方式,在第一方面的第七种可能的实现方式中,所述确定对所述低层协议处理后的所述数据包进行上层协议处理所需的目标套接字socket之前,还包括:利用所述并行协议栈实例包括的各协议栈实例中的一个父协议栈实例,创建与所述各协议栈实例均不存在关联关系的所述目标socket;所述父协议栈实例是应用APP采用随机方式或者参数指定方式或者负载均衡方式选定的。
结合第一方面、第一方面的第一种可能的实现方式、第一方面的第二种可能的实现方式、第一方面的第三种可能的实现方式和第一方面的第四种可能的实现方式,在第一方面的第八种可能的实现方式中,所述方法还包括:接收所述应用APP发送的第一数据包;确定对所述第一数据包进行协议处理所需要的所述目标套接字socket;确定与所述目标socket关联的所述第二协 议栈实例;利用所述目标socket和所述第二协议栈实例,对所述第一数据包进行协议处理。
第二方面是提供一种基于并行协议栈实例的数据包处理方法,所述并行协议栈实例中至少包括第一协议栈实例和第二协议栈实例,所述方法包括:接收应用APP发送的第一数据包;确定对所述第一数据包进行协议处理所需要的目标套接字socket;根据所述目标socket与第二协议栈实例的关联关系,确定与所述目标socket关联的所述第二协议栈实例;利用所述目标socket和所述第二协议栈实例,对所述第一数据包进行协议处理;其中,所述目标socket与所述第二协议栈实例的关联关系,是所述第一协议栈实例和所述第二协议栈实例对第二数据包进行协议处理时确定的,所述第一协议栈实例对所述第二数据包进行低层协议处理,所述第二协议栈实例对所述第二数据包进行上层协议处理,所述低层协议处理和所述上层协议处理共同完成对所述第二数据包的完整协议处理。
在第二方面的第一种可能的实现方式中,所述利用所述目标socket和所述第二协议栈实例,对所述第一数据包进行协议处理,包括:将所述第一数据包加入到所述目标socket的APP数据发送队列中;当根据所述第二协议栈实例对应的协议栈实例关联链表,轮询到所述目标socket的APP数据发送队列时,利用所述目标socket和所述第二协议栈实例对所述APP数据发送队列中的所述第一数据包分别进行低层协议处理和上层协议处理;所述第二协议栈实例对应的协议栈实例关联链表用于指示与所述第二协议栈实例存在关联关系的socket。
在第二方面的第二种可能的实现方式中,所述根据所述目标socket与第二协议栈实例的关联关系,确定与所述目标socket关联的第二协议栈实例,包括:根据亲和性图谱,判断所述目标socket是否存在关联的协议栈实例;所述亲和性图谱用于记载与所述目标socket关联的协议栈实例;若所述目标socket存在关联的协议栈实例,则确定所述与所述目标socket关联的协议栈实例为所述第二协议栈实例。
结合第二方面的第二种可能的实现方式,在第二方面的第三种可能的实现方式中,所述方法还包括:若所述目标socket不存在关联的协议栈实例,则将控制消息加入到所述目标socket的父协议栈实例的接收队列中;所述目标socket的父协议栈实例是用于创建所述目标socket的协议栈实例;所述控 制消息用于指示对所述第一数据包进行协议处理;当轮询到所述父协议栈实例的接收队列中的所述控制消息时,对所述控制消息进行解析,获得所述第一数据包;利用所述父协议栈实例对所述第一数据包进行协议处理;将所述亲和性图谱中记载的所述目标socket关联的协议栈实例更新为所述父协议栈实例。
结合第二方面、第二方面的第一种可能的实现方式、第二方面的第二种可能的实现方式和第二方面的第三种可能的实现方式,在第二方面的第四种可能的实现方式中,所述确定对所述第一数据包进行协议处理所需要的目标套接字socket,包括:在socket表中进行检索,确定对所述第一数据包进行协议处理所需的所述目标socket。
结合第二方面的第三种可能的实现方式,在第二方面的第五种可能的实现方式中,所述确定对所述第一数据包进行协议处理所需要的目标套接字socket之前,还包括:利用所述父协议栈实例,创建与所述并行协议栈实例包括的各协议栈实例均不存在关联关系的所述目标socket,所述父协议栈实例是所述APP采用随机方式或者参数指定方式或者负载均衡方式在所述各协议栈实例中选定的。
结合第二方面、第二方面的第一种可能的实现方式、第二方面的第二种可能的实现方式和第二方面的第三种可能的实现方式,在第二方面的第六种可能的实现方式中,所述利用所述目标socket和所述第二协议栈实例,对所述第一数据包进行协议处理之后,还包括:将所述协议处理后的第一数据包加入到网卡的发送队列中,以使所述网卡发送所述协议处理后的第一数据包。
第三方面是提供一种基于并行协议栈实例的数据包处理装置,所述并行协议栈实例中至少包括第一协议栈实例和第二协议栈实例,所述装置包括:低层处理模块,用于利用所述第一协议栈实例对网卡向所述第一协议栈实例分流的所述数据包进行低层协议处理;第一确定模块,用于确定对所述低层协议处理后的所述数据包进行上层协议处理所需的目标套接字socket;第二确定模块,用于根据所述目标socket,确定与所述目标socket关联的第二协议栈实例;上层处理模块,用于利用所述目标socket和所述第二协议栈实例对所述低层协议处理后的所述数据包进行所述上层协议处理;其中,所述低层协议处理模块和所述上层协议处理模块共同完成对所述数据包的完整协议处理。
在第三方面的第一种可能的实现方式中,所述第二确定模块,具体用于根据亲和性图谱中所述目标socket与所述并行协议栈实例包含的每个协议栈实例之间的亲和性,确定与所述目标socket关联的所述第二协议栈实例;所述目标socket与所述每个协议栈实例之间的亲和性用于指示所述网卡向所述每个协议栈实例已分流的数据包中,需要利用所述目标socket进行上层协议处理的数据包数量。
结合第三方面的第一种可能的实现方式,在第三方面的第二种可能的实现方式中,所述装置,还包括:更新模块,用于根据所述低层协议处理后的所述数据包的个数,更新所述亲和性图谱中所记载的所述目标socket与所述第一协议栈实例之间的亲和性。
结合第三方面的第二种可能的实现方式,在第三方面的第三种可能的实现方式中,所述装置,还包括:判断模块,用于判断n×A是否大于B,其中,A为所述目标socket与所述第一协议栈实例之间的亲和性,B为所述亲和性图谱中记载的所述目标socket与关联的协议栈实例之间的亲和性,n为预设系数;则所述第二确定模块,包括:第一确定单元,用于若n×A不大于B,则确定将所述亲和性图谱中记载的所述目标socket关联的协议栈实例作为与所述目标socket关联的所述第二协议栈实例。
结合第三方面的第三种可能的实现方式,在第三方面的第四种可能的实现方式中,所述第二确定模块,还包括:第二确定单元,用于若n×A大于B,则将所述第一协议栈实例确定为与所述目标socket关联的所述第二协议栈实例,并将所述亲和性图谱中记载的所述目标socket关联的协议栈实例更新为所述第一协议栈实例。
结合第三方面、第三方面的第一种可能的实现方式、第三方面的第二种可能的实现方式、第三方面的第三种可能的实现方式和第三方面的第四种可能的实现方式,在第三方面的第五种可能的实现方式中,所述第一确定模块,具体用于在socket表中进行检索,获得对所述低层协议处理后的数据包进行上层协议处理所需的所述目标socket。
结合第三方面、第三方面的第一种可能的实现方式、第三方面的第二种可能的实现方式、第三方面的第三种可能的实现方式和第三方面的第四种可能的实现方式,在第三方面的第六种可能的实现方式中,所述上层处理模块,包括:队列单元,用于将所述低层协议处理后的所述数据包加入到所述目标 socket的底层数据接收队列中;上层处理单元,用于当根据所述第二协议栈实例对应的协议栈实例关联链表,轮询到所述目标socket时,利用所述第二协议栈实例对所述底层数据接收队列中的所述数据包进行所述上层协议处理;所述第二协议栈实例对应的协议栈实例关联链表用于指示与所述第二协议栈实例存在关联关系的socket。
结合第三方面、第三方面的第一种可能的实现方式、第三方面的第二种可能的实现方式、第三方面的第三种可能的实现方式和第三方面的第四种可能的实现方式,在第三方面的第七种可能的实现方式中,所述装置,还包括:创建模块,用于利用所述并行协议栈实例包括的各协议栈实例中的一个父协议栈实例,创建与所述各协议栈实例均不存在关联关系的所述目标socket;所述父协议栈实例是应用APP采用随机方式或者参数指定方式或者负载均衡方式选定的。
结合第三方面、第三方面的第一种可能的实现方式、第三方面的第二种可能的实现方式、第三方面的第三种可能的实现方式和第三方面的第四种可能的实现方式,在第三方面的第八种可能的实现方式中,所述装置,还包括:接收模块,用于接收所述应用APP发送的第一数据包;所述第一确定模块,还用于确定对所述第一数据包进行协议处理所需要的所述目标套接字socket;所述第二确定模块,还用于确定对所述第一数据包进行协议处理所需要的所述目标套接字socket之后,确定与所述目标socket关联的所述第二协议栈实例;协议处理模块,用于利用所述目标socket和所述第二协议栈实例,对所述第一数据包进行协议处理。
第四方面是提供一种基于并行协议栈实例的数据包处理装置,所述并行协议栈实例中至少包括第一协议栈实例和第二协议栈实例,所述装置包括:接收模块,用于接收应用APP发送的第一数据包;第一确定模块,用于确定对所述第一数据包进行协议处理所需要的目标套接字socket;第二确定模块,用于根据所述目标socket与第二协议栈实例的关联关系,确定与所述目标socket关联的所述第二协议栈实例;第一处理模块,用于利用所述目标socket和所述第二协议栈实例,对所述第一数据包进行协议处理;其中,所述目标socket与所述第二协议栈实例的关联关系,是所述第一协议栈实例和所述第二协议栈实例对第二数据包进行协议处理时确定的,所述第一协议栈实例对所述第二数据包进行低层协议处理,所述第二协议栈实例对所述第二数据包 进行上层协议处理,所述低层协议处理和所述上层协议处理共同完成对所述第二数据包的完整协议处理。
在第四方面的第一种可能的实现方式中,所述第一处理模块,包括:队列单元,用于将所述第一数据包加入到所述目标socket的APP数据发送队列中;处理单元,用于当根据所述第二协议栈实例对应的协议栈实例关联链表,轮询到所述目标socket的APP数据发送队列时,利用所述目标socket和所述第二协议栈实例对所述APP数据发送队列中的所述第一数据包分别进行低层协议处理和上层协议处理;所述第二协议栈实例对应的协议栈实例关联链表用于指示与所述第二协议栈实例存在关联关系的socket。
在第四方面的第二种可能的实现方式中,所述第二确定模块,包括:判断单元,用于根据亲和性图谱,判断所述目标socket是否存在关联的协议栈实例;所述亲和性图谱用于记载与所述目标socket关联的协议栈实例;确定单元,用于若所述目标socket存在关联的协议栈实例,则确定所述与所述目标socket关联的协议栈实例为所述第二协议栈实例。
结合第四方面的第二种可能的实现方式,在第四方面的第三种可能的实现方式中,所述装置,还包括:队列模块,用于若所述目标socket不存在关联的协议栈实例,则将控制消息加入到所述目标socket的父协议栈实例的接收队列中;所述目标socket的父协议栈实例是用于创建所述目标socket的协议栈实例;所述控制消息用于指示对所述第一数据包进行协议处理;解析模块,用于当轮询到所述父协议栈实例的接收队列中的所述控制消息时,对所述控制消息进行解析,获得所述第一数据包;第二处理模块,用于利用所述父协议栈实例对所述第一数据包进行协议处理;更新模块,用于将所述亲和性图谱中记载的所述目标socket关联的协议栈实例更新为所述父协议栈实例。
结合第四方面、第四方面的第一种可能的实现方式、第四方面的第二种可能的实现方式和第四方面的第三种可能的实现方式,在第四方面的第四种可能的实现方式中,所述第一确定模块,具体用于在socket表中进行检索,确定对所述第一数据包进行协议处理所需的所述目标socket。
结合第四方面的第三种可能的实现方式,在第四方面的第五种可能的实现方式中,所述装置,还包括:创建模块,用于利用所述父协议栈实例,创建与所述并行协议栈实例包括的各协议栈实例均不存在关联关系的所述目标 socket,所述父协议栈实例是所述APP采用随机方式或者参数指定方式或者负载均衡方式在所述各协议栈实例中选定的。
结合第四方面、第四方面的第一种可能的实现方式、第四方面的第二种可能的实现方式和第四方面的第三种可能的实现方式,在第四方面的第六种可能的实现方式中,所述装置,还包括:发送模块,用于将所述协议处理后的第一数据包加入到网卡的发送队列中,以使所述网卡发送所述协议处理后的第一数据包。
本发明实施例提供的方法和装置,利用第一协议栈实例对向该第一协议栈实例分流的数据包进行低层协议处理,确定对低层协议处理后的数据包进行上层协议处理所需的目标socket之后,通过目标socket确定关联的第二协议栈实例,利用目标socket和第二协议栈实例,对低层协议处理后的数据包进行上层协议处理,由于采用了由不同的协议栈分别完成协议处理中的低层协议处理部分和上层协议处理部分,通过目标socket确定进行上层协议处理的第二协议栈实例,从而解决了由于APP指定的协议栈实例与网卡指定的协议栈实例冲突所导致的无法对数据包进行协议处理的技术问题。
附图说明
为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作一简单地介绍,显而易见地,下面描述中的附图是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。
图1为本发明一实施例提供的一种基于并行协议栈实例的数据包处理方法的流程示意图;
图2为本发明一实施例提供的另一种基于并行协议栈实例的数据包处理方法的流程示意图;
图3为本发明另一实施例提供的一种基于并行协议栈实例的数据包处理方法的流程示意图;
图4为本发明另一实施例提供的另一种基于并行协议栈实例的数据包处理方法的流程示意图;
图5为本发明一实施例提供的一种基于并行协议栈实例的数据包处理装 置的结构示意图;
图6为本发明一实施例提供的另一种基于并行协议栈实例的数据包处理装置的结构示意图;
图7为本发明另一实施例提供的一种基于并行协议栈实例的数据包处理装置的结构示意图;
图8为本发明另一实施例提供的另一种基于并行协议栈实例的数据包处理装置的结构示意图;
图9为本发明又一实施例提供的一种基于并行协议栈实例的数据包处理装置的结构示意图;
图10为本发明又一实施例提供的另一种基于并行协议栈实例的数据包处理装置的结构示意图。
具体实施方式
为使本发明实施例的目的、技术方案和优点更加清楚,下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。
图1为本发明一实施例提供的一种基于并行协议栈实例的数据包处理方法的流程示意图,本实施例所提供的方法由并行协议栈实例执行,该并行协议栈实例中至少包括第一协议栈实例和第二协议栈实例,如图1所示,包括:
101、利用第一协议栈实例对向该第一协议栈实例分流的数据包进行低层协议处理。
可选的,网卡包括多个物理队列,从与第一协议栈实例对应的物理队列中,获取向第一协议栈实例分流的数据包,利用第一协议栈实例对该数据包进行低层协议处理。其中,低层协议处理可为开放式系统互联(Open System Interconnect,OSI)中所规定的三层及以下的协议处理。
102、确定对低层协议处理后的数据包进行上层协议处理所需的目标socket。
可选的,在socket表中进行检索,获得对所述数据包进行上层协议处理所需的目标socket。其中,上层协议可为OSI中所规定的四层及以上的协议处理,socket表用于记录数据包的散列值与socket之间的对应关系,该散列值可为数据包的五元组信息,从而可根据数据包的散列值,在socket表中进行检索,获得对数据包进行上层协议处理所需的目标socket。
103、根据所述目标socket,确定与目标socket关联的第二协议栈实例。
可选的,预先利用各协议栈实例中的一个用于初始建立该目标socket的父协议栈实例,创建与各协议栈实例均不存在关联关系的所述目标socket,如将目标socket创建在内存的共享区,父协议栈实例是APP采用随机方式或者参数指定方式或者负载均衡方式所选定的。根据所述并行协议栈实例所包括的各协议栈实例与所述目标socket之间的亲和性,或者采用负载均衡策略,或者随机地,从各协议栈实例中,确定第二协议栈实例,建立所述目标socket与所述第二协议栈实例之间的关联关系。其中,协议栈实例与目标socket之间的亲和性用于指示网卡向该协议栈实例已分流的数据包中,需要利用所述目标socket进行上层协议处理的数据包总数。
104、利用所述目标socket和与所述目标socket关联的所述第二协议栈实例,对所述低层协议处理后的数据包进行上层协议处理,获得用户数据。
其中,所述低层协议处理和所述上层协议处理共同完成对所述数据包的完整协议处理,例如,底层协议处理完成数据包的OSI中所规定的三层及以下的协议处理,上层协议处理完成OSI中所规定的四层及以上的协议处理,低层协议处理和所述上层协议处理共同完成对所述数据包的OSI中所规定的七层协议处理。
可选的,将低层协议处理后的数据包加入到所述目标socket的底层数据接收队列中,当根据第二协议栈实例对应的协议栈实例关联链表,轮询到目标socket时,利用所述第二协议栈实例对所述底层数据接收队列中的所述数据包进行上层协议处理,获得数据包所携带的用户数据。其中,第二协议栈实例对应的协议栈实例关联链表用于指示与所述第二协议栈实例存在关联关系的socket。
进一步,本实施例所提供的基于并行协议栈实例的数据包处理方法,还可用于接收APP发送的第一数据包,继而确定对第一数据包进行协议处 理所需要的所述目标套接字socket,以及确定与所述目标socket关联的所述第二协议栈实例,进而利用所述目标socket和所述第二协议栈实例,对所述第一数据包进行协议处理。
本实施例中,利用第一协议栈实例对向该第一协议栈实例分流的数据包进行低层协议处理,确定对低层协议处理后的数据包进行上层协议处理所需的目标socket之后,通过目标socket确定关联的第二协议栈实例,利用目标socket和第二协议栈实例,对低层协议处理后的数据包进行上层协议处理,由于采用了由不同的协议栈分别完成协议处理中的低层协议处理部分和上层协议处理部分,通过目标socket确定进行上层协议处理的第二协议栈实例,从而解决了由于APP指定的协议栈实例与网卡指定的协议栈实例冲突所导致的无法对数据包进行协议处理的技术问题。
图2为本发明一实施例提供的另一种基于并行协议栈实例的数据包处理方法的流程示意图,本实施例所提供的方法由并行协议栈实例执行,如图2所示,包括:
201、从网卡中与第一协议栈对应的物理队列中获取数据包。
可选的,网卡中的各物理队列与并行协议栈中的各协议栈实例存在对应关系,可为物理队列与协议栈实例一一对应,或者多个物理队列对应一个协议栈实例,本实施例中对此不作限定。网卡将向第一协议栈实例分流的数据包加入与第一协议栈实例对应的物理队列中,第一协议栈实从该物理队列中获取该数据包。
202、利用第一协议栈实例对向所述第一协议栈实例分流的数据包进行低层协议处理。
可选的,第一协议栈从网卡的物理队列中获取到数据包之后,利用第一协议栈实例对该数据包进行低层协议处理,例如OSI中所规定的三层及以下协议处理。
203、确定对低层协议处理后的数据包进行上层协议处理所需的目标套接字socket。
可选的,在socket表中进行检索,获得对所述数据包进行上层协议处理所需的目标socket。其中,上层协议可为OSI中所规定的四层及以上的协议处理。
204、根据所述低层协议处理后的数据包的个数,更新亲和性图谱中所 记载的目标socket与所述第一协议栈实例之间的亲和性。
其中,协议栈实例与目标socket之间的亲和性用于指示网卡向该协议栈实例已分流的数据包中,需要利用所述目标socket进行上层协议处理的数据包总数。对于一个socket,可能会有多个连接出现,多个连接的流量也会分流到多个协议栈实例,如果配置需要由协议栈实例A处理socket a,那么协议栈实例B收到需要socket a处理的数据包后,需要转发给协议栈实例A处理,而如果配置由协议栈实例B直接处理socket a,则直接从缓存cache中获得该需要socket a处理的数据包即可,显然选择协议栈实例B处理socket a更高效。因此就认为socket a与协议栈实例B之间具有数据亲和性,从而优先将socket a的流量分到协议栈实例B上处理。即,选择与一个socket的亲和性最大的协议栈实例来处理该socket,使得最大的流量不需要转发,保证效率最大化。目标socket的亲和性图谱用于记录并行协议栈中各协议栈实例与目标socket的亲和性、当前与目标socket关联的关联协议栈实例、创建目标socket的父协议栈实例和目标socket对应的预设系数,包括亲和性数组、关联协议栈实例的标识、父协议栈实例的标识和预设系数。亲和性数组用于指示并行协议栈中各协议栈实例与目标socket的亲和性。
可选的,第一协议栈实例对数据包进行低层协议处理之后,统计所获得的低层协议处理后的数据包的个数,将统计所获得的个数增加到亲和性图谱的亲和性数组中,该第一协议栈实例与目标socket的亲和性中。
例如:若亲和性图谱的亲和性数组中,该第一协议栈实例与目标socket的亲和性为X,统计所获得的低层协议处理后的数据包的个数为Y,则更新亲和性图谱的亲和性数组中,该第一协议栈实例与目标socket的亲和性为A=(X+Y)。
205、判断n×A是否大于B,若是,则执行206-207,否则执行208-209。
其中,A为所述目标socket与所述第一协议栈实例之间的亲和性,B为目标socket与当前所关联的协议栈实例之间的亲和性,n为预设系数,n的取值范围为正数,一般情况下,n的取值为不大于1的正数,以减少与目标socket关联的协议栈实例发生改变的频率,反之若需要增大与目标socket关联的协议栈实例发生改变的频率,n取值可大于1;关联协议栈实例是所述亲和性图谱所记载的当前与所述目标socket关联的一个协议栈实 例。
206、若n×A大于B,则将所述第一协议栈实例记为所述亲和性图谱中的关联协议栈实例,以及建立所述第一协议栈实例与所述目标socket之间的关联关系。
可选的,若n×A大于B,则说明需要将亲和性图谱中的关联协议栈替换为第一协议栈,建立第一协议栈实例与目标socket之间的关联关系。
207、利用所述目标socket和与所述目标socket关联的第一协议栈实例,对所述低层协议处理后的数据包进行上层协议处理,获得用户数据。
可选的,第一协议栈实例继续对低层协议处理后的数据包进行上层协议处理,获得数据包所携带的用户数据,将该用户数据加入到目标socket的应用接收队列中,当APP轮询该队列时,从该队列中获取该用户数据。
208、若n×A不大于B,则确定将目标socket当前所关联的协议栈实例作为与该目标socket关联的第二协议栈实例。
209、利用所述目标socket和与所述目标socket关联的所述第二协议栈实例,对所述低层协议处理后的数据包进行上层协议处理,获得用户数据。
进一步,207和209中进行上层协议处理之后,向APP发送该用户数据。
可选的,将所述低层协议处理后的数据包加入到所述目标socket的底层数据接收队列中。当根据所述第二协议栈实例对应的协议栈实例关联链表,轮询到所述目标socket时,利用所述第二协议栈实例对所述底层数据接收队列中的所述数据包进行上层协议处理;所述第二协议栈实例对应的协议栈实例关联链表用于指示与所述第二协议栈实例存在关联关系的socket。
需要说明的是,低层协议处理和所述上层协议处理共同完成对所述数据包的完整协议处理,例如,底层协议处理完成数据包的OSI中所规定的三层及以下的协议处理,上层协议处理完成OSI中所规定的四层及以上的协议处理,低层协议处理和所述上层协议处理共同完成对所述数据包的OSI中所规定的七层协议处理。
本实施例中,利用第一协议栈实例对向该第一协议栈实例分流的数据包进行低层协议处理,确定对低层协议处理后的数据包进行上层协议处理 所需的目标socket之后,通过目标socket确定关联的第二协议栈实例,利用目标socket和第二协议栈实例,对低层协议处理后的数据包进行上层协议处理,由于采用了由不同的协议栈分别完成协议处理中的低层协议处理部分和上层协议处理部分,通过目标socket确定进行上层协议处理的第二协议栈实例,从而解决了由于APP指定的协议栈实例与网卡指定的协议栈实例冲突所导致的无法对数据包进行协议处理的技术问题。
图3为本发明另一实施例提供的一种基于并行协议栈实例的数据包处理方法的流程示意图,本实施例所提供的方法由并行协议栈实例执行,并行协议栈实例中至少包括第一协议栈实例和第二协议栈实例,如图3所示,包括:
301、接收APP发送的第一数据包。
302、确定对第一数据包进行协议处理所需要的目标socket。
可选的,在socket表中进行检索,获得对所述第一数据包进行协议处理所需的目标socket。其中,目标socket是APP采用随机方式或者参数指定方式或者负载均衡方式,所选定的各协议栈实例中的一个父协议栈实例,利用该父协议栈实例创建的与各协议栈实例均不存在关联关系的socket。
303、根据目标socket与第二协议栈实例的关联关系,确定与目标socket关联的第二协议栈实例。
其中,目标socket与所述第二协议栈实例的关联关系,是所述第一协议栈实例和所述第二协议栈实例对第二数据包进行协议处理时确定的,所述第一协议栈实例对所述第二数据包进行低层协议处理,所述第二协议栈实例对所述第二数据包进行上层协议处理,所述低层协议处理和所述上层协议处理共同完成对所述第二数据包的完整协议处理。
304、利用目标socket和与目标socket关联的第二协议栈实例,对所述第一数据包进行协议处理。
需要说明的是,低层协议处理和上层协议处理共同完成对所述数据包的完整协议处理,例如,底层协议处理完成数据包的OSI中所规定的三层及以下的协议处理,上层协议处理完成OSI中所规定的四层及以上的协议处理,低层协议处理和所述上层协议处理共同完成对所述数据包的OSI中所规定的七层协议处理。
本实施例中的第二协议栈实例的确定方法,可参考前述实施例中的确 定第二协议栈实例的方法,本实施例中不再赘述。
本实施例中,利用第一协议栈实例对向该第一协议栈实例分流的数据包进行低层协议处理,确定对低层协议处理后的数据包进行上层协议处理所需的目标socket之后,通过目标socket确定关联的第二协议栈实例,利用目标socket和第二协议栈实例,对低层协议处理后的数据包进行上层协议处理,由于采用了由不同的协议栈分别完成协议处理中的低层协议处理部分和上层协议处理部分,通过目标socket确定进行上层协议处理的第二协议栈实例,从而解决了由于APP指定的协议栈实例与网卡指定的协议栈实例冲突所导致的无法对数据包进行协议处理的技术问题。
图4为本发明另一实施例提供的另一种基于并行协议栈实例的数据包处理方法的流程示意图,本实施例所提供的方法由并行协议栈实例执行,并行协议栈实例中至少包括第一协议栈实例和第二协议栈实例,如图4所示,包括:
401、接收APP发送的第一数据包。
402、确定对第一数据包进行协议处理所需要的目标socket。
可选的,在socket表中进行检索,确定对所述第一数据包进行协议处理所需的目标socket。
进一步,402之前包括利用并行协议栈实例中的一个用于初始建立该目标socket的父协议栈实例,创建与并行协议栈实例包括的各协议栈实例均不存在关联关系的目标socket,其中,父协议栈实例是APP采用随机方式或者参数指定方式或者负载均衡方式在上述并行协议栈实例包括的各协议栈实例中选定的。
403、根据亲和性图谱,判断所述目标socket是否存在关联的协议栈实例。若存在,则执行404-405,否则执行406-408。
其中,亲和性图谱用于记载当前与所述目标socket关联的协议栈实例,亲和性图谱中记载的关联协议栈实例是当前与目标socket存在关联关系的协议栈实例。该关联关系是通过根据所述并行协议栈实例所包括的各协议栈实例与所述目标socket之间的亲和性,从各协议栈实例中确定的,继而建立目标socket与所述第二协议栈实例之间的关联关系。其中,协议栈实例与所述目标socket之间的亲和性用于指示网卡向该协议栈实例已分流的数据包中,需要利用所述目标socket进行上层协议处理的数据包总数。
404、若所述目标socket存在关联的协议栈实例,则将所述第一数据包加入到目标socket的APP数据发送队列中。
可选的,目标socket包括APP数据发送队列、APP数据接收队列和底层数据接收队列。其中,APP数据发送队列用于存放APP发出的数据包,APP数据接收队列用于存放向APP发送的数据包,底层数据接收队列用于存放网卡所分流的数据包。
405、当轮询到目标socket的APP数据发送队列时,利用所述目标socket和关联的第二协议栈实例对第一数据包进行协议处理。
可选的,当根据第二协议栈实例对应的协议栈实例关联链表,轮询到目标socket的APP数据发送队列时,利用目标socket和第二协议栈实例对APP数据发送队列中的第一数据包分别进行低层协议处理和上层协议处理。
其中,第二协议栈实例对应的协议栈实例关联链表用于指示与第二协议栈实例存在关联关系的socket。
需要说明的是,低层协议处理和上层协议处理共同完成对所述数据包的完整协议处理,例如,底层协议处理完成数据包的OSI中所规定的三层及以下的协议处理,上层协议处理完成OSI中所规定的四层及以上的协议处理,低层协议处理和所述上层协议处理共同完成对所述数据包的OSI中所规定的七层协议处理。
406、若所述目标socket不存在关联的协议栈实例,则将控制消息加入到所述目标socket的父协议栈实例的接收队列中。
其中,目标socket的父协议栈实例是用于创建所述目标socket的协议栈实例,控制消息用于指示对第一数据包进行协议处理。父协议栈实例的接收队列用于存放需要利用父协议栈进行处理的数据包或控制消息。
407、当轮询到该父协议栈实例的接收队列中的控制消息时,对控制消息进行解析,获得第一数据包。
可选的,对各个协议栈的接收队列进行轮询,当轮询到父协议栈的接收队列时,从该队列中取出该控制消息,对该控制消息进行解析,获得该第一数据包。
408、利用父协议栈实例对第一数据包进行协议处理。
409、将所述协议处理后的第一数据包加入到网卡的发送队列中,以使 网卡发送所述协议处理后的第一数据包。
本实施例中,通过利用第一协议栈实例对向该第一协议栈实例分流的数据包进行低层协议处理,确定对低层协议处理后的数据包进行上层协议处理所需的目标socket之后,通过目标socket确定关联的第二协议栈实例,利用目标socket和第二协议栈实例,对低层协议处理后的数据包进行上层协议处理,获得用户数据,由于采用了由不同的协议栈分别完成协议处理中的低层协议处理部分和上层协议处理部分,通过目标socket确定进行上层协议处理的第二协议栈实例,从而解决了由于APP指定的协议栈实例与网卡指定的协议栈实例冲突所导致的无法对数据包进行协议处理的技术问题。
图5为本发明一实施例提供的一种基于并行协议栈实例的数据包处理装置的结构示意图,并行协议栈实例中至少包括第一协议栈实例和第二协议栈实例,如图5所示,包括:低层处理模块51、第一确定模块52、第二确定模块55和上层处理模块53。
低层处理模块51,用于利用所述第一协议栈实例对网卡向所述第一协议栈实例分流的所述数据包进行低层协议处理。
第一确定模块52,与低层处理模块51连接,用于确定对所述低层协议处理后的所述数据包进行上层协议处理所需的目标套接字socket。
可选的,第一确定模块52,具体用于在socket表中进行检索,确定对所述数据包进行上层协议处理所需的目标socket。
第二确定模块55,与第一确定模块52连接,用于根据所述目标socket,确定与所述目标socket关联的第二协议栈实例。
可选的,第二确定模块55具体用于根据亲和性图谱中所述目标socket与所述并行协议栈实例包含的每个协议栈实例之间的亲和性,确定与所述目标socket关联的所述第二协议栈实例;所述目标socket与所述每个协议栈实例之间的亲和性用于指示所述网卡向所述每个协议栈实例已分流的数据包中,需要利用所述目标socket进行上层协议处理的数据包数量。
上层处理模块53,与第二确定模块55连接,用于利用所述目标socket和与所述目标socket关联的所述第二协议栈实例,对所述低层协议处理后的数据包进行上层协议处理。
其中,低层协议处理模块51和上层协议处理模块53共同完成对该数 据包的完整协议处理。
需要说明的是,低层协议处理和上层协议处理共同完成对所述数据包的完整协议处理,例如,底层协议处理完成数据包的OSI中所规定的三层及以下的协议处理,上层协议处理完成OSI中所规定的四层及以上的协议处理,低层协议处理和所述上层协议处理共同完成对所述数据包的OSI中所规定的七层协议处理。
可选的,上层处理模块53,具体用于将所述低层协议处理后的数据包加入到所述目标socket的底层数据接收队列中;当根据所述第二协议栈实例对应的协议栈实例关联链表,轮询到所述目标socket时,利用所述第二协议栈实例对所述底层数据接收队列中的所述数据包进行所述上层协议处理;所述第二协议栈实例对应的协议栈实例关联链表用于指示与所述第二协议栈实例存在关联关系的socket。
本实施例中,利用第一协议栈实例对向该第一协议栈实例分流的数据包进行低层协议处理,确定对低层协议处理后的数据包进行上层协议处理所需的目标socket之后,通过目标socket确定关联的第二协议栈实例,利用目标socket和第二协议栈实例,对低层协议处理后的数据包进行上层协议处理,由于采用了由不同的协议栈分别完成协议处理中的低层协议处理部分和上层协议处理部分,通过目标socket确定进行上层协议处理的第二协议栈实例,从而解决了由于APP指定的协议栈实例与网卡指定的协议栈实例冲突所导致的无法对数据包进行协议处理的技术问题。
图6为本发明一实施例提供的另一种基于并行协议栈实例的数据包处理装置的结构示意图,并行协议栈实例中至少包括第一协议栈实例和第二协议栈实例,如图6所示,在上一实施例的基础上,本实施例中的基于并行协议栈实例的数据包处理装置进一步包括:
创建模块54,与第一确定模块52连接,用于利用所述并行协议栈实例包括的各协议栈实例中的一个父协议栈实例,创建与所述各协议栈实例均不存在关联关系的所述目标socket。
其中,父协议栈实例是APP采用随机方式或者参数指定方式或者负载均衡方式选定的。
进一步,基于并行协议栈实例的数据包处理装置还包括:
更新模块57,与第一确定模块52连接,用于根据所述低层协议处理 后的数据包的个数,更新所述亲和性图谱中所记载的所述目标socket与所述第一协议栈实例之间的亲和性。
判断模块58,与更新模块57和第二确定模块55连接,用于判断n×A是否大于B,其中,A为所述目标socket与所述第一协议栈实例之间的亲和性,B为所述亲和性图谱中记载的所述目标socket与关联的协议栈实例之间的亲和性,n为预设系数,n取正数,具体n的取值可参考运行并行协议栈实例的CPU的处理性能,若CPU的处理性能优良则n可相应取值较小,反之,n取值较大;亲和性图谱所记载的关联协议栈实例是当前与目标socket关联的协议栈实例。
基于此,第二确定模块55进一步包括第一确定单元551和第二确定单元552。
第一确定单元551,用于若n×A不大于B,则确定将所述亲和性图谱中记载的所述目标socket关联的协议栈实例作为与所述目标socket关联的所述第二协议栈实例。
第二确定单元552,用于若n×A大于B,则将所述第一协议栈实例确定为与所述目标socket关联的所述第二协议栈实例,并将所述亲和性图谱中记载的所述目标socket关联的协议栈实例更新为所述第一协议栈实例。
进一步,上层处理模块53,包括:
队列单元531,用于将所述低层协议处理后的所述数据包加入到所述目标socket的底层数据接收队列中。
上层处理单元532,与队列单元531连接,用于当根据所述第二协议栈实例对应的协议栈实例关联链表,轮询到所述目标socket时,利用所述第二协议栈实例对所述底层数据接收队列中的所述数据包进行所述上层协议处理;所述第二协议栈实例对应的协议栈实例关联链表用于指示与所述第二协议栈实例存在关联关系的socket。
本实施例所提供的基于并行协议栈实例的数据包处理装置可设置于并行协议栈上。作为一种可实现方式,其中,低层处理模块51、第一确定模块52、第二确定模块55、更新模块57和判断模块58可设置于第一协议栈实例中;上层处理模块53中的队列单元531可设置于第一协议栈实例中,上层处理模块53中的上层处理单元532可设置于第二协议栈实例中。
进一步,基于并行协议栈实例的数据包处理装置,还包括:接收模块 61、和协议处理模块62。
接收模块61,与第一确定模块52连接,用于接收所述应用APP发送的第一数据包。
第一确定模块52,还用于确定对所述第一数据包进行协议处理所需要的所述目标套接字socket。
第二确定模块55,还用于确定对所述第一数据包进行协议处理所需要的所述目标套接字socket之后,确定与所述目标socket关联的所述第二协议栈实例。
协议处理模块62,与第二确定模块55连接,用于利用所述目标socket和所述第二协议栈实例,对所述第一数据包进行协议处理。
需要说明的是,低层协议处理和上层协议处理共同完成对所述数据包的完整协议处理,例如,底层协议处理完成数据包的OSI中所规定的三层及以下的协议处理,上层协议处理完成OSI中所规定的四层及以上的协议处理,低层协议处理和所述上层协议处理共同完成对所述数据包的OSI中所规定的七层协议处理。
本实施例提供的并行协议栈实例的数据包处理装置的各功能模块可用于执行图1和图2所示的并行协议栈实例的数据包处理方法流程,其具体工作原理不再赘述,详见方法实施例的描述。
本实施例中,利用第一协议栈实例对向该第一协议栈实例分流的数据包进行低层协议处理,确定对低层协议处理后的数据包进行上层协议处理所需的目标socket之后,通过目标socket确定关联的第二协议栈实例,利用目标socket和第二协议栈实例,对低层协议处理后的数据包进行上层协议处理,由于采用了由不同的协议栈分别完成协议处理中的低层协议处理部分和上层协议处理部分,通过目标socket确定进行上层协议处理的第二协议栈实例,从而解决了由于APP指定的协议栈实例与网卡指定的协议栈实例冲突所导致的无法对数据包进行协议处理的技术问题。
图7为本发明另一实施例提供的一种基于并行协议栈实例的数据包处理装置的结构示意图,并行协议栈实例中至少包括第一协议栈实例和第二协议栈实例,如图7所示,包括:接收模块71、第一确定模块72、第一处理模块73和第二确定模块70。
接收模块71,用于接收应用APP发送的第一数据包。
第一确定模块72,与接收模块71连接,用于确定对所述第一数据包进行协议处理所需要的目标套接字socket。
可选的,第一确定模块72具体用于在socket表中进行检索,获得对所述第一数据包进行协议处理所需的目标socket。
第二确定模块70,与第一确定模块72连接,用于根据所述目标socket与第二协议栈实例的关联关系,确定与目标socket关联的第二协议栈实例。
第一处理模块73,与第二确定模块70连接,用于利用目标socket和第二协议栈实例,对所述第一数据包进行协议处理。
其中,目标socket与所述第二协议栈实例的关联关系,是所述第一协议栈实例和所述第二协议栈实例对第二数据包进行协议处理时确定的,所述第一协议栈实例对所述第二数据包进行低层协议处理,所述第二协议栈实例对所述第二数据包进行上层协议处理,所述低层协议处理和所述上层协议处理共同完成对所述第二数据包的完整协议处理。
需要说明的是,低层协议处理和上层协议处理共同完成对所述数据包的完整协议处理,例如,底层协议处理完成数据包的OSI中所规定的三层及以下的协议处理,上层协议处理完成OSI中所规定的四层及以上的协议处理,低层协议处理和所述上层协议处理共同完成对所述数据包的OSI中所规定的七层协议处理。
本实施例中,利用第一协议栈实例对向该第一协议栈实例分流的数据包进行低层协议处理,确定对低层协议处理后的数据包进行上层协议处理所需的目标socket之后,通过目标socket确定关联的第二协议栈实例,利用目标socket和第二协议栈实例,对低层协议处理后的数据包进行上层协议处理,由于采用了由不同的协议栈分别完成协议处理中的低层协议处理部分和上层协议处理部分,通过目标socket确定进行上层协议处理的第二协议栈实例,从而解决了由于APP指定的协议栈实例与网卡指定的协议栈实例冲突所导致的无法对数据包进行协议处理的技术问题。
图8为本发明另一实施例提供的另一种基于并行协议栈实例的数据包处理装置的结构示意图,并行协议栈实例中至少包括第一协议栈实例和第二协议栈实例,如图8所示,在上一实施例的基础上,本实施例中的基于并行协议栈实例的数据包处理装置中的第二确定模块70进一步包括:
判断单元701,用于根据亲和性图谱,判断所述目标socket是否存在 关联的协议栈实例。
其中,亲和性图谱用于记载当前与所述目标socket关联的协议栈实例,亲和性图谱中的关联协议栈实例用于指示当前与所述目标socket关联的协议栈实例。
确定单元702,与判断单元701连接,用于若所述目标socket存在关联的协议栈实例,则确定所述与所述目标socket关联的协议栈实例为所述第二协议栈实例。
进一步,第一处理模块73包括:队列单元731和处理单元732。
队列单元731,用于将所述第一数据包加入到所述目标socket的APP数据发送队列中。
处理单元732,与队列单元731连接,用于当根据所述第二协议栈实例对应的协议栈实例关联链表,轮询到所述目标socket的APP数据发送队列时,利用所述目标socket和所述第二协议栈实例对所述APP数据发送队列中的所述第一数据包分别进行低层协议处理和上层协议处理;所述第二协议栈实例对应的协议栈实例关联链表用于指示与所述第二协议栈实例存在关联关系的socket。
进一步,基于并行协议栈实例的数据包处理装置还包括:创建模块78、队列模块75、解析模块76、第二处理模块77和更新模块80。
创建模块78,与第一确定模块72连接,用于利用父协议栈实例,创建与所述并行协议栈实例包括的各协议栈实例均不存在关联关系的所述目标socket。
其中,父协议栈实例是所述APP采用随机方式或者参数指定方式或者负载均衡方式在各协议栈实例中选定的。
队列模块75,与第一确定模块72连接,用于若所述目标socket不存在关联的协议栈实例,则将控制消息加入到所述目标socket的父协议栈实例的接收队列中;所述目标socket的父协议栈实例是用于创建所述目标socket的协议栈实例;所述控制消息用于指示对所述第一数据包进行协议处理。
解析模块76,与队列模块75连接,用于当轮询到所述父协议栈实例的接收队列中的所述控制消息时,对所述控制消息进行解析,获得所述第一数据包。
第二处理模块77,与解析模块76连接,用于利用所述父协议栈实例对所述第一数据包进行协议处理。
需要说明的是,低层协议处理和上层协议处理共同完成对所述数据包的完整协议处理,例如,底层协议处理完成数据包的OSI中所规定的三层及以下的协议处理,上层协议处理完成OSI中所规定的四层及以上的协议处理,低层协议处理和所述上层协议处理共同完成对所述数据包的OSI中所规定的七层协议处理。也就是说,上层协议处理所对应的网络层次高于低层协议处理所对应的网络层次。
更新模块74,与第二处理模块77连接,用于将所述亲和性图谱中记载的所述目标socket关联的协议栈实例更新为所述父协议栈实例
进一步,基于并行协议栈实例的数据包处理装置还包括:
发送模块79,与第二处理模块77和第一处理模块73连接,用于将所述协议处理后的第一数据包加入到网卡的发送队列中,以使网卡发送所述协议处理后的第一数据包。
本实施例提供的并行协议栈实例的数据包处理装置的各功能模块可用于执行图3和图4所示的并行协议栈实例的数据包处理方法流程,其具体工作原理不再赘述,详见方法实施例的描述。
本实施例中,利用第一协议栈实例对向该第一协议栈实例分流的数据包进行低层协议处理,确定对低层协议处理后的数据包进行上层协议处理所需的目标socket之后,通过目标socket确定关联的第二协议栈实例,利用目标socket和第二协议栈实例,对低层协议处理后的数据包进行上层协议处理,由于采用了由不同的协议栈分别完成协议处理中的低层协议处理部分和上层协议处理部分,通过目标socket确定进行上层协议处理的第二协议栈实例,从而解决了由于APP指定的协议栈实例与网卡指定的协议栈实例冲突所导致的无法对数据包进行协议处理的技术问题。
图9为本发明又一实施例提供的一种基于并行协议栈实例的数据包处理装置的结构示意图,如图9所示,本实施例中的装置可以包括:存储器81、通信接口82和处理器83。
存储器81,用于存放程序。具体的,程序可以包括程序代码,上述程序代码包括计算机操作指令。存储器81可能包含高速RAM存储器,也可能还包括非易失性存储器(non-volatile memory),例如至少一个磁盘存储 器。
通信接口82,用于接收向第一协议栈实例分流的数据包。
处理器83,用于执行存储器81存放的程序,以用于:利用所述第一协议栈实例对网卡向所述第一协议栈实例分流的所述数据包进行低层协议处理;确定对所述低层协议处理后的所述数据包进行上层协议处理所需的目标套接字socket;根据所述目标socket,确定与所述目标socket关联的第二协议栈实例;利用所述目标socket和所述第二协议栈实例对所述低层协议处理后的所述数据包进行所述上层协议处理;其中,所述低层协议处理和所述上层协议处理共同完成对所述数据包的完整协议处理。
可选的,处理器83具体用于利用各协议栈实例中的一个用于初始建立目标socket的父协议栈实例,创建与各协议栈实例均不存在关联关系的所述目标socket,其中,父协议栈实例是APP采用随机方式或者参数指定方式或者负载均衡方式所选定的;利用第一协议栈实例对向所述第一协议栈实例分流的数据包进行低层协议处理,确定对低层协议处理后的数据包进行上层协议处理所需的目标套接字socket;根据所述并行协议栈实例所包括的各协议栈实例与所述目标socket之间的亲和性,从各协议栈实例中,确定第二协议栈实例;所述协议栈实例与所述目标socket之间的亲和性用于指示网卡向该协议栈实例已分流的数据包中,需要利用所述目标socket进行上层协议处理的数据包总数;建立所述目标socket与所述第二协议栈实例之间的关联关系。利用所述目标socket和与所述目标socket关联的第二协议栈实例,对所述低层协议处理后的数据包进行上层协议处理,获得用户数据。
需要说明的是,低层协议处理和上层协议处理共同完成对所述数据包的完整协议处理,例如,底层协议处理完成数据包的OSI中所规定的三层及以下的协议处理,上层协议处理完成OSI中所规定的四层及以上的协议处理,低层协议处理和所述上层协议处理共同完成对所述数据包的OSI中所规定的七层协议处理。
本实施例提供的并行协议栈实例的数据包处理装置的各功能模块可用于执行图1和图2所示的并行协议栈实例的数据包处理方法流程,其具体工作原理不再赘述,详见方法实施例的描述。
本实施例中,利用第一协议栈实例对向该第一协议栈实例分流的数据 包进行低层协议处理,确定对低层协议处理后的数据包进行上层协议处理所需的目标socket之后,通过目标socket确定关联的第二协议栈实例,利用目标socket和第二协议栈实例,对低层协议处理后的数据包进行上层协议处理,由于采用了由不同的协议栈分别完成协议处理中的低层协议处理部分和上层协议处理部分,通过目标socket确定进行上层协议处理的第二协议栈实例,从而解决了由于APP指定的协议栈实例与网卡指定的协议栈实例冲突所导致的无法对数据包进行协议处理的技术问题。
图10为本发明又一实施例提供的另一种基于并行协议栈实例的数据包处理装置的结构示意图,如图10所示,本实施例中的装置可以包括:存储器91、通信接口92和处理器93。
存储器91,用于存放程序。具体的,程序可以包括程序代码,上述程序代码包括计算机操作指令。存储器91可能包含高速RAM存储器,也可能还包括非易失性存储器(non-volatile memory),例如至少一个磁盘存储器。
通信接口92,用于接收APP发送的第一数据包。
处理器93,用于执行存储器91存放的程序,以用于:接收应用APP发送的第一数据包;确定对所述第一数据包进行协议处理所需要的目标套接字socket;根据所述目标socket与第二协议栈实例的关联关系,确定与所述目标socket关联的所述第二协议栈实例;利用所述目标socket和所述第二协议栈实例,对所述第一数据包进行协议处理;其中,所述目标socket与所述第二协议栈实例的关联关系,是所述第一协议栈实例和所述第二协议栈实例对第二数据包进行协议处理时确定的,所述第一协议栈实例对所述第二数据包进行低层协议处理,所述第二协议栈实例对所述第二数据包进行上层协议处理,所述低层协议处理和所述上层协议处理共同完成对所述第二数据包的完整协议处理。
可选的,处理器93具体用于根据亲和性图谱,判断所述目标socket是否存在关联的协议栈实例;若所述目标socket存在关联的协议栈实例,则确定与所述目标socket关联的第二协议栈实例,利用所述目标socket和所述第二协议栈实例,对所述第一数据包进行协议处理,如将第一数据包加入到所述目标socket的APP数据发送队列中,当根据第二协议栈实例对应的协议栈实例关联链表,轮询到目标socket的APP数据发送队列时,利 用目标socket和第二协议栈实例对APP数据发送队列中的第一数据包分别进行低层协议处理和上层协议处理,其中,第二协议栈实例对应的协议栈实例关联链表用于指示与所述第二协议栈实例存在关联关系的目标socket。若所述目标socket不存在关联的协议栈实例,则将控制消息加入到所述目标socket的父协议栈实例的接收队列中;所述目标socket的父协议栈实例是用于创建所述目标socket的协议栈实例;所述控制消息用于指示对所述第一数据包进行协议处理;当轮询到所述接收队列中的所述控制消息时,对所述控制消息进行解析,获得所述第一数据包;利用所述父协议栈实例对所述第一数据包进行协议处理。
需要说明的是,低层协议处理和上层协议处理共同完成对所述数据包的完整协议处理,例如,底层协议处理完成数据包的OSI中所规定的三层及以下的协议处理,上层协议处理完成OSI中所规定的四层及以上的协议处理,低层协议处理和所述上层协议处理共同完成对所述数据包的OSI中所规定的七层协议处理。
进一步,通信接口92还用于将所述协议处理后的第一数据包加入到网卡的发送队列中,以使网卡发送所述协议处理后的第一数据包。
本实施例提供的并行协议栈实例的数据包处理装置的各功能模块可用于执行图3和图4所示的并行协议栈实例的数据包处理方法流程,其具体工作原理不再赘述,详见方法实施例的描述。
本实施例中,利用第一协议栈实例对向该第一协议栈实例分流的数据包进行低层协议处理,确定对低层协议处理后的数据包进行上层协议处理所需的目标socket之后,通过目标socket确定关联的第二协议栈实例,利用目标socket和第二协议栈实例,对低层协议处理后的数据包进行上层协议处理,由于采用了由不同的协议栈分别完成协议处理中的低层协议处理部分和上层协议处理部分,通过目标socket确定进行上层协议处理的第二协议栈实例,从而解决了由于APP指定的协议栈实例与网卡指定的协议栈实例冲突所导致的无法对数据包进行协议处理的技术问题。
本领域普通技术人员可以理解:实现上述各方法实施例的全部或部分步骤可以通过程序指令相关的硬件来完成。前述的程序可以存储于一计算机可读取存储介质中。该程序在执行时,执行包括上述各方法实施例的步骤;而前述的存储介质包括:ROM、RAM、磁碟或者光盘等各种可以存储 程序代码的介质。
最后应说明的是:以上各实施例仅用以说明本发明的技术方案,而非对其限制;尽管参照前述各实施例对本发明进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分或者全部技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本发明各实施例技术方案的范围。

Claims (32)

  1. 一种基于并行协议栈实例的数据包处理方法,其特征在于,所述并行协议栈实例中至少包括第一协议栈实例和第二协议栈实例,所述方法包括:
    利用所述第一协议栈实例对网卡向所述第一协议栈实例分流的所述数据包进行低层协议处理;
    确定对所述低层协议处理后的所述数据包进行上层协议处理所需的目标套接字socket;
    根据所述目标socket,确定与所述目标socket关联的第二协议栈实例;
    利用所述目标socket和所述第二协议栈实例对所述低层协议处理后的所述数据包进行所述上层协议处理;
    其中,所述低层协议处理和所述上层协议处理共同完成对所述数据包的完整协议处理。
  2. 根据权利要求1所述的方法,其特征在于,所述根据所述目标socket,确定与所述目标socket关联的第二协议栈实例,包括:
    根据亲和性图谱中所述目标socket与所述并行协议栈实例包含的每个协议栈实例之间的亲和性,确定与所述目标socket关联的所述第二协议栈实例;所述目标socket与所述每个协议栈实例之间的亲和性用于指示所述网卡向所述每个协议栈实例已分流的数据包中,需要利用所述目标socket进行上层协议处理的数据包数量。
  3. 根据权利要求2所述的方法,其特征在于,所述根据亲和性图谱中所述目标socket与所述并行协议栈实例包含的每个协议栈实例之间的亲和性,确定与所述目标socket关联的所述第二协议栈实例之前,还包括:
    根据所述低层协议处理后的所述数据包的个数,更新所述亲和性图谱中所记载的所述目标socket与所述第一协议栈实例之间的亲和性。
  4. 根据权利要求3所述的方法,其特征在于,所述根据所述低层协议处理后的所述数据包的个数,更新所述亲和性图谱中所记载的所述目标socket与所述第一协议栈实例之间的亲和性之后,还包括:
    判断n×A是否大于B,其中,A为所述目标socket与所述第一协议栈 实例之间的亲和性,B为所述亲和性图谱中记载的所述目标socket与关联的协议栈实例之间的亲和性,n为预设系数;
    则所述根据亲和性图谱中所述目标socket与所述并行协议栈实例包含的每个协议栈实例之间的亲和性,确定与所述目标socket关联的所述第二协议栈实例,包括:
    若n×A不大于B,则确定将所述亲和性图谱中记载的所述目标socket关联的协议栈实例作为与所述目标socket关联的所述第二协议栈实例。
  5. 根据权利要求4所述的方法,其特征在于,所述根据亲和性图谱中所述目标socket与所述并行协议栈实例包含的每个协议栈实例之间的亲和性,确定与所述目标socket关联的所述第二协议栈实例,还包括:
    若n×A大于B,则将所述第一协议栈实例确定为与所述目标socket关联的所述第二协议栈实例,并将所述亲和性图谱中记载的所述目标socket关联的协议栈实例更新为所述第一协议栈实例。
  6. 根据权利要求1-5任一项所述的方法,其特征在于,所述确定对所述低层协议处理后的所述数据包进行上层协议处理所需的目标套接字socket,包括:
    在socket表中进行检索,获得对所述低层协议处理后的所述数据包进行上层协议处理所需的所述目标socket。
  7. 根据权利要求1-5任一项所述的方法,其特征在于,所述利用所述目标socket和所述第二协议栈实例对所述低层协议处理后的所述数据包进行所述上层协议处理,包括:
    将所述低层协议处理后的所述数据包加入到所述目标socket的底层数据接收队列中;
    当根据所述第二协议栈实例对应的协议栈实例关联链表,轮询到所述目标socket时,利用所述第二协议栈实例对所述底层数据接收队列中的所述数据包进行所述上层协议处理;所述第二协议栈实例对应的协议栈实例关联链表用于指示与所述第二协议栈实例存在关联关系的socket。
  8. 根据权利要求1-5任一项所述的方法,其特征在于,所述确定对所述低层协议处理后的所述数据包进行上层协议处理所需的目标套接字socket之前,还包括:
    利用所述并行协议栈实例包括的各协议栈实例中的一个父协议栈实例, 创建与所述各协议栈实例均不存在关联关系的所述目标socket;所述父协议栈实例是应用APP采用随机方式或者参数指定方式或者负载均衡方式选定的。
  9. 根据权利要求1-5任一项所述的方法,其特征在于,所述方法还包括:
    接收所述应用APP发送的第一数据包;
    确定对所述第一数据包进行协议处理所需要的所述目标套接字socket;
    确定与所述目标socket关联的所述第二协议栈实例;
    利用所述目标socket和所述第二协议栈实例,对所述第一数据包进行协议处理。
  10. 一种基于并行协议栈实例的数据包处理方法,其特征在于,所述并行协议栈实例中至少包括第一协议栈实例和第二协议栈实例,所述方法包括:
    接收应用APP发送的第一数据包;
    确定对所述第一数据包进行协议处理所需要的目标套接字socket;
    根据所述目标socket与第二协议栈实例的关联关系,确定与所述目标socket关联的所述第二协议栈实例;
    利用所述目标socket和所述第二协议栈实例,对所述第一数据包进行协议处理;
    其中,所述目标socket与所述第二协议栈实例的关联关系,是所述第一协议栈实例和所述第二协议栈实例对第二数据包进行协议处理时确定的,所述第一协议栈实例对所述第二数据包进行低层协议处理,所述第二协议栈实例对所述第二数据包进行上层协议处理,所述低层协议处理和所述上层协议处理共同完成对所述第二数据包的完整协议处理。
  11. 根据权利要求10所述的方法,其特征在于,所述利用所述目标socket和所述第二协议栈实例,对所述第一数据包进行协议处理,包括:
    将所述第一数据包加入到所述目标socket的APP数据发送队列中;
    当根据所述第二协议栈实例对应的协议栈实例关联链表,轮询到所述目标socket的APP数据发送队列时,利用所述目标socket和所述第二协议栈实例对所述APP数据发送队列中的所述第一数据包分别进行低层协议处理和上层协议处理;所述第二协议栈实例对应的协议栈实例关联链表用于指示 与所述第二协议栈实例存在关联关系的socket。
  12. 根据权利要求10所述的方法,其特征在于,所述根据所述目标socket与第二协议栈实例的关联关系,确定与所述目标socket关联的第二协议栈实例,包括:
    根据亲和性图谱,判断所述目标socket是否存在关联的协议栈实例;所述亲和性图谱用于记载与所述目标socket关联的协议栈实例;
    若所述目标socket存在关联的协议栈实例,则确定所述与所述目标socket关联的协议栈实例为所述第二协议栈实例。
  13. 根据权利要求12所述的方法,其特征在于,所述方法还包括:
    若所述目标socket不存在关联的协议栈实例,则将控制消息加入到所述目标socket的父协议栈实例的接收队列中;所述目标socket的父协议栈实例是用于创建所述目标socket的协议栈实例;所述控制消息用于指示对所述第一数据包进行协议处理;
    当轮询到所述父协议栈实例的接收队列中的所述控制消息时,对所述控制消息进行解析,获得所述第一数据包;
    利用所述父协议栈实例对所述第一数据包进行协议处理;
    将所述亲和性图谱中记载的所述目标socket关联的协议栈实例更新为所述父协议栈实例。
  14. 根据权利要求10-13任一项所述的方法,其特征在于,所述确定对所述第一数据包进行协议处理所需要的目标套接字socket,包括:
    在socket表中进行检索,确定对所述第一数据包进行协议处理所需的所述目标socket。
  15. 根据权利要求13所述的方法,其特征在于,所述确定对所述第一数据包进行协议处理所需要的目标套接字socket之前,还包括:
    利用所述父协议栈实例,创建与所述并行协议栈实例包括的各协议栈实例均不存在关联关系的所述目标socket,所述父协议栈实例是所述APP采用随机方式或者参数指定方式或者负载均衡方式在所述各协议栈实例中选定的。
  16. 根据权利要求10-13任一项所述的方法,其特征在于,所述利用所述目标socket和所述第二协议栈实例,对所述第一数据包进行协议处理之后,还包括:
    将所述协议处理后的第一数据包加入到网卡的发送队列中,以使所述网卡发送所述协议处理后的第一数据包。
  17. 一种基于并行协议栈实例的数据包处理装置,其特征在于,所述并行协议栈实例中至少包括第一协议栈实例和第二协议栈实例,所述装置包括:
    低层处理模块,用于利用所述第一协议栈实例对网卡向所述第一协议栈实例分流的所述数据包进行低层协议处理;
    第一确定模块,用于确定对所述低层协议处理后的所述数据包进行上层协议处理所需的目标套接字socket;
    第二确定模块,用于根据所述目标socket,确定与所述目标socket关联的第二协议栈实例;
    上层处理模块,用于利用所述目标socket和所述第二协议栈实例对所述低层协议处理后的所述数据包进行所述上层协议处理;
    其中,所述低层协议处理模块和所述上层协议处理模块共同完成对所述数据包的完整协议处理。
  18. 根据权利要求17所述的装置,其特征在于,
    所述第二确定模块,具体用于根据亲和性图谱中所述目标socket与所述并行协议栈实例包含的每个协议栈实例之间的亲和性,确定与所述目标socket关联的所述第二协议栈实例;所述目标socket与所述每个协议栈实例之间的亲和性用于指示所述网卡向所述每个协议栈实例已分流的数据包中,需要利用所述目标socket进行上层协议处理的数据包数量。
  19. 根据权利要求18所述的装置,其特征在于,所述装置,还包括:
    更新模块,用于根据所述低层协议处理后的所述数据包的个数,更新所述亲和性图谱中所记载的所述目标socket与所述第一协议栈实例之间的亲和性。
  20. 根据权利要求19所述的装置,其特征在于,所述装置,还包括:
    判断模块,用于判断n×A是否大于B,其中,A为所述目标socket与所述第一协议栈实例之间的亲和性,B为所述亲和性图谱中记载的所述目标socket与关联的协议栈实例之间的亲和性,n为预设系数;
    则所述第二确定模块,包括:
    第一确定单元,用于若n×A不大于B,则确定将所述亲和性图谱中记 载的所述目标socket关联的协议栈实例作为与所述目标socket关联的所述第二协议栈实例。
  21. 根据权利要求20所述的装置,其特征在于,所述第二确定模块,还包括:
    第二确定单元,用于若n×A大于B,则将所述第一协议栈实例确定为与所述目标socket关联的所述第二协议栈实例,并将所述亲和性图谱中记载的所述目标socket关联的协议栈实例更新为所述第一协议栈实例。
  22. 根据权利要求17-21任一项所述的装置,其特征在于,
    所述第一确定模块,具体用于在socket表中进行检索,获得对所述低层协议处理后的数据包进行上层协议处理所需的所述目标socket。
  23. 根据权利要求17-21任一项所述的装置,其特征在于,所述上层处理模块,包括:
    队列单元,用于将所述低层协议处理后的所述数据包加入到所述目标socket的底层数据接收队列中;
    上层处理单元,用于当根据所述第二协议栈实例对应的协议栈实例关联链表,轮询到所述目标socket时,利用所述第二协议栈实例对所述底层数据接收队列中的所述数据包进行所述上层协议处理;所述第二协议栈实例对应的协议栈实例关联链表用于指示与所述第二协议栈实例存在关联关系的socket。
  24. 根据权利要求17-21任一项所述的装置,其特征在于,所述装置,还包括:
    创建模块,用于利用所述并行协议栈实例包括的各协议栈实例中的一个父协议栈实例,创建与所述各协议栈实例均不存在关联关系的所述目标socket;所述父协议栈实例是应用APP采用随机方式或者参数指定方式或者负载均衡方式选定的。
  25. 根据权利要求17-21任一项所述的装置,其特征在于,所述装置,还包括:
    接收模块,用于接收所述应用APP发送的第一数据包;
    所述第一确定模块,还用于确定对所述第一数据包进行协议处理所需要的所述目标套接字socket;
    所述第二确定模块,还用于确定对所述第一数据包进行协议处理所需要 的所述目标套接字socket之后,确定与所述目标socket关联的所述第二协议栈实例;
    协议处理模块,用于利用所述目标socket和所述第二协议栈实例,对所述第一数据包进行协议处理。
  26. 一种基于并行协议栈实例的数据包处理装置,其特征在于,所述并行协议栈实例中至少包括第一协议栈实例和第二协议栈实例,所述装置包括:
    接收模块,用于接收应用APP发送的第一数据包;
    第一确定模块,用于确定对所述第一数据包进行协议处理所需要的目标套接字socket;
    第二确定模块,用于根据所述目标socket与第二协议栈实例的关联关系,确定与所述目标socket关联的所述第二协议栈实例;
    第一处理模块,用于利用所述目标socket和所述第二协议栈实例,对所述第一数据包进行协议处理;
    其中,所述目标socket与所述第二协议栈实例的关联关系,是所述第一协议栈实例和所述第二协议栈实例对第二数据包进行协议处理时确定的,所述第一协议栈实例对所述第二数据包进行低层协议处理,所述第二协议栈实例对所述第二数据包进行上层协议处理,所述低层协议处理和所述上层协议处理共同完成对所述第二数据包的完整协议处理。
  27. 根据权利要求26所述的装置,其特征在于,所述第一处理模块,包括:
    队列单元,用于将所述第一数据包加入到所述目标socket的APP数据发送队列中;
    处理单元,用于当根据所述第二协议栈实例对应的协议栈实例关联链表,轮询到所述目标socket的APP数据发送队列时,利用所述目标socket和所述第二协议栈实例对所述APP数据发送队列中的所述第一数据包分别进行低层协议处理和上层协议处理;所述第二协议栈实例对应的协议栈实例关联链表用于指示与所述第二协议栈实例存在关联关系的socket。
  28. 根据权利要求26所述的装置,其特征在于,所述第二确定模块,包括:
    判断单元,用于根据亲和性图谱,判断所述目标socket是否存在关联的 协议栈实例;所述亲和性图谱用于记载与所述目标socket关联的协议栈实例;
    确定单元,用于若所述目标socket存在关联的协议栈实例,则确定所述与所述目标socket关联的协议栈实例为所述第二协议栈实例。
  29. 根据权利要求28所述的装置,其特征在于,所述装置,还包括:
    队列模块,用于若所述目标socket不存在关联的协议栈实例,则将控制消息加入到所述目标socket的父协议栈实例的接收队列中;所述目标socket的父协议栈实例是用于创建所述目标socket的协议栈实例;所述控制消息用于指示对所述第一数据包进行协议处理;
    解析模块,用于当轮询到所述父协议栈实例的接收队列中的所述控制消息时,对所述控制消息进行解析,获得所述第一数据包;
    第二处理模块,用于利用所述父协议栈实例对所述第一数据包进行协议处理;
    更新模块,用于将所述亲和性图谱中记载的所述目标socket关联的协议栈实例更新为所述父协议栈实例。
  30. 根据权利要求26-29任一项所述的装置,其特征在于,
    所述第一确定模块,具体用于在socket表中进行检索,确定对所述第一数据包进行协议处理所需的所述目标socket。
  31. 根据权利要求29所述的装置,其特征在于,所述装置,还包括:
    创建模块,用于利用所述父协议栈实例,创建与所述并行协议栈实例包括的各协议栈实例均不存在关联关系的所述目标socket,所述父协议栈实例是所述APP采用随机方式或者参数指定方式或者负载均衡方式在所述各协议栈实例中选定的。
  32. 根据权利要求26-29任一项所述的装置,其特征在于,所述装置,还包括:
    发送模块,用于将所述协议处理后的第一数据包加入到网卡的发送队列中,以使所述网卡发送所述协议处理后的第一数据包。
PCT/CN2014/091614 2014-01-29 2014-11-19 基于并行协议栈实例的数据包处理方法和装置 WO2015113435A1 (zh)

Priority Applications (3)

Application Number Priority Date Filing Date Title
JP2016549111A JP6359111B2 (ja) 2014-01-29 2014-11-19 並列プロトコル・スタック・インスタンスに基づいてデータパケットを処理する方法および装置
EP14880468.5A EP3091706B1 (en) 2014-01-29 2014-11-19 Data packet processing method and apparatus based on parallel protocol stack instances
US15/222,753 US10069947B2 (en) 2014-01-29 2016-07-28 Method and apparatus for processing data packet based on parallel protocol stack instances

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201410043721.0A CN104811431B (zh) 2014-01-29 2014-01-29 基于并行协议栈实例的数据包处理方法和装置
CN201410043721.0 2014-01-29

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US15/222,753 Continuation US10069947B2 (en) 2014-01-29 2016-07-28 Method and apparatus for processing data packet based on parallel protocol stack instances

Publications (1)

Publication Number Publication Date
WO2015113435A1 true WO2015113435A1 (zh) 2015-08-06

Family

ID=53695928

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2014/091614 WO2015113435A1 (zh) 2014-01-29 2014-11-19 基于并行协议栈实例的数据包处理方法和装置

Country Status (5)

Country Link
US (1) US10069947B2 (zh)
EP (1) EP3091706B1 (zh)
JP (1) JP6359111B2 (zh)
CN (1) CN104811431B (zh)
WO (1) WO2015113435A1 (zh)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2020224300A1 (zh) * 2019-05-06 2020-11-12 创新先进技术有限公司 基于用户态协议栈的报文分流方法、装置及系统
US10904719B2 (en) 2019-05-06 2021-01-26 Advanced New Technologies Co., Ltd. Message shunting method, device and system based on user mode protocol stack

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108270813B (zh) * 2016-12-30 2021-02-12 华为技术有限公司 一种异构多协议栈方法、装置及系统
CN108667864B (zh) * 2017-03-29 2020-07-28 华为技术有限公司 一种进行资源调度的方法和装置
WO2019019023A1 (zh) 2017-07-25 2019-01-31 Oppo广东移动通信有限公司 切换方法、接入网设备和终端设备
AU2018446009A1 (en) 2018-10-15 2021-05-06 Guangdong Oppo Mobile Telecommunications Corp., Ltd. Wireless communication method and device

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101217464A (zh) * 2007-12-28 2008-07-09 北京大学 一种udp数据包的传输方法
CN101227504A (zh) * 2008-02-18 2008-07-23 华为技术有限公司 一种实现协议栈之间切换的方法及装置
CN101399692A (zh) * 2007-09-27 2009-04-01 华为技术有限公司 业务迁移的方法和系统

Family Cites Families (23)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2002502189A (ja) * 1998-01-29 2002-01-22 ブリティッシュ・テレコミュニケーションズ・パブリック・リミテッド・カンパニー 移動データ転送用通信システム
US7647414B2 (en) 2002-07-26 2010-01-12 Broadcom Corporation System and method for managing multiple stack environments
CA2408474A1 (en) * 2002-10-17 2004-04-17 Ibm Canada Limited-Ibm Canada Limitee Apparatus and method for enabling efficient multi-protocol database transaction processing
US7802001B1 (en) * 2002-10-18 2010-09-21 Astute Networks, Inc. System and method for flow control within a stateful protocol processing system
US7562145B2 (en) * 2003-08-28 2009-07-14 International Business Machines Corporation Application instance level workload distribution affinities
US7734829B2 (en) 2004-06-09 2010-06-08 Emc Corporation Methods, systems, and computer program products for transparently controlling communications between network applications and a plurality of network communications protocol stacks using deferred protocol stack association
US7808983B2 (en) * 2004-07-08 2010-10-05 Cisco Technology, Inc. Network device architecture for centralized packet processing
US20070242671A1 (en) 2006-04-13 2007-10-18 Christenson David A Method and Apparatus for Routing Data Packets Between Different Internet Communications Stack Instances
CN1870654A (zh) 2006-06-21 2006-11-29 中国科学院计算技术研究所 一种支持ipv4和ipv6双协议栈网络通信模块的实现方法
DE602007013652D1 (de) * 2006-08-04 2011-05-19 Canon Kk Kommunikationsvorrichtung und Kommunikationssteuerungsverfahren
CN101132456B (zh) 2006-08-22 2011-08-10 中兴通讯股份有限公司 蓝牙多功能遥控器装置及其实现语音通信的方法
US7715428B2 (en) 2007-01-31 2010-05-11 International Business Machines Corporation Multicore communication processing
PT103744A (pt) 2007-05-16 2008-11-17 Coreworks S A Arquitectura de acesso ao núcleo de rede.
CN101415025B (zh) 2008-09-28 2011-09-07 中控科技集团有限公司 网络数据处理的方法、装置和系统
CN101426027B (zh) 2008-10-28 2012-06-06 华为技术有限公司 面向分布式虚拟机监控器的底层通信方法
US8849972B2 (en) 2008-11-25 2014-09-30 Polycom, Inc. Method and system for dispatching received sessions between a plurality of instances of an application using the same IP port
CN101541098A (zh) 2008-12-19 2009-09-23 中国移动通信集团浙江有限公司 移动通信中的协议栈仿真方法
CN101867558B (zh) 2009-04-17 2012-11-14 深圳市永达电子股份有限公司 用户态网络协议栈系统及处理报文的方法
CN101931584A (zh) 2009-06-22 2010-12-29 中兴通讯股份有限公司 支持同一系统中多种协议栈之间数据转发的方法和系统
CN101656677B (zh) 2009-09-18 2011-11-16 杭州迪普科技有限公司 一种报文分流处理方法及装置
WO2012105677A1 (ja) * 2011-02-04 2012-08-09 日本電気株式会社 パケット処理装置、パケット処理方法およびプログラム
CN102523208A (zh) 2011-12-06 2012-06-27 无锡聚云科技有限公司 多核架构下的应用层协议并行处理方法
CN104811432A (zh) 2014-01-29 2015-07-29 华为技术有限公司 基于并行协议栈实例的数据包处理方法和装置

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101399692A (zh) * 2007-09-27 2009-04-01 华为技术有限公司 业务迁移的方法和系统
CN101217464A (zh) * 2007-12-28 2008-07-09 北京大学 一种udp数据包的传输方法
CN101227504A (zh) * 2008-02-18 2008-07-23 华为技术有限公司 一种实现协议栈之间切换的方法及装置

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2020224300A1 (zh) * 2019-05-06 2020-11-12 创新先进技术有限公司 基于用户态协议栈的报文分流方法、装置及系统
US10904719B2 (en) 2019-05-06 2021-01-26 Advanced New Technologies Co., Ltd. Message shunting method, device and system based on user mode protocol stack

Also Published As

Publication number Publication date
EP3091706B1 (en) 2020-01-08
US20160337483A1 (en) 2016-11-17
US10069947B2 (en) 2018-09-04
JP2017509055A (ja) 2017-03-30
EP3091706A4 (en) 2016-12-28
CN104811431A (zh) 2015-07-29
CN104811431B (zh) 2018-01-16
EP3091706A1 (en) 2016-11-09
JP6359111B2 (ja) 2018-07-18

Similar Documents

Publication Publication Date Title
US11451476B2 (en) Multi-path transport design
WO2015113435A1 (zh) 基于并行协议栈实例的数据包处理方法和装置
US10044616B2 (en) Co-existence of routable and non-routable RDMA solutions on the same network interface
CN110050448B (zh) 管理多播业务的系统和方法
US8634415B2 (en) Method and system for routing network traffic for a blade server
CN103477588B (zh) 刀片服务器中刀片间网络业务的分类和管理方法和系统
US9602428B2 (en) Method and apparatus for locality sensitive hash-based load balancing
US20130148546A1 (en) Support for converged traffic over ethernet link aggregation (lag)
US11496599B1 (en) Efficient flow management utilizing control packets
JP2017517220A (ja) OpenFlow通信方法及びシステム、制御部、並びにサービスゲートウェイ
CN114915587B (zh) 流表老化管理方法及相关设备
WO2015165270A1 (zh) 一种数据包处理方法及设备
CN109361749B (zh) 报文处理方法、相关设备及计算机存储介质
WO2019084805A1 (zh) 一种分发报文的方法及装置
KR101984846B1 (ko) 객체 이동성을 제공하는 통신 방법 및 장치
WO2014067055A1 (zh) 流表刷新的方法及装置
JP6279970B2 (ja) プロセッサ、通信装置、通信システム、通信方法およびコンピュータプログラム
US12010195B2 (en) Efficient flow management utilizing control packets

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: 14880468

Country of ref document: EP

Kind code of ref document: A1

ENP Entry into the national phase

Ref document number: 2016549111

Country of ref document: JP

Kind code of ref document: A

NENP Non-entry into the national phase

Ref country code: DE

REEP Request for entry into the european phase

Ref document number: 2014880468

Country of ref document: EP

WWE Wipo information: entry into national phase

Ref document number: 2014880468

Country of ref document: EP