User mode multi-process communication unit and method, electronic equipment and storage medium

By setting up multiple user-state processes and one protocol stack process in the user-state, multiple user-state processes share a protocol stack set in the user-state for communication, solving the problem of protocol stack portability caused by different Linux kernel versions, and improving the compatibility, portability and stability of the protocol stack.

CN120104374APending Publication Date: 2025-06-06HANGZHOU ULIP XINCHUANG TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510224103.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-27
Publication Date
2025-06-06

AI Technical Summary

Technical Problem

During the development of network equipment, due to the different versions of the Linux kernel, the porting of the protocol stack is difficult, and existing solutions such as only the user-state protocol stack is running or the user-state protocol stack is parallel to the kernel protocol stack, which has problems such as difficulty in sharing information and reduced system stability.

Method used

By setting up multiple user-state processes and one protocol stack process in the user state, each user-state process sets the interface proxy module and the protocol stack process sets the interface proxy center and the interface proxy module of the user-state process are connected, so that multiple user-state processes share a protocol stack set in the user-state for communication.

Benefits of technology

It improves the compatibility, portability and stability of the protocol stack, reduces the difficulty of porting the protocol stack, and makes the porting operation of the protocol stack simpler and more efficient.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120104374A_ABST
    Figure CN120104374A_ABST
Patent Text Reader

Abstract

The invention discloses a user mode multi-process communication unit and method, electronic equipment and a storage medium, the communication unit comprises a plurality of user mode processes and a protocol stack process, and each user mode process sends and receives data to and from the protocol stack process through an interface agent module; the protocol stack process is provided with an interface agent center and a protocol stack, the interface agent center receives data sent by each interface agent module and sends the received data to the protocol stack, and the protocol stack carries out data processing on the data, sends the data to the kernel and receives and processes data returned by the kernel; and the interface agent center judges a sending object of the processed data and sends the data to the interface agent module of the corresponding user mode process. According to the user mode multi-process communication unit, communication is achieved by sharing the protocol stack arranged in the user mode through the multiple user mode processes, the transplantation difficulty of the protocol stack can be effectively reduced, and the protocol stack transplantation operation can be easily and efficiently achieved in the follow-up process.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of user-mode multi-process communication, and in particular to a user-mode multi-process communication unit, method, electronic device and storage medium. Background Art

[0002] In the field of computer communications, the Linux kernel protocol stack used by network devices is generally a special protocol stack developed and improved on the basis of the original Linux kernel protocol stack. When a new network device is developed, the Linux kernel version it uses may be inconsistent with the Linux kernel version used by the original network device, and the protocol stacks of the two will also be different. Therefore, when it is necessary to port the functions developed on the original Linux kernel protocol stack to the new network device, the porting operation is very difficult and labor-intensive due to the different Linux kernel versions.

[0003] The existing solution is usually to run the protocol stack in the user space of the Linux operating system instead of using the protocol stack that comes with the kernel. However, the existing solutions also have corresponding problems. If a solution is adopted in which only the user-mode protocol stack is run, each user-mode process of the solution is equipped with an independent protocol stack, and the protocol stacks of each user-mode process are independent of each other, then there will be a problem that information cannot be shared; and when a solution is adopted in which the user-mode protocol stack and the kernel protocol stack are run in parallel, if there is a proxy module in the kernel, the transplantation process will also involve the transplantation of kernel functions, and the system development will also be difficult, and the stability of the system will be reduced. Summary of the invention

[0004] The purpose of the present invention is to provide a user-mode multi-process communication unit, method, electronic device and storage medium, which realize communication by multiple user-mode processes sharing a protocol stack set in user mode, can effectively improve the compatibility, portability and stability of the protocol stack, reduce the difficulty of porting the protocol stack, and facilitate the subsequent simple and efficient implementation of the protocol stack porting operation.

[0005] In order to achieve the above object, the present invention discloses a user-mode multi-process communication unit, which includes: Multiple user-mode processes and a protocol stack process, Each of the user state processes is provided with an interface proxy module, and each of the user state processes sends data to the protocol stack process through the interface proxy module, and receives data returned by the protocol stack process; The protocol stack process is provided with an interface proxy center and a protocol stack. The interface proxy center is respectively connected to the interface proxy modules of the user-state processes. The interface proxy center receives data sent by the interface proxy modules and sends the received data to the protocol stack. The protocol stack processes the received data and sends the processed data to the kernel through the kernel packet receiving and sending module, and receives and processes the data returned by the kernel to send the processed data to the interface proxy center. The interface proxy center determines the sending object of the data and sends the data to the interface proxy module of the corresponding user-state process.

[0006] Optionally, the interface proxy module is compiled in the form of a lib library and integrated into the user state process.

[0007] Optionally, each of the interface proxy modules is provided with multiple first socket interfaces, and the interface proxy center is provided with multiple second socket interfaces, and the multiple first socket interfaces correspond one-to-one to the multiple second socket interfaces. The user state process sends data to the interface proxy center through the first socket interface, and the interface proxy center receives the data sent by the user state process through the second socket interface.

[0008] Optionally, the interface proxy center includes a judge and a distributor, the judge is connected to each of the interface proxy modules, the judge is used to judge the type of data received by each of the interface proxy modules, the protocol stack is provided with multiple processing interfaces, the distributor is connected to each of the processing interfaces, and the distributor is used to call the corresponding processing interface according to the type judged by the judge to send the received data to the protocol stack.

[0009] Optionally, the protocol stack process is set in user state, and the kernel packet receiving and sending module is set in kernel state. The kernel packet receiving and sending module transfers the data sent by the protocol stack to the kernel in the kernel state through shared memory, and transfers the data packet of the kernel to the protocol stack.

[0010] In order to achieve the above object, the present invention discloses a user-mode multi-process communication method, which comprises: The user state process sends the first data through the interface proxy module; The interface proxy center receives the first data sent by the interface proxy module, and sends the first data to the protocol stack; The protocol stack processes the first data into second data, and sends the second data to the kernel through the kernel packet transceiver module; The protocol stack receives the third data returned by the kernel through the kernel packet receiving and sending module, processes the third data into fourth data, and sends the fourth data to the interface proxy center; The interface proxy center determines a sending object of the fourth data, and sends the fourth data to an interface proxy module of a corresponding user state process; The corresponding user state process receives the fourth data through the interface proxy module.

[0011] Furthermore, the “user state process sends the first data through the interface proxy module” includes: The user state process sends the first data to the interface proxy center through the first socket interface; The “interface proxy center receives the first data sent by the interface proxy module” includes: The interface proxy center receives the first data sent by the user state process through a second socket interface corresponding to the first socket interface.

[0012] Further, the interface proxy center includes a determiner and a distributor, and the "sending the first data to the protocol stack" includes: The determiner determines the type of the first data; The distributor calls a processing interface corresponding to the protocol stack according to the type determined by the determiner to send the first data to the protocol stack.

[0013] In order to achieve the above object, the present invention discloses an electronic device, which includes: one or more processors; One or more memories are used to store one or more programs. When one or more of the programs are executed by the processor, the processor implements the user-mode multi-process communication method as described above.

[0014] In order to achieve the above-mentioned object, the present invention discloses a computer-readable storage medium on which a program is stored. When the program is executed by a processor, the user-mode multi-process communication method as described above is implemented.

[0015] The present invention realizes the communication of multiple user-state processes through a protocol stack process. Each user-state process is provided with an interface proxy module, and sends data to the protocol stack process through the interface proxy module. The protocol stack process is provided with an interface proxy center and a protocol stack. The interface proxy center is respectively connected to the interface proxy module of each user-state process to receive the data sent by the receiver, and sends the received data to the protocol stack. The protocol stack processes the received data and sends it to the kernel through the kernel transceiver module to receive and process the data returned by the kernel, and sends the processed data to the interface proxy center. The interface proxy center determines the sending object of the data to send it to the interface proxy module of the corresponding user-state process. The corresponding user-state process receives the returned data through the interface proxy module. The above-mentioned multiple user-state processes share a protocol stack set in the user state to realize communication, which can effectively improve the compatibility, portability and stability of the protocol stack, reduce the difficulty of transplanting the protocol stack, and is conducive to the subsequent simple and efficient implementation of the protocol stack transplantation operation. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] Figure 1 The module diagram of user state and kernel state in the user state multi-process communication unit of the embodiment of the present invention.

[0017] Figure 2 The module diagram of the user state process and the protocol state process in the user state multi-process communication unit according to the embodiment of the present invention.

[0018] Figure 3 The module diagram is of the interface proxy module, the interface proxy center and the protocol stack in the user-mode multi-process communication unit according to the embodiment of the present invention.

[0019] Figure 4 The present invention is a flowchart of a method for user-mode multi-process communication according to an embodiment of the present invention.

[0020] Figure 5 4 is a system diagram of an electronic device according to an embodiment of the present invention. DETAILED DESCRIPTION

[0021] In order to explain the technical content, structural features, achieved objectives and effects of the present invention in detail, the following is a detailed description in conjunction with the implementation methods and the accompanying drawings.

[0022] Embodiment 1 See also Figures 1 to 3 The present invention discloses a user-mode multi-process communication unit, which includes: A plurality of user-mode processes 10 and a protocol stack process 20, Each user state process 10 is provided with an interface proxy module 11, and each user state process 10 sends data to the protocol stack process 20 through the interface proxy module 11, and receives data returned by the protocol stack process 20; The protocol stack process 20 is provided with an interface proxy center 21 and a protocol stack 22. The interface proxy center 21 is respectively connected to the interface proxy modules 11 of each user state process 10. The interface proxy center 21 receives data sent by each interface proxy module 11, and sends the received data to the protocol stack 22. The protocol stack 22 processes the received data, and sends the processed data to the kernel 32 through the kernel packet receiving and sending module 31, and receives and processes the data returned by the kernel 32 to send the processed data to the interface proxy center 21. The interface proxy center 21 determines the sending object of the data, and sends the data to the interface proxy module 11 of the corresponding user state process 10.

[0023] Furthermore, the interface proxy module 11 is compiled and integrated into the user state process 10 in the form of a lib library, and provides a plurality of first socket interfaces fd1 for the user state process 10 to implement communication between the user state process 10 and the protocol stack process 20 .

[0024] It is understandable that if Figure 2 As shown, the user state process 10 sends data by calling the first socket interface fd1 provided by the interface proxy module 11, and the interface proxy module 11 of each user state process 10 sends data to the interface proxy center 21 of the protocol stack process 20 through inter-process communication, and is not limited to this.

[0025] Furthermore, each interface proxy module 11 is provided with multiple first socket interfaces fd1, and the interface proxy center 21 is provided with multiple second socket interfaces. The multiple first socket interfaces correspond one-to-one to the multiple second socket interfaces. The user state process 10 sends data to the interface proxy center 21 through the first socket interface fd1, and the interface proxy center 21 receives the data sent by the user state process 10 through the second socket interface, which is beneficial to improving the communication efficiency between the user state process 10 and the protocol stack process 20.

[0026] It should be noted that, as shown in Figure 3, the interface proxy module 11 and the interface proxy center 21 are provided with four first socket interfaces fd1 and four second socket interfaces fd2. For example, the interface proxy module 11 sends data through the first socket interface fd10, and the interface proxy center 21 receives the data through the corresponding second socket interface fd20, and calls the corresponding processing interface 221 of the protocol stack 22 to send data to the kernel 32 through the protocol stack 22, and is not limited to this.

[0027] It can be understood that, in this embodiment, the data types sent by the interface proxy module 11 include socket data, bind data, listen data, accept data, send data, sendto data and sendmsg data. For example, when the user state process 10 needs to create a socket, it will call the socket creation interface (first socket interface) provided by the interface proxy module 11, and the interface proxy module 11 will send the socket creation message (socket data) to the interface proxy center 21. The interface proxy center 21 calls the socket creation interface (processing interface 221) provided by the protocol stack 22 to create a socket, and waits to receive the socket creation success message returned by the protocol stack 22 to forward it to the user state process 10 through the interface proxy module 11.

[0028] Furthermore, the interface proxy center 21 includes a judger 211 and a distributor 212. The judger 211 is connected to each interface proxy module 11. The judger 211 is used to judge the type of data received by each interface proxy module 11. The protocol stack 22 is provided with multiple processing interfaces 221. The distributor 212 is connected to each processing interface 221. The distributor 212 is used to call the corresponding processing interface 221 according to the type judged by the judger 211 to send the received data to the protocol stack 22.

[0029] It should be noted that, in this embodiment, Figure 3 As shown, the judge 211 is an epoll multiplexing mechanism, the distributor 212 is an event distributor, and the protocol stack 22 is a protocol stack transplanted from the Linux kernel protocol stack to the user state. It implements data reception and transmission based on the TCP / UDP protocol, and provides the distributor 212 with a processing interface 221 including a socket interface, a bind interface, a listen interface, an accept interface, a send interface, a sendto interface, and a sendmsg interface.

[0030] It can be understood that when the interface proxy center 21 receives data returned by the protocol stack 22, the distributor 212 is responsible for sending the received returned data to the judge 211. After the judge 211 determines the sending object of the returned data, it sends the data to the interface proxy module 11 of the corresponding user state process 10.

[0031] Furthermore, the protocol stack process 20 is set in the user state, and the kernel packet receiving and sending module 31 is set in the kernel state. The kernel packet receiving and sending module 31 transmits the data sent by the protocol stack 22 to the kernel 32 in the kernel state through shared memory, and transmits the data packet of the kernel 32 to the protocol stack 22.

[0032] The above-mentioned protocol stack process 20 runs in the user-mode space independently of each user-mode application process, which can reduce the coupling between the protocol stack 22 and the Linux system kernel and effectively reduce the difficulty of porting. For example, when the Linux system is upgraded, the protocol stack 22 can be quickly ported to the new system without complicated modifications. It can also make the development of the protocol stack 22 simple and efficient, and facilitate the location of system problems.

[0033] The present invention realizes the communication of multiple user-state processes 10 through a protocol stack process 20. Each user-state process 10 is provided with an interface proxy module 11, and sends data to the protocol stack process 20 through the interface proxy module 11. The protocol stack process 20 is provided with an interface proxy center 21 and a protocol stack 22. The interface proxy center 21 is respectively connected to the interface proxy module 11 of each user-state process 10 to receive the data sent by the receiver, and sends the received data to the protocol stack 22. The protocol stack 22 processes the received data and sends it to the kernel 32 through the kernel transceiver module 31 to receive and process the data returned by the kernel 32, and sends the processed data to the interface proxy center 21. The interface proxy center 21 determines the sending object of the data to send it to the interface proxy module 11 of the corresponding user-state process 10, and the corresponding user-state process 10 receives the returned data through the interface proxy module 11. The above-mentioned multiple user-state processes 10 share a protocol stack 22 set in the user state to realize communication, which can effectively improve the compatibility, portability and stability of the protocol stack 22, reduce the difficulty of transplanting the protocol stack 22, and is conducive to the subsequent simple and efficient implementation of the protocol stack 22 transplantation operation.

[0034] Embodiment 2 See also Figures 1 to 4 The present invention discloses a user-mode multi-process communication method, which comprises: 201. The user state process 10 sends first data through the interface proxy module 11; Furthermore, “the user state process 10 sends the first data through the interface proxy module 11” includes: 2011. The user state process 10 sends first data to the interface proxy center 21 through the first socket interface fd1; 202. The interface proxy center 21 receives the first data sent by the interface proxy module 11, and sends the first data to the protocol stack 22; Furthermore, “the interface proxy center 21 receives the first data sent by the interface proxy module 11” includes: 2021. The interface proxy center 21 receives the first data sent by the user state process 10 through the second socket interface fd2 corresponding to the first socket interface fd1.

[0035] Further, the interface proxy center 21 includes a determiner 211 and a distributor 212, and "sending the first data to the protocol stack 22" includes: 2022. The determiner 211 determines the type of the first data; 2023 . The distributor 212 calls the processing interface 221 corresponding to the protocol stack 22 according to the type determined by the determiner 211 , so as to send the first data to the protocol stack 22 .

[0036] 203. The protocol stack 22 processes the first data into second data, and sends the second data to the kernel 32 through the kernel packet receiving and sending module 31; 204. The protocol stack 22 receives the third data returned by the kernel 32 through the kernel packet receiving and sending module 31, processes the third data into fourth data, and sends the fourth data to the interface proxy center 21; 205. The interface proxy center 21 determines the sending object of the fourth data, and sends the fourth data to the interface proxy module 11 of the corresponding user state process 10; 206 . The corresponding user state process 10 receives fourth data through the interface proxy module 11 .

[0037] Embodiment 3 See also Figure 4 and Figure 5 , the present invention discloses an electronic device, comprising: One or more processors 301; One or more memories 302 are used to store one or more programs. When the one or more programs are executed by the processor, the processor implements the user-mode multi-process communication method as described above.

[0038] Embodiment 4 An embodiment of the present application discloses a computer-readable storage medium on which a program is stored. When the program is executed by a processor, the user-mode multi-process communication method as described above is implemented.

[0039] Embodiment 5 The embodiment of the present application discloses a computer program product or a computer program, which includes a computer instruction stored in a computer-readable storage medium. A processor of an electronic device reads the computer instruction from the computer-readable storage medium, and the processor executes the computer instruction, so that the electronic device executes the above-mentioned user-mode multi-process communication method.

[0040] It should be understood that in the embodiments of the present application, the processor referred to may be a central processing unit (CPU), and the processor may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.

[0041] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by hardware related to computer program instructions, and the program can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. The storage medium can be a disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM).

[0042] The above disclosure is only the preferred embodiment of the present invention, which certainly cannot be used to limit the scope of rights of the present invention. Therefore, equivalent changes made according to the scope of the patent application of the present invention are still within the scope covered by the present invention.

Claims

1. A user-mode multi-process communication unit, characterized in that: include: Multiple user-mode processes and a protocol stack process, Each of the user state processes is provided with an interface proxy module, and each of the user state processes sends data to the protocol stack process through the interface proxy module, and receives data returned by the protocol stack process; The protocol stack process is provided with an interface proxy center and a protocol stack. The interface proxy center is respectively connected to the interface proxy modules of the user-state processes. The interface proxy center receives data sent by the interface proxy modules and sends the received data to the protocol stack. The protocol stack processes the received data and sends the processed data to the kernel through the kernel packet receiving and sending module, and receives and processes the data returned by the kernel to send the processed data to the interface proxy center. The interface proxy center determines the sending object of the data and sends the data to the interface proxy module of the corresponding user-state process.

2. The user-mode multi-process communication unit according to claim 1, characterized in that: The interface proxy module is compiled and integrated into the user mode process in the form of a lib library.

3. The user-mode multi-process communication unit according to claim 1, characterized in that: Each of the interface proxy modules is provided with multiple first socket interfaces, and the interface proxy center is provided with multiple second socket interfaces. The multiple first socket interfaces correspond one-to-one to the multiple second socket interfaces. The user state process sends data to the interface proxy center through the first socket interface, and the interface proxy center receives the data sent by the user state process through the second socket interface.

4. The user-mode multi-process communication unit according to claim 1, characterized in that: The interface proxy center includes a judger and a distributor. The judger is connected to each of the interface proxy modules and is used to judge the type of data received by each of the interface proxy modules. The protocol stack is provided with multiple processing interfaces. The distributor is connected to each of the processing interfaces and is used to call the corresponding processing interface according to the type judged by the judge to send the received data to the protocol stack.

5. The user-mode multi-process communication unit according to claim 1, characterized in that: The protocol stack process is set in the user state, and the kernel packet receiving and sending module is set in the kernel state. The kernel packet receiving and sending module transfers the data sent by the protocol stack to the kernel in the kernel state through shared memory, and transfers the data packet of the kernel to the protocol stack.

6. A user-mode multi-process communication method, characterized in that: include: The user state process sends the first data through the interface proxy module; The interface proxy center receives the first data sent by the interface proxy module, and sends the first data to the protocol stack; The protocol stack processes the first data into second data, and sends the second data to the kernel through the kernel packet transceiver module; The protocol stack receives the third data returned by the kernel through the kernel packet receiving and sending module, processes the third data into fourth data, and sends the fourth data to the interface proxy center; The interface proxy center determines a sending object of the fourth data, and sends the fourth data to an interface proxy module of a corresponding user state process; The corresponding user state process receives the fourth data through the interface proxy module.

7. The user-mode multi-process communication method according to claim 6, characterized in that: The “user state process sends the first data through the interface proxy module” includes: The user state process sends the first data to the interface proxy center through the first socket interface; The “interface proxy center receives the first data sent by the interface proxy module” includes: The interface proxy center receives the first data sent by the user state process through a second socket interface corresponding to the first socket interface.

8. The user-mode multi-process communication method according to claim 6, characterized in that: The interface proxy center includes a judger and a distributor, and the "sending the first data to the protocol stack" includes: The determiner determines the type of the first data; The distributor calls a processing interface corresponding to the protocol stack according to the type determined by the determiner to send the first data to the protocol stack.

9. An electronic device, characterized in that: include: one or more processors; One or more memories are used to store one or more programs. When one or more of the programs are executed by the processor, the processor implements the user-mode multi-process communication method as described in any one of claims 6 to 8.

10. A computer-readable storage medium having a program stored thereon, characterized in that: When the program is executed by a processor, the user-mode multi-process communication method according to any one of claims 6 to 8 is implemented.