Relay bridging unvarnished transmission method and system for wireless network card and wired network card

By using the Socket API interface and data processing module in user space for packet address mapping and forwarding judgment, the problem of incompatibility between wifi network cards and wired network cards in embedded Linux devices is solved, and flexible bridge between wireless and wired network cards is realized, improving Device compatibility and portability.

CN119071307APending Publication Date: 2024-12-03湖南智领通信科技有限公司
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411251127.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-06
Publication Date
2024-12-03

AI Technical Summary

Technical Problem

In the prior art, embedded Linux devices cannot effectively bridge wired network cards in STA mode, resulting in incompatible data transmission, and the drivers of wifi network cards of different manufacturers do not comply with the wireless network subsystem protocol of the Linux system, resulting in portability of the bridge function. Poor sex.

Method used

By using the Socket API interface in the user space, connecting the wireless network card and the wired network card interface, using the data processing module to map and forward and judge the packet address, realizing the network card bridge transit function, independent of the wifi network card driver framework, and supporting any network card bridge.

Benefits of technology

It realizes flexible bridging between wireless and wired network cards, reduces dependence on wifi network card drivers, improves application compatibility and portability, and supports network card bridging in STA and AP modes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119071307A_ABST
    Figure CN119071307A_ABST
Patent Text Reader

Abstract

The invention relates to a wireless network card and wired network card relay bridging unvarnished transmission method and system. The method comprises the following steps: respectively connecting a wireless network card interface and a wired network card interface in a kernel space with a Socket API interface in a user space; continuously acquiring data packets sent by the wireless network card and the wired network card through the Socket API interface, and sending the data packets to a data processing module in the user space; the method comprises the following steps: carrying out packet address mapping processing on a currently received data packet through a data processing module, carrying out forwarding judgment according to a processing result, sending a forwarding judgment result and the processed data packet to a Socket API interface, and sending the processed data packet to a corresponding network card through the Socket API interface according to the forwarding judgment result. By adopting the method, the flexibility of the application can be improved, and any network card bridging unvarnished transmission function is supported.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of signal processing, and in particular to a method and system for relay bridging transparent transmission between a wireless network card and a wired network card. Background Art

[0002] Embedded Linux networking devices usually need to bridge the data between the wired Ethernet RJ-45 and the wifi wireless network card. Wifi usually has AP and STA (client) modes. In AP mode, wifi uses the Linux kernel bridge module to bind the wifi and wired eth network cards to the bridge device br0 to achieve data intercommunication. In STA mode, the network card does not have enough information for bridging, which is stipulated by 802.11. Therefore, the wifi network card needs to enable the 4addr function to join the bridge, and the accessed AP also needs to start the 4addr mode for normal data transmission. Linux system embedded devices all use the kernel bridge function mode to achieve wireless and wired data interconnection. When the wifi is in STA mode, the 4ddr mode needs to be enabled. Different manufacturers may have incompatibility issues with whether to enable the 4addr function. Some existing wifi network card drivers on the market are not implemented according to the Linux system wireless network subsystem protocol. In this way, the wifi network card does not support the bridging function and cannot achieve wireless and wired relay.

[0003] The Linux bridge is implemented at the data link layer, and has obvious restrictions on whether the WiFi driver complies with the kernel's network protocol stack and the WiFi working mode. Wireless bridging requires the WiFi driver to be implemented in accordance with the kernel's 802.11 wireless subsystem framework. WiFi in Station mode needs to enable 4-address, which is the 4 mac address fields in the 802.11 packet header. Therefore, Linux wireless bridging has standard processes and regulations for WiFi network card drivers, and is not well compatible with some non-standard WiFi network cards. The portability of implementing network card bridging functions on different platforms is poor. Summary of the invention

[0004] Based on this, it is necessary to provide a method and system for relay bridging transparent transmission between a wireless network card and a wired network card in order to solve the above technical problems.

[0005] A method for relay bridging transparent transmission between a wireless network card and a wired network card, the method comprising:

[0006] Connect the wireless network card interface and wired network card interface in the kernel space to the Socket API interface in the user space respectively;

[0007] Continuously obtain data packets sent by wireless network cards and wired network cards through the Socket API interface, and send the data packets to the data processing module in the user space;

[0008] The data processing module performs packet address mapping processing on the currently received data packet, performs forwarding judgment based on the processing result, sends the forwarding judgment result and the processed data packet to the Socket API interface, and sends the processed data packet to the corresponding network card through the Socket API interface based on the forwarding judgment result.

[0009] A wireless network card and wired network card relay bridge transparent transmission system, the system comprises: a data link layer and an application layer, the data link layer comprises a wireless network card interface and a wired network card interface, the application layer comprises a Socket API interface and a data processing module;

[0010] The Socket API interface is connected to the wireless network card interface and the wired network card interface respectively, and is used to continuously obtain data packets sent by the wireless network card and the wired network card, send the data packets to the data processing module, and obtain the forwarding judgment result and the data packet for packet address mapping processing from the data processing module, and send the processed data packet to the corresponding network card according to the forwarding judgment result;

[0011] The data processing module is used to perform packet address mapping on the currently received data packets, make forwarding judgments based on the processing results, and send the forwarding judgment results and processed data packets to the Socket API interface.

[0012] The above-mentioned wireless network card and wired network card relay bridge transparent transmission method and system respectively connect the wireless network card interface and the wired network card interface in the kernel space with the Socket API interface in the user space, thereby realizing the network card bridge transparent transmission function through the socket API function interface in the application layer, continuously obtaining the data packets sent by the wireless network card and the wired network card through the Socket API interface, sending the data packets to the data processing module in the user space, performing packet address mapping processing on the currently received data packets through the data processing module, performing forwarding judgment according to the processing result, sending the forwarding judgment result and the processed data packets to the Socket API interface, and sending the processed data packets to the corresponding network card through the Socket API interface according to the forwarding judgment result. The embodiment of the present invention does not rely on the wifi network card driver framework, improves the flexibility of the application, and supports any network card bridge transparent transmission function. BRIEF DESCRIPTION OF THE DRAWINGS

[0013] Figure 1 It is a flowchart of a method for relay bridging transparent transmission between a wireless network card and a wired network card in one embodiment;

[0014] Figure 2 A schematic diagram of a software framework for implementing network card bridging based on a Socket API interface in one embodiment;

[0015] Figure 3 It is an application scenario diagram of a method for relay bridging transparent transmission between a wireless network card and a wired network card in one embodiment;

[0016] Figure 4 A schematic diagram of a network card data receiving process in an embodiment;

[0017] Figure 5 The figure is a schematic diagram of the Ethernet data packet processing flow in one embodiment. DETAILED DESCRIPTION

[0018] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.

[0019] In view of the various restrictions that the Linux kernel bridge is not compatible with non-standard WiFi and that 4DDR needs to be enabled to support STA relay, the method of the present invention proposes to implement the network card bridging function through the socket API interface function at the user level. Compared with the existing wireless bridge, the kernel size is simplified, and the coupling and dependence on the WiFi network card driver architecture are reduced. Any WiFi network card wlan0 can be bridged with the wired network card eth0 for data transparent transmission.

[0020] In one embodiment, Figure 1 As shown, a method for relay bridging transparent transmission between a wireless network card and a wired network card is provided, comprising the following steps:

[0021] Step 102, connecting the wireless network card interface and the wired network card interface in the kernel space to the Socket API interface in the user space respectively.

[0022] like Figure 2 The software framework diagram for realizing network card bridging based on Socket API interface is shown. After the program is started, the underlying data of the network card can be directly accessed through Socket raw original socket, and the sending and receiving of link layer frames can be realized at the application layer.

[0023] Step 104: continuously obtain data packets sent by the wireless network card and the wired network card through the Socket API interface, and send the data packets to the data processing module in the user space.

[0024] like Figure 3The application scenario diagram of the relay bridging transparent transmission method of the wireless network card and the wired network card shown is illustrated by taking the current application scenario including the wifi network card Wlan0 and the wired network card eth0 as an example. Regardless of whether the wifi network card is in STA mode or AP mode, the method of the present invention can realize the relay bridging of the wireless network card and the wired network card.

[0025] like Figure 4 The schematic diagram of the network card data receiving process shown in the figure calls the socket function interface to point to the wlan0 network card and the wired eth0 network card respectively, starts the network card receiving function, and submits the data to the data processing module after receiving the network card data. The method of the present invention realizes the network card bridge transparent transmission at the application layer, supports WiFi network cards of various architectures, and has no difference in the use of bridges in different working modes of WiFi.

[0026] Step 106, perform packet address mapping processing on the currently received data packet through the data processing module, make a forwarding judgment based on the processing result, send the forwarding judgment result and the processed data packet to the Socket API interface, and send the processed data packet to the corresponding network card through the Socket API interface based on the forwarding judgment result.

[0027] like Figure 5 The Ethernet data packet processing flow shown in the figure shows that when the receiving module receives data from the wifi network card Wlan0 or the wired network card eth0, it will send the data to the data processing module. The processing module will distinguish the data packets by frame type, detect the arp packet, obtain the correspondence between the ip address and the mac address, modify the address mapping of the TCP / IP packet, fill in the Ethernet protocol packet content, modify and forward it, and realize the transparent transmission of the network card data.

[0028] In the above-mentioned wireless network card and wired network card relay bridge transparent transmission method, by connecting the wireless network card interface and the wired network card interface in the kernel space to the Socket API interface in the user space respectively, the network card bridge transparent transmission function is realized in the application layer through the socketAPI function interface, and the data packets sent by the wireless network card and the wired network card are continuously obtained through the Socket API interface, and the data packets are sent to the data processing module in the user space. The data processing module performs packet address mapping processing on the currently received data packets, and forwarding judgment is performed according to the processing result. The forwarding judgment result and the processed data packet are sent to the Socket API interface, and the processed data packet is sent to the corresponding network card through the Socket API interface according to the forwarding judgment result. The embodiment of the present invention does not rely on the wifi network card driver framework, improves the flexibility of the application, and supports any network card bridge transparent transmission function.

[0029] In one embodiment, connecting the wireless network card interface and the wired network card interface in the kernel space to the Socket API interface in the user space respectively includes: in the user space, using the Socket API interface to create raw sockets for monitoring and operating the wired network card and the wireless network card respectively; binding each raw socket to the corresponding network card interface.

[0030] In one embodiment, packet address mapping processing is performed on the currently received data packet, including: classifying the current data frame according to the frame type, if the current data packet is an Arp packet, obtaining the correspondence between the IP address and the MAC address of the Arp packet, performing packet address mapping processing on the IP address and the MAC address, and if the current data packet is a TCP / IP packet, performing address mapping modification on the TCP / IP packet.

[0031] In one embodiment, after modifying the address mapping of the TCP / IP packet, the method further includes: modifying and filling the content of the TCP / IP packet.

[0032] In one embodiment, performing forwarding judgment according to the processing result includes: obtaining an address mapping relationship of the processed data packet, and obtaining a forwarding judgment result according to the IP address and MAC address of the target device.

[0033] It should be understood that although Figure 1 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figure 1 At least part of the steps may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.

[0034] In one embodiment, a wireless network card and a wired network card relay bridge transparent transmission system is provided, comprising a data link layer and an application layer, wherein the data link layer comprises a wireless network card interface and a wired network card interface, and the application layer comprises a Socket API interface and a data processing module;

[0035] The Socket API interface is connected to the wireless network card interface and the wired network card interface respectively, and is used to continuously obtain data packets sent by the wireless network card and the wired network card, send the data packets to the data processing module, and obtain the forwarding judgment result and the data packet for packet address mapping processing from the data processing module, and send the processed data packet to the corresponding network card according to the forwarding judgment result;

[0036] The data processing module is used to perform packet address mapping processing on the currently received data packet, make a forwarding judgment based on the processing result, and send the forwarding judgment result and the processed data packet to the Socket API interface.

[0037] The network interface devices of the system include wireless network cards and wired network cards, which respectively use corresponding data link layer protocols to communicate at the data link layer.

[0038] In one of the embodiments, connecting the wireless network card interface and the wired network card interface in the kernel space to the Socket API interface in the user space respectively includes: in the user space, using the Socket API interface to create raw sockets for monitoring and operating the wired network card and the wireless network card respectively; binding each raw socket to the corresponding network card interface.

[0039] In one of the embodiments, performing packet address mapping processing on the currently received data packet includes: classifying the current data frame according to the frame type, if the current data packet is an Arp packet, obtaining the correspondence between the IP address and the MAC address of the Arp packet, performing packet address mapping processing on the IP address and the MAC address, and if the current data packet is a TCP / IP packet, performing address mapping modification on the TCP / IP packet.

[0040] In one of the embodiments, after modifying the address mapping of the TCP / IP packet, the method further includes: modifying and filling the content of the TCP / IP packet.

[0041] In one of the embodiments, performing forwarding judgment according to the processing result includes: obtaining an address mapping relationship of the processed data packet, and obtaining a forwarding judgment result according to the IP address and MAC address of the target device.

[0042] For the specific definition of the wireless network card and wired network card relay bridge transparent transmission system, please refer to the definition of the wireless network card and wired network card relay bridge transparent transmission method above, which will not be repeated here. Each module in the above-mentioned wireless network card and wired network card relay bridge transparent transmission system can be implemented in whole or in part through software, hardware and their combination. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.

[0043] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0044] The above-mentioned embodiments only express several implementation modes of the present invention, and the description thereof is relatively specific and detailed, but it cannot be understood as limiting the scope of the invention. It should be pointed out that, for a person of ordinary skill in the art, several modifications and improvements can be made without departing from the concept of the present invention, and these all belong to the protection scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the attached claims.

Claims

1. A method for relay bridging and transparent transmission between a wireless network card and a wired network card. It is characterized in that The method comprises: Connect the wireless network card interface and wired network card interface in the kernel space to the Socket API interface in the user space respectively; Continuously obtain data packets sent by wireless network cards and wired network cards through the Socket API interface, and send the data packets to the data processing module in the user space; The data processing module performs packet address mapping processing on the currently received data packet, performs forwarding judgment based on the processing result, sends the forwarding judgment result and the processed data packet to the Socket API interface, and sends the processed data packet to the corresponding network card through the Socket API interface based on the forwarding judgment result.

2. The method according to claim 1, It is characterized in that The step of connecting the wireless network card interface and the wired network card interface in the kernel space to the Socket API interface in the user space respectively includes: In user space, use the Socket API interface to create raw sockets for monitoring and operating wired network cards and wireless network cards respectively; Bind each raw socket to the corresponding network card interface.

3. The method according to claim 1, It is characterized in that The packet address mapping process for the currently received data packet includes: The current data frame is classified according to the frame type. If the current data packet is an Arp packet, the correspondence between the IP address and the MAC address of the Arp packet is obtained, and the IP address and the MAC address are processed for packet address mapping. If the current data packet is a TCP / IP packet, the address mapping of the TCP / IP packet is modified.

4. The method according to claim 3, It is characterized in that After modifying the address mapping of the TCP / IP packet, it also includes: Modify and fill the content of TCP / IP packets.

5. The method according to any one of claims 1 or 3, It is characterized in that Forwarding decisions based on processing results include: The address mapping relationship of the processed data packet is obtained, and the forwarding judgment result is obtained according to the IP address and MAC address of the target device.

6. A wireless network card and wired network card relay bridge transparent transmission system, It is characterized in that The system includes a data link layer and an application layer, the data link layer includes a wireless network card interface and a wired network card interface, and the application layer includes a Socket API interface and a data processing module; The Socket API interface is connected to the wireless network card interface and the wired network card interface respectively, and is used to continuously obtain data packets sent by the wireless network card and the wired network card, send the data packets to the data processing module, and obtain the forwarding judgment result and the data packet for packet address mapping processing from the data processing module, and send the processed data packet to the corresponding network card according to the forwarding judgment result; The data processing module is used to perform packet address mapping processing on the currently received data packet, make a forwarding judgment based on the processing result, and send the forwarding judgment result and the processed data packet to the Socket API interface.

7. The system according to claim 6, It is characterized in that The Socket API interface is connected to the wireless network card interface and the wired network card interface respectively, including: The Socket API interface creates raw sockets for monitoring and operating wired network cards and wireless network cards respectively; The Socket API interface binds each raw socket to the corresponding network card interface.

8. The system according to claim 6, It is characterized in that The packet address mapping process for the currently received data packet includes: The current data frame is classified according to the frame type. If the current data packet is an Arp packet, the correspondence between the IP address and the MAC address of the Arp packet is obtained, and the IP address and the MAC address are processed for packet address mapping. If the current data packet is a TCP / IP packet, the address mapping of the TCP / IP packet is modified.

9. The system according to claim 8, It is characterized in that After modifying the address mapping of the TCP / IP packet, it also includes: Modify and fill the content of TCP / IP packets.

10. The system according to any one of claims 6 or 8, It is characterized in that Forwarding decisions based on processing results include: The address mapping relationship of the processed data packet is obtained, and the forwarding judgment result is obtained according to the IP address and MAC address of the target device.

Citation Information

Cited By

  • Embedded platform ad hoc network equipment communication optimization method and device, equipment and medium

    CN121217573A