A kind of method for switching network
Technical field
The present invention relates to a kind of method for switching network.
Background technology
Along with the day by day expansion of people to data traffic requirement, and cable network is universal, current, operator is in providing the wide area Access Network services such as 2G/3G/LTE/4G, also start to lay on a large scale WIFI network, be intended to guide user to carry out data service by WIFI network, thereby slow down the pressure of wide area Access Network.In addition, 3G network and cable network respectively have its pluses and minuses, and 3G networks and has good region coverage property, and mobility is good, but rate are higher; Cable network signal is stable, and speed is fast not as good as 3G network, also accessible cable network of the accessible 3G network of user.
Summary of the invention
In view of the above-mentioned problems in the prior art, main purpose of the present invention is to address the deficiencies of the prior art, the method for switching network that a kind of real time monitoring network connection status is provided and switches flexibly between 3G network pattern and wan mouth pattern.
The invention provides a kind of method for switching network, comprise the following steps: S1: after access 3G network pattern, whether timing detects pppoe server and is communicated with, if continuous the detection all for five times of described pppoe server is communicated with, described pppoe server is up state S2: in the time monitoring described pppoe server and be up state, network automatically switches to pppoe network schemer and connects; S3: after access wan mouth network schemer, whether the next timing of form that adopts ping to wrap detects 3G network and be communicated with, and ping once wrapped in every five minutes, and once comprised five bags, more than bag thought that this ping wraps unsuccessfully if lose 2, otherwise success; S4: after continuous 5 ping wrap unsuccessfully, described 3G network is in up state not, and network is switched to wan mouth pattern and connects.
Optionally, in described step S1, detecting the concrete steps whether described pppoe server be communicated with is: by Ethernet, send specific padi broadcast packet, if there is pppoe server to receive padi bag, can return to corresponding pado bag, program counter adds 1; If there is each time pado bag to return in the padi broadcast packet of continuous five times, counter is added to after 5, and network connection automatically switches into wan mouth pattern and connects; If pado broadcast packet in the padi broadcast packet of continuous five times once does not return, described counter carries out zero clearing, continues to send specific padi broadcast packet.
The present invention has the following advantages and beneficial effect: the present invention can real time monitoring network connection status,
Accompanying drawing explanation
Fig. 1 is the FB(flow block) of the method for switching network of the embodiment of the present invention.
Embodiment
The present invention is further illustrated with specific embodiment below with reference to accompanying drawings.
As shown in Figure 1: a kind of method for switching network of the embodiment of the present invention, comprises the following steps:
Si: after access 3G network pattern, whether timing detects pppoe server and be communicated with, if continuous the detection all for five times of described pppoe server is communicated with, described pppoe server is up state;
S2: in the time monitoring described pppoe server and be up state, network automatically switches to pppoe network schemer and connects;
S3: after access wan mouth network schemer, whether the next timing of form that adopts ping to wrap detects 3G network and be communicated with, and ping once wrapped in every five minutes, and once comprised five bags, more than bag thought that this ping wraps unsuccessfully if lose 2, otherwise success;
S4: after continuous 5 ping wrap unsuccessfully, described 3G network is in up state not, and network is switched to wan mouth pattern and connects.
As the preferred implementation of above-described embodiment, in described step S1, detect the concrete steps whether described pppoe server be communicated with and be:
By Ethernet, send specific padi broadcast packet, if there is pppoe server to receive padi bag, can return to corresponding pado bag, program counter adds 1;
If there is each time pado bag to return in the padi broadcast packet of continuous five times, counter is added to after 5, and network connection automatically switches into wan mouth pattern and connects;
If pado broadcast packet in the padi broadcast packet of continuous five times once does not return, described counter carries out zero clearing, continues to send specific padi broadcast packet.
Finally it should be noted that: above-described each embodiment, only for technical scheme of the present invention is described, is not intended to limit; Although the present invention is had been described in detail with reference to previous embodiment, those of ordinary skill in the art is to be understood that: its technical scheme that still can record previous embodiment is modified, or to wherein partly or entirely technical characterictic be equal to replacement; And these modifications or replacement do not make the essence of appropriate technical solution depart from the scope of various embodiments of the present invention technical scheme.