Disclosure of Invention
In view of this, the present invention provides a method for implementing cross-network routing in a distributed soft bus, wherein the method includes:
step S1, configuring a network interface on an intelligent terminal, wherein the network interface comprises a local area network virtual network port and a cross-network virtual network port, and the local area network virtual network port is connected with the cross-network virtual network port through a network bridge;
Step S2, configuring iptables rules, wherein the iptables rules are used for connecting local area network equipment and external network equipment through network segment mapping and equipment mapping;
Step S3, according to the configured iptables rule,
For a data packet from the local area network device entering from a local area network virtual network port, forwarding the data packet to a first link between a cross-network virtual network port and an external network device for communication;
Forwarding a data packet from the external network equipment entering from a cross-network virtual network port to a second link between the local area network virtual network port and the local area network for communication;
Step S4, dynamically updating the iptables rule of the first link and the second link when the network topology changes;
And S5, evaluating the real-time sending rate and congestion conditions of the first link and the second link, and carrying out congestion management on the data packets entering and exiting the local area network virtual network port and the cross-network virtual network port based on the priority.
In particular, in step S5, evaluating the real-time transmission rate across the network link specifically includes:
in the first link and the second link, data substreams of different applications are included;
The real-time transmission rate in the link at time point r is calculated according to the following formula:
Wherein Sa (r) represents the real-time transmission rate of the link a at the time point r, τa represents the basic transmission rate of the link a, K E K, K represents the set of all the data transmission substreams on the link a, K represents the kth data transmission substream on the link a, wk represents the weighting factor of the data transmission substream K, and Ek(ra\r) represents the actual transmission rate of the substream K of the link a at other time points except the time point r.
In particular, in step S5, evaluating congestion conditions across network links specifically includes:
congestion risk index of link a at time point rThe calculation mode of (a) is as follows:
where R '∈ra \r, R' represents a certain point in time associated with link a, Ra represents a set of all points in time associated with link a, and Ra \r represents the removal of point in time R in set Ra; Indicating a function, wherein the number of elements used for counting and meeting a certain condition is only 0 or 1, if the condition in a bracket is met, the value of the indicating function is 1, otherwise, 0;uar indicates the bandwidth utilization lower limit of a link a at a time point r; the upper bandwidth utilization limit for link a at point in time r' is indicated.
In particular, in step S5, congestion management of packets entering and exiting the network based on priority includes dividing different application flows into different priorities according to service types;
When the calculated congestion risk index of the link a exceeds a preset threshold, the transmission rate of the low-priority application flow is reduced and the transmission priority of the high-priority application flow is improved by adjusting the weighting factor wk of the data transmission sub-flow k.
In particular, the method further comprises:
when the local area network interface is found to be started, the network segment mapping rule is configured according to the local area network segment and the subnet mask;
When the local area network equipment is monitored to be online, equipment mapping rules are configured according to the IP address and the port of the local area network equipment and the IP address and the port of the external network;
When the local area network interface is found to be deactivated, deleting the corresponding network segment mapping rule;
And when the local area network equipment is monitored to be offline, deleting the corresponding equipment mapping rule.
The invention also discloses a device for realizing the cross-network routing in the distributed soft bus, which comprises:
The network interface configuration module is used for configuring a network interface on the intelligent terminal, wherein the network interface comprises a local area network virtual network port and a cross-network virtual network port, and the local area network virtual network port is connected with the cross-network virtual network port through a network bridge;
the iptables rule configuration module is used for configuring iptables rules, and the iptables rules are connected with local area network equipment and external network equipment through network segment mapping and equipment mapping;
A data forwarding module, configured to, according to the configured iptables rule,
For a data packet from the local area network device entering from a local area network virtual network port, forwarding the data packet to a first link between a cross-network virtual network port and an external network device for communication;
Forwarding a data packet from the external network equipment entering from a cross-network virtual network port to a second link between the local area network virtual network port and the local area network for communication;
the dynamic route management module is used for dynamically updating the iptables rule of the first link and the second link when the network topology changes;
And the rate and congestion management module is used for evaluating the real-time sending rate and congestion conditions of the first link and the second link and carrying out congestion management on the data packets entering and exiting the local area network virtual network port and the cross-network virtual network port based on the priority.
The beneficial effects are that:
by the technical scheme of the invention, the method and the device for realizing the cross-network routing in the distributed soft bus are realized, and have the following technical effects:
The intelligent terminal can flexibly configure network interfaces, including local area network virtual network ports and cross-network virtual network ports, and are connected through a network bridge, so that network connectivity among devices is realized.
Flexible iptables rule configuration is provided, network segment mapping and device mapping are realized, so that local area network devices and external network devices can access each other, and basic support is provided for data transmission.
According to the configured iptables rule, the data packet entering and exiting the network is forwarded transparently, so that a cross-network routing function is realized, and data can be transferred between different networks in a seamless manner.
The method can dynamically update the iptables rule according to the network topology change, realize dynamic route management and ensure the real-time performance and stability of network communication.
And the real-time sending rate and congestion condition of the cross-network link are evaluated, and the congestion management is carried out on the data packets entering and exiting the network through the priority, so that the efficiency and the reliability of data transmission are improved.
Detailed Description
The invention will now be described in detail by way of example with reference to the accompanying drawings.
The invention provides a method for realizing cross-network routing in a distributed soft bus, which is shown in figure 1 and comprises the following steps:
The method comprises the steps of configuring a network interface on an intelligent terminal, wherein the network interface comprises a local area network virtual network port and a cross-network virtual network port, the local area network virtual network port and the cross-network virtual network port are connected through a network bridge, and firstly, configuring a network, namely configuring different network interfaces and IP addresses according to actual network environments and requirements to ensure connectivity among different networks.
The intelligent terminal is configured by creating a local area network virtual portal and a cross-network virtual portal and connecting them through a bridge.
1) And configuring a virtual network port LAN port of the local area network. A virtual portal is created for the intelligent terminal to become part of the local area network. A local IP address is assigned to the virtual portal for communication with other devices in the same local area network. This configuration may ensure that the device is able to communicate directly with other devices in the local area network.
2) Configuring a cross-network virtual network port WAN port. A virtual portal is created for the intelligent terminal so that the intelligent terminal can communicate across different networks. An IP address, i.e. the entry address of the entire subnet, is assigned to the virtual portal. In this way, the device is able to communicate with devices on other sub-networks.
3) The local area network virtual network port and the cross-network virtual network port are connected through the network bridge. A bridge is a network device that may connect multiple network interfaces together to logically represent a network. The local network virtual network port and the cross-network virtual network port are added into the network bridge, so that the communication between the local network virtual network port and the cross-network virtual network port is ensured.
By the configuration, the data transmission of the device between the local area network and other networks can be realized. The lan virtual portal allows devices to communicate directly with other devices within the lan, while the lan virtual portal allows devices to communicate with devices on other networks. By connecting the network bridge, the two virtual network ports can realize seamless forwarding and transmission of data.
And secondly, the iptables rule is configured to forward and process the data packet entering and exiting the network by configuring the iptables rule, so that the flexible data packet filtering and forwarding strategy can be realized by using various matching conditions and actions provided by the iptables rule.
The mapping table is managed using the iptables mechanism, mapping for segments:
iptables-t nat-APOSTROUTING-s 172.17.0.0/16-j MASQUERADE
the 172.17.0.0/16 part is the LAN segment ip and mask that need to be configured. After the configuration is completed, when the local area network equipment actively accesses the external network address, the proxy node automatically establishes random port mapping for the local area network equipment.
For device mapping:
iptables-t nat-A PREROUTING-d 10.152.227.173-p tcp--dport 10088-jDNAT--to 172.17.0.2:8888
The 10.152.227.173,10088,172.17.0.2:8888 parts are the intranet ip+port to be mapped and the extranet ip+port after mapping. The external network ip address can be obtained by searching the proxy interface address, and the external network port number searches an unused port for configuration. After configuration is completed, when the external network equipment accesses the local area network equipment, the external network equipment can access through the external network ip+port, so that the effect of network crossing is achieved.
And when the data packet reaches the intelligent terminal node, forwarding the data packet to a target network according to rule configuration and action definition. Thus, the data packet can realize transparent transmission among different networks and realize the function of cross-network routing;
When the local area network discovers the corresponding interface up, the module performs network segment automatic mapping. After the configuration is completed, when the local area network equipment actively accesses the external network address, the proxy node automatically establishes random port mapping for the local area network equipment.
When local area network equipment is on line, the module performs single equipment monitoring port mapping. After configuration is completed, when the external network equipment accesses the local area network equipment, the external network equipment can access through the external network ip+port, so that the effect of network crossing is achieved.
When the cross-network data is transmitted, the data of the transmitting end (the intelligent device 1) passes through the hong-Monte device (the cross-network route), and the source address is automatically switched into the external network IP. When the data arrives at the opposite-end hong Menu device, the destination address is switched to intranet IP again, and finally arrives at the intelligent device 6.
Dynamically updating the iptables rule according to the network topology change to realize dynamic route management;
dynamic route management may be implemented by updating and modifying iptables rules based on network topology and dynamic changes. In this way, the network can be flexibly route-adjusted and optimized according to real-time requirements.
1) When the local area network discovers the corresponding interface up, the cross-network route management module performs network segment automatic mapping,
2) When local area network equipment is on line, mapping and storing records of monitoring ports of single equipment are carried out across network route management module interfaces;
3) When the local area network discovers that the corresponding interface is down, the cross-network route management module deletes the automatic mapping of the network segments;
4) When local area network equipment is off line, deleting single equipment monitoring port mapping and deleting records across a network route management interface;
and evaluating the real-time sending rate and congestion condition of the cross-network link, and carrying out congestion management on the data packets entering and exiting the network based on the priority.
Assessing the real-time transmission rate across the network link specifically includes:
in the first link and the second link, data substreams of different applications are included;
The real-time transmission rate in the link at time point r is calculated according to the following formula:
Wherein Sa (r) represents the real-time transmission rate of the link a at the time point r, τa represents the basic transmission rate of the link a, K E K, K represents the set of all the data transmission substreams on the link a, K represents the kth data transmission substream on the link a, wk represents the weighting factor of the data transmission substream K, and Ek(ra\r) represents the actual transmission rate of the substream K of the link a at other time points except the time point r.
In particular, in step S5, evaluating congestion conditions across network links specifically includes:
congestion risk index of link a at time point rThe calculation mode of (a) is as follows:
where R '∈ra \r, R' represents a certain point in time associated with link a, Ra represents a set of all points in time associated with link a, and Ra \r represents the removal of point in time R in set Ra; Indicating a function, wherein the number of elements used for counting and meeting a certain condition is only 0 or 1, if the condition in a bracket is met, the value of the indicating function is 1, otherwise, 0;uar indicates the bandwidth utilization lower limit of a link a at a time point r; the upper bandwidth utilization limit for link a at point in time r' is indicated.
In step S5, the evaluation of congestion conditions across network links specifically includes:
congestion risk index of link a at time point rThe calculation mode of (a) is as follows:
where R '∈ra \r, R' represents a certain point in time associated with link a, Ra represents a set of all points in time associated with link a, and Ra \r represents the removal of point in time R in set Ra; Indicating a function, wherein the number of elements used for counting and meeting a certain condition is only 0 or 1, if the condition in a bracket is met, the value of the indicating function is 1, otherwise, 0;uar indicates the bandwidth utilization lower limit of a link a at a time point r; the upper bandwidth utilization limit for link a at point in time r' is indicated.
In step S5, the congestion management of the data packet entering and exiting the network based on the priority comprises dividing different application flows into different priorities according to the service type;
When the calculated congestion risk index of the link a exceeds a preset threshold, the transmission rate of the low-priority application flow is reduced and the transmission priority of the high-priority application flow is improved by adjusting the weighting factor wk of the data transmission sub-flow k.
The invention also discloses a device for realizing the cross-network routing in the distributed soft bus, as shown in figure 2, comprising:
The network interface configuration module is used for configuring a network interface on the intelligent terminal, wherein the network interface comprises a local area network virtual network port and a cross-network virtual network port, and the local area network virtual network port is connected with the cross-network virtual network port through a network bridge;
the iptables rule configuration module is used for configuring iptables rules, and the iptables rules are connected with local area network equipment and external network equipment through network segment mapping and equipment mapping;
A data forwarding module, configured to, according to the configured iptables rule,
For a data packet from the local area network device entering from a local area network virtual network port, forwarding the data packet to a first link between a cross-network virtual network port and an external network device for communication;
Forwarding a data packet from the external network equipment entering from a cross-network virtual network port to a second link between the local area network virtual network port and the local area network for communication;
the dynamic route management module is used for dynamically updating the iptables rule of the first link and the second link when the network topology changes;
And the rate and congestion management module is used for evaluating the real-time sending rate and congestion conditions of the first link and the second link and carrying out congestion management on the data packets entering and exiting the local area network virtual network port and the cross-network virtual network port based on the priority.
The solution claimed by the device corresponds to the solution in the previous method embodiment one by one, so that a description thereof is omitted.
In summary, the above embodiments are only preferred embodiments of the present invention, and are not intended to limit the scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
It will be evident to those skilled in the art that the embodiments of the invention are not limited to the details of the foregoing illustrative embodiments, and that the embodiments of the present invention may be embodied in other specific forms without departing from the spirit or essential characteristics thereof. The present embodiments are, therefore, to be considered in all respects as illustrative and not restrictive, the scope of embodiments being indicated by the appended claims rather than by the foregoing description, and all changes which come within the meaning and range of equivalency of the claims are therefore intended to be embraced therein. Any reference sign in a claim should not be construed as limiting the claim concerned. Furthermore, it is evident that the word "comprising" does not exclude other elements or steps, and that the singular does not exclude a plurality. A plurality of units, modules or means recited in a system, means or terminal claim may also be implemented by means of software or hardware by means of one and the same unit, module or means. The terms first, second, etc. are used to denote a name, but not any particular order.
Finally, it should be noted that the above-mentioned embodiments are merely for illustrating the technical solution of the embodiment of the present invention, and not for limiting, and although the embodiment of the present invention has been described in detail with reference to the above-mentioned preferred embodiments, it should be understood by those skilled in the art that modifications and equivalent substitutions can be made to the technical solution of the embodiment of the present invention without departing from the spirit and scope of the technical solution of the embodiment of the present invention.