Data transmission method and gateway device
Patent Information
- Application Number
- CN202211287433.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-10-20
- Publication Date
- 2026-10-30
- Estimated Expiration
- 2042-10-20
AI Technical Summary
[0005]本申请提供了一种数据传输方法及网关设备,可以解决相关技术的家庭网关的功能较为单一的问题
[0017]本申请提供的技术方案带来的有益效果至少包括:
Smart Images

Figure CN117955772B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data transmission technology, and in particular to a data transmission method and gateway device. Background Technology
[0002] A home gateway (such as a home router) typically includes a physical wide area network (WAN) interface. When operating in routing mode, this WAN interface can be used to access the external network, for example, by connecting to the incoming network cable. When operating in bridged mode, this WAN interface can be used to access the internal network, such as a cable TV network.
[0003] When the WAN interface operates in routing mode, the home gateway can provide Layer 3 routing services, such as internet access, to internal network devices (e.g., laptops). When the WAN interface operates in bridged mode, the home gateway can provide Layer 2 switching services, such as video-on-demand services, to internal network devices.
[0004] However, once the home gateway is started, its physical WAN interface is fixed to one working mode, so the function of the home gateway is relatively simple. Summary of the Invention
[0005] This application provides a data transmission method and a gateway device, which can solve the problem of the limited functionality of home gateways in related technologies. The technical solution is as follows:
[0006] On one hand, a gateway device is provided, comprising: a processor, a physical wide area network (WAN) interface, and multiple virtual WAN interfaces, wherein the media access control (MAC) addresses of the multiple virtual WAN interfaces are different from each other, and at least one of the multiple virtual WAN interfaces operates in routing mode, and at least one of the virtual WAN interfaces operates in bridging mode; the processor is used for:
[0007] Receive the first data packet through the physical WAN interface;
[0008] If the MAC address of the first virtual WAN interface operating in the routing mode among the plurality of virtual WAN interfaces is the same as the destination MAC address of the first data packet, then the first data packet is determined to be a data packet received from the first virtual WAN interface, and the first data packet is processed by the kernel protocol stack according to the three-layer routing forwarding method;
[0009] If the MAC address of each of the plurality of virtual WAN interfaces is different from the destination MAC address of the first data packet, then the first data packet is determined to be a data packet received from at least one second virtual WAN interface operating in the bridge mode, and the first data packet is processed by the kernel protocol stack in accordance with the Layer 2 switching method.
[0010] On the other hand, a data transmission method is provided, applied to a gateway device; the gateway device includes: a physical wide area network (WAN) interface and multiple virtual WAN interfaces, wherein the media access control (MAC) addresses of the multiple virtual WAN interfaces are different from each other, and at least one of the multiple virtual WAN interfaces operates in routing mode, and at least one of the virtual WAN interfaces operates in bridging mode; the method includes:
[0011] Receive the first data packet through the physical WAN interface;
[0012] If the MAC address of the first virtual WAN interface operating in the routing mode among the plurality of virtual WAN interfaces is the same as the destination MAC address of the first data packet, then the first data packet is determined to be a data packet received from the first virtual WAN interface, and the first data packet is processed by the kernel protocol stack according to the three-layer routing forwarding method;
[0013] If the MAC address of each of the plurality of virtual WAN interfaces is different from the destination MAC address of the first data packet, then the first data packet is determined to be a data packet received from at least one second virtual WAN interface operating in the bridge mode, and the first data packet is processed by the kernel protocol stack in accordance with the Layer 2 switching method.
[0014] In another aspect, a gateway device is provided, the gateway device comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the data transmission method as described above.
[0015] In another aspect, a computer-readable storage medium is provided, wherein a computer program is stored therein, the computer program being loaded and executed by a processor to implement the data transmission method as described above.
[0016] In another aspect, a computer program product containing instructions is provided, which, when run on the computer, causes the computer to perform the data transmission method described above.
[0017] The beneficial effects of the technical solution provided in this application include at least the following:
[0018] This application provides a data transmission method and a gateway device. The gateway device includes multiple virtual WAN interfaces, at least one of which operates in routing mode and at least one in bridging mode. Upon receiving a first data packet, the gateway device can determine the receiving interface for the kernel protocol stack to receive the first data packet based on the destination MAC address of the first data packet and the operating mode of each virtual WAN interface, thereby effectively processing the first data packet. Thus, the gateway device can provide Layer 3 routing services and Layer 2 switching services to its connected intranet devices through a single physical WAN interface. Therefore, the gateway device provided in this application has relatively rich functionality. Attached Figure Description
[0019] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0020] Figure 1 This is a schematic diagram of the structure of a gateway device provided in an embodiment of this application;
[0021] Figure 2 This is a schematic diagram illustrating the connection between a gateway device and a service providing device according to an embodiment of this application;
[0022] Figure 3 This is a schematic diagram illustrating the connection between a gateway device and an intranet device according to an embodiment of this application;
[0023] Figure 4 This is a flowchart of a data transmission method provided in an embodiment of this application;
[0024] Figure 5 This is a flowchart of another data transmission method provided in an embodiment of this application;
[0025] Figure 6 This is a flowchart of yet another data transmission method provided in the embodiments of this application;
[0026] Figure 7 This is a schematic diagram of another gateway device provided in an embodiment of this application. Detailed Implementation
[0027] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be described in further detail below with reference to the accompanying drawings.
[0028] Figure 1This is a schematic diagram of a gateway device provided in an embodiment of this application. Figure 1 As can be seen, the gateway device 110 includes a physical WAN interface 01 and a power interface 02. The physical WAN interface can be used to connect to multiple service providing devices, and the power interface 02 can be used to connect to a power source.
[0029] In the embodiments of this application, see Figure 2 The physical WAN interface 01 can be connected to multiple different service providing devices 130 via switch 120. These multiple service providing devices 130 may include: a first service providing device for providing video-on-demand services, and a second service providing device for providing internet access services.
[0030] Each service provides equipment 130, which can be a server. This server can be a single server, a server cluster consisting of several servers, or a cloud computing service center.
[0031] Please continue reading Figure 1 The gateway device 110 may also include multiple physical local area network (LAN) interfaces 03. For example, Figure 1 Four physical LAN interfaces 03 are shown. Each physical LAN interface can be used to connect to an internal network device 140 and can also be connected to a virtual WAN port via a virtual bridge.
[0032] Optional, see Figure 3 The intranet device 140 can be a laptop or a desktop computer.
[0033] This application provides a data transmission method, which is applied to a gateway device, for example... Figure 1 The gateway device 110 shown includes a physical WAN interface and multiple virtual WAN interfaces. The media access control (MAC) addresses (also referred to as physical addresses) of the multiple virtual WAN interfaces are different from each other, and at least one of the virtual WAN interfaces operates in route mode, and at least one virtual WAN interface operates in bridge mode. Optionally, the gateway device can be a router or an optical network unit (ONU), such as an ONU with Wireless-Fidelity (Wi-Fi) functionality. See also... Figure 4 The method includes:
[0034] Step 101: Receive the first data packet through the physical WAN interface.
[0035] In this embodiment, any one of a plurality of service providing devices connected to the gateway device can send a first data packet to the gateway device. Correspondingly, the gateway device can receive the first data packet through its physical WAN interface.
[0036] Step 102: If the MAC address of the first virtual WAN interface operating in routing mode among multiple virtual WAN interfaces is the same as the destination MAC address of the first data packet, then the first data packet is determined to be a data packet received from the first virtual WAN interface, and the first data packet is processed by the kernel protocol stack according to the three-layer routing forwarding method.
[0037] After receiving the first data packet through the physical WAN interface, the gateway device can detect whether there is a virtual WAN interface among the multiple virtual WAN interfaces that is operating in routing mode and whose MAC address is the same as the destination MAC address of the first data packet. If the gateway device determines that the MAC address of the first virtual WAN interface operating in routing mode among the multiple virtual WAN interfaces is the same as the destination MAC address of the first data packet, it can identify the first data packet as a data packet received from the first virtual WAN interface. That is, it can identify the first virtual WAN interface as the receiving interface for the kernel protocol stack to receive the first data packet, and process the first data packet through the kernel protocol stack according to the Layer 3 routing forwarding method.
[0038] For example, after determining the receiving interface for the kernel protocol stack to receive the first data packet, the gateway device can call the receiving function to pass the first data packet to the kernel protocol stack. The kernel protocol stack then processes the first data packet according to a Layer 3 routing forwarding method. The function parameter of this receiving function includes the identifier of the first virtual WAN interface. Processing the first data packet according to the Layer 3 routing forwarding method means that the kernel protocol stack updates the source MAC address of the first data packet to the MAC address of the first virtual WAN interface, and updates the source MAC address of the first data packet to the MAC address of the next-hop device (e.g., the gateway device's internal network device).
[0039] In one alternative implementation, the gateway device can first filter from a plurality of virtual WAN interfaces to select at least one virtual WAN interface that is enabled and operating in routing mode (i.e., operating in routing mode). Then, for each of the at least one virtual WAN interface, the gateway device can detect whether the MAC address of the virtual WAN interface is the same as the destination MAC address of the first data packet. If the gateway device determines that the MAC address of a certain virtual WAN interface is the same as the destination MAC address, that is, the certain virtual WAN interface is the first virtual WAN interface mentioned above, then the first data packet can be identified as a data packet received from the first virtual WAN interface.
[0040] In another optional implementation, for each of the multiple virtual WAN interfaces, the gateway device can detect whether the MAC address of that virtual WAN interface is the same as the destination MAC address of the first data packet. If the gateway device determines that the MAC address of a certain virtual WAN interface is the same as the destination MAC address, it can detect that the operating mode of that virtual WAN interface is routing mode and enabled, that is, it can detect whether the virtual WAN interface is working in routing mode. If the gateway device determines that the virtual WAN interface is working in routing mode, that is, if the virtual WAN interface is the first virtual WAN interface mentioned above, it can then determine that virtual WAN interface as the receiving interface for the kernel protocol stack to receive the first data packet.
[0041] Step 103: If the MAC address of each virtual WAN interface in the multiple virtual WAN interfaces is different from the destination MAC address of the first data packet, then the first data packet is determined to be a data packet received from at least one second virtual WAN interface working in bridge mode, and the first data packet is processed by the kernel protocol stack in accordance with the Layer 2 switching method.
[0042] In this embodiment, the gateway device can designate each of the multiple virtual WAN interfaces operating in bridged mode as the receiving interface for the kernel protocol stack to receive the first data packet.
[0043] Alternatively, the gateway device stores a forwarding information table for each of the multiple virtual WAN interfaces operating in bridged mode. This forwarding information table is a forwarding database (FDB) table maintained by the gateway device's kernel for the virtual bridge containing that virtual WAN interface. The FDB table of each virtual bridge containing a virtual WAN interface operating in bridged mode records the source MAC addresses of historical data packets sent by that virtual WAN. Any two virtual WAN interfaces reside on different virtual bridges.
[0044] After the gateway device determines that the MAC address of each virtual WAN interface is different from the destination MAC address of the first data packet, if it detects that the destination MAC address of the first data packet is recorded in the forwarding information (i.e., the FDB table of the virtual bridge where the second virtual WAN interface is located) of the second virtual WAN interface operating in bridge mode, then the first data packet can be identified as a data packet received from the second virtual WAN interface, and the second virtual WAN interface can be used as the receiving interface for the kernel protocol stack to receive the first data packet. This saves processing resources for the gateway device.
[0045] As described above, a gateway device can designate at least one WAN interface operating in bridged mode as the packet receiving interface. It can be understood that processing the first data packet according to Layer 2 switching means forwarding the first data packet directly through the LAN interface corresponding to the virtual WAN interface operating in bridged mode. The LAN interface corresponding to the virtual WAN interface refers to the LAN interface connected to the virtual WAN interface through the virtual bridge containing the virtual WAN interface.
[0046] Understandably, if the gateway device detects that the destination MAC address of the first data packet is not recorded in the forwarding information table of each virtual WAN interface operating in bridged mode, then the first data packet can be identified as a data packet received from all virtual WAN interfaces operating in bridged mode. That is, all virtual WAN interfaces operating in bridged mode are used as the receiving interfaces for the kernel protocol stack to receive the first data packet.
[0047] In summary, this application provides a data transmission method. The gateway device includes multiple virtual WAN interfaces, at least one of which operates in routing mode and at least one in bridging mode. Upon receiving a first data packet, the gateway device can determine the receiving interface for the kernel protocol stack to receive the first data packet based on the destination MAC address of the first data packet and the operating mode of each virtual WAN interface, thus effectively processing the first data packet. Therefore, the gateway device can provide Layer 3 routing services and Layer 2 switching services to its connected intranet devices through a single physical WAN interface. It is evident that the gateway device provided in this application has relatively rich functionality.
[0048] In this embodiment, the gateway device's driver program pre-writes program statements for creating virtual WAN interfaces. After the gateway device starts, its kernel (which runs on the gateway device's processor) can load the driver program to call the interface creation function provided by the kernel to create multiple virtual WAN interfaces. Optionally, the number of virtual WAN interfaces can be greater than or equal to 5 and less than or equal to 15. For example, the number of virtual WAN interfaces can be 8.
[0049] After creating multiple virtual WAN interfaces, for each virtual WAN interface, staff can configure its attributes using a mobile terminal (such as a mobile phone or laptop) connected to the gateway device. These attributes may include: the virtual WAN interface's activation status, its MAC address, and its operating mode. The activation status can be enabled or disabled. The operating mode can be either routing mode or bridging mode.
[0050] Understandably, this routing mode can include multiple sub-modes, including: Point-to-Point Protocol over Ethernet (PPPOE) sub-mode, Dynamic Host Configuration Protocol (DHCP) sub-mode, and Static Internet Protocol (IP) sub-mode. The communication methods of the gateway device differ under different sub-modes.
[0051] Figure 5 This is a flowchart illustrating another data transmission method provided in an embodiment of this application, which can be applied to a gateway device. The gateway device includes a physical WAN interface and multiple virtual WAN interfaces. The MAC addresses of the multiple virtual WAN interfaces are different, and at least one of the virtual WAN interfaces operates in routing mode, while at least one virtual WAN interface operates in bridging mode. See also... Figure 5 The method may include:
[0052] Step 201: Receive the first data packet through the physical WAN interface.
[0053] A gateway device can connect to multiple different service providers through its physical WAN interface (also known as a network interface card). For example, the gateway device's physical WAN interface can connect to multiple service providers through a switch. Any one of the multiple service providers can send a first data packet to the gateway device. Correspondingly, the gateway device can receive the first data packet through its physical WAN interface.
[0054] In this embodiment, after the network interface card (NIC) receives the first data packet, it can write the first data packet into the memory of the gateway device and notify the gateway device's processor, such as the central processing unit (CPU), by triggering an interrupt event. The processor can then trigger the NIC's driver to call the interrupt handler function. During the execution of the interrupt handler function, the driver can read the first data packet from memory and convert its format to skb format (i.e., the first data packet is identified by skb) that the gateway device's kernel protocol stack can recognize. Afterward, the processor can call the receive function to pass the skb-formatted first data packet to the kernel protocol stack for processing. However, before calling the receive function, the processor needs to determine the virtual WAN interface that received the first data packet. Based on this, after executing step 201, the gateway device can execute steps 202 to 208 to achieve the effect of processing the first data packet through the kernel protocol stack.
[0055] It is understandable that the interrupt handler function called by the network card driver can be one that the driver has registered according to the requirements of the kernel protocol stack, and this interrupt handler function can be rx_handle(). The packet receiving function can be netif_receive_skb().
[0056] Step 202: Check whether the MAC address of each virtual WAN interface in the multiple virtual WAN interfaces is the same as the destination MAC address of the first data packet.
[0057] If the gateway device determines that the target virtual WAN interface among the multiple virtual WAN interfaces has the same destination MAC address as the first data packet, then step 203 can be executed. If the gateway device determines that the MAC address of each virtual WAN interface among the multiple virtual WAN interfaces is different from the destination MAC address of the first data packet, then step 206 can be executed.
[0058] In the first alternative implementation, for each of the multiple virtual WAN interfaces, the gateway device can compare whether the MAC address of the virtual WAN interface is the same as the destination MAC address of the first data packet.
[0059] In the second optional implementation, the MAC addresses of multiple virtual WAN interfaces are consecutive. This consecutiveness can mean that the MAC addresses of the multiple virtual WAN interfaces can form an arithmetic sequence. In this case, the gateway device can determine the target difference between the destination MAC address of the first data packet and the MAC address of the auxiliary virtual WAN interface, and detect whether this target difference is one of a series of consecutive candidate differences. The MAC address of the auxiliary virtual WAN interface is the minimum value among the MAC addresses of the multiple virtual WAN interfaces. Each candidate difference is the difference between the MAC address of one of the multiple virtual WAN interfaces and the MAC address of the auxiliary virtual WAN interface.
[0060] If the gateway device determines that the target difference is one of a plurality of alternative differences, it can determine that the MAC address of one of the plurality of virtual WAN interfaces is the same as the destination MAC address of the first data packet. If the gateway device determines that the target difference is different from any of the plurality of alternative differences, it can determine that the MAC address of each of the plurality of virtual WAN interfaces is different from the destination MAC address of the first data packet.
[0061] Since MAC addresses typically include multiple values, and since there is no need to compare the MAC address of each virtual WAN interface with the destination MAC address of the first data packet, the second implementation method, compared to the first, ensures that the gateway device can quickly determine whether there is a virtual WAN interface among the multiple virtual WAN interfaces whose MAC address is the same as the destination MAC address of the first data packet.
[0062] Optionally, the common difference of the arithmetic sequence can be 1.
[0063] For example, assuming there are 8 virtual WAN interfaces, the common difference of this arithmetic sequence is 1, and correspondingly, multiple consecutive alternative differences can be from 0 to 7. If the difference between the destination MAC address of the first data packet and the MAC address of the auxiliary virtual WAN interface among the multiple virtual WAN interfaces is equal to 1, then the gateway device can determine that among the multiple virtual WAN interfaces arranged in ascending order of MAC address, the MAC address of the second virtual WAN interface is the same as the destination MAC address of the first data packet.
[0064] If the difference between the destination MAC address of the first data packet and the MAC address of the auxiliary virtual WAN interface is equal to 9, the gateway device can determine that the MAC address of each of the multiple virtual WAN interfaces is different from the destination MAC address of the first data packet.
[0065] Step 203: Check whether the target virtual WAN interface is enabled and whether the working mode of the target virtual WAN interface is routing mode.
[0066] Once the gateway device determines that the MAC address of the target virtual WAN interface among multiple virtual WAN interfaces is the same as the destination MAC address of the first data packet, it can detect whether the target virtual WAN interface is enabled and whether the working mode of the target virtual WAN interface is routing mode. In other words, it can detect whether the target virtual WAN interface is working in routing mode.
[0067] If the gateway device determines that the target virtual WAN interface is enabled and that the target virtual WAN interface is operating in routing mode, then step 204 can be executed. If the gateway device determines that the target virtual WAN interface is not enabled, and / or that the target virtual WAN interface is operating in bridged mode, then step 205 can be executed.
[0068] Step 204: Identify the first data packet as a data packet received from the target virtual WAN interface, and process the first data packet through the kernel protocol stack according to the three-layer routing forwarding method.
[0069] If the gateway device determines that the target virtual WAN interface is working in routing mode, that is, the target virtual WAN interface is the first virtual WAN interface mentioned above, then the first data packet can be identified as a data packet received from the target virtual WAN interface (i.e., the first virtual WAN interface). In other words, the gateway device can identify the target virtual WAN interface as the packet receiving interface for the kernel protocol stack to receive the first data packet.
[0070] Then, the gateway device's processor can call the packet receiving function to pass the first data packet to the kernel protocol stack. Correspondingly, the gateway device's kernel protocol stack can then process the first data packet according to the Layer 3 routing forwarding method.
[0071] For example, the kernel protocol stack can update the source MAC address of the first data packet to the MAC address of the first virtual WAN interface, and can update the destination MAC address of the first data packet to the MAC address of the next-hop device, thus processing the first data packet according to a Layer 3 routing forwarding method. Afterwards, the kernel protocol stack can forward the processed first data packet to the internal network device connected to the gateway device based on the communication protocol corresponding to the sub-mode of the first virtual WAN interface.
[0072] For example, if the submode of the first virtual WAN interface is PPPoE submode, then the communication protocol can be the PPPoE protocol.
[0073] Step 205: Discard the first data packet.
[0074] If the gateway device determines that the target virtual WAN interface is not enabled, and / or the target virtual WAN interface is operating in bridged mode, it can determine that the first data packet is not a data packet that the gateway device needs to process, and thus can discard the first data packet.
[0075] Therefore, if the destination MAC address of the first data packet is the same as the MAC address of the fifth virtual WAN interface among multiple virtual WAN interfaces, and the fifth virtual WAN interface is not enabled and / or the fifth virtual WAN interface is in bridged mode, the gateway device can discard the first data packet.
[0076] Step 206: Check whether the destination MAC address of the first data packet is recorded in the forwarding information table of each virtual WAN interface operating in bridged mode.
[0077] The gateway device also includes bridged-mode virtual WAN interfaces, meaning the gateway device can act as a switch to directly forward received data packets. When the gateway device acts as a switch, regardless of whether the MAC address of the received data packet is the same as the MAC address of one of the multiple virtual WAN interfaces, if the gateway device has previously sent a historical data packet from a virtual WAN interface with a source address matching the reference MAC address, then upon receiving a data packet with a destination address matching that reference MAC address, it can designate that virtual WAN interface as the receiving interface. Alternatively, if the gateway device has not received a data packet with the reference MAC address, it can use all virtual WAN interfaces operating in bridged mode as receiving interfaces. Furthermore, for each virtual WAN interface, after the gateway device sends a historical data packet from that virtual WAN interface, it can record the source MAC address of that data packet in the FDB table (i.e., the forwarding information table of that virtual WAN interface) of the virtual bridge containing that virtual WAN interface.
[0078] Based on this, if the gateway device determines that the MAC address of each virtual WAN interface among the multiple virtual WAN interfaces is different from the destination MAC address of the first data packet, it can detect whether the destination MAC address of the first data packet is recorded in the FDB table of the virtual bridge where each virtual WAN interface working in bridge mode is located.
[0079] If the gateway device determines that the FDB table of the virtual bridge containing one of the multiple virtual WAN interfaces operating in bridge mode contains the destination MAC address of the first data packet, then it can be determined that the second virtual interface previously sent a historical data packet with the source address as the destination MAC address, and step 207 can be executed. If the gateway device determines that the FDB table of the virtual bridge containing each of the multiple virtual WAN interfaces operating in bridge mode does not contain the destination MAC address of the first data packet, then step 208 can be executed.
[0080] In this embodiment, after the gateway device determines that the MAC address of each of the multiple virtual WAN interfaces is different from the destination MAC address of the first data packet, it can poll and detect the multiple virtual WAN interfaces. For the polled virtual WAN interface, if the gateway device determines that the virtual WAN interface is in bridge mode and enabled (i.e., the virtual WAN interface is working in bridge mode), it can check whether the FDB table of the virtual bridge where the virtual WAN interface is located records the destination MAC address of the first data packet. If the gateway device determines that the polled virtual WAN interface is not enabled and / or is working in routing mode, it can detect the next virtual WAN interface until all virtual WAN interfaces have been detected.
[0081] Step 207: Identify the first data packet as a data packet received from the second virtual WAN interface, and process the first data packet through the kernel protocol stack in accordance with the Layer 2 switching method.
[0082] If the gateway device determines that the destination MAC address of the first data packet is recorded in the FDB table of the virtual bridge where the second virtual WAN interface, which is operating in bridge mode, is located, then the first data packet can be identified as a data packet received from the second virtual WAN interface, that is, the second virtual WAN interface can be identified as the receiving interface through which the kernel protocol stack receives the first data packet.
[0083] Subsequently, the gateway device's processor can call the packet receiving function to pass the first data packet to the kernel protocol stack. Accordingly, the gateway device's kernel protocol stack can process the first data packet using Layer 2 switching. For example, after the first data packet is passed to the kernel protocol stack, the kernel protocol stack can pass the first data packet through a virtual bridge to a physical LAN interface connected to the second virtual WAN interface, and then transmit it to the intranet device connected to that physical LAN interface.
[0084] Step 208: Determine the first data packet as a data packet received from all virtual WAN interfaces operating in bridged mode among multiple virtual WAN interfaces, and process the first data packet through the kernel protocol stack in accordance with the Layer 2 switching method.
[0085] If the gateway device determines that the destination MAC address of the first data packet is not recorded in the FDB table of the virtual bridge where each virtual WAN interface is working in bridge mode, then the first data packet can be identified as a data packet received from all virtual WAN interfaces working in bridge mode, and the first data packet can be processed by the kernel protocol stack in accordance with the Layer 2 switching method.
[0086] Therefore, if the FDB table of the virtual bridge containing each virtual WAN interface operating in bridged mode does not record the destination MAC address of the first data packet, the gateway device can use all virtual WAN interfaces operating in bridged mode as packet receiving interfaces for the kernel protocol stack. Accordingly, the gateway device can broadcast the received first data packet.
[0087] Understandably, the gateway device stores a broadcast variable `send_all` to indicate whether received data packets are broadcast. If the value of this broadcast variable is a first value (e.g., 1), the gateway device can broadcast the received data packets; if the value of this broadcast variable is a first value (e.g., 0), the gateway device will not broadcast the received data packets.
[0088] If the gateway device determines that the MAC address of any of the multiple virtual WAN interfaces is different from the destination MAC address of the first data packet, it can set the value of the broadcast variable to the first value. Then, the gateway device can load a broadcast judgment program to determine if any of the multiple virtual WAN interfaces is operating in bridged mode and has the destination MAC address of the first data packet recorded in its forwarding information. If the broadcast judgment program determines that the destination MAC address of the first data packet is recorded in the FDB table of the virtual bridge containing the second virtual WAN interface operating in bridged mode, it can update the value of the broadcast variable from the first value to the second value and record the identifier of the second virtual WAN interface as the identifier of the receiving interface. If the broadcast judgment program determines that the destination MAC address of the first data packet is not recorded in the FDB table of the virtual bridge containing each of the multiple virtual WAN interfaces operating in bridged mode, it can keep the value of the broadcast variable unchanged from the first value.
[0089] Next, the gateway device can load an interface determination program, which can read the value of the broadcast variable. If the variable value read by the interface determination program is the first value, then all virtual WAN interfaces operating in bridged mode can be determined as the receiving interface for the kernel protocol stack to receive the first data packet. If the variable value read by the interface determination program is 0, then the virtual WAN interface indicated by the read receiving interface identifier can be determined as the receiving interface for the kernel protocol stack to receive the first data packet.
[0090] As described in steps 201 to 208 above, the gateway device can first determine the virtual WAN interface on which the kernel protocol stack receives the first data packet, and then call the packet receiving function to pass the first data packet to the kernel protocol stack. That is, this process only requires calling the packet receiving function once. It eliminates the need to first call the packet receiving function with an arbitrary virtual WAN interface identifier to pass the first data packet to the kernel protocol stack, allowing the kernel protocol stack to determine the virtual WAN interface receiving the first data packet, and then call the packet receiving function based on the identifier of the virtual WAN interface receiving the first data packet, so that the kernel protocol can process the first data packet. Therefore, the data packet processing efficiency is improved.
[0091] Steps 201 to 208 above are exemplary descriptions of the packet receiving process of a gateway device receiving data packets via a physical WAN. This gateway device can also send data packets via the physical WAN; see [link to relevant documentation]. Figure 6 The packet sending process of the gateway device through the physical WAN is detailed in steps 209 to 216 below.
[0092] Step 209: Receive the second data packet through the physical LAN interface.
[0093] The gateway device can connect to an intranet device via a physical LAN interface. The intranet device can send a second data packet to the gateway device, and the gateway device can receive the second data packet via the same physical LAN interface.
[0094] Step 210: Check whether the working mode of the physical LAN interface is routing mode.
[0095] After receiving the second data packet through the physical LAN interface, the gateway device can detect whether the physical LAN interface is in routing mode. If the gateway device determines that the physical LAN interface is in routing mode, it can proceed to step 211. If the gateway device determines that the physical LAN interface is in bridging mode, it can proceed to step 214.
[0096] In this embodiment, the gateway device pre-stores attribute information of the physical LAN interface, including the operating mode of the physical LAN interface. The gateway device can read the attribute information of the physical LAN interface and detect whether the operating mode of the physical LAN interface is routing mode.
[0097] Step 211: Based on the destination IP address of the second data packet, determine the third virtual WAN interface corresponding to the destination IP address from multiple virtual WAN interfaces.
[0098] If the gateway device determines that the working mode of the physical LAN interface is routing mode, it can determine the third virtual WAN interface corresponding to the destination IP address from multiple virtual WAN interfaces based on the destination IP address of the second data packet.
[0099] In this embodiment, the gateway device can connect to multiple routers via a physical WAN interface, with each router corresponding to a virtual WAN interface, and each router can connect to a second service provider. For example, the physical WAN interface of the gateway device can connect to multiple routers via a switch.
[0100] After determining that the physical LAN interface is operating in routing mode, the gateway device can determine the target router indicated by the IP address corresponding to the destination IP address from the pre-stored routing table based on the destination IP address of the second data packet. Then, the gateway device can determine the third virtual WAN interface corresponding to the target router from among multiple virtual WAN interfaces.
[0101] Step 212: Determine the third virtual WAN interface as the sending interface for the second data packet, and process the second data packet through the kernel protocol stack.
[0102] After identifying the third virtual WAN interface, the gateway device can designate it as the sending interface for the second data packet and then process it through the kernel protocol stack. For example, the gateway device can use the kernel protocol stack to encapsulate the source IP address and source MAC address into the second data packet, where the source IP address is the IP address of the third virtual WAN interface and the source MAC address is the MAC address of the third virtual WAN interface.
[0103] Step 213: Send the second data packet processed by the kernel protocol stack to the router corresponding to the third virtual WAN interface through the physical WAN interface.
[0104] After the gateway device processes the second data packet through the kernel protocol stack, it can send the processed second data packet to the router corresponding to the third virtual WAN interface through the physical WAN interface.
[0105] In this embodiment, after the kernel protocol stack of the gateway device processes the second data packet, it can call a packet sending function to pass the processed second data packet to the driver, and then send it from the physical WAN interface (i.e., the network card) to the router corresponding to the third virtual WAN interface. This packet sending function can be the function dev_hard_start_xmit(skb,dev,txq).
[0106] Step 214: Check whether the destination MAC address of the second data packet is recorded in the forwarding information table of each virtual WAN interface operating in bridged mode.
[0107] After the gateway device determines that the working mode of the physical LAN interface is bridged, it can check whether the destination MAC address of the second data packet is recorded in the FDB table of the virtual bridge where each virtual WAN interface working in bridged mode is located.
[0108] If the destination MAC address of the second data packet is recorded in the FDB table of the virtual bridge containing the fourth virtual WAN interface operating in bridge mode, then proceed to step 214. If the destination MAC address of the second data packet is not recorded in the FDB table of the virtual bridge containing each virtual WAN interface operating in bridge mode, then proceed to step 215.
[0109] Step 215: Determine the fourth virtual WAN interface as the packet sending interface of the kernel protocol stack, and process the second data packet through the kernel protocol stack.
[0110] If the destination MAC address of the second data packet is recorded in the FDB table of the virtual bridge containing the fourth virtual WAN interface that is operating in bridge mode, the gateway device can identify the fourth virtual WAN interface as the packet sending interface of the kernel protocol stack and process the second data packet through the kernel protocol stack.
[0111] For example, the kernel protocol stack can directly call the packet sending function to pass the second data packet to the driver, which then sends it out through the physical WAN interface. Furthermore, the kernel protocol stack can also record the source MAC address of this second data packet in the FDB table of the virtual bridge where the fourth virtual WAN interface resides.
[0112] Step 216: Identify all virtual WAN interfaces operating in bridged mode among the multiple virtual WAN interfaces as the packet sending interfaces of the kernel protocol stack, and process the second data packet through the kernel protocol stack.
[0113] If the gateway device determines that the destination MAC address of the second data packet is not recorded in the FDB table of the virtual bridge where each virtual WAN interface operating in bridge mode is located, then all virtual WAN interfaces operating in bridge mode can be identified as the packet sending interface of the kernel protocol stack, and the second data packet can be processed by the kernel protocol stack.
[0114] For example, a gateway device can copy the second data packet to obtain multiple second data packets, the number of which is equal to the number of all virtual WAN interfaces operating in bridged mode. Then, the gateway device's kernel protocol stack can broadcast the second data packets through all virtual WAN interfaces and record the source MAC address of the second data packet in the FDB table of the virtual bridge containing each virtual WAN interface.
[0115] As described above, the gateway device provided in this application embodiment can achieve simultaneous access to multiple WAN ports through a single physical WAN interface. This allows the gateway device to provide different services to internal network devices simultaneously, such as PPPoE, DHCP, and Layer 2 switching services, thereby enriching the gateway device's functionality. Furthermore, this approach avoids increasing the manufacturing cost of the gateway device while enhancing its functionality. In addition, since the gateway device can simultaneously support bridging and routing modes, it simplifies network management configuration.
[0116] It is understood that the above embodiments are illustrative examples using the first data packet as a unicast packet. If the first data packet is a broadcast packet, the gateway device can use all enabled virtual WAN interfaces as receiving interfaces for the first data packet and process the first data packet through the kernel protocol stack. Whether a data packet is a unicast or broadcast packet depends on the last digit of the first byte of the data packet's MAC address.
[0117] It is also understood that the order of the steps in the data transmission method provided in this application embodiment can be appropriately adjusted, and the steps can be added or removed as appropriate. For example, steps 209 to 216 can also be deleted as appropriate. Any variations that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the protection scope of this application, and therefore will not be elaborated further.
[0118] In summary, this application provides a data transmission method. The gateway device includes multiple virtual WAN interfaces, at least one of which operates in routing mode and at least one in bridging mode. Upon receiving a first data packet, the gateway device can determine the receiving interface for the kernel protocol stack to receive the first data packet based on the destination MAC address of the first data packet and the operating mode of each virtual WAN interface, thus effectively processing the first data packet. Therefore, the gateway device can provide Layer 3 routing services and Layer 2 switching services to its connected intranet devices through a single physical WAN interface. It is evident that the gateway device provided in this application has relatively rich functionality.
[0119] This application also provides a gateway device, see [link to relevant documentation] Figure 7 The gateway device 110 includes a processor 1101, a physical WAN interface, and multiple virtual WAN interfaces. The media access control MAC addresses of the multiple virtual WAN interfaces are different from each other, and at least one of the virtual WAN interfaces operates in routing mode, and at least one of the virtual WAN interfaces operates in bridged mode. The processor 1101 is used for:
[0120] Receive the first data packet through the physical WAN interface;
[0121] If the MAC address of the first virtual WAN interface operating in routing mode among multiple virtual WAN interfaces is the same as the destination MAC address of the first data packet, then the first data packet is determined to be a data packet received from the first virtual WAN interface, and the first data packet is processed by the kernel protocol stack according to the three-layer routing forwarding method;
[0122] If the MAC address of each of the multiple virtual WAN interfaces is different from the destination MAC address of the first data packet, then the first data packet is determined to be a data packet received from at least one second virtual WAN interface operating in bridge mode, and the first data packet is processed by the kernel protocol stack in accordance with the Layer 2 switching method.
[0123] Optionally, the gateway device stores a forwarding information table for each virtual WAN interface operating in bridged mode among multiple virtual WAN interfaces. The forwarding information table records the source MAC addresses of historical data packets sent by the virtual WAN interface. The processor 1101 can be used for:
[0124] If the destination MAC address of the first data packet is recorded in the forwarding information table of a second virtual WAN interface that is operating in bridged mode among multiple virtual WAN interfaces, then the first data packet is identified as a data packet received from the second virtual WAN interface.
[0125] If the destination MAC address of the first data packet is not recorded in the forwarding information table of each virtual WAN interface operating in bridged mode, then the first data packet is identified as a data packet received from all virtual WAN interfaces operating in bridged mode.
[0126] Optionally, the gateway device connects to multiple routers via physical WAN interfaces, with each router corresponding to a virtual WAN interface. The gateway device also includes physical LAN interfaces. The processor 1101 can also be used for:
[0127] Receive the second data packet via the physical LAN interface;
[0128] If the physical LAN interface is in routing mode, then based on the destination Internet Protocol (IP) address of the second data packet, the third virtual WAN interface corresponding to the destination IP address is determined from multiple virtual WAN interfaces.
[0129] The third virtual WAN interface is designated as the sending interface for the second data packet, and the second data packet is processed through the kernel protocol stack.
[0130] Optionally, the processor 1101 can also be used for:
[0131] The second data packet, processed by the kernel protocol stack, is sent to the router corresponding to the third virtual WAN interface via the physical WAN interface.
[0132] The source MAC address of the processed second data packet is the MAC address of the third virtual WAN interface.
[0133] Optionally, the gateway device stores a forwarding information table for each virtual WAN interface operating in bridged mode, among multiple virtual WAN interfaces. The forwarding information table records the source MAC addresses of historical data packets sent by the virtual WAN interface. The processor 1101 can also be used for:
[0134] If the physical LAN interface is in bridged mode, and the forwarding information table of a fourth virtual WAN interface that is in bridged mode among multiple virtual WAN interfaces records the destination MAC address of the second data packet, then the fourth virtual WAN interface is determined as the packet sending interface of the kernel protocol stack, and the second data packet is processed by the kernel protocol stack.
[0135] Alternatively, if the physical LAN interface is in bridged mode and the forwarding information table of each virtual WAN interface in bridged mode does not record the destination MAC address of the second data packet, then all virtual WAN interfaces in bridged mode are identified as the packet sending interfaces of the kernel protocol stack, and the second data packet is processed by the kernel protocol stack.
[0136] Optionally, the MAC addresses of multiple virtual WAN interfaces can be consecutive.
[0137] Optionally, the processor 1101 can also be used for:
[0138] If the destination MAC address of the first data packet is the same as the MAC address of the fifth virtual WAN interface among multiple virtual WAN interfaces, and the fifth virtual WAN interface is not enabled and / or the fifth virtual WAN interface is in bridged mode, then the first data packet is discarded.
[0139] In summary, this application provides a gateway device including multiple virtual WAN interfaces. At least one virtual WAN interface operates in routing mode, and at least one virtual WAN interface operates in bridging mode. Upon receiving a first data packet, the gateway device can determine the receiving interface for the kernel protocol stack to receive the first data packet based on the destination MAC address of the first data packet and the operating mode of each virtual WAN interface, thereby effectively processing the first data packet. Therefore, the gateway device can provide Layer 3 routing services and Layer 2 switching services to its connected intranet devices through a single physical WAN interface. Thus, the gateway device provided in this application has relatively rich functionality.
[0140] This application provides a gateway device, see [link to relevant documentation] Figure 7The gateway device 1101 may include a memory 1102, a processor 1101, and a computer program stored in the memory 1102 and executable on the processor 1101. When the processor 1101 executes the computer program, it implements the data transmission method provided in the above embodiments, for example... Figures 4 to 6 Any of the methods described herein.
[0141] This application provides a computer-readable storage medium storing a computer program, which is loaded by a processor and executes the data transmission method provided in the above embodiments, for example... Figures 4 to 6 Any of the methods described herein.
[0142] This application also provides a computer program product containing instructions that, when run on a computer, cause the computer to execute the data transmission method provided in the above-described method embodiments, for example... Figures 1 to 3 Any of the methods described herein.
[0143] Those skilled in the art will understand that all or part of the steps of the above embodiments can be implemented by hardware or by a program instructing related hardware. The program can be stored in a computer-readable storage medium, such as a read-only memory, a disk, or an optical disk.
[0144] It should be understood that the term "and / or" as used herein indicates that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, or B existing alone. The character " / " generally indicates that the preceding and following objects are in an "or" relationship. Furthermore, the term "at least one" in this application means one or more, and the term "multiple" in this application means two or more.
[0145] In this application, the terms "first," "second," etc., are used to distinguish identical or similar items with substantially the same function. It should be understood that there is no logical or temporal dependency between "first," "second," and "nth," nor is there any limitation on quantity or execution order. For example, without departing from the scope of the various examples described, a first virtual WAN interface may be referred to as a second virtual WAN interface, and similarly, a second virtual WAN interface may be referred to as a first virtual WAN interface.
[0146] The above description is merely an exemplary embodiment of this application and is not intended to limit this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.
Claims
1. A gateway device, characterized in that, The gateway device includes: a processor, a physical wide area network (WAN) interface, and multiple virtual WAN interfaces. The media access control (MAC) addresses of the multiple virtual WAN interfaces are different from each other, and at least one of the virtual WAN interfaces operates in routing mode, and at least one virtual WAN interface operates in bridged mode. The processor is used for: Receive the first data packet through the physical WAN interface; If the MAC address of the first virtual WAN interface operating in the routing mode among the plurality of virtual WAN interfaces is the same as the destination MAC address of the first data packet, then the first data packet is determined to be a data packet received from the first virtual WAN interface, and the first data packet is processed by the kernel protocol stack according to the three-layer routing forwarding method; If the MAC address of each of the plurality of virtual WAN interfaces is different from the destination MAC address of the first data packet, then the first data packet is determined to be a data packet received from at least one second virtual WAN interface operating in the bridge mode, and the first data packet is processed by the kernel protocol stack in accordance with the Layer 2 switching method.
2. The gateway device according to claim 1, characterized in that, The gateway device stores a forwarding information table for each virtual WAN interface operating in bridged mode, and the forwarding information table records the source MAC addresses of historical data packets sent by the virtual WAN interface; the processor is used for: If the destination MAC address of the first data packet is recorded in the forwarding information table of a second virtual WAN interface that is operating in the bridged mode among the plurality of virtual WAN interfaces, then the first data packet is determined to be a data packet received from the second virtual WAN interface; If the destination MAC address of the first data packet is not recorded in the forwarding information table of each of the plurality of virtual WAN interfaces operating in the bridged mode, then the first data packet is determined to be a data packet received from all virtual WAN interfaces operating in the bridged mode.
3. The gateway device according to claim 1, characterized in that, The gateway device is connected to multiple routers via the physical WAN interface, with each router corresponding to a virtual WAN interface; the gateway device also includes a physical local area network (LAN) interface; the processor is further configured to: Receive the second data packet through the physical LAN interface; If the physical LAN interface is in the routing mode, then based on the destination Internet Protocol (IP) address of the second data packet, the third virtual WAN interface corresponding to the destination IP address is determined from the plurality of virtual WAN interfaces; The third virtual WAN interface is designated as the sending interface for the second data packet, and the second data packet is processed through the kernel protocol stack.
4. The gateway device according to claim 3, characterized in that, The processor is also used for: The second data packet processed by the kernel protocol stack is sent to the router corresponding to the third virtual WAN interface through the physical WAN interface; The source MAC address of the processed second data packet is the MAC address of the third virtual WAN interface.
5. The gateway device according to claim 3, characterized in that, The gateway device stores a forwarding information table for each virtual WAN interface in bridged mode among multiple virtual WAN interfaces. The forwarding information table records the source MAC addresses of historical data packets sent by the virtual WAN interface. The processor is further configured to: If the physical LAN interface is in the bridging mode, and the forwarding information table of a fourth virtual WAN interface in the bridging mode among the plurality of virtual WAN interfaces records the destination MAC address of the second data packet, then the fourth virtual WAN interface is determined as the packet sending interface of the kernel protocol stack, and the second data packet is processed by the kernel protocol stack. Alternatively, if the physical LAN interface operates in bridged mode, and the forwarding information table of each of the plurality of virtual WAN interfaces operating in bridged mode does not record the destination MAC address of the second data packet, then all the virtual WAN interfaces operating in bridged mode among the plurality of virtual WAN interfaces are determined as the packet sending interfaces of the kernel protocol stack, and the second data packet is processed through the kernel protocol stack.
6. The gateway device according to any one of claims 1 to 5, characterized in that, The MAC addresses of the multiple virtual WAN interfaces are consecutive.
7. The gateway device according to any one of claims 1 to 5, characterized in that, Also includes: If the destination MAC address of the first data packet is the same as the MAC address of the fifth virtual WAN interface among the plurality of virtual WAN interfaces, and the fifth virtual WAN interface is not enabled and / or the fifth virtual WAN interface is in bridged mode, then the first data packet is discarded.
8. A data transmission method for a gateway device, characterized in that, The method is applied to a gateway device, the gateway device including: a physical wide area network (WAN) interface and multiple virtual WAN interfaces, wherein the media access control (MAC) addresses of the multiple virtual WAN interfaces are different from each other, and at least one of the multiple virtual WAN interfaces operates in routing mode, and at least one of the virtual WAN interfaces operates in bridging mode; the method includes: Receive the first data packet through the physical WAN interface; If the MAC address of the first virtual WAN interface operating in the routing mode among the plurality of virtual WAN interfaces is the same as the destination MAC address of the first data packet, then the first data packet is determined to be a data packet received from the first virtual WAN interface, and the first data packet is processed by the kernel protocol stack according to the three-layer routing forwarding method; If the MAC address of each of the plurality of virtual WAN interfaces is different from the destination MAC address of the first data packet, then the first data packet is determined to be a data packet received from at least one second virtual WAN interface operating in the bridge mode, and the first data packet is processed by the kernel protocol stack in accordance with the Layer 2 switching method.
9. The method according to claim 8, characterized in that, The gateway device stores a forwarding information table for each virtual WAN interface in bridged mode among multiple virtual WAN interfaces. The forwarding information table records the source MAC address of historical data packets sent by the virtual WAN interface. The step of identifying the first data packet as a data packet received from at least one second virtual WAN interface operating in the bridged mode includes: If the destination MAC address of the first data packet is recorded in the forwarding information table of a second virtual WAN interface that is operating in the bridged mode among the plurality of virtual WAN interfaces, then the first data packet is determined to be a data packet received from the second virtual WAN interface; If the destination MAC address of the first data packet is not recorded in the forwarding information table of each of the plurality of virtual WAN interfaces operating in the bridged mode, then the first data packet is determined to be a data packet received from all virtual WAN interfaces operating in the bridged mode.
10. The method according to claim 8, characterized in that, The gateway device is connected to multiple routers through the physical WAN interface, and each router corresponds to a virtual WAN interface; The gateway device further includes: a physical local area network (LAN) interface; the method further includes: Receive the second data packet through the physical LAN interface; If the physical LAN interface is in the routing mode, then based on the destination Internet Protocol (IP) address of the second data packet, the third virtual WAN interface corresponding to the destination IP address is determined from the plurality of virtual WAN interfaces; The third virtual WAN interface is designated as the sending interface for the second data packet, and the second data packet is processed through the kernel protocol stack.
Citation Information
Patent Citations
Method and system for realizing multi-WAN connection service processing based on PON uplink home gateway
CN110417603A
Message forwarding method and gateway
CN111614565A