A method and apparatus for implementing cross-network routing in a distributed soft bus
By configuring local area networks and cross-network virtual network ports on smart terminals and using iptables rules to map network segments and devices, and dynamically updating the rules to adapt to network changes, the complexity and dynamism of cross-network routing configuration in distributed systems are solved, achieving efficient cross-network data transmission and stable network communication.
Patent Information
- Application Number
- CN202411404696.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-10
- Publication Date
- 2025-10-28
- Estimated Expiration
- 2044-10-10
AI Technical Summary
Existing technologies for implementing cross-network routing in distributed systems suffer from problems such as complex configuration, high cost, and difficulty in coping with dynamic network environments.
By configuring local area network virtual ports and cross-network virtual ports on smart terminals, and using bridge connections, combined with iptables rules to map network segments and devices, dynamically updating iptables rules to adapt to network topology changes, assessing link speed and congestion, and performing transparent packet forwarding and congestion management.
It enables flexible network interface configuration, supports seamless communication between devices, provides an efficient cross-network routing solution, ensures the real-time performance and stability of network communication, and improves the efficiency and reliability of data transmission.
Smart Images

Figure CN119583418B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of network communication, and specifically relates to a method and apparatus for implementing cross-network routing in a distributed soft bus. Background Art
[0002] In traditional network environments, cross-network routing and data transmission often rely on dedicated routers and protocols for packet forwarding. However, this approach has limitations and shortcomings when dealing with complex network topology changes and the need for flexible configuration. With the rapid development of the Internet of Things (IoT), smart devices, and distributed systems, the demand for cross-network routing and data transmission is increasing. Supported by system communication services such as distributed soft buses, ad hoc networking and data transmission between devices have become more important. However, current technologies still face challenges in implementing cross-network routing, such as complex configuration, high costs, and difficulty in handling dynamic network environments. Therefore, it is necessary to propose a new technical solution to address these challenges. The background technology of this invention addresses these problems, aiming to achieve cross-network routing and data transmission in a distributed soft bus in an efficient and flexible manner. By applying key technologies such as flexible configuration of network interfaces, flexible configuration of iptables rules, transparent packet forwarding, and dynamic route management, this invention aims to provide a simple and efficient solution to meet the needs of cross-network communication in modern distributed systems. Summary of the Invention
[0003] In view of this, the present invention provides a method for implementing cross-network routing in a distributed soft bus, characterized in that the method includes:
[0004] Step S1: Configure the network interface on the smart terminal; the network interface includes a local area network virtual port and a cross-network virtual port, and the local area network virtual port and the cross-network virtual port are connected by a network bridge;
[0005] Step S2: Configure iptables rules, which connect LAN devices and external network devices through network segment mapping and device mapping;
[0006] Step S3: According to the configured iptables rules,
[0007] For data packets from the local area network device that enter through the local area network virtual port, they are forwarded to the first link between the cross-network virtual port and the external network device for communication.
[0008] For data packets from the external network device that enter through the cross-network virtual interface, they are forwarded to the second link between the local area network virtual interface and the local area network for communication.
[0009] Step S4: When the network topology changes, dynamically update the iptables rules for the first and second links;
[0010] Step S5: Evaluate the real-time transmission rate and congestion status of the first link and the second link, and perform congestion management on data packets entering and leaving the local area network virtual interface and the cross-network virtual interface based on priority.
[0011] Specifically, in step S5, evaluating the real-time transmission rate across the network link includes:
[0012] The first and second links include data sub-streams from different applications;
[0013] Calculate the real-time transmission rate at time r in the link using the following formula:
[0014]
[0015] Among them, S a (r) represents the real-time transmission rate of link a at time point r, τ a Let w represent the base transmission rate of link a, k ∈ K, where K represents the set of all data transmission substreams on link a, and k represents the k-th data transmission substream on link a. k E represents the weighting factor of the data transmission sub-stream k. k (r a\r ) represents the actual transmission rate of sub-stream k in link a at time points other than time point r.
[0016] Specifically, in step S5, assessing the congestion across network links includes:
[0017] Congestion risk index of link a at time point r The calculation method is:
[0018]
[0019] Where r'∈R a r' represents a specific time point related to link a, R a R represents the set of all time points related to link a. a \r represents the set R a Remove time point r from the middle; This indicates an indicator function used to count the number of elements that satisfy a certain condition. Its value is either 0 or 1. If the condition in parentheses is true, the value of the indicator function is 1; otherwise, it is 0. u a r This represents the lower limit of bandwidth utilization for link a at time point r; This indicates the maximum bandwidth utilization of link a at time point r'.
[0020] Specifically, in step S5, congestion management of data packets entering and leaving the network based on priority includes: classifying different application flows into different priorities according to service type;
[0021] When the calculated congestion risk index of link a exceeds a preset threshold, the weighting factor w of the data transmission sub-stream k is adjusted. k This reduces the sending rate of low-priority application streams and increases the sending priority of high-priority application streams.
[0022] Specifically, the method further includes:
[0023] When the LAN interface is enabled, configure the network segment mapping rules based on the LAN segment and subnet mask.
[0024] When a device on the local area network is detected to be online, configure device mapping rules based on the device's IP address and port, and its external IP address and port.
[0025] When a local area network interface is found to be disabled, delete the corresponding network segment mapping rules;
[0026] When a device on the local area network is detected to be offline, delete the corresponding device mapping rule.
[0027] The present invention also discloses an apparatus for implementing cross-network routing in a distributed soft bus, comprising:
[0028] A network interface configuration module is used to configure network interfaces on a smart terminal; the network interface includes a local area network virtual port and a cross-network virtual port, and the local area network virtual port and the cross-network virtual port are connected by a network bridge;
[0029] The iptables rule configuration module is used to configure iptables rules, which connect LAN devices and WAN devices through network segment mapping and device mapping.
[0030] The data forwarding module is used to forward data according to the configured iptables rules.
[0031] For data packets from the local area network device that enter through the local area network virtual port, they are forwarded to the first link between the cross-network virtual port and the external network device for communication.
[0032] For data packets from the external network device that enter through the cross-network virtual interface, they are forwarded to the second link between the local area network virtual interface and the local area network for communication.
[0033] The dynamic routing management module is used to dynamically update the iptables rules of the first and second links when the network topology changes.
[0034] The rate and congestion management module is used to evaluate the real-time transmission rate and congestion status of the first link and the second link, and to perform congestion management on data packets entering and leaving the local area network virtual interface and the cross-network virtual interface based on priority.
[0035] Beneficial effects:
[0036] The technical solution of this invention provides a method and apparatus for implementing cross-network routing in a distributed soft bus, which has the following technical effects:
[0037] It can flexibly configure network interfaces on smart terminals, including local area network virtual ports and cross-network virtual ports, and connect them through a network bridge to achieve network connectivity between devices.
[0038] It provides flexible iptables rule configuration to implement network segment mapping and device mapping, enabling LAN devices and external network devices to access each other, providing basic support for data transmission.
[0039] Based on the configured iptables rules, data packets entering and leaving the network are transparently forwarded, realizing cross-network routing and enabling seamless data transfer between different networks.
[0040] It can dynamically update iptables rules based on changes in network topology, enabling dynamic routing management and ensuring the real-time performance and stability of network communication.
[0041] By assessing the real-time transmission rate and congestion status across network links and prioritizing data packets entering and leaving the network for congestion management, the efficiency and reliability of data transmission are improved. Attached Figure Description
[0042] Figure 1 This invention presents a method for implementing cross-network routing in a distributed soft bus.
[0043] Figure 2 This is a schematic diagram of a cross-network routing device implemented in a distributed soft bus according to the present invention. Detailed Implementation
[0044] The present invention will now be described in detail with reference to the accompanying drawings and embodiments.
[0045] This invention provides a method for implementing cross-network routing in a distributed soft bus, such as... Figure 1 As shown, it includes:
[0046] Configure network interfaces on the smart terminal. The network interfaces include local area network virtual ports and cross-network virtual ports, and the local area network virtual ports and cross-network virtual ports are connected by a network bridge. I. Network Configuration: Configure different network interfaces and IP addresses according to the actual network environment and needs to ensure connectivity between different networks.
[0047] Configure the smart terminal as follows: Create a local area network virtual port and a cross-network virtual port, and connect them through a bridge.
[0048] 1) Configure a virtual LAN port. Create a virtual network port for the smart terminal, making it part of the local area network (LAN). Assign a local IP address to this virtual port to enable communication with other devices on the same LAN. This configuration ensures that the device can communicate directly with other devices on the LAN.
[0049] 2) Configure a cross-network virtual WAN port. Create a virtual WAN port for the smart terminal, enabling it to communicate across different networks. Assign an IP address to this virtual WAN port; this IP address serves as the entry address for the entire subnet. This allows the device to communicate with devices on other subnets.
[0050] 3) Connect the LAN virtual port and the cross-network virtual port using a bridge. A bridge is a network device that connects multiple network interfaces together, making them logically appear as a single network. Add the LAN virtual port and the cross-network virtual port to the bridge to ensure they can communicate with each other.
[0051] The above configuration enables data transmission between the device and other networks. The LAN virtual port allows the device to communicate directly with other devices within the LAN, while the network virtual port allows the device to communicate with devices on other networks. Through a bridge connection, these two virtual ports can achieve seamless data forwarding and transmission.
[0052] Configure iptables rules to implement network segment mapping and device mapping, enabling LAN devices to actively access external network addresses, and external network devices to access LAN devices; 2. iptables rule configuration: By configuring iptables rules, data packets entering and leaving the network can be forwarded and processed. Various matching conditions and actions provided by iptables can be used to implement flexible packet filtering and forwarding strategies.
[0053] The iptables mechanism is used to manage mapping tables, specifically for network segment mappings:
[0054] iptables-t nat-APOSTROUTING-s 172.17.0.0 / 16-j MASQUERADE
[0055] The 172.17.0.0 / 16 section contains the IP address and subnet mask for the local area network (LAN) segment that needs to be configured. After configuration, when LAN devices actively access external network addresses, the proxy node will automatically establish random port mappings for the LAN devices.
[0056] For device mapping:
[0057] iptables -t nat -A PREROUTING -d 10.152.227.173 -p tcp --dport 10088-jDNAT --to 172.17.0.2:8888
[0058] The part 10.152.227.173, 10088, and 172.17.0.2:8888 represents the internal network IP address and port to be mapped, as well as the mapped external network IP address and port. The external network IP address can be obtained by looking up the proxy interface address, and the external network port number is an unused port to be configured. After configuration, external network devices can access local network devices via the external network IP address and port, achieving network traversal.
[0059] Based on the configured iptables rules, data packets entering and leaving the network are transparently forwarded, achieving cross-network routing. When a data packet arrives at the smart terminal node, it is forwarded to the target network according to the rule configuration and action definition. In this way, data packets can be transparently transmitted between different networks, realizing the function of cross-network routing.
[0060] When the corresponding interface is found to be up on the local area network (LAN), this module automatically performs network segment mapping. After configuration, when LAN devices actively access external network addresses, the proxy node will automatically establish random port mappings for the LAN devices.
[0061] When a LAN device comes online, this module performs single-device listening port mapping. After configuration, external network devices can access the LAN device via its external IP address and port, achieving network traversal.
[0062] During cross-network data transmission, the data from the sending end (smart device 1) passes through the HarmonyOS device (cross-network router), and the source address is automatically switched to the external IP address. When the data arrives at the other end of the HarmonyOS device, the destination address is switched back to the internal IP address, and finally arrives at smart device 6.
[0063] The iptables rules are dynamically updated based on changes in network topology to achieve dynamic route management.
[0064] Dynamic routing management can be achieved by updating and modifying iptables rules based on network topology and dynamic changes. This allows the network to flexibly adjust and optimize routes according to real-time needs.
[0065] 1) When the corresponding interface is found to be up on the local area network, the cross-network routing management module automatically maps the network segment.
[0066] 2) When a local area network device comes online, the cross-network routing management module interface performs single-device listening port mapping and stores the record;
[0067] 3) When the corresponding interface is found to be down on the local area network, the cross-network routing management module deletes the network segment and automatically maps it;
[0068] 4) When a LAN device is taken offline, the cross-network routing management interface deletes the single device listening port mapping and deletes the record;
[0069] Assess real-time transmission rates and congestion across network links, and manage congestion of incoming and outgoing data packets based on priority.
[0070] Evaluating the real-time transmission rate across network links specifically includes:
[0071] The first and second links include data sub-streams from different applications;
[0072] Calculate the real-time transmission rate at time r in the link using the following formula:
[0073]
[0074] Among them, S a (r) represents the real-time transmission rate of link a at time point r, τ a Let w represent the base transmission rate of link a, k ∈ K, where K represents the set of all data transmission substreams on link a, and k represents the k-th data transmission substream on link a. k E represents the weighting factor of the data transmission sub-stream k. k (r a\r ) represents the actual transmission rate of sub-stream k in link a at time points other than time point r.
[0075] Specifically, in step S5, assessing the congestion across network links includes:
[0076] Congestion risk index of link a at time point r The calculation method is:
[0077]
[0078] Where r'∈Ra r' represents a specific time point related to link a, R a R represents the set of all time points related to link a. a \r represents the set R a Remove time point r from the middle; This indicates an indicator function used to count the number of elements that satisfy a certain condition. Its value is either 0 or 1. If the condition in parentheses is true, the value of the indicator function is 1; otherwise, it is 0. u a r This represents the lower limit of bandwidth utilization for link a at time point r; This indicates the maximum bandwidth utilization of link a at time point r'.
[0079] In step S5, assessing the congestion across network links specifically includes:
[0080] Congestion risk index of link a at time point r The calculation method is:
[0081]
[0082] Where r'∈R a r' represents a specific time point related to link a, R a R represents the set of all time points related to link a. a \r represents the set R a Remove time point r from the middle; This indicates an indicator function used to count the number of elements that satisfy a certain condition. Its value is either 0 or 1. If the condition in parentheses is true, the value of the indicator function is 1; otherwise, it is 0. u a r This represents the lower limit of bandwidth utilization for link a at time point r; This indicates the maximum bandwidth utilization of link a at time point r'.
[0083] In step S5, congestion management of data packets entering and leaving the network based on priority specifically includes: classifying different application flows into different priorities according to service type;
[0084] When the calculated congestion risk index of link a exceeds a preset threshold, the weighting factor w of the data transmission sub-stream k is adjusted. k This reduces the sending rate of low-priority application streams and increases the sending priority of high-priority application streams.
[0085] This invention also discloses a device for implementing cross-network routing in a distributed soft bus, such as... Figure 2 As shown, it includes:
[0086] A network interface configuration module is used to configure network interfaces on a smart terminal; the network interface includes a local area network virtual port and a cross-network virtual port, and the local area network virtual port and the cross-network virtual port are connected by a network bridge;
[0087] The iptables rule configuration module is used to configure iptables rules, which connect LAN devices and WAN devices through network segment mapping and device mapping.
[0088] The data forwarding module is used to forward data according to the configured iptables rules.
[0089] For data packets from the local area network device that enter through the local area network virtual port, they are forwarded to the first link between the cross-network virtual port and the external network device for communication.
[0090] For data packets from the external network device that enter through the cross-network virtual interface, they are forwarded to the second link between the local area network virtual interface and the local area network for communication.
[0091] The dynamic routing management module is used to dynamically update the iptables rules of the first and second links when the network topology changes.
[0092] The rate and congestion management module is used to evaluate the real-time transmission rate and congestion status of the first link and the second link, and to perform congestion management on data packets entering and leaving the local area network virtual interface and the cross-network virtual interface based on priority.
[0093] The scheme for which this device requests protection corresponds one-to-one with the scheme in the previous method embodiment, so it will not be described again.
[0094] In summary, the above are merely preferred embodiments of the present invention and are not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
[0095] It will be apparent to those skilled in the art that the embodiments of the present invention are not limited to the details of the exemplary embodiments described above, and that the embodiments of the present invention can be implemented in other specific forms without departing from the spirit or essential characteristics of the embodiments of the present invention. Therefore, the embodiments should be considered exemplary and non-limiting in all respects, and the scope of the embodiments of the present invention is defined by the appended claims rather than the foregoing description. Therefore, all variations falling within the meaning and scope of equivalents of the claims are intended to be encompassed within the embodiments of the present invention. No reference numerals in the claims should be construed as limiting the scope of the claims. Furthermore, it is clear that the word "comprising" does not exclude other units or steps, and the singular does not exclude the plural. Multiple units, modules, or devices recited in the system, apparatus, or terminal claims may also be implemented by the same unit, module, or device through software or hardware. The terms "first," "second," etc., are used to indicate names and do not indicate any particular order.
[0096] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the embodiments of the present invention and are not intended to limit them. Although the embodiments of the present invention have been described in detail with reference to the above preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions to the technical solutions of the embodiments of the present invention should not depart from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for implementing cross-network routing in a distributed soft bus, characterized in that, The method includes: Step S1: Configure the network interface on the smart terminal; the network interface includes a local area network virtual port and a cross-network virtual port, and the local area network virtual port and the cross-network virtual port are connected by a network bridge; Step S2: Configure iptables rules, which connect LAN devices and external network devices through network segment mapping and device mapping; Step S3: According to the configured iptables rules, For data packets from the local area network device that enter through the local area network virtual port, they are forwarded to the first link between the cross-network virtual port and the external network device for communication. For data packets from the external network device that enter through the cross-network virtual interface, they are forwarded to the second link between the local area network virtual interface and the local area network for communication. Step S4: When the network topology changes, dynamically update the iptables rules for the first and second links; Step S5: Evaluate the real-time transmission rate and congestion status of the first link and the second link, and perform congestion management on data packets entering and leaving the local area network virtual interface and the cross-network virtual interface based on priority; Specifically, in step S5, evaluating the real-time transmission rates of the first link and the second link includes: The first and second links include data sub-streams from different applications; Calculate the real-time transmission rate at time r in the link using the following formula: Among them, S a (r) represents the real-time transmission rate of link a at time point r, τ a Let w represent the base transmission rate of link a, k ∈ K, where K represents the set of all data transmission substreams on link a, and k represents the k-th data transmission substream on link a. k E represents the weighting factor of the data transmission sub-stream k. k (r a\r This represents the actual transmission rate of substream k at time points other than time point r in link a. In step S5, assessing the congestion status of the first and second links specifically includes: The congestion risk index f of link a at time point r a r The calculation method is: Where r'∈R a r' represents a specific time point related to link a, R a R represents the set of all time points related to link a. a \r represents the set R a Remove time point r from the middle; This indicates an indicator function used to count the number of elements that satisfy a certain condition. Its value is either 0 or 1. If the condition in parentheses is true, the value of the indicator function is 1; otherwise, it is 0. u a r This represents the lower limit of bandwidth utilization for link a at time point r; This indicates the maximum bandwidth utilization of link a at time point r'.
2. The method according to claim 1, characterized in that, In step S5, congestion management of data packets entering and leaving the network based on priority specifically includes: classifying different application flows into different priorities according to service type; When the calculated congestion risk index of link a exceeds a preset threshold, the weighting factor w of the data transmission sub-stream k is adjusted. k This reduces the sending rate of low-priority application streams and increases the sending priority of high-priority application streams.
3. The method according to claim 2, characterized in that, The method further includes: When the LAN interface is enabled, configure the network segment mapping rules based on the LAN segment and subnet mask. When a device on the local area network is detected to be online, configure device mapping rules based on the device's IP address and port, and its external IP address and port. When a local area network interface is found to be disabled, delete the corresponding network segment mapping rules; When a device on the local area network is detected to be offline, delete the corresponding device mapping rule.
4. An apparatus for implementing cross-network routing in a distributed soft bus, characterized in that, include: A network interface configuration module is used to configure network interfaces on a smart terminal; the network interface includes a local area network virtual port and a cross-network virtual port, and the local area network virtual port and the cross-network virtual port are connected by a network bridge; The iptables rule configuration module is used to configure iptables rules, which connect LAN devices and WAN devices through network segment mapping and device mapping. The data forwarding module is used to forward data according to the configured iptables rules. For data packets from the local area network device that enter through the local area network virtual port, they are forwarded to the first link between the cross-network virtual port and the external network device for communication. For data packets from the external network device that enter through the cross-network virtual interface, they are forwarded to the second link between the local area network virtual interface and the local area network for communication. The dynamic routing management module is used to dynamically update the iptables rules of the first and second links when the network topology changes. The rate and congestion management module is used to evaluate the real-time transmission rate and congestion status of the first link and the second link, and to perform congestion management on data packets entering and leaving the local area network virtual interface and the cross-network virtual interface based on priority. The rate and congestion management module, used to evaluate the real-time transmission rates of the first and second links, specifically includes: The first and second links include data sub-streams from different applications; Calculate the real-time transmission rate at time r in the link using the following formula: Among them, S a (r) represents the real-time transmission rate of link a at time point r, τ a Let w represent the base transmission rate of link a, k ∈ K, where K represents the set of all data transmission substreams on link a, and k represents the k-th data transmission substream on link a. k E represents the weighting factor of the data transmission sub-stream k. k (r a\r This represents the actual transmission rate of substream k at time points other than time point r in link a. The rate and congestion management module, used to assess the congestion status of the first and second links, specifically includes: The congestion risk index f of link a at time point r a r The calculation method is: Where r'∈R a r' represents a specific time point related to link a, R a R represents the set of all time points related to link a. a \r represents the set R a Remove time point r from the middle; This indicates an indicator function used to count the number of elements that satisfy a certain condition. Its value is either 0 or 1. If the condition in parentheses is true, the value of the indicator function is 1; otherwise, it is 0. u a r This represents the lower limit of bandwidth utilization for link a at time point r; This indicates the maximum bandwidth utilization of link a at time point r'.
Citation Information
Patent Citations
MEC-based wireless network transmission optimization method and system
CN111866947A
Port real-time data stream visualization method and system based on finite-state machine
CN115396323A