Disclosure of Invention
The invention aims to realize multi-link network aggregation by installing APP on an android system. The technical scheme adopted by the invention is as follows:
the invention provides a multi-link network aggregation method based on an android system, which comprises the following steps:
acquiring IP states of all network ports, and circularly acquiring IP information of all network ports;
generating a virtual network port tun0 and modifying a routing table;
acquiring a data packet by the aggregation client terminal program, and processing the data packet according to the IP states of all the network ports;
the aggregation client terminal program judges the link communication quality according to the IP information of all network ports acquired in a circulating way;
the aggregate client sub-program allocates the processed data packets to different communication links based on link communication quality.
Further, the step of circularly acquiring the IP information of all the network ports includes: if the IP of the mobile network is cleared by the android system, the cleared IP of the mobile network is automatically recovered.
Further, the step of generating the virtual network port tun0 and modifying the routing table includes:
creating a VPN class, wherein the VPN class inherits the VpnService of the android system;
setting special route and modifying route table in Kernel layer.
Further, the step of determining the link communication quality by the aggregation client sub-program according to the IP information of all the network ports acquired in a circulating manner includes:
transmitting a bandwidth monitoring packet to an aggregation server, and recording the transmission bandwidth of each communication link;
receiving the receiving bandwidth of each communication link, and determining the bandwidth change rate of each communication link according to the sending bandwidth and the receiving bandwidth;
and determining the link for transmitting the data packet according to the bandwidth change rate of each communication link.
Further, the step of the aggregation client sub-program distributing the processed data packets to different communication links according to the link communication quality includes sending data to and receiving data from the external network; the step of transmitting data to the external network comprises:
the application layer sends out unprocessed data packets;
the data packet is guided to a virtual network port tun0 after passing through a Framework layer and a HAL layer;
the virtual network port tun0 sends the data packet to an aggregation program, and the aggregation program carries out slicing processing on the processed data packet;
the aggregation client terminal program transmits the data packet after slicing to an aggregation server through a real link;
and the aggregation server performs packet grouping processing on the data packets subjected to the slicing processing.
Further, the step of receiving data from the external network includes:
the aggregation client subprogram transmits the external network data to the aggregation program through a real link;
the aggregation client subprogram packs the data;
the aggregation client terminal program sends the data packet after being packaged to the virtual network port tun0;
the virtual network port tun0 sends the data packet after being packetized to an application layer; the packet passes through the frame layer and the HAL layer before being directed to the virtual network port tun 0.
Further, the IP states of all the ports include a communication link IP state, an aggregation server IP state, and an IP state of the virtual port tun 0.
Further, the communication link includes: 2G network, 3G network, 4G network, 5G network, 2.4GWiFi, 5GWiFi, wired network.
In another aspect, the present invention further provides a computer apparatus, which is characterized by comprising a memory and a processor, wherein the memory is used for storing at least one program, and the processor is used for loading the at least one program to execute any of the android system-based multilink network aggregation methods.
In another aspect, the present invention further provides a computer readable storage medium, in which a program executable by a processor is stored, wherein the program executable by the processor is configured to perform any one of the android system-based multilink network aggregation methods when executed by the processor.
The beneficial effects of the invention are as follows: when the mobile phone is in a high-bandwidth application scene, such as live broadcast or downloading of a large file, the uplink and downlink rates of the mobile phone can be obviously improved, the effect of link bandwidth superposition is achieved, and the loads are reasonably distributed to different links according to the real-time condition of the network, so that the stability of the mobile phone network is improved.
Detailed Description
The present application is further described below with reference to the drawings and specific examples. The described embodiments should not be construed as limitations on the present application, and all other embodiments, which may be made by those of ordinary skill in the art without the exercise of inventive faculty, are intended to be within the scope of the present application.
In the following description, reference is made to "some embodiments" which describe a subset of all possible embodiments, but it is to be understood that "some embodiments" can be the same subset or different subsets of all possible embodiments and can be combined with one another without conflict.
Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing embodiments of the present application only and is not intended to be limiting of the present application.
At present, there are three main ways of surfing the internet on the android system, one is through a mobile cellular network (through a 2G/3G/4G/5G module), one is through a WiFi network (through a WiFi chip with a 2.4G/5G frequency band), and the other is through a wired network (the device itself is provided with a wired network port or is converted into a wired network port through an external type pc-c/micro-usb). The android system has a set of grading mechanism defined officially for the network, and the system can select the network with the highest current grading as the system network according to the current network condition. In general, the wired network scores highest, second to WiFi, and last to the mobile cellular network. At the same time, the android system can only select one network to be connected to the Internet, and multilink concurrency cannot be achieved. If the mobile phone browses the webpage and is connected with the WiFi, the system automatically switches the network from 'mobile data' to the WiFi.
At present, the multi-network acceleration function on domestic mobile phones cannot be realized by overlapping bandwidths. Only one of the mobile network/WiFi/wired network can be used at the same time, and only when the currently used network is not good, the other network on the mobile phone is replaced, and the acceleration of bandwidth superposition in the real sense is not realized, and no link superposition is seen through the verification of the mobile phone speed measurement.
The existing aggregation technology does not find that link aggregation is realized by installing APP (application) on a native android system.
The embodiment of the invention mainly solves the problems that: and realizing multi-link network aggregation by installing the APP on the android system. When the mobile phone is in a high-bandwidth application scene, such as live broadcast or downloading of a large file, the uplink and downlink rates of the mobile phone can be obviously improved, the effect of link bandwidth superposition is achieved, and the loads are reasonably distributed to different links according to the real-time condition of the network, so that the stability of the mobile phone network is improved.
The multi-link aggregation can use two or more of 2G/3G/4G/5G networks, wiFi and wired networks at the same time to realize multi-link network aggregation, and the multi-link aggregation is particularly characterized in that the uplink bandwidth and the downlink bandwidth of the networks have the superposition effect.
In the embodiment of the invention, the subroutine part of the aggregation APP is obtained by modifying based on/inheriting the VpnService class provided by the android SDK.
The interaction between the data packet of the common android APP and the external network is that the flow direction of the data packet comprises:
when a data packet is sent out from the application layer: an application layer- > -a Framework layer- > -a HAL layer- > -a Kernel layer- > -a real portal- > -an external network;
when the application layer receives the external network data: external network- > real portal- > Kernel layer- > HAL layer- > frame layer- > application layer.
After the VpnService is started, the android system generates a virtual network port tun, a routing rule is set in a Kernel layer, and data originally reaching a real network port is guided to the virtual network port device tun. The program processes the data from the tun port in the Framework layer and then transmits the data to the actual network port for sending. The link of the application layer receiving data is similar, after the processing is performed on the frame layer, the data is guided to the tun port by the kernel layer, and finally the data is transmitted to the application layer. After VpnService is turned on, the flow direction of the data packet is changed to:
when a data packet is sent out from the application layer: an application layer- > -a frame layer- > -a HAL layer- > -a Kernel layer- > -a virtual portal (tun) - > -a HAL layer- > -a frame layer (VPN program process) - > -a HAL layer- > -a Kernel layer- > -an actual portal- > -an external network;
when the application layer receives the external network data: external network- > actual network port- > Kernel layer- > HAL layer- > frame work layer (VPN program process) - > HAL layer- > Kernel layer- > virtual network port (tun) - > Kernel layer- > HAL layer- > frame work layer- > application layer.
The following are practical operation steps in the embodiment of the present invention:
s1, acquiring IP states of all network ports. And circularly acquiring the IP information of all the network ports. After connecting with WiFi, if the IP of the mobile network is cleared by the android system, automatically recovering the IP;
s2, creating a VPN class, and inheriting from the VpnService;
s3, setting special routes in the class of the step 2, so that the IP of the aggregation server does not leave a turn port;
s4, packaging the aggregation algorithm into an aggregation library for the call of an aggregation program;
s5, transmitting the IP of a real link (a mobile network port/WiFi/network port) and the IP of a tun port to be created by VpnService and the IP of an aggregation server as parameters to an aggregation library for an aggregation program to call;
s6, configuring a route between a tun0 (virtual network port generated by a VPN subprogram) and a real link (mobile network port/WiFi/network port) in the VPN class, and when the ip of the link changes, immediately updating the route and transmitting parameters to an aggregation program;
s7, configuring an interface, and adding necessary basic functional controls such as 'start aggregation' and 'stop aggregation' on the UI. Associating the control with the aggregation subprogram at the back end, so as to start and stop the aggregation program on the interface;
s8, compiling to generate an APK package.
In the embodiment of the invention, after the polymerization APP is started, the VpnService is started, and the main function of the method is that a virtual network port tun0 is generated; modifying a routing table positioned in the Kernel layer, and streaming the data of the application layer to tun0; the data will be processed at the frame layer.
The network flow direction of the APP data transmission in the embodiment of the invention is shown in fig. 1, and the network flow direction of the APP data reception in the embodiment of the invention is shown in fig. 2. By utilizing the technical scheme provided by the embodiment of the invention, after APP data are sent to the Kernel layer, the APP data are guided to a tun port and then are processed by an aggregation program of the frame work layer, and the APP data are sent to a plurality of real links after being processed; according to the technical scheme, data received from an external real link is processed by an aggregation program of a frame work layer, is guided to a tun port by a kernel layer after being processed, and is then sent to an APP of an application layer.
In the embodiment of the present invention, the idea of setting the virtual route tun0 port route is as follows: assuming that all network IP addresses are set a, the IP of the aggregation server is set B, and the set of IP without aggregation server is A1. A1 and B together are set A, and
the set A1 is made up of a plurality of subsets, the known IP address is converted into a 2-ary 32-bit system, i.e. A1 can consist of 32 subsets, each of which subset and B are +.>
What is currently done is to find the set A1 and then add the IP of A1 to the route.
The route setting method comprises the following steps:
converting the aggregate server IP to a 2-ary, e.g., the aggregate server IP (e.g., 39.108.117.187) to a 2-ary is:
0010 0111 0110 1100 0111 0101 1011 1011
the most significant bit of the aggregation server IP is inverted, and the other positions are 0, denoted as ip_1, namely:
1000 0000 0000 0000 0000 0000 0000 0000
the corresponding mask number is 1 bit; inverting the next highest order of the aggregation server ip, and taking 0 from the third highest order to the last position, denoted as ip_2, for example:
0100 0000 0000 0000 0000 0000 0000 0000
its corresponding mask number is 2 bits; and so on, find out the 32 ips of ip_1 through ip_32 and record their corresponding masks. The 32 "ips and their corresponding masks" are added to the route one by one.
The technical scheme provided by the embodiment of the invention has the following actual measurement effects in reality: after the aggregation App is started on the android mobile phone, the android mobile phone can normally surf the Internet, browse the webpage and watch the video. The bandwidths of the links can be effectively overlapped by testing with a speed measuring website or speed measuring software, such as speedtest, iperf. When the mobile phone only has a mobile network, the aggregation App is started, so that the mobile phone can normally surf the Internet, but no superposition effect exists; and then connecting WiFi, enabling the aggregation App to automatically add the WiFi link into the aggregation link, and measuring the speed again in the environment, wherein the bandwidth has obvious superposition effect.
While the preferred embodiments of the present invention have been described in detail, the invention is not limited to the embodiments, and various equivalent modifications and substitutions can be made by one skilled in the art without departing from the spirit of the invention, and these modifications and substitutions are intended to be included within the scope of the present invention as defined in the appended claims.