Data packet processing method and device, equipment and storage medium

By performing IPsec operations through a virtual network card, the method integrates IPsec without altering the TCP/IP protocol stack, ensuring easier maintenance and upgrades.

CN119094141APending Publication Date: 2024-12-06GUANGDONG OPPO MOBILE TELECOMMUNICATIONS CORP LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310657969.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-06-05
Publication Date
2024-12-06

AI Technical Summary

Technical Problem

Direct implementation of the IPsec protocol on the TCP/IP protocol stack requires major changes to the original code, disrupting the protocol stack's structure and complicating maintenance and upgrades.

Method used

Performing IPsec operations through a virtual network card without altering the TCP/IP protocol stack, allowing IPsec operations to be integrated without modifying the network layer processing of IP packets.

Benefits of technology

Preserves the original code structure of the TCP/IP protocol stack, facilitating easier maintenance and upgrades while implementing IPsec functionality.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119094141A_ABST
    Figure CN119094141A_ABST
Patent Text Reader

Abstract

The invention discloses a data packet processing method and device, equipment and a storage medium, and relates to the field of communication. The method comprises the following steps: performing SA query on a data packet in a first format; under the condition that the result of the SA query indicates that IPsec operation is performed on the data packet in the first format, the data packet in the first format is transmitted to the virtual network card; and performing the IPsec operation on the data packet in the first format through the virtual network card to obtain a data packet in a second format. According to the method, the TCP / IP protocol stack does not need to be greatly changed, and subsequent maintenance and upgrading of the protocol stack are facilitated.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of communications, and in particular to a data packet processing method, device, equipment and storage medium. Background Art

[0002] Internet Protocol Security (IPsec) is a protocol used to provide security services for Internet communications, and is implemented on the basis of the Transmission Control Protocol / Internet Protocol (TCP / IP) protocol.

[0003] In the related art, in order to directly implement the IPsec protocol process based on the TCP / IP protocol stack, it is usually necessary to destroy the original code of the TCP / IP protocol stack and make major changes to the original code of the TCP / IP protocol stack, which is not conducive to subsequent protocol stack maintenance, upgrades, etc. Summary of the invention

[0004] The present application provides a method, apparatus, device and storage medium for processing a data packet. The technical solution is as follows:

[0005] According to one aspect of the present application, a data packet processing method is provided, the method being performed by an electronic device, the electronic device including a virtual network card, the method comprising:

[0006] Performing a security association SA query on the data packet in the first format;

[0007] When the result of the SA query indicates that an IPsec operation is to be performed on the data packet in the first format, the data packet in the first format is transferred to the virtual network card;

[0008] The IPsec operation is performed on the data packet in the first format through the virtual network card to obtain a data packet in a second format.

[0009] According to one aspect of the present application, a data packet processing device is provided, the device comprising:

[0010] A query module, used for performing a security alliance SA query on a data packet in a first format;

[0011] a transfer module, configured to transfer the data packet in the first format to the virtual network card when the result of the SA query indicates that an IPsec operation is performed on the data packet in the first format;

[0012] The virtual network card module is used to perform the IPsec operation on the data packet in the first format to obtain a data packet in the second format.

[0013] According to one aspect of the present application, an electronic device is provided, comprising: a processor; a transceiver connected to the processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to load and execute the executable instructions to implement the data packet processing method as described in the above aspects.

[0014] According to one aspect of the present application, a computer-readable storage medium is provided, in which executable instructions are stored. The executable instructions are loaded and executed by a processor to implement the data packet processing method as described in the above aspects.

[0015] According to one aspect of the present application, a computer program product is provided, which includes computer instructions, the computer instructions are stored in a computer-readable storage medium, a processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes to implement the data packet processing method described in the above aspects.

[0016] According to one aspect of the present application, a chip is provided, which includes a programmable logic circuit and / or program instructions, and when the chip is running, it is used to implement the data packet processing method described in the above aspects.

[0017] According to one aspect of the present application, a computer program is provided, wherein the computer program includes computer instructions, and a processor of a computer device executes the computer instructions so that the computer device executes the data packet processing method as described in the above aspects.

[0018] The technical solution provided by the embodiments of the present application includes at least the following beneficial effects:

[0019] IPsec operations are performed by the virtual network card, and there is no need to insert IPsec operations into the process of processing IP packets at the network layer. Therefore, there is no need to make major changes to the TCP / IP protocol stack. The functions of the IPsec protocol can be implemented while retaining the original code structure of the TCP / IP protocol stack to a large extent, which is conducive to the subsequent maintenance and upgrade of the protocol stack. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0021] Figure 1 A schematic diagram of the structure of an lwIP protocol stack in the related art is shown;

[0022] Figure 2 A schematic diagram of the structure of an lwIP protocol stack in the related art is shown;

[0023] Figure 3 A schematic diagram of a process for implementing data transmission based on the IPsec protocol in the related art is shown;

[0024] Figure 4 A schematic diagram of a process for implementing data reception based on the IPsec protocol in the related art is shown;

[0025] Figure 5 A schematic diagram of a communication system provided by some exemplary embodiments of the present application is shown;

[0026] Figure 6 A schematic flow chart of a data packet processing method provided by some exemplary embodiments of the present application is shown;

[0027] Figure 7 A schematic flow chart of a data packet processing method provided by some exemplary embodiments of the present application is shown;

[0028] Figure 8 A schematic flow chart of a data packet processing method provided by some exemplary embodiments of the present application is shown;

[0029] Fig. 9 A schematic diagram of the structure of an lwIP protocol stack provided by some exemplary embodiments of the present application is shown;

[0030] Fig.10 A schematic flow chart of a data packet processing method provided by some exemplary embodiments of the present application is shown;

[0031] Fig.11 A structural block diagram of a data packet processing device provided by some exemplary embodiments of the present application is shown;

[0032] Fig.12 A schematic structural diagram of an electronic device provided by some exemplary embodiments of the present application is shown. DETAILED DESCRIPTION

[0033] In order to make the purpose, technical scheme and advantages of the present application clearer, the implementation mode of the present application will be further described in detail below in conjunction with the accompanying drawings. The exemplary embodiments will be described in detail here, and examples thereof are shown in the accompanying drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The implementation modes described in the following exemplary embodiments do not represent all implementation modes consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the attached claims.

[0034] The terms used in this disclosure are for the purpose of describing specific embodiments only and are not intended to limit the disclosure. The singular forms of "a", "said" and "the" used in this disclosure and the appended claims are also intended to include plural forms unless the context clearly indicates otherwise. It should also be understood that the term "and / or" used herein refers to and includes any or all possible combinations of one or more associated listed items.

[0035] It should be understood that although the terms first, second, third, etc. may be used in the present disclosure to describe various information, such information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of the present disclosure, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".

[0036] Light weight IP (lwIP) structure:

[0037] The Transmission Control Protocol / Internet Protocol (TCP / IP) protocol suite contains a series of network protocols that form the basis of the Internet and is the core protocol for Internet communications.

[0038] The implementation basis of the data packet processing method provided by the present application is the TCP / IP protocol. In other words, the data packet processing method provided by the present application can be used in any scenario where the TCP / IP protocol is used for Internet communication.

[0039] The following uses the lwIP protocol stack as an example to illustrate how the data packet processing method provided by this application is implemented on the basis of the lwIP protocol. When the data packet processing method provided by this application is applied to other TCP / IP protocol stacks (such as BSD stack, uC / IP stack, uIP stack, TinyTcp stack), the relevant content of the data packet processing method provided by this application applied to the lwIP protocol stack can be referred to, and no further details will be given.

[0040] lwIP is a lightweight TCP / IP protocol stack. The original intention of lwIP is to reduce the occupation of random access memory (RAM) while maintaining the main functions of the TCP / IP protocol, that is, to implement the functions of basic transport layer protocols and network side protocols with a smaller memory occupation.

[0041] The hierarchical structure of lwIP is as follows Figure 1 As shown, the application layer 110, the transport layer 120, the network layer 130 and the network interface layer 140 are involved.

[0042] The application layer 110 is at the top of the hierarchical structure and is responsible for sending and receiving data. The application layer 110 provides specific applications for Internet operations. Each application can select the required transmission service type and organize the data according to the requirements of the transport layer before transmitting it to the lower layer.

[0043] The basic task of the transport layer 120 is to provide data transmission services. The transport layer 120 must not only systematically manage the flow of data information, but also provide reliable transmission services to ensure that data reaches the destination accurately and in an orderly manner. In short, the transport layer 120 provides services such as flow control, error control, and Quality of Service (QoS) management.

[0044] The network layer 130 is also called the network interconnection layer or IP layer. The intermediate device used by the network layer 130 is called a router. The network layer 130 has three main functions: encapsulating packets into datagrams; sending datagrams directly to the target computer or router; and handing over datagrams to the corresponding network interface module in the network interface layer 140.

[0045] The network interface layer 140 includes a data link layer and a physical layer (not shown in the figure). The data link layer may also be called a link layer or a Netif network card layer, which is used to process the hardware part of Internet communication, such as a physical interface, optical fiber, etc. The physical layer may also be called the bottom link.

[0046] The structure of the lwIP protocol stack can be divided into the following Figure 2 As shown, it includes a transport layer 120, an IP layer 132, a route 134, a Netif network card 142, and a bottom link 144. Among them, the IP layer 132 belongs to the network layer 130, the route 134 is an intermediate device used by the network layer 130, the Netif network card 142 is located in the data link layer, and the bottom link 144 is the physical layer.

[0047] The data sent by the application layer 110 is encapsulated in the transport layer 120 based on the transport layer protocol. The transport layer protocol can be the TCP protocol or the User Datagram Protocol (UDP). The TCP segment or UDP datagram encapsulated by the transport layer 120 is transmitted to the network layer 130, which encapsulates it into an IP packet and routes it according to information such as the IP address to find a suitable Netif network card 142. The Netif network card 142 sends the data sent by the network layer 130 to the bottom link 144, which then sends it outward.

[0048] Correspondingly, after receiving the data, the bottom link 144 sends it to the Netif network card 142, which then passes it to the upper layer. After being parsed layer by layer by the network layer protocol and the transport layer protocol, the data is passed to the application layer 110 for parsing.

[0049] Internet Protocol Security (IPsec):

[0050] IPsec is a protocol suite used to encrypt and authenticate IP packets, mainly including the Encapsulating Security Payload (ESP) protocol and the Authentication Header (AH) protocol. The ESP protocol provides data encryption, data source authentication, integrity protection, and anti-replay services for IP packets, while the AH protocol provides data source authentication, integrity protection, and anti-replay services for IP packets. The ESP protocol and the AH protocol can be used separately or simultaneously. When the AH protocol and the ESP protocol are used simultaneously, the message will be encapsulated by ESP first and then by AH; when IPsec decapsulates, AH decapsulation is performed first and then by ESP decapsulation.

[0051] Devices supporting the IPsec protocol need to encrypt and authenticate IP packets based on the negotiated Security Association (SA). SA is an agreement between the two communicating parties on certain negotiation elements, such as the security protocol used by both parties, the encapsulation mode used for data transmission, the encryption and verification algorithm used by the protocol, the key used for data transmission, etc. Only when SA is established between the two communicating parties can secure data transmission be carried out.

[0052] In the application of IPSec protocol, there are two databases. One is the Security Policy Database (SPD), which defines several security policies, indicating how to deal with each IP data stream, such as transparent transmission, discarding, executing IPSec encryption, executing IPSec decryption, etc. The other is the Security Association Database (SAD), which is responsible for storing various parameters of SA, such as encryption algorithm, authentication algorithm, lifetime, key, IP security protocol, destination address, etc.

[0053] The process of data transmission based on IPsec protocol is as follows Figure 3 As shown:

[0054] Step 301: Perform SPD query.

[0055] The data transmitted by the transport layer is encapsulated into an IP packet by the IP layer. According to the parameters such as the IP address and port carried by the IP packet, the corresponding SP is queried in the Security Policy Database (SPD) to determine whether the data needs to be encapsulated by IPsec. If the data needs to be encapsulated by IPsec, step 302 is executed; if the data does not need to be encapsulated by IPsec, step 305 is executed.

[0056] Step 302: Determine whether encryption is required.

[0057] According to the SP found in step 301, it is determined whether the data needs to be encrypted. If the data needs to be encrypted, step 303 is executed; if the data does not need to be encrypted, step 305 is executed.

[0058] Step 303: Perform SAD query.

[0059] Query the SA parameters in the SAD to obtain the parameters required for data encryption, such as protocol, algorithm, key, etc.

[0060] Step 304: Perform ESP / AH encapsulation. According to the parameters obtained in step 303, the IP packet is encapsulated based on the ESP protocol and / or the AH protocol.

[0061] Step 305: Routing. Routing is performed according to parameters such as the destination address carried in the IP packet, and the correct or appropriate network interface layer network card is selected.

[0062] Step 306: Data is sent out. The network card of the network interface layer sends out the encapsulated IP packet.

[0063] The process of implementing data reception based on IPsec protocol is as follows Figure 4 As shown:

[0064] Step 401: Determine whether the inner layer protocol is the ESP protocol or the AH protocol.

[0065] After receiving the data, the network card of the network interface layer obtains the inner layer protocol of the IP packet. If the inner layer protocol of the IP packet is the ESP protocol and / or the AH protocol, step 402 is executed; if the inner layer protocol of the IP packet is not the ESP protocol or the AH protocol, step 404 is executed.

[0066] Step 402: Perform SAD query.

[0067] According to the IP address, Security Parameters Index (SPI) and other parameters carried by the IP packet, the corresponding SA parameters are queried in the SAD, such as the algorithm and key required to parse the IP packet.

[0068] Step 403: ESP / AH parsing.

[0069] Parse the IP packet according to the queried SA parameters. If the inner layer protocol includes the ESP protocol, perform ESP parsing. If the inner layer protocol includes the AH protocol, perform AH parsing. If the inner layer protocol includes the ESP protocol and the AH protocol, perform AH parsing first, then perform ESP parsing.

[0070] Step 404: IP layer parsing.

[0071] The IP packet is submitted upward to the IP layer and further parsed based on the IP layer protocol.

[0072] Step 405: Transport layer parsing.

[0073] The IP packet is handed over to the transport layer and further parsed based on the transport layer protocol.

[0074] As mentioned above, the IPsec protocol works at the network layer in the TCP / IP protocol stack. IPsec is a supplementary protocol for data security based on the TCP / IP protocol stack.

[0075] To directly implement the IPsec protocol flow based on the TCP / IP protocol stack, it is necessary to make major changes to the TCP / IP protocol stack code, and insert the steps of SPD query, SAD query, ESP encapsulation / parsing, AH encapsulation / parsing into the network side's IP packet processing flow. The disadvantages of this implementation method are obvious. On the one hand, it will destroy the original TCP / IP protocol stack code structure, which is not conducive to subsequent maintenance and upgrades. On the other hand, the implementation complexity is relatively high, especially for nested SA (that is, both ESP encapsulation and AH encapsulation), the logical judgment is more complicated, which will have a negative impact on the stability, security, simplicity and success rate of data transmission.

[0076] Figure 5 A schematic diagram of a communication system provided by an exemplary embodiment of the present application is shown. The communication system includes electronic devices, such as a network device 510 and a terminal device 520.

[0077] The network device 510 in the present application is a device with wireless transceiver functions, and the network device 510 includes but is not limited to: Evolved Node B (eNB), Radio Network Controller (RNC), Node B (NB), Base Station Controller (BSC), Base Transceiver Station (BTS), Home Base Station (e.g., Home Evolved Node B, or Home Node B, HNB), Baseband Unit (BBU), Access Point (AP) in Wireless Fidelity (Wi-Fi) system, Wireless Relay Node, Wireless Backhaul Node, Transmission Point (TP) or Transmission and Reception Point (TRP), etc., and can also be the Next Generation Node B (Next Generation Node B) in the fifth generation (5G) mobile communication system. B, gNB) or transmission point (TRP or TP), or, one or a group of (including multiple antenna panels) antenna panels of a base station in a 5G system, or, it can also be a network node constituting a gNB or a transmission point, such as a baseband unit (BBU) or a distributed unit (Distributed Unit, DU), or a base station in a Beyond Fifth Generation (B5G) or a 6th Generation (6G) mobile communication system, or a core network (CN), fronthaul, backhaul, radio access network (RAN), network slicing, etc. The network device may be a device including one or more of a centralized unit (CU) node, a DU node, and an active antenna unit (AAU) node. In addition, the CU may be divided into a network device in the RAN, or the CU may be divided into a network device in the CN, which is not limited in the present application.

[0078] The terminal device 520 in this application is a device with wireless transceiver functions, or is called user equipment (UE), access terminal, user unit, user station, mobile station, mobile station, remote station, remote terminal, mobile device, user terminal, terminal, wireless communication equipment, user agent, user device. The terminal includes but is not limited to: handheld devices, wearable devices, vehicle-mounted devices and Internet of Things devices, such as: mobile phones, tablet computers, e-book readers, laptop computers, desktop computers, televisions, game consoles, mobile Internet devices (Mobile Internet Device, MID), augmented reality (Augmented Reality, AR) terminals, virtual reality (Virtual Reality, VR) terminals and mixed reality (Mixed Reality, MR) terminals, wearable devices, handles, electronic tags, controllers, wireless terminals in industrial control (Industrial Control), wireless terminals in self-driving (Self Driving), wireless terminals in remote medical care (Remote Medical), wireless terminals in smart grids (Smart Grid), wireless terminals in transportation safety (Transportation Safety), wireless terminals in smart cities (Smart City), wireless terminals in smart homes (Smart Home), wireless terminals in remote medical surgery (Remote Medical Surgery), cellular phones, cordless phones, Session Initiation Protocol (Session Initiation Protocol, SIP) phones, wireless local loops (Wireless Local Loops) Local Loop, WLL) station, Personal Digital Assistant (PDA), TV Set Top Box (STB), Customer Premise Equipment (CPE), etc.

[0079] The terminal device 520 is within the coverage of the network device 510. The network device 510 and the terminal device 520 communicate with each other through some air interface technology, such as a Uu interface.

[0080] Exemplarily, there are two communication scenarios between the network device 510 and the terminal device 520: an uplink communication scenario and a downlink communication scenario. Uplink communication refers to sending signals to the network device 510; downlink communication refers to sending signals to the terminal device 520.

[0081] The technical solutions provided in the embodiments of the present application can be applied to various communication systems, such as: Global System of Mobile Communication (GSM) system, Orthogonal Frequency Division Multiplexing (OFDM) system, Code Division Multiple Access (CDMA) system, Wideband Code Division Multiple Access (WCDMA) system, General Packet Radio Service (GPRS), Long Term Evolution (LTE) system, LTE Frequency Division Duplex (FDD) system, LTE Time Division Duplex (TDD) system, Advanced Long Term Evolution (LTE-A) system, Universal Mobile Telecommunication System (UMTS), Worldwide Interoperability for Microwave Access (WiMAX) communication system, 5G mobile communication system, New Radio (NR) system, NR system evolution system, LTE on unlicensed spectrum (LTE-Based Access to Unlicensed Spectrum, LTE-U) system, NR (NR-Based Access to Unlicensed Spectrum, NR-U) system on unlicensed spectrum, terrestrial communication network (Terrestrial Networks, TN) system, non-terrestrial communication network (Non-Terrestrial Networks, NTN) system, wireless local area network (Wireless Local Area Networks, WLAN), wireless fidelity (Wireless Fidelity, Wi-Fi), cellular Internet of Things system, cellular passive Internet of Things system, can also be applied to the subsequent evolution system of 5G NR system, and can also be applied to B5G, 6G and subsequent evolution systems. In some embodiments of the present application, "NR" may also be referred to as 5G NR system or 5G system.Among them, the 5G mobile communication system may include non-standalone (NSA) and / or standalone (SA). In addition, the terminal device 520 may also include a smart printer, a train detector, a gas station sensor, etc., and its main functions include at least one of collecting data, receiving control information and downlink data from the network device 510, and transmitting uplink data to the network device 510.

[0082] The technical solutions provided in the embodiments of the present application can also be applied to machine type communication (MTC), long term evolution technology for machine-to-machine communication (LTE-M), device to device (D2D) network, machine to machine (M2M) network, Internet of Things (IoT) network or other networks. Among them, IoT network can include, for example, Internet of Vehicles. Among them, the communication methods in the Internet of Vehicles system are collectively referred to as vehicle to other devices (Vehicle to X, V2X, X can represent anything), for example, the V2X can include: vehicle to vehicle (V2V) communication, vehicle to infrastructure (V2I) communication, vehicle to pedestrian communication (V2P) or vehicle to network (V2N) communication, etc.

[0083] The network device 510 and the terminal device 520 may be respectively configured with multiple antennas, which may include at least one transmitting antenna for sending signals and at least one receiving antenna for receiving signals. In addition, each electronic device also additionally includes a transmitter chain and a receiver chain, and those skilled in the art can understand that they may include multiple components related to signal transmission and reception (such as processors, modulators, multiplexers, demodulators, demultiplexers or antennas, etc.). Therefore, the network device 510 and the terminal device 520 can communicate through multi-antenna technology.

[0084] The communication system provided in the present application can be applied to but not limited to at least one of the following communication scenarios: an uplink communication scenario, a downlink communication scenario, and a sidelink communication scenario.

[0085] Figure 6 The flowchart of the data packet processing method provided by some exemplary embodiments of the present application is shown. Figure 1Taking the electronic device in the communication system shown in the figure as an example, the method includes at least some of the following steps:

[0086] Step 610: Perform SA query on the data packet in the first format;

[0087] SA is an agreement between the two communicating parties on certain negotiation elements. SA information includes at least one of the security protocol used by the two communicating parties, the encapsulation mode used for data transmission, the encryption and verification algorithm used by the protocol, and the key used for data transmission. SA query can be understood as a query based on SA information, or as querying SA information.

[0088] In the present application, the format of a data packet includes at least one of a first format, a second format, and a third format, wherein "first", "second", and "third" are used to distinguish the formats of the data packet.

[0089] Exemplarily, the first format refers to the IP packet format encapsulated by the IP layer, which has an IP header and a data part. Alternatively, the first format refers to the IP packet format after being parsed by the IP layer, which does not have an IP header and only has a data part. Alternatively, the first format refers to the data packet format after being parsed by the data link layer, and so on.

[0090] Performing an SA query on a data packet in the first format can be understood as querying whether the data packet in the first format already carries SA information; or, querying whether the data packet in the first format needs to carry SA information; or, querying whether the data packet in the first format needs to perform an IPsec operation based on the SA information; or, querying whether the data packet in the first format should perform an IPsec operation based on the SA information; or, querying whether the data packet in the first format has already performed an IPsec operation based on SA.

[0091] In some embodiments, the SA query includes at least one of an SPD query and an inner layer protocol query.

[0092] IPsec operations can be understood as operations related to the IPsec protocol, such as at least one of SPD query, SAD query, ESP encapsulation, ESP parsing, AH encapsulation, AH parsing, etc. Among them, parsing can also be understood as decapsulation.

[0093] The IPsec protocol includes at least one of the AH protocol, the ESP protocol, and the Internet Key Exchange (IKE) protocol.

[0094] Step 630: When the result of the SA query indicates that an IPsec operation is performed on the data packet in the first format, the data packet in the first format is delivered to the virtual network card;

[0095] The result of the SA query indicates that the IPsec operation is performed on the data packet in the first format. It can be understood that the result of the SA query indicates that the IPsec operation needs to be performed on the data packet in the first format, or the result of the SA query indicates that the IPsec operation should be performed on the data packet in the first format.

[0096] The data packet in the first format is transmitted by the electronic device to the virtual network card. The virtual network card in the present application has IPsec operation capability, that is, the virtual network card in the present application can perform operations related to the IPsec protocol, such as at least one of SPD query, SAD query, ESP encapsulation, ESP parsing, AH encapsulation, AH parsing, etc.

[0097] In some embodiments, the virtual network card in the present application is a virtual network card dedicated to performing operations related to the IPsec protocol, or it can be understood that the virtual network card in the present application is a virtual network card that only has IPsec operation capabilities.

[0098] In some embodiments, the virtual network card in the present application not only supports operations related to the IPsec protocol, but also supports operations unrelated to the IPsec protocol; that is, the virtual network card in the present application has both IPsec operation capabilities and other optional Internet operation capabilities.

[0099] In some embodiments, the virtual network card is located at the data link layer of the electronic device.

[0100] In some embodiments, the virtual network card is implemented based on a physical network card structure of the TCP / IP protocol.

[0101] Step 650: Perform an IPsec operation on the data packet in the first format through the virtual network card to obtain a data packet in the second format.

[0102] The IPsec operation performed on the data packet in the first format is determined based on the SA query result.

[0103] After the IPsec operation is performed by the virtual network card, the data packet in the first format becomes a data packet in the second format. Since the main purpose of the IPsec protocol is encryption and authentication, it can be considered that the data content carried by the data packet before the IPsec operation and the data packet after the IPsec operation is the same, but the format of the data packet changes before and after the IPsec operation.

[0104] The second format includes a data packet format different from the first format. For example, the first format is a data packet format before IPsec encapsulation, and the second format is a data packet format after IPsec encapsulation. Alternatively, the first format is a data packet format before IPsec parsing, and the second format is a data packet format after IPsec parsing.

[0105] To sum up, the method provided by the present application performs IPsec operations by a virtual network card, and there is no need to insert IPsec operations into the process of processing IP packets at the network layer. Therefore, there is no need to make major changes to the TCP / IP protocol stack. The functions of the IPsec protocol can be implemented while retaining the original code structure of the TCP / IP protocol stack to a large extent, which is beneficial to the subsequent maintenance and upgrade of the protocol stack.

[0106] Figure 7 The flowchart of the data packet processing method provided by some exemplary embodiments of the present application is shown. Figure 1 Taking the electronic device in the communication system shown in the figure as an example, the method includes at least some of the following steps:

[0107] Step 710: Perform SA query on the data packet in the first format;

[0108] SA information includes at least one of the security protocol used by both communicating parties, the encapsulation mode used for data transmission, the encryption and verification algorithm used by the protocol, the key used for data transmission, etc. SA query can be understood as a query based on SA information, or as querying SA information.

[0109] Performing an SA query on a data packet in the first format can be understood as querying whether the data packet in the first format already carries SA information; or, querying whether the data packet in the first format needs to carry SA information; or, querying whether the data packet in the first format needs to perform an IPsec operation based on the SA information; or, querying whether the data packet in the first format should perform an IPsec operation based on the SA information; or, querying whether the data packet in the first format has already performed an IPsec operation based on SA.

[0110] IPsec operations can be understood as operations related to the IPsec protocol, such as at least one of SPD query, SAD query, ESP encapsulation, ESP parsing, AH encapsulation, AH parsing, etc. Among them, parsing can also be understood as decapsulation.

[0111] The IPsec protocol includes at least one of the AH protocol, the ESP protocol, and the IKE protocol.

[0112] The SA query includes at least one of an SPD query and an inner layer protocol query.

[0113] The data packet in the first format is transmitted by the electronic device to the virtual network card. The virtual network card in the present application has IPsec operation capability, that is, the virtual network card in the present application can perform operations related to the IPsec protocol, such as at least one of SPD query, SAD query, ESP encapsulation, ESP parsing, AH encapsulation, AH parsing, etc.

[0114] In some embodiments, the virtual network card in the present application is a virtual network card dedicated to performing operations related to the IPsec protocol, or it can be understood that the virtual network card in the present application is a virtual network card that only has IPsec operation capabilities.

[0115] In some embodiments, the virtual network card in the present application not only supports operations related to the IPsec protocol, but also supports operations unrelated to the IPsec protocol; that is, the virtual network card in the present application has both IPsec operation capabilities and other optional Internet operation capabilities.

[0116] In some embodiments, the virtual network card is located at the data link layer of the electronic device.

[0117] In some embodiments, the virtual network card is implemented based on a physical network card structure of the TCP / IP protocol.

[0118] Step 722: When the result of the SPD query indicates that IPsec encapsulation is performed on the data packet in the first format, the data packet in the first format is delivered to the virtual network card;

[0119] In some embodiments, during the process of routing the data packet in the first format, an SA query is performed on the data packet in the first format.

[0120] In some embodiments, the SA query includes an SPD query.

[0121] The result of the SPD query indicates that IPsec encapsulation is performed on the data packet in the first format. It can be understood that the result of the SPD query indicates that IPsec encapsulation is required for the data packet in the first format, or the result of the SPD query indicates that IPsec encapsulation should be performed on the data packet in the first format. The IPsec encapsulation refers to encapsulation based on the IPsec protocol, such as ESP encapsulation and / or AH encapsulation.

[0122] In some embodiments, when the result of the SPD query indicates that IPsec encapsulation is performed on the data packet in the first format, the data packet in the first format is routed to the virtual network card.

[0123] Step 730: Perform IPsec encapsulation on the data packet in the first format through the virtual network card;

[0124] In some embodiments, the IPsec operation includes IPsec encapsulation, and IPsec encapsulation is performed on a data packet in a first format through a virtual network card to obtain a data packet in a second format.

[0125] In some embodiments, the IPsec encapsulation includes at least one of ESP encapsulation and AH encapsulation.

[0126] In some embodiments, when the result of the SPD query indicates that IPsec encapsulation is performed on a data packet in a first format, the virtual network card receives the data packet in the first format, and based on the result of the SPD query, determines whether the data packet in the first format needs to be encrypted, that is, determines whether the data carried by the data packet in the first format needs to be encrypted. If the data packet in the first format needs to be encrypted, a SAD query is performed, that is, the SA parameters are queried in the SAD, so as to obtain the encryption parameters required to encrypt the data packet in the first format, such as the protocol, algorithm, key, etc.

[0127] In some embodiments, IPsec encapsulation is performed on the data packet in the first format according to the encryption parameters queried in the SAD.

[0128] In some embodiments, a data packet in a first format is encapsulated by ESP based on the ESP protocol through a virtual network card, and / or an AH encapsulation is performed on the data packet in the first format based on the AH protocol to obtain a data packet in a second format.

[0129] In some embodiments, the virtual network card first performs ESP encapsulation on the data packet in the first format based on the ESP protocol, and then performs AH encapsulation on the data packet in the first format based on the AH protocol. Such an encapsulation method of performing both ESP encapsulation and AH encapsulation may also be referred to as nested encapsulation, or nested mode, or SA in nested mode.

[0130] Step 740: passing the data packet in the second format from the virtual network card to the physical network card of the link layer;

[0131] The physical network card of the link layer receives the data packet in the second format and can continue to perform operations on the data packet in the second format, such as sending the data packet in the second format.

[0132] Step 724: When the result of the SPD query indicates that IPsec encapsulation is not performed on the data packet in the first format, the data packet in the first format is routed to the physical network card of the link layer;

[0133] In some embodiments, during the process of routing the data packet in the first format, an SA query is performed on the data packet in the first format.

[0134] In some embodiments, the SA query includes an SPD query.

[0135] The result of the SPD query indicates that IPsec encapsulation is not performed on the data packet in the first format. It can be understood that the result of the SPD query indicates that IPsec encapsulation is not required for the data packet in the first format, or the result of the SPD query indicates that IPsec encapsulation should not be performed on the data packet in the first format.

[0136] In some embodiments, the result of the SPD query indicates that no IPsec operation is performed on the data packet in the first format, and the data packet in the first format is routed by the electronic device to the physical network card of the link layer.

[0137] The physical network card of the link layer receives the data packet in the first format and can continue to perform operations on the data packet in the first format, such as sending the data packet in the first format.

[0138] Step 752: When the result of the inner layer protocol query indicates that IPsec parsing is to be performed on the data packet in the first format, the data packet in the first format is delivered to the virtual network card;

[0139] In some embodiments, after parsing the header of the data packet in the first format through the network layer, an SA query is performed on the data packet in the first format.

[0140] In some embodiments, the SA query comprises an inner layer protocol query.

[0141] The result of the inner layer protocol query indicates that IPsec parsing is to be performed on the data packet in the first format. It can be understood that the result of the inner layer protocol query indicates that IPsec parsing is required for the data packet in the first format, or the result of the inner layer protocol query indicates that IPsec parsing should be performed on the data packet in the first format.

[0142] In some embodiments, when the result of the inner layer protocol query indicates that IPsec parsing is performed on the data packet in the first format, the data packet in the first format is passed to the virtual network card. The result of the inner layer protocol query includes: the inner layer protocol corresponding to the data packet in the first format includes the ESP protocol, and / or the inner layer protocol corresponding to the data packet in the first format includes the AH protocol.

[0143] Step 760: Perform IPsec parsing on the data packet in the first format through the virtual network card;

[0144] In some embodiments, the IPsec operation includes IPsec parsing, and performing IPsec parsing on a data packet in a first format through a virtual network card to obtain a data packet in a second format.

[0145] In some embodiments, IPsec parsing includes at least one of ESP parsing and AH parsing.

[0146] In some embodiments, a data packet in a first format is parsed by a virtual network card based on an ESP protocol, and / or an AH protocol is parsed by a virtual network card based on an AH protocol to obtain a data packet in a second format.

[0147] When the result of the inner layer protocol query includes that the inner layer protocol corresponding to the data packet in the first format includes the ESP protocol, the data packet in the first format is subjected to ESP parsing based on the ESP protocol through the virtual network card.

[0148] When the result of the inner layer protocol query includes that the inner layer protocol corresponding to the data packet in the first format includes the AH protocol, the data packet in the first format is subjected to AH parsing based on the AH protocol through the virtual network card.

[0149] When the result of the inner layer protocol query includes that the inner layer protocol corresponding to the data packet in the first format includes the ESP protocol and the AH protocol, the data packet in the first format is firstly subjected to AH parsing based on the AH protocol by the virtual network card, and then subjected to ESP parsing based on the ESP protocol by the virtual network card. Such a parsing method of performing both ESP parsing and AH parsing may also be referred to as nested parsing, or nested mode, or SA in nested mode.

[0150] The second format includes a data packet format different from the first format. The data packet format before IPsec encapsulation is different from the data packet format before IPsec parsing. The data packet format after IPsec encapsulation is different from the data packet format after IPsec parsing.

[0151] Step 770: passing the data packet in the second format from the virtual network card to the network layer;

[0152] When the network layer receives the data packet in the second format, it can continue to perform operations on the data packet in the second format, such as: continuing to perform IP layer parsing on the data packet in the second format to obtain a data packet in the third format, and passing the data packet in the third format to the transport layer; or, passing the data packet in the second format to the transport layer.

[0153] The third format includes a data packet format different from the first format and the second format. For example, the first format is a data packet format before IPsec parsing, the second format is a data packet format after IPsec parsing, and the third format is a data packet format after IPsec parsing and IP layer parsing.

[0154] Step 754: When the result of the inner layer protocol query indicates that IPsec parsing is not performed on the data packet in the first format, the data packet in the first format is passed to the network layer.

[0155] In some embodiments, after parsing the header of the data packet in the first format through the network layer, an SA query is performed on the data packet in the first format.

[0156] In some embodiments, the SA query comprises an inner layer protocol query.

[0157] The result of the inner layer protocol query indicates that IPsec parsing is not performed on the data packet in the first format. It can be understood that the result of the inner layer protocol query indicates that IPsec parsing is not required for the data packet in the first format, or the result of the inner layer protocol query indicates that IPsec parsing should not be performed on the data packet in the first format.

[0158] In some embodiments, when the result of the inner layer protocol query indicates that IPsec parsing is not performed on the data packet in the first format, the data packet in the first format is passed to the network layer. The result of the inner layer protocol query includes: the inner layer protocol corresponding to the data packet in the first format does not include the ESP protocol, and the inner layer protocol corresponding to the data packet in the first format does not include the AH protocol.

[0159] When the network layer receives a data packet in the first format, it can continue to perform operations on the data packet in the first format, such as: continuing to perform IP layer parsing on the data packet in the first format to obtain a data packet in the third format, and passing the data packet in the third format to the transport layer; or, passing the data packet in the first format to the transport layer.

[0160] The third format includes a data packet format different from the first format and the second format.

[0161] In summary, the method provided by the present application performs IPsec operations by a virtual network card, and does not need to insert IPsec operations into the process of processing IP packets at the network layer. Therefore, there is no need to make major changes to the TCP / IP protocol stack. The functions of the IPsec protocol can be realized on the basis of retaining the original code structure of the TCP / IP protocol stack to a large extent, which is conducive to the subsequent maintenance and upgrade of the protocol stack. In addition, the SA query step that originally needs to be executed at the network layer is combined with the routing step. Compared with the related art, the complexity of IP packet processing at the network layer is reduced. The code structure of the SA query is more independent and less coupled with the code structure of the TCP / IP protocol stack, which further benefits the subsequent system maintenance and upgrade. Whether it is only necessary to perform ESP encapsulation / parsing, only need to perform AH encapsulation / parsing, or need to perform ESP encapsulation / parsing and AH encapsulation / parsing, the method provided by the present application has a lower logic judgment complexity, which is beneficial to the stability, security, simplicity and success rate of data transmission.

[0162] Figure 8 The flowchart of the data packet processing method provided by some exemplary embodiments of the present application is shown. Figure 1 The electronic device in the communication system shown is implemented and applied to Fig. 9 Taking the lwIP protocol stack shown in the figure as an example, the method includes at least some of the following steps:

[0163] Step 801: Encapsulate data based on the transport layer protocol;

[0164] The transport layer protocol includes TCP protocol or UDP protocol. Data is encapsulated into data segments or message segments at the transport layer.

[0165] Step 802: Encapsulate data based on the network layer protocol;

[0166] At the network layer, the data segments are encapsulated into data packets or IP packets. The header of the IP packet is called the IP header.

[0167] Step 803: Routing IP packets and performing SA query;

[0168] The IP packet is passed to the router, which routes the IP packet based on parameters such as the IP address carried in the IP packet.

[0169] During the routing process, an SA query is performed on the IP packet, that is, whether the IP packet needs to carry SA information; or, whether the IP packet needs to perform an IPsec operation based on the SA information; or, whether the IP packet should perform an IPsec operation based on the SA information.

[0170] IPsec operation can be understood as an operation related to the IPsec protocol, such as at least one of SPD query, SAD query, IPsec encapsulation, etc. Among them, parsing can also be understood as decapsulation. IPsec encapsulation refers to encapsulation based on the IPsec protocol, such as ESP encapsulation and / or AH encapsulation.

[0171] The IPsec protocol includes at least one of the AH protocol, the ESP protocol, and the IKE protocol.

[0172] The SA query includes the SPD query, or includes the SPD query and the SAD query.

[0173] SPD query refers to querying the corresponding SP in the SPD based on the IP address, port and other parameters carried by the IP packet.

[0174] Based on the SP queried in the SPD, determine whether IPsec encapsulation is required for the data. If IPsec encapsulation is required, route the IP packet to the virtual network card and execute step 804. If IPsec encapsulation is not required, route the IP packet to the physical network card and execute step 806.

[0175] At the same time, based on the SP queried in the SPD, determine whether the data needs to be encrypted. If encryption is required, perform a SAD query. SAD query refers to querying SA parameters in SAD to obtain the parameters required for data encryption, such as protocol, algorithm, key, etc.

[0176] Step 804: Perform IPsec encapsulation;

[0177] IPsec encapsulation is performed according to the SPD query result in step 803, or IPsec encapsulation is performed according to the SPD query result and the SAD query result in step 803. IPsec encapsulation includes ESP encapsulation and / or AH encapsulation.

[0178] Step 805: Routing the IP packet again;

[0179] The IP packet encapsulated by IPsec is passed from the virtual network card to the router, and the router again routes the IP packet based on parameters such as the IP address carried in the IP packet.

[0180] Since the IP packet has completed IPsec encapsulation, IPsec encapsulation is no longer needed, the IP packet is routed to the physical network card, and step 806 is executed.

[0181] Step 806: The physical network card transmits the data frame to the underlying link;

[0182] At the data link layer, the IP packet is encapsulated into a data frame, and the physical network card passes the data frame to the underlying link.

[0183] Step 807: The data is sent out through the bottom layer link.

[0184] That is to say, the physical layer converts the data frame into a binary bit stream and sends it outward, passing the data to the underlying link of other electronic devices.

[0185] In summary, the method provided by the present application performs IPsec operations by a virtual network card, and does not need to insert IPsec operations into the process of processing IP packets at the network layer. Therefore, there is no need to make major changes to the TCP / IP protocol stack. The functions of the IPsec protocol can be realized on the basis of retaining the original code structure of the TCP / IP protocol stack to a large extent, which is conducive to the subsequent maintenance and upgrade of the protocol stack. In addition, the SA query step that originally needs to be executed at the network layer is combined with the routing step. Compared with the related art, the complexity of IP packet processing at the network layer is reduced. The code structure of the SA query is more independent and less coupled with the code structure of the TCP / IP protocol stack, which further benefits the subsequent system maintenance and upgrade. Whether it is only necessary to perform ESP encapsulation / parsing, only need to perform AH encapsulation / parsing, or need to perform ESP encapsulation / parsing and AH encapsulation / parsing, the method provided by the present application has a lower logic judgment complexity, which is beneficial to the stability, security, simplicity and success rate of data transmission.

[0186] Fig.10 The flowchart of the data packet processing method provided by some exemplary embodiments of the present application is shown. Figure 1The electronic device in the communication system shown is implemented and applied to Fig. 9 Taking the lwIP protocol stack shown in the figure as an example, the method includes at least some of the following steps:

[0187] Step 1001: Upload data to the physical network card through the underlying link;

[0188] The physical layer receives the data in bit form and transmits the data to the physical network card of the data link layer.

[0189] Step 1002: The physical network card transmits the data to the router;

[0190] The physical network card converts the data in bit form into a data frame, parses the data frame, and transmits the data part in the data frame to the router. The data part of the data frame includes the IP packet.

[0191] Step 1003: The router passes the data to the IP layer;

[0192] The router routes the IP packet based on the IP address and other parameters carried in the IP packet and passes the IP packet to the IP layer.

[0193] Step 1004: Parsing the IP packet header based on the network layer protocol;

[0194] Parse the IP packet header based on the network layer protocol to obtain the data part of the IP packet.

[0195] Step 1005: Perform SA query;

[0196] The IP packet is passed to the router, which performs an SA query, that is, queries whether the IP packet already carries SA information; or queries whether the IP packet needs to perform IPsec operations based on the SA information; or queries whether the IP packet should perform IPsec operations based on the SA information; or queries whether the IP packet has already performed IPsec operations based on SA.

[0197] IPsec operation can be understood as an operation related to the IPsec protocol, such as at least one of SPD query, SAD query, IPsec parsing, etc. Among them, parsing can also be understood as decapsulation. IPsec parsing refers to parsing based on the IPsec protocol, such as ESP parsing and / or AH parsing.

[0198] The IPsec protocol includes at least one of the AH protocol, the ESP protocol, and the IKE protocol.

[0199] SA query includes inner protocol query. Inner protocol query refers to querying the inner protocol in the IP packet. Based on the inner protocol query result, it is determined whether the inner protocol of the IP packet is the ESP protocol or the AH protocol.

[0200] If the inner layer protocol of the IP packet includes the ESP protocol and / or the AH protocol, a SAD query is performed, and the IP packet is routed to the virtual network card, and step 1006 is executed. That is, according to the IP address, SPI and other parameters carried by the IP packet, the corresponding SA parameters are queried in the SAD, such as the algorithm and key required to parse the IP packet.

[0201] If the inner layer protocol of the IP packet does not include the ESP protocol or the AH protocol, the IP packet is transferred to the IP layer and step 1007 is executed.

[0202] Step 1006: Perform IPsec analysis;

[0203] IPsec parsing is performed based on the SAD query result in step 1005. IPsec parsing includes ESP parsing and / or AH parsing.

[0204] The IP packet after IPsec parsing is completed is still a complete IP packet, except that the IPsec header (such as ESP header and / or AH header) is removed and / or data decryption is completed.

[0205] When the result of the inner layer protocol query includes that the inner layer protocol of the IP packet includes the ESP protocol, the IP packet is subjected to ESP parsing based on the ESP protocol through the virtual network card.

[0206] When the result of the inner layer protocol query includes that the inner layer protocol of the IP packet includes the AH protocol, the IP packet is subjected to AH parsing based on the AH protocol through the virtual network card.

[0207] When the result of the inner layer protocol query includes that the inner layer protocol of the IP packet includes the ESP protocol and the AH protocol, the IP packet is firstly subjected to AH parsing based on the AH protocol through the virtual network card, and then subjected to ESP parsing based on the ESP protocol through the virtual network card. Such a parsing method of performing both ESP parsing and AH parsing may also be referred to as nested parsing, or nested mode, or SA of nested mode.

[0208] Step 1007: Parsing the IP packet based on the network layer protocol;

[0209] The IP packet is passed to the IP layer, which continues to parse the IP packet based on the network layer protocol to obtain the data part of the IP packet, such as the data segment or the message segment.

[0210] Step 1008: Parse the data segment based on the transport layer protocol.

[0211] The data segment is passed to the transport layer, which continues to parse the data segment based on the transport layer protocol.

[0212] In summary, the method provided by the present application performs IPsec operations by a virtual network card, and does not need to insert IPsec operations into the process of processing IP packets at the network layer. Therefore, there is no need to make major changes to the TCP / IP protocol stack. The functions of the IPsec protocol can be realized on the basis of retaining the original code structure of the TCP / IP protocol stack to a large extent, which is conducive to the subsequent maintenance and upgrade of the protocol stack. In addition, the SA query step that originally needs to be executed at the network layer is combined with the routing step. Compared with the related art, the complexity of IP packet processing at the network layer is reduced. The code structure of the SA query is more independent and less coupled with the code structure of the TCP / IP protocol stack, which further benefits the subsequent system maintenance and upgrade. Whether it is only necessary to perform ESP encapsulation / parsing, only need to perform AH encapsulation / parsing, or need to perform ESP encapsulation / parsing and AH encapsulation / parsing, the method provided by the present application has a lower logic judgment complexity, which is beneficial to the stability, security, simplicity and success rate of data transmission.

[0213] Fig. 9 The lwIP protocol stack shown has an IPsec structure, wherein the transport layer 910 is used to implement step 801 and / or step 1008, the IP layer 920 is used to implement step 802 and / or step 1007 and / or step 1004, the router 930 is used to implement step 803 and / or step 805 and / or step 1005 and / or step 1003, the virtual network card 940 is used to implement step 804 and / or step 1006, the physical network card 950 is used to implement step 806 and / or step 1002, and the underlying link 960 is used to implement step 807 and / or step 1001.

[0214] The data structure of the virtual network card 940 is the same as that of the physical network card 950 , but the virtual network card 940 is not connected to the real physical link, that is, the virtual network card 940 is not connected to the physical network card 950 and the underlying link 960 .

[0215] Fig.11 The structural block diagram of the data packet processing device provided by some exemplary embodiments of the present application is shown. The device includes at least some modules in the following query module 1120, transfer module 1140, and virtual network card module 1160:

[0216] A query module 1120, configured to query a security alliance SA on a data packet in a first format;

[0217] A transfer module 1140, configured to transfer the data packet in the first format to the virtual network card if the result of the SA query indicates that an IPsec operation is performed on the data packet in the first format;

[0218] The virtual network card module 1160 is used to perform the IPsec operation on the data packet in the first format to obtain a data packet in the second format.

[0219] In some embodiments, the query module 1120 is further configured to perform an SA query on the data packet in the first format during the process of routing the data packet in the first format.

[0220] In some embodiments, the transfer module 1140 is further configured to route the data packet in the first format to the virtual network card when the result of the SPD query indicates that IPsec encapsulation is to be performed on the data packet in the first format.

[0221] In some embodiments, the virtual network card module 1160 is further used to perform the IPsec encapsulation on the data packet in the first format.

[0222] In some embodiments, the transfer module 1140 is further configured to transfer the data packet in the second format from the virtual network card to a physical network card at the link layer.

[0223] In some embodiments, the transfer module 1140 is further configured to route the data packet in the first format to a physical network card of a link layer when a result of the SPD query indicates that IPsec encapsulation is not performed on the data packet in the first format.

[0224] In some embodiments, the query module 1120 is further configured to perform an SA query on the data packet in the first format after parsing the header of the data packet in the first format through the network layer.

[0225] In some embodiments, the transfer module 1140 is further configured to transfer the data packet in the first format to the virtual network card when the result of the inner layer protocol query indicates that IPsec parsing is to be performed on the data packet in the first format.

[0226] In some embodiments, the virtual network card module 1160 is further used to perform the IPsec parsing on the data packet in the first format.

[0227] In some embodiments, the result of the inner layer protocol query includes: the inner layer protocol corresponding to the data packet in the first format includes the ESP protocol and / or the AH protocol.

[0228] In some embodiments, the virtual network card module 1160 is further used to perform the IPsec parsing on the data packet in the first format based on the ESP protocol and / or the AH protocol.

[0229] In some embodiments, the transfer module 1140 is further configured to transfer the data packet in the second format from the virtual network card to the network layer.

[0230] In some embodiments, the delivery module 1140 is further configured to deliver the data packet in the first format to the network layer when the result of the inner layer protocol query indicates that IPsec parsing is not to be performed on the data packet in the first format.

[0231] In summary, the device provided by the present application performs IPsec operations by a virtual network card module, and does not need to insert IPsec operations into the process of processing IP packets at the network layer. Therefore, there is no need to make major changes to the TCP / IP protocol stack. The functions of the IPsec protocol can be realized on the basis of retaining the original code structure of the TCP / IP protocol stack to a large extent, which is conducive to the subsequent maintenance and upgrade of the protocol stack. In addition, the SA query step that originally needs to be executed at the network layer is combined with the routing step. Compared with the related art, the complexity of the network layer IP packet processing is reduced. The code structure of the SA query is more independent and less coupled with the code structure of the TCP / IP protocol stack, which further benefits the subsequent system maintenance and upgrade. Whether it is only necessary to perform ESP encapsulation / parsing, only need to perform AH encapsulation / parsing, or need to perform ESP encapsulation / parsing and AH encapsulation / parsing, the method provided by the present application has a lower logic judgment complexity, which is beneficial to the stability, security, simplicity and success rate of data transmission.

[0232] It should be noted that the device provided in the above embodiment is only illustrated by the division of the above functional modules. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.

[0233] Regarding the device in this embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.

[0234] Fig.12 A schematic diagram of the structure of an electronic device (terminal device or network device) provided by some exemplary embodiments of the present application is shown. The electronic device 1200 includes: a processor 1201, a receiver 1202, a transmitter 1203, a memory 1204 and a bus 1205.

[0235] The processor 1201 includes one or more processing cores, and the processor 1201 executes various functional applications and information processing by running software programs and modules. In some embodiments, the processor 1201 can be used to implement the functions and steps of the query module 1120 and / or the virtual network card module 1160 described above.

[0236] Receiver 1202 and transmitter 1203 can be implemented as a communication component, which can be a communication chip. In some embodiments, receiver 1202 can be used to implement the function and steps of receiving the data as described above. In some embodiments, transmitter 1203 can be used to implement the function and steps of sending the data as described above.

[0237] The memory 1204 is connected to the processor 1201 via a bus 1205. The memory 1204 may be used to store at least one instruction, and the processor 1201 may be used to execute the at least one instruction to implement each step in the above method embodiment.

[0238] In addition, the memory 1204 can be implemented by any type of volatile or non-volatile storage device or a combination thereof. The volatile or non-volatile storage device includes but is not limited to: a magnetic disk or an optical disk, an Electrically Erasable Programmable Read Only Memory (EEPROM), an Erasable Programmable Read-Only Memory (EPROM), a Static Random-Access Memory (SRAM), a Read-Only Memory (ROM), a magnetic storage device, a flash memory, and a Programmable Read-Only Memory (PROM).

[0239] In some embodiments, the receiver 1202 receives signals / data independently, or the processor 1201 controls the receiver 1202 to receive signals / data, or the processor 1201 requests the receiver 1202 to receive signals / data, or the processor 1201 cooperates with the receiver 1202 to receive signals / data.

[0240] In some embodiments, the transmitter 1203 independently sends signals / data, or the processor 1201 controls the transmitter 1203 to send signals / data, or the processor 1201 requests the transmitter 1203 to send signals / data, or the processor 1201 cooperates with the transmitter 1203 to send signals / data.

[0241] In an exemplary embodiment of the present application, a computer-readable storage medium is also provided, wherein at least one program is stored in the computer-readable storage medium, and the at least one program is loaded and executed by a processor. The computer-readable storage medium is used to implement the data packet processing method provided by the above-mentioned various method embodiments.

[0242] In an exemplary embodiment of the present application, a chip is also provided, which includes a programmable logic circuit and / or program instructions. When the chip runs on an electronic device, it is used to implement the data packet processing methods provided by the above-mentioned various method embodiments.

[0243] In an exemplary embodiment of the present application, a computer program product is further provided. When the computer program product is executed on a processor of a computer device, the computer device executes the above-mentioned data packet processing method.

[0244] In an exemplary embodiment of the present application, a computer program is further provided. The computer program includes computer instructions. A processor of a computer device executes the computer instructions, so that the computer device executes the above-mentioned data packet processing method.

[0245] Those skilled in the art should be aware that in one or more of the above examples, the functions described in the embodiments of the present application can be implemented with hardware, software, firmware, or any combination thereof. When implemented using software, these functions can be stored in a computer-readable medium or transmitted as one or more instructions or codes on a computer-readable medium. Computer-readable media include computer storage media and communication media, wherein the communication media include any media that facilitates the transmission of a computer program from one place to another. The storage medium can be any available medium that a general or special-purpose computer can access.

[0246] The above description is only an optional embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application shall be included in the protection scope of the present application.

Claims

1. A data packet processing method, It is characterized in that The method is performed by an electronic device, the electronic device includes a virtual network card, and the method includes: Performing a security association SA query on the data packet in the first format; When the result of the SA query indicates that an IPsec operation is to be performed on the data packet in the first format, the data packet in the first format is transferred to the virtual network card; The IPsec operation is performed on the data packet in the first format through the virtual network card to obtain a data packet in a second format.

2. The method according to claim 1, It is characterized in that The performing SA query on the data packet in the first format includes: In the process of routing the data packet in the first format, an SA query is performed on the data packet in the first format.

3. The method according to claim 2, It is characterized in that The SA query includes an SPD query, and the IPsec operation includes an IPsec encapsulation; When the result of the SA query indicates that an IPsec operation is performed on the data packet in the first format, delivering the data packet in the first format to the virtual network card includes: When the result of the SPD query indicates that IPsec encapsulation is performed on the data packet in the first format, the data packet in the first format is routed to the virtual network card.

4. The method according to claim 3, It is characterized in that The performing the IPsec operation on the data packet in the first format through the virtual network card includes: The IPsec encapsulation is performed on the data packet in the first format through the virtual network card.

5. The method according to any one of claims 2 to 4, It is characterized in that The method further comprises: The data packet in the second format is transferred from the virtual network card to the physical network card of the link layer.

6. The method according to claim 3 or 4, It is characterized in that The method further comprises: When the result of the SPD query indicates that IPsec encapsulation is not performed on the data packet in the first format, the data packet in the first format is routed to a physical network card of the link layer.

7. The method according to claim 1, It is characterized in that The performing SA query on the data packet in the first format includes: After parsing the packet header of the data packet in the first format through the network layer, an SA query is performed on the data packet in the first format.

8. The method according to claim 7, It is characterized in that The SA query includes an inner layer protocol query, and the IPsec operation includes IPsec parsing; When the result of the SA query indicates that an IPsec operation is performed on the data packet in the first format, delivering the data packet in the first format to the virtual network card includes: When the result of the inner layer protocol query indicates to perform IPsec parsing on the data packet in the first format, the data packet in the first format is transferred to the virtual network card.

9. The method according to claim 7, It is characterized in that The performing the IPsec operation on the data packet in the first format through the virtual network card includes: The IPsec parsing is performed on the data packet in the first format through the virtual network card.

10. The method according to claim 8 or 9, It is characterized in that The results of the inner layer protocol query include: The inner layer protocol corresponding to the data packet in the first format includes the ESP protocol and / or the AH protocol.

11. The method according to claim 10, It is characterized in that The performing the IPsec parsing on the data packet in the first format by the virtual network card includes: The IPsec parsing is performed on the data packet in the first format based on the ESP protocol and / or the AH protocol through the virtual network card.

12. The method according to any one of claims 7 to 11, It is characterized in that The method further comprises: The data packet in the second format is passed from the virtual network card to the network layer.

13. The method according to any one of claims 8 to 11, It is characterized in that The method further comprises: When the result of the inner layer protocol query indicates that IPsec parsing is not performed on the data packet in the first format, the data packet in the first format is delivered to the network layer.

14. A data packet processing device, It is characterized in that The device comprises: A query module, used for performing a security alliance SA query on a data packet in a first format; a transfer module, configured to transfer the data packet in the first format to the virtual network card when the result of the SA query indicates that an IPsec operation is performed on the data packet in the first format; The virtual network card module is used to perform the IPsec operation on the data packet in the first format to obtain a data packet in the second format.

15. An electronic device, It is characterized in that The electronic device comprises: processor; a transceiver connected to the processor; a memory for storing executable instructions for the processor; The processor is configured to load and execute the executable instructions to implement the data packet processing method as described in any one of claims 1 to 13.

16. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores executable instructions, which are loaded and executed by a processor, so that the computer-readable storage medium implements the data packet processing method according to any one of claims 1 to 13.

17. A chip, It is characterized in that The chip includes a programmable logic circuit or a program, and the chip is used to implement the data packet processing method as described in any one of claims 1 to 13.

18. A computer program product, It is characterized in that The computer program product includes computer instructions, which are stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the data packet processing method as described in any one of claims 1 to 13.

19. A computer program, It is characterized in that The computer program includes computer instructions, and a processor of a computer device executes the computer instructions, so that the computer device executes the data packet processing method according to any one of claims 1 to 13.