Forwarding network packet system for network simulation

By introducing a shared queue mechanism between user space and kernel space, the problem of low network packet forwarding performance in user space network simulation schemes is solved, achieving high-throughput network packet capture and forwarding, and expanding the application scenarios of user space simulation.

CN122268819APending Publication Date: 2026-06-23SHANGHAI JIAOTONG UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411876839.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-19
Publication Date
2026-06-23

AI Technical Summary

Technical Problem

Existing user-space network simulation solutions suffer from low network packet forwarding performance, especially in large-scale network simulation scenarios, resulting in a throughput rate far lower than that of kernel-space simulation tools.

Method used

By introducing a shared queue mechanism between user space and kernel space, network packet exchange is performed using network packet pointers, link layer source addresses, and destination addresses. Combined with user space device binding modules, queue control modules, and kernel modules, efficient network packet capture, processing, and forwarding are achieved.

Benefits of technology

It significantly improves the forwarding throughput rate of user-space network simulation, approaching or even surpassing the performance of kernel-space simulation tools, and expands the application scenarios of user-space simulation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122268819A_ABST
    Figure CN122268819A_ABST
Patent Text Reader

Abstract

The application discloses a forwarding network packet system for network simulation, which comprises a user state device binding module, a user state queue control module and a kernel module, wherein the user state queue control module runs in the user program space in the form of a library, the kernel module runs in the operating system kernel space, and the kernel module assists the user state device binding module and the user state queue control module to complete the request of the user simulation program. The application can enable the user state simulation program to capture, process and forward network packets at a high throughput, and expand the application scenario of the user state simulation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to a technology in the field of distributed information processing, specifically a network packet forwarding system for network simulation. Background Technology

[0002] The application scenarios for user-space emulation solutions remain relatively limited, mainly concentrated in small-scale wireless network simulation environments. This limitation stems from significant shortcomings in existing user-space network emulation solutions: low performance in forwarding network packets. Compared to kernel-based network emulation tools, user-space network emulation typically uses Linux-provided network packet capture tools (such as tap and veth devices) to capture and forward network packets. This process usually involves copying network packets between the operating system and user programs, introducing additional overhead that makes the forwarding performance of user-space emulation significantly lower than that of kernel-space emulation tools. Summary of the Invention

[0003] To address the aforementioned shortcomings of existing technologies, this invention proposes a network packet forwarding system for network simulation scenarios. This system enables user-space simulation programs to capture, process, and forward network packets at high throughput rates, thereby expanding the application scenarios of user-space simulation.

[0004] This invention is achieved through the following technical solution:

[0005] This invention relates to a network packet forwarding system for network simulation, comprising: a user-space device binding module, a user-space queue control module, and a kernel module including a queue management unit and a network packet distribution unit. The user-space device binding module sends the device name requested by the user-space simulation program to the kernel module and maps the corresponding shared queue to the user program space. The queue management unit, based on the device name requested by the user-space device binding module, queries the corresponding device through an interface provided by the operating system, creates a shared queue, generates a globally unique offset index for it, records the relationship between the offset index and the shared queue, and the binding relationship between the device and the shared queue, and finally returns the queue's offset index to the user-space device binding module to complete the mapping of the shared queue to the user program space. The user-space queue control module reads or writes to the corresponding shared queue according to the operation request of the user-space simulation program and sends the distribution operation to the network packet distribution unit for distribution. The network packet distribution unit, based on the distribution request from the user-space queue control module, finds the corresponding device and shared queue, converts the data in the shared queue into network packets, and distributes the network packets to the devices through an internal interface of the operating system, enabling the network packets to be received by the devices.

[0006] The user program space refers to the memory area allocated by the operating system for user programs to run in a non-privileged mode, where they cannot directly access system resources.

[0007] The kernel module runs in the operating system kernel space, that is, in the privileged mode of the area where the operating system kernel works, and manages hardware resources and core system functions.

[0008] The operation requests include: capturing network packets and forwarding network packets.

[0009] The aforementioned network packet capture specifically refers to the following: when a simulated node sends a network packet, the network packet is read from the corresponding device by the user-space simulation program, and then the network packet is subjected to simulation operations (such as discarding the network packet to indicate a packet loss operation, or storing the network packet and waiting for a period of time before forwarding it to indicate a delayed operation).

[0010] The aforementioned forwarding of network packets specifically refers to: writing the network packet into the network device corresponding to the link layer target address based on the link layer target address of the network packet, so that the network packet is received by the corresponding network device, that is, by the emulated node that owns the network device.

[0011] The binding relationship refers to finding the unique queue corresponding to it through the offset index and finding the corresponding queue through the device.

[0012] The shared queues include RX queues and TX queues, with each shared queue having a one-to-one correspondence with a device. The queue data in the shared queues consists of network packet pointers, link-layer source addresses, and destination addresses from the operating system.

[0013] The network packet pointer refers to the memory representation of the network packet received by the device in the operating system. Data can be converted into a network packet through this pointer. The network packet can also be converted into a queue of data by combining its pointer, link layer source address and destination address. Technical effect

[0014] Compared with existing technologies, this invention, based on the characteristics of network simulation, uses a shared queue and network packet pointers, link layer source addresses, and destination addresses as data for network packet switching. This overcomes the high overhead of network packet switching in existing technologies and achieves a forwarding throughput rate far exceeding that of existing user-space network simulators. Attached Figure Description

[0015] Figure 1 This is a schematic diagram of the system of the present invention;

[0016] Figure 2 This is a diagram illustrating a local simulation.

[0017] Figure 3 This is a diagram illustrating remote forwarding.

[0018] Figure 4 A diagram showing the comparison of local forwarding throughput rates for various forwarding schemes;

[0019] Figure 5 This is a schematic diagram comparing the remote forwarding throughput rate of the example and the user-space network simulator EMANE. Detailed Implementation

[0020] like Figure 1 As shown, this embodiment relates to a network packet forwarding system for network simulation, which includes: a user-mode device binding module, a user-mode queue control module, and a kernel module. The user-mode queue control module runs in the user program space as a program library, and the kernel module runs in the operating system kernel space, assisting the user-mode device binding module and the user-mode queue control module in fulfilling the requests of the user simulation program.

[0021] The kernel module includes a queue management unit and a network packet distribution unit. The queue management unit, based on the device name requested by the user-mode device binding module, queries the corresponding device through an interface provided by the operating system, creates a shared queue, generates a globally unique offset index for it, and records the relationship between the offset index and the shared queue, as well as the binding relationship between the device and the shared queue. Finally, it returns the queue's offset index to the user-mode device binding module to complete the mapping of the shared queue to the user program space. The user-mode queue control module, based on operation requests in the user-mode simulation program for capturing, processing, and / or forwarding network packets, reads or writes to the corresponding shared queues and sends the distribution operation to the network packet distribution unit for distribution. The network packet distribution unit, based on the distribution request from the user-mode queue control module, locates the corresponding device and shared queue, converts the data in the shared queue into network packets, and distributes the network packets to the devices through an internal operating system interface, enabling the devices to receive the network packets.

[0022] The creation of the shared queue specifically includes:

[0023] Step a: The user-mode device binding module receives the binding device name from the user-mode emulation program and sends it to the queue management unit in the kernel module.

[0024] Step b: After receiving the bound device name, the queue management unit queries the device corresponding to the device name through the interface provided by the operating system kernel, allocates and initializes the shared queue, and registers a callback function for the device.

[0025] Step c: The queue management unit generates a globally unique offset index for the shared queue. Specifically, the offset index is a 64-bit integer. The queue management unit maintains a globally unique 64-bit integer variable. Each time a shared queue is created, this number is incremented, and the incremented value is used as the offset index of the shared queue.

[0026] Step d: Record the one-to-one binding relationship between the offset index and the shared queue, and the one-to-one binding relationship between the device and the shared queue. Specifically, the queue management unit maintains two hash tables, one with the offset index as the key and the shared queue pointer as the value, and the other with the device pointer as the key and the shared queue pointer as the value. Recording the binding relationship means inserting the corresponding key-value pair into the hash table and finding the corresponding shared queue in the hash table through the device or offset index.

[0027] Step e: Return the queue offset index to the user-space device binding module. This module uses the offset index to call the mmap system call function provided by the operating system, using the offset index as the offset parameter of the function's input parameter. The system call function requests the mmap implementation provided by the kernel module. In the kernel module's mmap implementation, the offset parameter in the input parameter is converted into an offset index (both are 64-bit integers). The corresponding shared queue is found through this offset index, and the shared queue is memory-mapped to user-space space through the operating system's interface, allowing the user-space simulation program to access the queue through the user-space control queue module.

[0028] The aforementioned registration and reception callback function refers to a method provided by the operating system for network devices to register and receive callback functions. This method takes a function pointer as its input parameter. After the method is called, the function pointer is recorded in the network device. When the network device receives a network packet, it uses the network packet as an input parameter to call the previously recorded function pointer. The queue management unit in the kernel module implements a custom reception callback function. This function converts network packets into queue data and writes them to the corresponding shared queue's RX queue. This custom reception callback function is used as an input parameter when registering the reception callback function for the device. Therefore, after completing the process of creating a shared queue for the device, the network packets received by the device can be read from the RX queue of its corresponding shared queue.

[0029] The shared queue includes an RX queue and a TX queue. The queue data in the shared queue consists of network packet pointers, link layer source addresses, and destination addresses from the operating system.

[0030] The captured network packets specifically include:

[0031] Step a: The custom receive callback function described above will write the network packets received by device A into the RX queue of the shared queue corresponding to device A;

[0032] Step b: The user-mode simulation program sends a read request to the user-mode queue control module with the shared queue address corresponding to device A as the input parameter. The read request will read the queue information in the RX queue of the shared queue corresponding to device A and return it to the user-mode simulation program.

[0033] Step c: The user-space simulation program obtains the queue information and can treat it as a network packet from device A for simulation processing, such as waiting for a period of time before forwarding it to achieve a delay effect.

[0034] The aforementioned forwarded network packets specifically include:

[0035] Step a: The user-space simulation program finds the corresponding target device based on the link layer target address of the queue data, and sends a write request to the user-space queue control module with the shared queue of the target device as the input parameter.

[0036] Step b: The user-space queue control module writes the queue data to the TX queue of the shared queue of the target device.

[0037] Step c: The user-space simulation program sends a distribution request to the user-space queue control module with the name of the target device as the input parameter. The user-space queue control module then sends the request to the network packet distribution unit in the kernel module.

[0038] Step d: The network packet distribution unit queries the device corresponding to the input device name and the corresponding shared queue, reads the queue data of the TX shared queue in the shared queue, converts the queue data into a network packet according to the network packet pointer in the data, and forwards the network packet to the corresponding device through a function provided by the operating system.

[0039] like Figure 2 As shown, this embodiment illustrates a local network packet forwarding method for the aforementioned system, comprising:

[0040] Step a: Start two containers on a single machine to represent two simulation nodes in the simulation network. Each simulation node has a network device. The user-space simulation program binds a shared queue to each network device through the user-space queue binding module and maps it to the user-space simulation program address space.

[0041] Step b: The user-space simulation program captures network packets from each network device sequentially according to the above description;

[0042] Step c: After capturing the network packet, perform a forwarding operation: Based on the link layer target address recorded in the queue data, query the corresponding device and shared queue, and according to the above description, forward the queue data to the target device through the user-space queue control module.

[0043] like Figure 3 As shown, this embodiment illustrates a method for remotely forwarding network packets in the aforementioned system. By creating a Virtual Extended Local Area Network (VXLAN) between two devices and communicating internally via UDP, cross-machine communication between the two devices is achieved. Specifically, it includes:

[0044] Step a: Start containers on two machines to represent two simulation nodes in the simulation network. Each simulation node has a network device, and a VXLAN device is created between the two simulation nodes.

[0045] Step b: The user-space simulation program binds a shared queue to each network device and VXLAN device and maps it to their address space through the user-space queue binding module.

[0046] Step c: The user-space simulation program performs network packet capture operations according to the above description.

[0047] Step d: After the capture operation, query the corresponding device based on the link-layer target address in the queue data. If the device is a remote device, then use the VXLAN device as the target device for forwarding. This operation will forward network packets to the VXLAN device, which will then forward the network packets to its paired remote VXLAN device, thus achieving cross-machine forwarding of network packets.

[0048] Step e: A remote forwarding thread will be started on each remote machine. This remote forwarding thread will check the VXLAN RX shared queue. If there is data in the RX shared queue, it will forward the data to the target local device according to the link layer target address of the queue data, thus completing the forwarding operation of the remote network packet.

[0049] Through specific practical experiments, firstly, in a test environment with a single physical server, CPU configured as Intel Xeon 6438N, and memory configured as 512GB, two simulation nodes were started. The local forwarding throughput between the nodes was tested using the iperf tool in TCP mode. The experimental results are as follows: Figure 4 As shown, the present invention achieves the same order of magnitude in local forwarding throughput as the kernel forwarding scheme OVS, Linux Bridge, which is far superior to existing user-space forwarding schemes and has better forwarding performance.

[0050] Further testing was conducted on two physical servers, both equipped with Intel Xeon 6438N CPUs and 512GB of memory. A simulation node was started on each machine, and the remote forwarding throughput between the two nodes was tested using the iperf tool in TCP mode. Figure 5 As shown, the present invention has a higher upper limit for remote forwarding throughput than the existing distributed user-space network simulator EMANE.

[0051] Compared with existing technologies, this invention provides higher local and remote forwarding rates than existing user-space network simulation schemes, improves the performance ceiling of network simulation, and expands the application scenarios of user-space network simulation.

[0052] The above-described specific implementations can be partially adjusted by those skilled in the art in different ways without departing from the principles and purpose of the present invention. The scope of protection of the present invention is defined by the claims and is not limited to the above-described specific implementations. All implementation schemes within the scope of the claims are bound by the present invention.

Claims

1. A network packet forwarding system for network simulation, characterized in that, include: The system comprises a user-mode device binding module, a user-mode queue control module, and a kernel module containing a queue management unit and a network packet distribution unit. The user-mode device binding module sends the device name requested by the user-mode emulation program to the kernel module and maps the shared queue corresponding to the device to the user program space. The user-mode queue control module reads or writes to the corresponding shared queues according to the operation requests of the user-mode simulation program, and sends the distribution operation to the network packet distribution unit for distribution. The queue management unit queries the corresponding device through the interface provided by the operating system based on the name of the bound device requested by the user-mode device binding module, creates a shared queue, generates a globally unique offset index for it, and records the relationship between the offset index and the shared queue, as well as the binding relationship between the device and the shared queue. Finally, it returns the offset index of the queue to the user-mode device binding module to complete the operation of mapping the shared queue to the user program space. The network packet distribution unit, based on the distribution request from the user-space queue control module, locates the corresponding device and shared queue, converts the data in the shared queue into network packets, and distributes the network packets to the device through the internal interface of the operating system, enabling the device to receive the network packets. The user program space refers to the memory area allocated by the operating system for user programs to run in a non-privileged mode, which cannot directly access system resources. The kernel module runs in the operating system kernel space, that is, in the privileged mode of the area where the operating system kernel works, and manages hardware resources and core system functions.

2. The network packet forwarding system for network simulation according to claim 1, characterized in that, The operation requests include: capturing network packets and forwarding network packets; The aforementioned network packet capture refers to: when a simulated node sends a network packet, the network packet is read from the corresponding device through a user-space simulation program, and then the network packet is simulated. The aforementioned forwarding of network packets refers to: writing the network packet into the network device corresponding to the link layer target address according to the link layer target address of the network packet, so that the network packet is received by the corresponding network device, that is, by the emulated node that owns the network device.

3. The network packet forwarding system for network simulation according to claim 1, characterized in that, The shared queues include RX queues and TX queues. Each shared queue has a one-to-one correspondence with a device. The queue data in the shared queues are network packet pointers, link layer source addresses, and destination addresses in the operating system. The network packet pointer refers to the memory representation of the network packets received by the device in the operating system, which is used to convert data into network packets. The network packet also combines its pointer with its link layer source and destination addresses to form a queue of data.

4. The network packet forwarding system for network simulation according to claim 1, characterized in that, The creation of the shared queue specifically includes: Step a: The user-mode device binding module receives the binding device name from the user-mode emulation program and sends it to the queue management unit in the kernel module; Step b: After receiving the bound device name, the queue management unit queries the device corresponding to the device name through the interface provided by the operating system kernel, allocates and initializes the shared queue, and registers a callback function for the device. Step c: The queue management unit generates a globally unique offset index for the shared queue. Specifically, the offset index is a 64-bit integer. The queue management unit maintains a globally unique 64-bit integer variable. Each time a shared queue is created, this number is incremented, and the incremented value is used as the offset index of the shared queue. Step d: Record the one-to-one binding relationship between the offset index and the shared queue, and the one-to-one binding relationship between the device and the shared queue. Specifically, the queue management unit maintains two hash tables, one with the offset index as the key and the shared queue pointer as the value, and the other with the device pointer as the key and the shared queue pointer as the value. Recording the binding relationship means inserting the corresponding key-value pair into the hash table and finding the corresponding shared queue in the hash table through the device or offset index. Step e: Return the queue offset index to the user-space device binding module. This module uses the offset index to call the mmap system call function provided by the operating system, using the offset index as the offset parameter of the input parameter of the function. The system call function will request the mmap implementation provided by the kernel module. In the mmap implementation of the kernel module, the offset parameter in the input parameter will be converted into an offset index. The corresponding shared queue will be found through the offset index. The shared queue will be memory-mapped to the user-space space through the interface of the operating system, so that the user-space simulation program can access the queue through the user-space control queue module.

5. The network packet forwarding system for network simulation according to claim 4, characterized in that, The aforementioned registration and reception callback function refers to a method provided by the operating system for network devices to register and receive callback functions. The input parameter of this method is a function pointer. After the method is called, the function pointer is recorded in the network device. When the network device receives a network packet, it will call the previously recorded function pointer with the network packet as the input parameter. The queue management unit in the kernel module implements a custom reception callback function. Its function implementation is to convert the network packet into queue data and write it into the RX queue of the corresponding shared queue. This custom reception callback function will be used as the input parameter when registering the reception callback function for the device. Therefore, after the process of creating a shared queue for the device is completed, the network packets received by the device can be read from the RX queue of its corresponding shared queue.

6. The network packet forwarding system for network simulation according to claim 2, characterized in that, The captured network packets specifically include: Step a: The custom receive callback function described above will write the network packets received by device A into the RX queue of the shared queue corresponding to device A; Step b: The user-mode simulation program sends a read request to the user-mode queue control module with the shared queue address corresponding to device A as the input parameter. The read request will read the queue information in the RX queue of the shared queue corresponding to device A and return it to the user-mode simulation program. Step c: The user-space simulation program obtains the queue information and can treat it as a network packet from device A for simulation processing, such as waiting for a period of time before forwarding it to achieve a delay effect.

7. The network packet forwarding system for network simulation according to claim 2, characterized in that, The aforementioned forwarded network packets specifically include: Step a: The user-space simulation program finds the corresponding target device based on the link layer target address of the queue data, and sends a write request to the user-space queue control module with the shared queue of the target device as the input parameter; Step b: The user-space queue control module writes the queue data to the TX queue of the shared queue of the target device; Step c: The user-space simulation program sends a distribution request to the user-space queue control module with the name of the target device as the input parameter. The user-space queue control module then sends the request to the network packet distribution unit in the kernel module. Step d: The network packet distribution unit queries the device corresponding to the input device name and the corresponding shared queue, reads the queue data of the TX shared queue in the shared queue, converts the queue data into a network packet according to the network packet pointer in the data, and forwards the network packet to the corresponding device through a function provided by the operating system.

8. A method for local forwarding of network packets based on the system described in any one of claims 1-7, characterized in that, include: Step a: Start two containers on a single machine to represent two simulation nodes in the simulation network. Each simulation node has a network device. The user-space simulation program binds a shared queue to each network device through the user-space queue binding module and maps it to the user-space simulation program address space. Step b: The user-space simulation program captures network packets from each network device sequentially according to the above description; Step c: After capturing the network packet, perform a forwarding operation: Based on the link layer target address recorded in the queue data, query the corresponding device and shared queue, and according to the above description, forward the queue data to the target device through the user-space queue control module.

9. A method for remotely forwarding network packets based on the system described in any one of claims 1-7, characterized in that, Cross-machine communication between two devices is achieved by creating a Virtual Extended Local Area Network (VXLAN) between them and communicating internally via UDP. Specifically, this includes: Step a: Start containers on two machines to represent two simulation nodes in the simulation network. Each simulation node has a network device, and a VXLAN device is created between the two simulation nodes. Step b: The user-space emulation program binds a shared queue to each network device and VXLAN device and maps it to their address space through the user-space queue binding module; Step c: The user-space simulation program performs network packet capture operations according to the above description; Step d: After the capture operation, query the corresponding device based on the link layer target address in the queue data. If the device is a remote device, then use the VXLAN device as the target device for forwarding. This operation will forward the network packet to the VXLAN device, and the VXLAN device will further forward the network packet to the remote VXLAN device that is its counterpart, thus realizing cross-machine forwarding of network packets. Step e: A remote forwarding thread will be started on each remote machine. This remote forwarding thread will check the VXLAN RX shared queue. If there is data in the RX shared queue, it will forward the data to the target local device according to the link layer target address of the queue data, thus completing the forwarding operation of the remote network packet.