A BPF-based heterogeneous communication link IP adaptation system and method

By sinking the protocol conversion logic to the kernel mode and using BPF technology to directly process data packets in the kernel mode, the performance bottleneck in the IP adaptation of heterogeneous communication links is solved, realizing low-latency and high-throughput IP adaptation of communication links, which is suitable for devices such as drones and special rescue vehicles that need to be removed from the ground mobile network environment.

CN122640485APending Publication Date: 2026-08-25CHINA AEROSPACE TIMES ELECTRONICS CORP
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202610439843.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-04-03
Publication Date
2026-08-25

AI Technical Summary

Technical Problem

Existing technologies suffer from performance bottlenecks in the IP adaptation of heterogeneous communication links, including lengthy processing paths, wasted CPU resources, and synchronous I/O overhead, resulting in high latency and low throughput, which is particularly evident in application scenarios with high speed and real-time requirements.

Method used

A BPF-based heterogeneous communication link IP adaptation system is adopted, which moves the protocol conversion logic from user space to kernel space. The BPF programmable virtual network device and BPF protocol conversion program module are used to directly complete the parsing and encapsulation of data packets in kernel space, avoiding the switching between user space and kernel space and memory copying.

Benefits of technology

It achieves low-latency, high-throughput IP-based communication links, significantly reducing CPU load and memory bandwidth consumption, improving system performance, and adapting to application scenarios with high-speed and real-time requirements.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122640485A_ABST
    Figure CN122640485A_ABST
Patent Text Reader

Abstract

The application relates to a BPF-based heterogeneous communication link IP adaptation system and method, and belongs to the technical field of embedded systems and network protocol conversion. The system comprises a BPF programmable virtual network device, a BPF protocol conversion program module and a physical communication link driving interface module. The application sinks the protocol conversion logic of IP data packets and special format messages from a user state to a kernel state, and completes the whole process in the kernel state, thereby avoiding the switching between the user state and the kernel state. The application realizes low-delay and high-throughput communication link IP communication.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of embedded systems and network protocol conversion technology, and relates to a BPF-based heterogeneous communication link IP adaptation system and method. Background Technology

[0002] In equipment such as drones and special rescue vehicles that need to operate outside of ground-based mobile networks, various proprietary protocol communication links are widely used. Examples include the telemetry, control, and image transmission communication links carried by some drones and the emergency communication radios carried by special vehicles. These communication links were not designed to follow the standard TCP / IP protocol stack, making it impossible to directly integrate into existing IP networks and hindering the use of mature IP routing protocols for large-scale, flexible heterogeneous networking.

[0003] To address this issue, given the large amount of existing hardware, current technical solutions typically employ software adaptation, involving IP-based modifications to the host computer (usually a Linux system) connected to the communication link.

[0004] like Figure 1 As shown, a popular technical solution is to use the Linux kernel's TUN / TAP virtual network interface technology. Its specific implementation includes the following modules: (1) Dedicated communication link driver: A dedicated driver running in user space, responsible for communicating with physical communication link transceiver devices and sending and receiving proprietary format messages.

[0005] (2) IP interface: Create a TUN / TAP virtual network interface (such as tap0) on the host computer and configure its IP address.

[0006] (3) Protocol conversion program: a protocol conversion program that calls the dedicated communication link driver to send and receive data packets, performs secondary encapsulation of data packets based on the IP protocol stack, and forwards them to the TUN / TAP interface.

[0007] Based on the above modules, the transmission and reception path of a data packet in the host computer system is as follows: Data reception path: When the physical communication link transceiver receives a message, the dedicated driver in user space reads it into user space memory. The program decapsulates the message, extracts the payload, and hands it over to the protocol conversion program. Upon receiving the message content, the protocol conversion program writes the payload to the file descriptor of the TUN / TAP interface using the `write` system call. This process copies the data from user space to kernel space. Subsequently, IP applications that need to use this data (e.g., a socket bound to the `tap0` interface) read the data from the kernel's socket buffer using the `read` system call, which again copies the data from kernel space to user space.

[0008] Data transmission path: The IP application sends IP packets to the TUN / TAP interface via the `write` system call, and the data is copied from user space to kernel space. The user-space protocol converter reads the packet from the TUN / TAP interface via the `read` system call, and the data is copied from kernel space back to user space. The program then encapsulates the IP packet into a proprietary format message and calls a dedicated driver to send it out through the physical interface.

[0009] While this solution achieves protocol conversion and IP-based architecture, its user-space protocol conversion architecture has inherent performance bottlenecks, specifically as follows: (1) The processing path is lengthy and requires switching between kernel mode and user mode: Since the protocol conversion logic is implemented in the user mode application, the data packets must be transferred back and forth between the kernel network protocol stack and the user mode application, which makes it impossible to achieve efficient kernel mode fast processing.

[0010] (2) The use of message copying results in serious waste of CPU resources: The above-mentioned cross-space transmission is completed through memory copying. Regardless of the receiving or sending path, the data packet needs to undergo at least two memory copies (for example, copying from kernel mode to user mode for processing, and then copying from user mode back to kernel mode for forwarding), which directly leads to high CPU resource usage and memory bandwidth consumption.

[0011] (3) Reliance on synchronous I / O, resulting in high system call overhead: Each memory copy is accompanied by system calls such as read or write. These synchronous I / O operations are not only numerous, but each call also triggers expensive context switching, further increasing data processing latency and limiting the maximum throughput of the system.

[0012] In summary, in high-speed, multi-interface, or real-time-critical application scenarios, the performance overhead caused by user-mode switching, memory copying, and frequent system calls becomes a serious bottleneck. Summary of the Invention

[0013] The technical problem solved by this invention is to overcome the shortcomings of the prior art and propose a heterogeneous communication link IP adaptation system and method based on BPF. Through optimized design, it solves the problems of low performance and high latency caused by multiple memory copies and user mode / kernel mode switching in the existing TUN / TAP virtual network card scheme, thereby realizing low latency and high throughput IP-based communication links.

[0014] The solution of the present invention is: a BPF-based heterogeneous communication link IP adaptation system, comprising: a BPF programmable virtual network device, a BPF protocol conversion program module, and a physical communication link driver interface module; BPF programmable virtual network device is used to provide a standard network interface to upper-layer IP applications and is responsible for completing the transmission of IP data packets between the BPF protocol conversion module and the upper-layer IP applications. The BPF protocol conversion module parses and encapsulates received IP packets into proprietary format messages in kernel mode, and receives proprietary format messages and decapsulates them into IP packets. The physical communication link driver interface module is a low-level driver program for communicating with the communication link transceiver device. It is responsible for completing the transmission of proprietary format messages between the BPF protocol conversion program module and the communication link transceiver device.

[0015] Furthermore, the IP packet transmission between the BPF programmable virtual network device and the upper-layer IP application includes: When sending IP packets, the upper-layer IP application sends the IP packets to the BPF programmable virtual network device through the standard socket API; When receiving IP packets, the upper-layer IP application receives them through a socket bound to the BPF programmable virtual network device.

[0016] Furthermore, the process of parsing the received IP data packets in kernel mode includes: the BPF protocol conversion program module directly accessing the memory of the IP data packets in kernel mode, parsing the IP data packet header information, and extracting the payload that needs to be transmitted through the communication link.

[0017] Furthermore, the received IP data packets are encapsulated in kernel mode, including: the BPF protocol conversion program module adds proprietary protocol headers, trailers, and checksum information to the payload in the kernel according to the protocol specifications of the proprietary communication link, and encapsulates it into a complete proprietary format message.

[0018] Furthermore, the BPF protocol conversion program module directly calls the kernel interface provided by the physical communication link driver interface module to deliver the encapsulated proprietary format message to the driver program that communicates with the communication link transceiver device, and the driver program controls the sending out.

[0019] Furthermore, receiving proprietary format messages and decapsulating them into IP data packets includes: the BPF protocol conversion program module parses the proprietary format messages in kernel mode, verifies their validity, and strips the header and trailer information of the proprietary protocol to extract the internally encapsulated payload.

[0020] Furthermore, the BPF protocol conversion module constructs a standard IP packet or UDP / TCP packet in the kernel, fills it with the extracted payload, and then injects it into the BPF programmable virtual network device for upper-layer IP applications to receive.

[0021] A BPF-based method for adapting heterogeneous communication links to IP includes: when data is transmitted between an upper-layer IP application and a communication link transceiver device, the logic for converting IP data packets to proprietary format messages is moved from user mode to kernel mode and completed entirely in kernel mode to avoid switching between user mode and kernel mode.

[0022] Furthermore, the upper-layer IP application sends data to the communication link transceiver device, including: Upper-layer IP applications send IP packets to BPF programmable virtual network devices via standard socket APIs; The BPF programmable virtual network device receives IP packets and triggers the BPF protocol conversion module; The BPF protocol conversion module directly accesses the memory of the IP packet, parses the header information, and extracts the payload that needs to be transmitted through the communication link. Then, according to the protocol specifications of the proprietary communication link, it adds proprietary protocol headers, trailers, and checksum information to the payload and encapsulates it into a complete proprietary format message. Finally, it calls the kernel interface provided by the physical communication link driver interface module to deliver the encapsulated proprietary format message to the driver program that communicates with the communication link transceiver device. The driver controls the sending of proprietary format messages to the communication link transceiver device.

[0023] Furthermore, the upper-layer IP application receives data transmitted by the communication link transceiver device, including: The physical communication link driver interface module receives proprietary format message data and puts it into memory, and triggers the BPF protocol conversion program module; The BPF protocol conversion module parses proprietary format messages, verifies their validity, and strips away the proprietary protocol header and trailer information to extract the internally encapsulated payload. Then, it constructs a standard IP packet or UDP / TCP packet and fills it with the extracted payload. Finally, it injects the newly constructed IP packet into the BPF programmable virtual network device. Upper-layer IP applications receive IP packets through sockets bound to BPF programmable virtual network devices.

[0024] The advantages of this invention compared to the prior art are: (1) This invention employs low processing latency and extremely short processing path; by utilizing BPF / XDP technology, data packets are processed in the early stages of network driver, bypassing many complex processing flows in the Linux kernel network protocol stack, significantly shortening the path of data packets from the network card to the application, greatly reducing communication latency, which is especially important for application scenarios with high real-time requirements.

[0025] (2) This invention significantly improves performance by eliminating unnecessary memory copies; by performing protocol conversion directly in kernel mode, it completely eliminates the round-trip copying of data between user mode and kernel mode. This greatly reduces CPU load and memory bandwidth consumption, resulting in an order-of-magnitude improvement in system performance. The protocol conversion logic is implemented by a BPF program, which can be dynamically loaded and updated during system runtime without recompiling the kernel or loading unstable kernel modules. At the same time, the verifier mechanism of the BPF virtual machine ensures that the code loaded into the kernel is safe and will not cause kernel crashes, thus balancing high performance and stability.

[0026] (3) The present invention has high throughput capability and adapts to gateway requirements; due to the reduction of CPU overhead and latency, the number of data packets (PPS) that the system can process per unit time is greatly increased, which significantly improves the effective throughput of the communication link and can adapt to the data transmission requirements of higher speed. Attached Figure Description

[0027] Figure 1 The packet processing flow is a TUN-based communication link IP-based driver implementation method. Figure 2 This invention provides a data packet processing flow for an efficient communication link IP adaptation method. Detailed Implementation

[0028] The present invention will be further described below with reference to the accompanying drawings and embodiments.

[0029] This invention provides an efficient IP-based driver implementation method for communication links that eliminates copying. The original method is optimized as follows: the protocol conversion logic is executed in kernel mode, avoiding the switching between user mode and kernel mode; the kernel data path is reconstructed to achieve zero copying, eliminating unnecessary memory copying; and the traditional I / O interface is bypassed, avoiding the overhead of synchronous system calls.

[0030] A solution based on Linux kernel BPF (Berkeley Packet Filter) and XDP (eXpress Data Path) technologies fundamentally avoids unnecessary data copying by performing protocol conversion directly in kernel mode.

[0031] like Figure 2 The diagram shown is an improved packet processing flowchart proposed in this invention. Its core idea is to move the protocol conversion logic from user space to kernel space, utilizing a BPF program to complete the work in the early stages of packet processing.

[0032] The technical solution of this invention mainly includes the following core components: BPF Programmable Virtual Network Device: Creates a kernel-mode virtual network device that can be controlled by a BPF program to provide a standard network interface to upper-layer IP applications.

[0033] BPF Protocol Conversion Program: One or more BPF programs loaded into the kernel and attached to the driver paths of the aforementioned virtual network devices or physical devices. This program is the core of the protocol conversion, directly parsing, encapsulating, and decapsulating data packets in kernel mode.

[0034] Physical communication link driver interface: The low-level driver for communicating with the hardware. This solution modifies this driver or utilizes its provided interface, allowing BPF programs to directly call its send and receive functions.

[0035] The specific workflow is as follows: (1) Data transmission (IP packet to proprietary protocol message) process: The upper-layer IP application sends an IP packet to the BPF programmable virtual network device created above, just like using a regular network card, through the standard socket API.

[0036] The IP packet is received by the virtual network device in kernel mode, triggering the BPF protocol conversion program attached to it.

[0037] The BPF program directly accesses the memory of the IP packet in kernel mode, parses its header information, and extracts the payload that needs to be transmitted through the communication link.

[0038] The BPF program adds proprietary protocol headers, trailers, and checksums to the payload in the kernel according to the protocol specifications of the proprietary communication link, encapsulating it into a complete proprietary format message.

[0039] BPF programs deliver encapsulated proprietary messages to the driver program by directly calling the kernel interface (kfuncs) provided by the physical communication link driver, and the driver program controls the hardware to send them out.

[0040] During this process, the IP data packet is encapsulated into a proprietary message and delivered to the physical driver, all within kernel mode, without any data copying between user mode and kernel mode.

[0041] (2) Data reception (proprietary protocol message to IP packet) process: The physical communication link hardware receives external messages and notifies its driver through interrupts or other means.

[0042] The physical communication link driver places the received proprietary format message data into memory (e.g., a DMA ring buffer).

[0043] The driver triggers the BPF protocol conversion procedure (e.g., via an XDP hook point). The BPF procedure can access the raw packet data before the kernel network protocol stack processes the packet, and even before the kernel allocates the core data structure sk_buff for it.

[0044] The BPF program parses the proprietary format message in kernel mode, verifies its validity, and strips off its protocol header and trailer to extract the internally encapsulated IP payload.

[0045] The BPF program constructs a standard IP packet (or directly a UDP / TCP packet) in the kernel and fills it with the extracted payload.

[0046] The BPF program injects this newly constructed IP packet into the BPF programmable virtual network device.

[0047] Upper-layer IP applications can then receive this standard IP data packet through the socket bound to this virtual network device.

[0048] Although the present invention has been disclosed above with reference to preferred embodiments, it is not intended to limit the present invention. Any person skilled in the art can make possible changes and modifications to the technical solutions of the present invention by utilizing the methods and techniques disclosed above without departing from the spirit and scope of the present invention. Therefore, any simple modifications, equivalent changes and alterations made to the above embodiments based on the technical essence of the present invention without departing from the content of the technical solutions of the present invention shall fall within the protection scope of the technical solutions of the present invention.

Claims

1. A BPF-based heterogeneous communication link IP adaptation system, characterized in that, include: BPF programmable virtual network device, BPF protocol conversion program module, physical communication link driver interface module; BPF programmable virtual network device is used to provide a standard network interface to upper-layer IP applications and is responsible for completing the transmission of IP data packets between the BPF protocol conversion module and the upper-layer IP applications. The BPF protocol conversion module parses and encapsulates received IP packets into proprietary format messages in kernel mode, and receives proprietary format messages and decapsulates them into IP packets. The physical communication link driver interface module is a low-level driver program for communicating with the communication link transceiver device. It is responsible for completing the transmission of proprietary format messages between the BPF protocol conversion program module and the communication link transceiver device.

2. The BPF-based heterogeneous communication link IP adaptation system according to claim 1, characterized in that, The IP packet transmission between the BPF programmable virtual network device and the upper-layer IP application includes: When sending IP packets, the upper-layer IP application sends the IP packets to the BPF programmable virtual network device through the standard socket API; When receiving IP packets, the upper-layer IP application receives them through a socket bound to the BPF programmable virtual network device.

3. The BPF-based heterogeneous communication link IP adaptation system according to claim 1, characterized in that, The aforementioned parsing of received IP packets in kernel mode includes: the BPF protocol conversion program module directly accesses the memory of the IP packets in kernel mode, parses the IP packet header information, and extracts the payload that needs to be transmitted through the communication link.

4. The BPF-based heterogeneous communication link IP adaptation system according to claim 3, characterized in that, The received IP data packets are encapsulated in kernel mode, including: the BPF protocol conversion program module adds proprietary protocol headers, trailers and checksum information to the payload in the kernel according to the protocol specifications of the proprietary communication link, and encapsulates it into a complete proprietary format message.

5. A BPF-based heterogeneous communication link IP adaptation system according to claim 4, characterized in that, The BPF protocol conversion module directly calls the kernel interface provided by the physical communication link driver interface module to deliver the encapsulated proprietary format message to the driver program that communicates with the communication link transceiver device, and the driver program controls the sending out.

6. The BPF-based heterogeneous communication link IP adaptation system according to claim 4, characterized in that, The process of receiving proprietary format messages and decapsulating them into IP data packets includes: the BPF protocol conversion program module parses the proprietary format messages in kernel mode, verifies their validity, and strips the header and trailer information of the proprietary protocol to extract the internally encapsulated payload.

7. A BPF-based heterogeneous communication link IP adaptation system according to claim 6, characterized in that, The BPF protocol conversion module constructs a standard IP packet or UDP / TCP packet in the kernel, fills it with the extracted payload, and then injects it into the BPF programmable virtual network device for upper-layer IP applications to receive.

8. A method for adapting a heterogeneous communication link to IP based on BPF as described in any one of claims 1 to 7, characterized in that, This includes: when data is transmitted between upper-layer IP applications and communication link transceiver devices, the logic for converting IP data packets into proprietary format messages is moved from user mode to kernel mode, and the entire process is completed in kernel mode to avoid switching between user mode and kernel mode.

9. A method for adapting heterogeneous communication links to IP based on BPF according to claim 8, characterized in that, Upper-layer IP applications send data to the communication link transceiver devices, including: Upper-layer IP applications send IP packets to BPF programmable virtual network devices via standard socket APIs; The BPF programmable virtual network device receives IP packets and triggers the BPF protocol conversion module; The BPF protocol conversion module directly accesses the memory of the IP packet, parses the header information, and extracts the payload that needs to be transmitted through the communication link. Then, according to the protocol specifications of the proprietary communication link, it adds proprietary protocol headers, trailers, and checksum information to the payload and encapsulates it into a complete proprietary format message. Finally, it calls the kernel interface provided by the physical communication link driver interface module to deliver the encapsulated proprietary format message to the driver program that communicates with the communication link transceiver device. The driver controls the sending of proprietary format messages to the communication link transceiver device.

10. A BPF-based heterogeneous communication link IP adaptation method according to claim 8, characterized in that, The upper-layer IP application receives data transmitted by the communication link transceiver device, including: The physical communication link driver interface module receives proprietary format message data and puts it into memory, and triggers the BPF protocol conversion program module; The BPF protocol conversion module parses proprietary format messages, verifies their validity, and strips away the proprietary protocol header and trailer information to extract the internally encapsulated payload. Then, it constructs a standard IP packet or UDP / TCP packet and fills it with the extracted payload. Finally, it injects the newly constructed IP packet into the BPF programmable virtual network device. Upper-layer IP applications receive IP packets through sockets bound to BPF programmable virtual network devices.