[go: up one dir, main page]
More Web Proxy on the site http://driver.im/

CN110535813B - Method and device for processing coexistence of kernel mode protocol stack and user mode protocol stack - Google Patents

Method and device for processing coexistence of kernel mode protocol stack and user mode protocol stack Download PDF

Info

Publication number
CN110535813B
CN110535813B CN201810516951.2A CN201810516951A CN110535813B CN 110535813 B CN110535813 B CN 110535813B CN 201810516951 A CN201810516951 A CN 201810516951A CN 110535813 B CN110535813 B CN 110535813B
Authority
CN
China
Prior art keywords
protocol stack
socket
function
mode protocol
type
Prior art date
Legal status (The legal status 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 status listed.)
Expired - Fee Related
Application number
CN201810516951.2A
Other languages
Chinese (zh)
Other versions
CN110535813A (en
Inventor
许加烜
曹志文
程杜勇
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Wangsu Science and Technology Co Ltd
Original Assignee
Wangsu Science and Technology Co Ltd
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 Wangsu Science and Technology Co Ltd filed Critical Wangsu Science and Technology Co Ltd
Priority to CN201810516951.2A priority Critical patent/CN110535813B/en
Publication of CN110535813A publication Critical patent/CN110535813A/en
Application granted granted Critical
Publication of CN110535813B publication Critical patent/CN110535813B/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/448Execution paradigms, e.g. implementations of programming paradigms
    • G06F9/4482Procedural
    • 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/18Multiprotocol handlers, e.g. single devices capable of handling multiple protocols

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computer And Data Communications (AREA)

Abstract

The embodiment of the invention provides a method and a device for processing a kernel mode protocol stack and a user mode protocol stack in a coexistence manner, belonging to the technical field of networks. The method comprises the following steps: taking over the system socket related function, and using the interface specification which is consistent with the POSIX standard; modifying the taken over system socket related function and modifying the socket function corresponding to the application program to enable the kernel mode protocol stack interface to be unified with the user mode protocol stack interface; and selecting a kernel mode protocol stack or a user mode protocol stack to process the message transmitted and received by the application program according to a preset message transmission rule. The method and the device for processing the coexistence of the kernel mode protocol stack and the user mode protocol stack provided by the embodiment of the invention unify the kernel mode protocol stack interface and the user mode protocol stack interface, realize the coexistence of a single application and multiple protocol stacks, only need to perform simple interface replacement according to the user mode protocol stack for an application program needing to use the user mode protocol stack, and have the advantages of small workload of application program source program transplantation and high system performance.

Description

Method and device for processing coexistence of kernel mode protocol stack and user mode protocol stack
Technical Field
The present invention relates to the field of network technologies, and in particular, to a method and an apparatus for processing a kernel-mode protocol stack and a user-mode protocol stack concurrently.
Background
With the continuous development of network communication technology, the bandwidth and traffic of network communication increase, and the processing capability of a network protocol stack is easy to form a bottleneck of system performance. In a traditional kernel-mode protocol stack, a network card informs the protocol stack of the arrival of a new data packet through hardware interrupt, a network card driver of a kernel is responsible for processing the hardware interrupt, the data packet is copied into a buffer area (DMA) opened by the kernel from a network card queue, and then the data packet is sent to a buffer area designated by a user program through a series of protocol processing flows. In this process, interrupt processing, memory copy, system call (lock, soft interrupt, context switch), etc. seriously affect the processing capability of the network data packet. The scheduling of the operating system to the application and packet processing may be across CPU scheduling, with local failures further affecting network performance, and the rapid development of the internet requires high-performance network processing capabilities.
The user mode protocol stack is executed in the user mode, and system calling and memory copying are not needed, so that the network performance of the system is greatly improved. The user mode protocol stack can be flexibly customized according to different requirements, so that the user mode protocol stack is favored by developers. The main problems of the existing method for processing the coexistence of the kernel mode protocol stack and the user mode protocol stack are as follows: the source program using the kernel mode protocol stack and the source program using the user mode protocol stack coexist, and because the source program of the application program cannot be locally changed, when the application program is transplanted from the kernel mode protocol stack to the user mode protocol stack, a large number of network related system call interfaces need to be modified, so that the workload is large, and the overall performance of the system is poor.
Disclosure of Invention
The embodiment of the invention provides a method and a device for processing a kernel mode protocol stack and a user mode protocol stack in a coexistence mode, which are used for solving the problems that an application program source program cannot be locally changed and the transplanting workload is large in the process of switching an application program from the kernel mode protocol stack to the user mode protocol stack.
In order to achieve the above purpose, the embodiment of the invention adopts the following technical scheme:
in a first aspect, an embodiment of the present invention provides a method for processing a kernel-mode protocol stack and a user-mode protocol stack concurrently, where the method includes:
taking over the system socket related function, and using the interface specification which is consistent with the POSIX standard;
modifying the taken over system socket related function and modifying the socket function corresponding to the application program to enable the kernel mode protocol stack interface to be unified with the user mode protocol stack interface;
and selecting a kernel mode protocol stack or a user mode protocol stack to process the message transmitted and received by the application program according to a preset message transmission rule.
In a first possible implementation manner of the first aspect, the modifying the system socket related function after taking over includes:
identifying a socket type of the function call;
if the socket type called by the function is a socket creating function, continuously judging whether the type parameter of the socket creating function contains a protocol stack flag bit;
if the type parameter of the created socket function does not contain a protocol stack flag bit, adding the protocol stack flag bit in the type parameter of the created socket function;
adding a protocol stack flag bit on a file descriptor returned by the created socket function;
and if the socket function type called by the function is not the socket function creation, adding a protocol stack flag bit on the type parameter of the socket function.
In a second possible implementation manner of the first aspect, the modifying a socket function corresponding to the application includes:
when the application program executes the creating operation, a protocol stack flag bit is added on the type parameter of the creating socket function.
In a third possible implementation manner of the first aspect, selecting, according to a preset message transmission rule, to use a kernel-mode protocol stack or a user-mode protocol stack to process a send-receive message of an application program, includes:
and selecting a protocol stack according to the protocol stack flag bit on the returned file descriptor, and calling the socket function of the selected protocol stack after removing the protocol stack flag bit on the file descriptor when the socket function type is identified not to create the socket function.
With reference to the first aspect, or the first possible implementation manner of the first aspect, or the second possible implementation manner of the first aspect, or the third possible implementation manner of the first aspect, in a fourth possible implementation manner, the method includes:
and setting the protocol stack flag bit of the socket function corresponding to the system socket function and the application program according to the message processing efficiency requirement.
With reference to the first aspect, or the first possible implementation manner of the first aspect, or the second possible implementation manner of the first aspect, or the third possible implementation manner of the first aspect, in a fifth possible implementation manner, the method includes:
identifying the type of the message according to the characteristics of the header of the message;
if the message type is control flow, processing the message by using a kernel mode protocol stack;
and if the message type is data flow, processing the message by using a user mode protocol stack.
In a second aspect, an embodiment of the present invention provides a device for processing a kernel-mode protocol stack and a user-mode protocol stack concurrently, where the device includes: a protocol stack interface processing unit and a message processing unit;
the protocol stack interface processing unit is used for taking over system socket related functions and using an interface specification which is consistent with a POSIX standard;
the protocol stack interface processing unit is also used for reconstructing a system socket related function after taking over and reconstructing a socket function corresponding to an application program, so that a kernel mode protocol stack interface is unified with a user mode protocol stack interface;
the message processing unit is used for selecting a kernel mode protocol stack or a user mode protocol stack to process the receiving and sending messages of the application program according to a preset message transmission rule.
In a first possible implementation manner of the second aspect, the protocol stack interface processing unit is configured to modify a system socket related function after takeover, and specifically includes:
identifying a socket type of the function call;
if the socket type called by the function is a socket creating function, continuously judging whether the type parameter of the socket creating function contains a protocol stack flag bit;
if the type parameter of the created socket function does not contain a protocol stack flag bit, adding the protocol stack flag bit in the type parameter of the created socket function;
adding a protocol stack flag bit on a file descriptor returned by the created socket function;
and if the socket function type called by the function is not the socket function creation, adding a protocol stack flag bit on the type parameter of the socket function.
In a second possible implementation manner of the second aspect, the protocol stack interface processing unit is configured to modify a socket function corresponding to an application program, and specifically includes:
when the application program executes the creating operation, a protocol stack flag bit is added on the type parameter of the creating socket function.
In a third possible implementation manner of the second aspect, the message processing unit is configured to select, according to a preset message transmission rule, to use a kernel-mode protocol stack or a user-mode protocol stack to process a message received by and sent from an application program, and specifically includes:
and selecting a protocol stack according to the protocol stack flag bit on the returned file descriptor, and calling the socket function of the selected protocol stack after removing the protocol stack flag bit on the file descriptor when the socket function type is identified not to create the socket function.
With reference to the second aspect, or the first possible implementation manner of the second aspect, or the second possible implementation manner of the second aspect, or the third possible implementation manner of the second aspect, in a fourth possible implementation manner, the method further includes a protocol stack type selecting unit; the protocol stack type selection unit is used for setting protocol stack flag bits of a system socket function and a socket function corresponding to an application program according to the requirement of message processing efficiency.
With reference to the second aspect, or the first possible implementation manner of the second aspect, or the second possible implementation manner of the second aspect, or the third possible implementation manner of the second aspect, in a fifth possible implementation manner, the method further includes a protocol stack type identifying unit; the protocol stack type identification unit is used for identifying the message type according to the message header characteristics; if the message type is control flow, processing the message by using a kernel mode protocol stack; and if the message type is data flow, processing the message by using a user mode protocol stack.
According to the technical scheme provided by the embodiment of the invention, the kernel mode protocol stack interface and the user mode protocol stack interface are unified by taking over the system socket related function, using the interface specification which accords with the POSIX standard, further modifying the taken over system socket related function and modifying the socket function corresponding to the application program, and further selecting and using the kernel mode protocol stack or the user mode protocol stack to process the receiving and sending messages of the application program according to the preset message transmission rule. According to the technical scheme provided by the embodiment of the invention, on one hand, the kernel mode protocol stack interface and the user mode protocol stack interface are unified, and the source program transplantation of the application program is facilitated. On the other hand, single-application multi-protocol stack coexistence is realized, the source program of the application program can be locally transplanted, and the transplanting workload is reduced. Therefore, according to the technical scheme provided by the embodiment of the invention, for the application program which needs to use the user mode protocol stack, only simple interface replacement needs to be carried out according to the user mode protocol stack, the workload of application program source program transplantation is small, and the system performance is high.
In a third aspect, a computer-readable storage medium is provided, on which a computer program is stored, which, when being executed by at least one processor, may carry out the above-mentioned first aspect or possible embodiments and advantages of the first aspect.
In a fourth aspect, a computer program product is provided, where the computer program product includes a non-volatile computer-readable storage medium storing a computer program, and the computer program, when executed, causes a computer to implement the steps of the method of the first aspect, and the problem solving embodiments and advantages of the computer program product may refer to the first aspect or possible embodiments and advantages of the first aspect, and repeated details are not repeated.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings needed to be used in the description of the embodiments will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
FIG. 1 is a flowchart of a first embodiment of a method for processing a kernel-mode protocol stack and a user-mode protocol stack concurrently according to the present invention;
FIG. 2 is a flow chart of a dual stack packet reception according to an embodiment of the present invention;
FIG. 3 is a flow chart of dual stack unpacking according to an embodiment of the present invention;
FIG. 4 is a schematic structural diagram of a first embodiment of the apparatus of the present invention;
FIG. 5 is a schematic structural diagram of a second embodiment of the apparatus of the present invention;
fig. 6 is a schematic structural diagram of an apparatus according to another embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The core of the network is the forwarding process of the message, if the message control plane and the data forwarding plane are not separated, the message firstly enters the kernel area and then is copied to the user area for processing by the upper application program, and in order to fully support each function of the user space, a large number of interfaces for butt joint are embedded in the protocol stack. If the application program can directly take over the network data packet processing, the memory management and the CPU scheduling, the performance can be improved qualitatively, especially for large-scale network data packets. Fig. 1 is a flowchart of a first embodiment of a method for processing a kernel-mode protocol stack and a user-mode protocol stack concurrently according to the present invention, and as shown in fig. 1, the method of this embodiment may include the following contents.
And S101, taking over a system socket related function, and using an interface specification which is consistent with a POSIX standard.
When the datagram needs to cross the kernel area and the user area during the transmission, the cost of context switching and data copying caused by the interruption of the datagram greatly limits the speed of processing the datagram. For example, a DPDK (Data Plane Development Kit) may be used to bypass the kernel.
S102, modifying the taken-over system socket related function and modifying the socket function corresponding to the application program, so that the kernel mode protocol stack interface and the user mode protocol stack interface are unified.
The existing TCP/IP protocols are run on the basis of a kernel, while user mode protocols are developed additionally, which run outside the kernel. Preferably, the user mode protocol stack interface conforms to the POSIX standard, so that the kernel mode protocol stack interface and the user mode protocol stack interface are unified. POSIX denotes a Portable Operating System Interface (UNIX), which defines the Interface standard that an Operating System should provide for applications.
Specifically, the modifying the system socket related function after taking over may include: identifying a socket type of the function call; if the socket type called by the function is a socket creating function, continuously judging whether the type parameter of the socket creating function contains a protocol stack flag bit; if the type parameter of the created socket function does not contain a protocol stack flag bit, adding the protocol stack flag bit in the type parameter of the created socket function; adding a protocol stack flag bit on a file descriptor returned by the created socket function; and if the socket function type called by the function is not the socket function creation, adding a protocol stack flag bit on the type parameter of the socket function. The modifying the socket function corresponding to the application program may specifically include: when the application program executes the creating operation, a protocol stack flag bit is added on the type parameter of the creating socket function.
S103, according to a preset message transmission rule, selecting and using a kernel mode protocol stack or a user mode protocol stack to process the message.
Specifically, a protocol stack is selected according to a protocol stack flag bit on the returned file descriptor, and when the socket function type is identified not to be the socket function creation, the selected socket function of the protocol stack is called after the protocol stack flag bit on the file descriptor is removed.
In a specific application, the flag bits of the protocol stack of the socket function corresponding to the system socket function and the application program are usually set according to the requirement of message processing efficiency. Identifying the type of the message according to the characteristics of the header of the message; if the message type is control flow, processing the message by using a kernel mode protocol stack; and if the message type is data flow, processing the message by using a user mode protocol stack.
Fig. 2 is a flow chart of a dual stack packet reception according to an embodiment of the present invention. As shown in fig. 2, the dual stack packet receiving method of the present embodiment may include the following.
S201, receiving the message by the network port.
S202, whether the user mode protocol stack processing rules are matched or not is judged.
And judging whether the user mode protocol stack processing rule is matched, if so, executing S203, otherwise, executing S204.
And S203, processing the message by using a user mode protocol stack.
And S204, processing the message by using a kernel mode protocol stack.
And S205, handing the message to an upper application program for processing.
The specific process is as follows: the network card receives the message, judges whether the user mode protocol stack is needed to be moved according to the rule set by the user, if so, the network card enters the user mode protocol stack for processing, otherwise, the network card enters the kernel mode protocol stack for processing, and the network card is processed by an upper application program after the protocol stack processing is finished.
Fig. 3 is a flowchart of dual stack package issuing according to an embodiment of the present invention. As shown in fig. 3, the dual protocol stack acceptance method of the present embodiment may include the following.
And S301, upper layer application program messages.
S302, whether the user mode protocol stack processing rule is matched or not is judged.
And judging whether the user mode protocol stack processing rule is matched, if so, executing S303, and otherwise, executing S304.
S303, processing the message by using a user mode protocol stack.
And S304, processing the message by using a kernel mode protocol stack.
S305, the message is delivered to the internet access to be sent out.
The specific process is as follows: and the upper application program judges whether a user mode protocol stack is needed to be used or not according to a user setting rule, if so, the upper application program enters the user mode protocol stack for processing, otherwise, the upper application program enters the kernel mode protocol stack for processing, and the upper application program is sent out from the internet access after the protocol stack processing is finished.
In this implementation, on one hand, the source program of the application program is conveniently transplanted by unifying the kernel-mode protocol stack interface and the user-mode protocol stack interface. On the other hand, single-application multi-protocol stack coexistence is realized, the source program of the application program can be locally transplanted, and the transplanting workload is reduced. Therefore, according to the technical scheme provided by the embodiment, for the application program which needs to use the user mode protocol stack, only simple interface replacement needs to be performed according to the user mode protocol stack, the workload of application program source program transplantation is small, and the system performance is high.
In the method, preferably, the type parameter of the user mode protocol stack interface includes a protocol stack flag bit, and the protocol stack flag bit is used to identify a protocol stack type. Specifically, in the process of developing the user mode protocol stack, when the application program creates the socket, a protocol stack flag bit of the user mode protocol stack is added on the basis of the type parameter, and other socket related functions of the application program do not need to be changed. Further, judging the type of the protocol stack according to whether the type parameter of the protocol stack interface comprises a protocol stack flag bit; and adding a protocol stack flag bit on the returned file descriptor according to the judged protocol stack type. And further, selecting a protocol stack according to the protocol stack flag bit on the returned file descriptor, and calling a function of the selected protocol stack after removing the protocol stack flag bit on the file descriptor.
In this embodiment, frame design and coding logic of a source program of a user mode protocol stack do not need to be used, and for an application program source program of the user mode protocol stack, simple interface replacement is only needed according to the user mode protocol stack. The replacement work includes:
(1) when the application program creates the socket, a protocol stack flag bit is added on the basis of the type parameter.
(2) Other socket related functions of the application do not need to be changed.
(3) The application takes over the socket related functions of the system using an interface consistent with the POSIX standard.
For creating the socket, judging the sockets of different protocol stacks according to whether the original type parameters have protocol stack marks, and adding a protocol stack mark bit on the returned file descriptor.
For other socket related functions, according to the flag bit of the protocol stack on the file descriptor, after removing the flag bit, the functions of different protocol stacks are called.
As above, preferably, the message transmission rule includes: if the message type is control flow, processing the message by using a kernel mode protocol stack; and if the message type is data flow, processing the message by using a user mode protocol stack.
In the scheme of the embodiment, the kernel is only used for processing the control flow, and all data flow related operations are processed in a user mode, so that performance bottlenecks of kernel packet copying, thread scheduling, system calling, interruption and the like are avoided, and various performance tuning means are assisted, so that higher performance is achieved.
Fig. 4 is a schematic structural diagram of a first embodiment of the apparatus of the present invention, and as shown in fig. 4, the apparatus of this embodiment may include: a protocol stack interface processing unit 401 and a message processing unit 402. The protocol stack interface processing unit 401 is configured to take over a system socket related function, and use an interface specification that conforms to the POSIX standard; the protocol stack interface processing unit 401 is further configured to modify a system socket related function after taking over, and modify a socket function corresponding to the application program, so that the kernel-mode protocol stack interface is unified with the user-mode protocol stack interface; the message processing unit 402 is configured to select a kernel-mode protocol stack or a user-mode protocol stack to process a message sent by an application according to a preset message transmission rule.
The apparatus of this embodiment may be used to perform the method of the embodiment of the method shown in fig. 1, and the implementation principle and the technical effect to be achieved are similar, and are not described herein again.
In the above apparatus, the protocol stack interface processing unit 401 is configured to modify a system socket related function after taking over, and specifically may include: identifying a socket type of the function call; if the socket type called by the function is a socket creating function, continuously judging whether the type parameter of the socket creating function contains a protocol stack flag bit; if the type parameter of the created socket function does not contain a protocol stack flag bit, adding the protocol stack flag bit in the type parameter of the created socket function; adding a protocol stack flag bit on a file descriptor returned by the created socket function; and if the socket function type called by the function is not the socket function creation, adding a protocol stack flag bit on the type parameter of the socket function.
In the above apparatus, the protocol stack interface processing unit 401 is configured to modify a socket function corresponding to an application program, and may specifically include: when the application program executes the creating operation, a protocol stack flag bit is added on the type parameter of the creating socket function.
In the above apparatus, the message processing unit 402 is configured to select, according to a preset message transmission rule, to use a kernel-mode protocol stack or a user-mode protocol stack to process a message sent and received by an application program, and specifically may include: and selecting a protocol stack according to the protocol stack flag bit on the returned file descriptor, and calling the socket function of the selected protocol stack after removing the protocol stack flag bit on the file descriptor when the socket function type is identified not to create the socket function.
The implementation principle and the technical effect to be achieved of the device of the present embodiment have been discussed above, and are not described herein again.
Fig. 5 is a schematic structural diagram of a second embodiment of the apparatus of the present invention, as shown in fig. 5, the apparatus of this embodiment may further include a protocol stack type selecting unit 501 and a protocol stack type identifying unit 502, where the protocol stack type selecting unit 501 is configured to set a protocol stack flag bit of a system socket function and a socket function corresponding to an application program according to a requirement of message processing efficiency. The protocol stack type identifying unit 502 is configured to identify a packet type according to a header feature of the packet; if the message type is control flow, processing the message by using a kernel mode protocol stack; and if the message type is data flow, processing the message by using a user mode protocol stack.
The implementation principle and the technical effect to be achieved of the device of the present embodiment have been discussed above, and are not described herein again.
Fig. 6 is a schematic structural diagram of an apparatus according to another embodiment of the present invention, and as shown in fig. 6, the apparatus includes at least one processor 601 (e.g., CPU), a memory 603, and at least one communication bus 604 for implementing connection communication between the apparatuses. The processor 601 is adapted to execute executable modules, such as computer programs, stored in the memory 603. The Memory 603 may include a Random Access Memory (RAM) and may further include a non-volatile Memory (non-volatile Memory), such as at least one disk Memory.
In some embodiments, the memory 603 stores a program 605, and the program 605 is executable by the processor 601, where the program includes executing a method for processing a kernel-mode protocol stack and a user-mode protocol stack concurrently, and the method includes:
taking over the system socket related function, and using the interface specification which is consistent with the POSIX standard;
modifying the taken over system socket related function and modifying the socket function corresponding to the application program to enable the kernel mode protocol stack interface to be unified with the user mode protocol stack interface;
and selecting a kernel mode protocol stack or a user mode protocol stack to process the message transmitted and received by the application program according to a preset message transmission rule.
Preferably, the program for executing the method for processing coexistence of the kernel-mode protocol stack and the user-mode protocol stack, which modifies the system socket related function after takeover, includes:
identifying a socket type of the function call;
if the socket type called by the function is a socket creating function, continuously judging whether the type parameter of the socket creating function contains a protocol stack flag bit;
if the type parameter of the created socket function does not contain a protocol stack flag bit, adding the protocol stack flag bit in the type parameter of the created socket function;
adding a protocol stack flag bit on a file descriptor returned by the created socket function;
and if the socket function type called by the function is not the socket function creation, adding a protocol stack flag bit on the type parameter of the socket function.
Preferably, the program for executing the method for processing coexistence of the kernel-mode protocol stack and the user-mode protocol stack, where the modifying a socket function corresponding to the application program, includes:
when the application program executes the creating operation, a protocol stack flag bit is added on the type parameter of the creating socket function.
The above program for executing the method for processing the coexistence of the kernel mode protocol stack and the user mode protocol stack preferably selects and uses the kernel mode protocol stack or the user mode protocol stack to process the transmission and reception messages of the application program according to a preset message transmission rule, and includes:
and selecting a protocol stack according to the protocol stack flag bit on the returned file descriptor, and calling the socket function of the selected protocol stack after removing the protocol stack flag bit on the file descriptor when the socket function type is identified not to create the socket function.
Preferably, the program for executing the method for processing coexistence of the kernel-mode protocol stack and the user-mode protocol stack includes:
and setting the protocol stack flag bit of the socket function corresponding to the system socket function and the application program according to the message processing efficiency requirement.
Preferably, the program for executing the method for processing coexistence of the kernel-mode protocol stack and the user-mode protocol stack includes:
identifying the type of the message according to the characteristics of the header of the message;
if the message type is control flow, processing the message by using a kernel mode protocol stack;
and if the message type is data flow, processing the message by using a user mode protocol stack.
Finally, it should be noted that: the above examples are only intended to illustrate the technical solution of the present invention, but not to limit it; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.

Claims (12)

1. A method for processing the coexistence of a kernel mode protocol stack and a user mode protocol stack is characterized by comprising the following steps:
taking over the system socket related function, and using the interface specification which is consistent with the POSIX standard;
modifying the taken-over system socket related function and the socket function corresponding to the application program according to the socket type called by the function, so that the kernel mode protocol stack interface is unified with the user mode protocol stack interface;
selecting a kernel mode protocol stack or a user mode protocol stack to process the receiving and sending messages of the application program according to a preset message transmission rule;
the socket function corresponding to the modified application program specifically includes: when the application program executes the creating operation, a protocol stack flag bit is added on the type parameter of the creating socket function.
2. The method of claim 1, wherein modifying the system socket-related function after takeover based on the socket type of the function call comprises:
if the socket type called by the function is a socket creating function, continuously judging whether the type parameter of the socket creating function contains a protocol stack flag bit;
if the type parameter of the created socket function does not contain a protocol stack flag bit, adding the protocol stack flag bit in the type parameter of the created socket function;
adding a protocol stack flag bit on a file descriptor returned by the created socket function;
and if the socket function type called by the function is not the socket function creation, adding a protocol stack flag bit on the type parameter of the socket function.
3. The method of claim 1, wherein selecting to use a kernel-mode protocol stack or a user-mode protocol stack to process the transceiving messages of the application according to a preset message transmission rule comprises:
and selecting a protocol stack according to the protocol stack flag bit on the returned file descriptor, and calling the socket function of the selected protocol stack after removing the protocol stack flag bit on the file descriptor when the socket function type is identified not to create the socket function.
4. The method of any of claims 1-3, wherein the messaging rules comprise:
and setting the protocol stack flag bit of the socket function corresponding to the system socket function and the application program according to the message processing efficiency requirement.
5. The method of any of claims 1-3, wherein the messaging rules comprise:
identifying the type of the message according to the characteristics of the header of the message;
if the message type is control flow, processing the message by using a kernel mode protocol stack;
and if the message type is data flow, processing the message by using a user mode protocol stack.
6. A device for processing the coexistence of a kernel mode protocol stack and a user mode protocol stack is characterized by comprising: a protocol stack interface processing unit and a message processing unit;
the protocol stack interface processing unit is used for taking over system socket related functions and using an interface specification which is consistent with a POSIX standard;
the protocol stack interface processing unit is also used for reconstructing a system socket related function after taking over and reconstructing a socket function corresponding to an application program, so that a kernel mode protocol stack interface is unified with a user mode protocol stack interface;
the message processing unit is used for selecting a kernel mode protocol stack or a user mode protocol stack to process the receiving and sending messages of the application program according to a preset message transmission rule;
the protocol stack interface processing unit is used for reconstructing the taken-over system socket related function according to the socket type of the function call;
the protocol stack interface processing unit is configured to modify a socket function corresponding to an application program, and specifically includes: when the application program executes the creating operation, a protocol stack flag bit is added on the type parameter of the creating socket function.
7. The apparatus according to claim 6, wherein the protocol stack interface processing unit is configured to modify the taken over system socket related function according to a socket type of the function call, and specifically includes:
if the socket type called by the function is a socket creating function, continuously judging whether the type parameter of the socket creating function contains a protocol stack flag bit;
if the type parameter of the created socket function does not contain a protocol stack flag bit, adding the protocol stack flag bit in the type parameter of the created socket function;
adding a protocol stack flag bit on a file descriptor returned by the created socket function;
and if the socket function type called by the function is not the socket function creation, adding a protocol stack flag bit on the type parameter of the socket function.
8. The apparatus according to claim 6, wherein the message processing unit is configured to select, according to a preset message transmission rule, to use a kernel-mode protocol stack or a user-mode protocol stack to process a message sent and received by an application program, and specifically includes:
and selecting a protocol stack according to the protocol stack flag bit on the returned file descriptor, and calling the socket function of the selected protocol stack after removing the protocol stack flag bit on the file descriptor when the socket function type is identified not to create the socket function.
9. The apparatus of any one of claims 6-8, further comprising a protocol stack type selection unit; the protocol stack type selection unit is used for setting protocol stack flag bits of a system socket function and a socket function corresponding to an application program according to the requirement of message processing efficiency.
10. The apparatus of any one of claims 6-8, further comprising a protocol stack type identification unit; the protocol stack type identification unit is used for identifying the message type according to the message header characteristics; if the message type is control flow, processing the message by using a kernel mode protocol stack; and if the message type is data flow, processing the message by using a user mode protocol stack.
11. A computer-readable storage medium, characterized in that it stores a computer program comprising program instructions which, when executed by a processor, cause the processor to carry out the steps of the method of processing a kernel-mode protocol stack and a user-mode protocol stack concurrently according to any one of claims 1 to 5.
12. A computer program product, characterized in that it comprises a non-transitory computer-readable storage medium storing a computer program which, when executed, causes a computer to implement the steps of the method for processing a kernel-mode protocol stack and a user-mode protocol stack concurrently according to any one of claims 1 to 5.
CN201810516951.2A 2018-05-25 2018-05-25 Method and device for processing coexistence of kernel mode protocol stack and user mode protocol stack Expired - Fee Related CN110535813B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810516951.2A CN110535813B (en) 2018-05-25 2018-05-25 Method and device for processing coexistence of kernel mode protocol stack and user mode protocol stack

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810516951.2A CN110535813B (en) 2018-05-25 2018-05-25 Method and device for processing coexistence of kernel mode protocol stack and user mode protocol stack

Publications (2)

Publication Number Publication Date
CN110535813A CN110535813A (en) 2019-12-03
CN110535813B true CN110535813B (en) 2022-04-22

Family

ID=68656951

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810516951.2A Expired - Fee Related CN110535813B (en) 2018-05-25 2018-05-25 Method and device for processing coexistence of kernel mode protocol stack and user mode protocol stack

Country Status (1)

Country Link
CN (1) CN110535813B (en)

Families Citing this family (17)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113055269B (en) * 2019-12-27 2023-03-07 厦门网宿有限公司 Virtual private network data transmission method and device
CN111162833B (en) * 2020-04-08 2020-08-04 北京前沿探索深空科技有限公司 Low-orbit satellite information forwarding method, device and system, controller and medium
CN112261031B (en) * 2020-10-19 2023-08-29 腾讯科技(深圳)有限公司 TCP protocol stack updating method, device, equipment and storage medium
CN112422453B (en) * 2020-12-09 2022-05-24 新华三信息技术有限公司 Message processing method, device, medium and equipment
CN112637329B (en) * 2020-12-21 2022-08-23 网络通信与安全紫金山实验室 Identification method, device, equipment and storage medium of multiple application programs
CN114745144A (en) * 2020-12-24 2022-07-12 网神信息技术(北京)股份有限公司 Access control method and apparatus, electronic device, storage medium, and program
CN112883007A (en) * 2021-02-20 2021-06-01 杭州迪普科技股份有限公司 Native protocol message processing method and device for Linux system
CN115334156A (en) * 2021-04-26 2022-11-11 深信服科技股份有限公司 Message processing method, device, equipment and storage medium
CN116803067A (en) * 2021-05-31 2023-09-22 华为技术有限公司 Communication method and system supporting multiple protocol stacks
CN113259400B (en) * 2021-07-14 2021-09-28 南京易科腾信息技术有限公司 Network interaction system, method and storage medium based on network protocol
CN114697194B (en) * 2022-02-17 2023-07-14 清华大学 Blocking event notification method and device
CN115174206B (en) * 2022-07-01 2024-04-02 江苏深网科技有限公司 User mode application security detection method and detection system in transparent network bridge mode
CN115460470B (en) * 2022-08-19 2024-03-26 烽火通信科技股份有限公司 Multicast data forwarding method, device, equipment and readable storage medium
CN115827120B (en) * 2023-01-10 2023-05-23 苏州浪潮智能科技有限公司 User state network stack calling and user state interface setting method and device
CN117041379B (en) * 2023-07-10 2024-04-19 中科驭数(北京)科技有限公司 Method and device for simultaneously monitoring newly-built connection of user mode protocol stack and kernel mode protocol stack
CN116846991B (en) * 2023-07-11 2024-09-27 中科驭数(北京)科技有限公司 Network application data forwarding method and device
CN117395329B (en) * 2023-12-13 2024-02-06 井芯微电子技术(天津)有限公司 Method, device and storage medium for receiving and transmitting Ethernet two-layer protocol message

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101841470A (en) * 2010-03-29 2010-09-22 东南大学 High-speed capturing method of bottom-layer data packet based on Linux
CN102339234A (en) * 2011-07-12 2012-02-01 迈普通信技术股份有限公司 Device for operating protocol stack and method
CN103997500A (en) * 2014-06-04 2014-08-20 西北工业大学 Achieving method of light-weight real-time TCP/IP protocol stack
CN106302199A (en) * 2016-08-10 2017-01-04 成都广达新网科技股份有限公司 A kind of User space protocol stack realization method and system based on L3 Switching machine equipment

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8121148B2 (en) * 2005-03-24 2012-02-21 Ixia Protocol stack using shared memory
US8116312B2 (en) * 2006-02-08 2012-02-14 Solarflare Communications, Inc. Method and apparatus for multicast packet reception
US10129180B2 (en) * 2015-01-30 2018-11-13 Nicira, Inc. Transit logical switch within logical router

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101841470A (en) * 2010-03-29 2010-09-22 东南大学 High-speed capturing method of bottom-layer data packet based on Linux
CN102339234A (en) * 2011-07-12 2012-02-01 迈普通信技术股份有限公司 Device for operating protocol stack and method
CN103997500A (en) * 2014-06-04 2014-08-20 西北工业大学 Achieving method of light-weight real-time TCP/IP protocol stack
CN106302199A (en) * 2016-08-10 2017-01-04 成都广达新网科技股份有限公司 A kind of User space protocol stack realization method and system based on L3 Switching machine equipment

Also Published As

Publication number Publication date
CN110535813A (en) 2019-12-03

Similar Documents

Publication Publication Date Title
CN110535813B (en) Method and device for processing coexistence of kernel mode protocol stack and user mode protocol stack
US11677851B2 (en) Accelerated network packet processing
CN102334112B (en) Method and system for virtual machine networking
TWI408934B (en) Network interface techniques
CN108270676B (en) Network data processing method and device based on Intel DPDK
CN110138553B (en) IPSec VPN gateway data packet processing device and method
US10630587B2 (en) Shared memory communication in software defined networking
CN109088820B (en) Cross-device link aggregation method and device, computing device and storage medium
CN110391999A (en) A kind of data communications method and system
CN111211999A (en) OVS-based real-time virtual network implementation method
CN114244560A (en) Traffic processing method and device
CN111813547A (en) DPDK-based data packet processing method and device
CN104572315B (en) Realize method, communication entity and the distributed communication system of intersubsystem communication
WO2020113817A1 (en) Network isolation method and apparatus based on user mode protocol stack
US20130110968A1 (en) Reducing latency in multicast traffic reception
CN106790162B (en) Virtual network optimization method and system
CN113472523A (en) User mode protocol stack message processing optimization method, system, device and storage medium
CN112217772B (en) Protocol stack implementation method, device and storage medium
CN114816651A (en) Communication method, device and system
CN113553279B (en) RDMA communication acceleration set communication method and system
CN111586040B (en) High-performance network data receiving method and system
CN112422457B (en) Message processing method and device and computer storage medium
CN116821041A (en) Efficient queue access for user space packet processing
CN118410001B (en) Method, system, device, product and equipment for data transmission between graphic processing units
CN116170404B (en) DPDK-based data forwarding method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
CF01 Termination of patent right due to non-payment of annual fee
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20220422