Disclosure of Invention
The invention provides a network switching method and a terminal, and the method can automatically switch the terminal from a wireless local area network to a mobile network when the terminal cannot access the Internet by using the wireless local area network.
A first aspect of the present invention provides a network switching method, including:
the terminal accesses a wireless local area network;
after the terminal accesses the wireless local area network, the terminal judges whether the wireless local area network can access the Internet or not;
and if the wireless local area network can not access the Internet, the terminal disconnects the wireless local area network and uses a mobile network.
With reference to the first aspect of the present invention, in a first possible implementation manner of the first aspect, before the terminal accesses a wireless local area network, the method includes:
when the terminal uses a mobile network, the terminal detects an accessible wireless local area network.
With reference to the first aspect or the first possible implementation manner of the first aspect, in a second possible implementation manner of the first aspect, the accessing, by the terminal, a wireless local area network includes:
the terminal is connected with the wireless local area network and acquires the routing information of the wireless local area network;
and the terminal sets a default route as the route of the wireless local area network according to the acquired route information of the wireless local area network, so that the terminal is accessed to the wireless local area network.
With reference to the second possible implementation manner of the first aspect of the present invention, in a third possible implementation manner of the first aspect, the setting, by the terminal, a default route to a route of the wireless local area network according to the obtained route information of the wireless local area network specifically includes:
and the terminal sets the default route as the route of the wireless local area network and simultaneously keeps the route of the mobile network in a route table.
With reference to the first aspect of the present invention, in a fourth possible implementation manner of the first aspect, if the wireless local area network cannot access the internet, the disconnecting the wireless local area network and using a mobile network by the terminal includes:
and setting a default route as the route of the mobile network so that the terminal accesses the mobile network.
With reference to the first aspect or any one of the first to fourth possible implementation manners of the first aspect, in a fifth possible implementation manner of the first aspect, after the terminal disconnects the wireless local area network, the method further includes:
and the terminal sets the wireless local area network as a restricted network which forbids automatic access.
With reference to the first aspect or any one of the first to fifth possible implementation manners of the first aspect, in a sixth possible implementation manner of the first aspect, before the terminal accesses the wireless local area network, the method further includes:
when the terminal detects the wireless local area network, judging whether the wireless local area network is a limited network which the terminal forbids automatic access;
and when the wireless local area network is not a limited network which is forbidden to be automatically accessed by the terminal, the terminal accesses the wireless local area network.
A second aspect of the present invention provides a terminal, including:
the access unit is used for accessing a wireless local area network;
the judging unit is used for judging whether the wireless local area network can access the Internet or not after the access unit accesses the wireless local area network;
and the switching unit is used for disconnecting the access unit from the wireless local area network and using a mobile network if the judging unit judges that the wireless local area network can not access the Internet.
With reference to the second aspect of the present invention, in a first possible implementation manner of the second aspect, the terminal further includes:
a detecting unit, configured to detect an accessible wireless local area network when the terminal uses a mobile network before the access unit accesses the wireless local area network.
With reference to the second aspect or the first possible implementation manner of the second aspect, in a second possible implementation manner of the second aspect, the access unit is configured to access a wireless local area network, and includes:
for: connecting the wireless local area network and acquiring the routing information of the wireless local area network; and setting a default route as the route of the wireless local area network according to the acquired route information of the wireless local area network, so that the access unit is accessed to the wireless local area network.
With reference to the second possible implementation manner of the second aspect, in a third possible implementation manner of the second aspect, the setting, by the access unit, a default route as the route of the wireless local area network according to the obtained route information of the wireless local area network includes:
for setting a default route as the route of the wireless local area network while maintaining the route of the mobile network in a routing table.
With reference to the second aspect of the present invention, in a fourth possible implementation manner of the second aspect, the switching unit is configured to disconnect the access unit from the wireless local area network and use a mobile network if the determining unit determines that the wireless local area network cannot access the internet, and includes: for setting a default route as the route of the mobile network such that the access unit accesses the mobile network.
With reference to the second aspect or any one of the first to fourth possible implementation manners of the second aspect, in a fifth possible implementation manner of the second aspect, the access unit is further configured to set the wireless local area network as a restricted network that prohibits automatic access after the handover unit disconnects the terminal from the wireless local area network.
With reference to the second aspect of the present invention or any one of the first to fifth possible implementation manners of the second aspect, in a sixth possible implementation manner of the second aspect, the access unit is further configured to determine, when the detection unit detects the wireless local area network, whether the wireless local area network is a restricted network to which the terminal prohibits automatic access, and, when the wireless local area network is not the restricted network to which the terminal prohibits automatic access, access the access unit to the wireless local area network.
In the invention, the terminal can judge whether the accessed wireless local area network can access the Internet, and if the wireless local area network cannot access the Internet, the mobile network can be switched from the wireless local area network, so that the network smoothness of the terminal can be kept, the interruption of data service is avoided, and the user experience is improved.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
As shown in fig. 1, embodiment 1 of the present invention provides a method for network handover, including:
101. the terminal accesses the wireless local area network.
The terminal can be a mobile phone, a tablet computer or other mobile terminals. The terminal can access the wireless local area network when using the mobile network. For example, when the terminal uses the mobile network to process services, and detects that a wireless local area network is around, the terminal can access the wireless local area network.
102. After the terminal accesses a wireless local area network, the terminal judges whether the wireless local area network can access the Internet.
For example, the terminal resolves the domain name through the DNS, and determines that the wireless lan can access the internet if the corresponding IP address can be obtained, and determines that the wireless lan cannot access the internet if the corresponding IP address cannot be obtained. Or, connecting a website by using the ping function, if a response is received, judging that the wireless local area network can access the internet, and if no response is received, judging that the wireless local area network cannot access the internet. Or the terminal judges whether the http request is redirected, if so, judges that the internet can be accessed through the wireless local area network, and if not, judges that the internet cannot be accessed through the wireless local area network. The terminal can also receive a notice sent by the network side, and judge whether the wireless local area network can access the internet according to the notice. For example, when the terminal receives a notification indicating that the wireless lan can access the internet from the network side, it is determined that the wireless lan can access the internet, and when the terminal receives a notification indicating that the terminal is denied access from the network side, it is determined that the wireless lan cannot access the internet.
103. And if the wireless local area network can not access the Internet, the terminal disconnects the wireless local area network and uses a mobile network.
The mobile network may comprise an LTE, 3G or 2G network, etc.
By applying the method of the embodiment, when the terminal can not access the internet through the wireless local area network, the terminal can automatically switch back to the mobile network from the wireless local area network, so that the network smoothness of the terminal is kept.
In order to more clearly describe the present invention, the following examples are given.
As shown in fig. 2, embodiment 2 of the present invention provides a method for network handover, including:
201. the terminal detects whether a wireless local area network exists around.
For example, the terminal accesses the internet using a mobile network while detecting whether a wireless local area network exists around.
202. When the terminal detects the wireless local area network, whether the detected wireless local area network is a limited network which the terminal forbids automatic access is judged.
Specifically, a user or a system may set a list of restricted networks in a terminal, traverse a wireless local area network recorded in the list of restricted networks when the terminal detects the wireless local area network, determine that the detected wireless local area network is not a restricted network to which the terminal prohibits automatic access if the detected wireless local area network is not in the list of restricted networks, and determine that the detected wireless local area network is a restricted network to which the terminal prohibits automatic access if the detected wireless local area network is in the list of restricted networks.
If the detected wireless lan is a restricted network to which the terminal prohibits automatic access, step 202 is executed to step 209.
If it is determined in step 202 that the detected wireless local area network is not a restricted network to which the terminal prohibits automatic access, step 203 is executed.
203. The terminal is connected with the wireless local area network and acquires the routing information of the wireless local area network.
Specifically, when it is determined that the detected wireless local area network is not a restricted network to which the terminal prohibits automatic access, the terminal may prompt the user to connect to the wireless local area network, and after the user manually connects the terminal to the wireless local area network, the terminal successfully connects to the wireless local area network, and adds routing information of the wireless local area network to the routing table. The terminal may also automatically connect to the wireless local area network when it is determined that the detected wireless local area network is not a restricted network to which the terminal prohibits automatic access, and add routing information of the wireless local area network to the routing table. If there are multiple wlan scenarios, the terminal may provide the user with a wlan list including all detected wlans that can be used for connection, so that the user can select the desired wlan.
204. And setting a default route as the route of the wireless local area network according to the acquired route information of the wireless local area network, so that the terminal is accessed to the wireless local area network.
In step 204, the terminal sets the default route as the route of the wireless local area network, and simultaneously, keeps the route of the mobile network in a route table, and automatically accesses the wireless local area network. The terminal reserves the route of the mobile network in the route table, so the terminal can access the mobile network by using the route of the mobile network at any time.
205. The terminal judges whether the wireless local area network can access the internet.
If the terminal determines that the wireless lan can access the internet, step 206 is executed.
If the terminal determines that the wireless lan cannot access the internet, step 207 is executed.
206. The terminal accesses the internet using a wireless local area network.
207. And setting a default route as the route of the mobile network, so that the terminal is accessed into the mobile network and simultaneously is disconnected from the wireless local area network.
208. And setting the disconnected wireless local area network as a restricted network.
Specifically, when the terminal disconnects the wireless local area network, the wireless local area network is added to the list of the limited network, so that the terminal is prevented from automatically connecting the wireless local area network incapable of accessing the internet again.
209. The internet is accessed using a mobile network.
The steps of embodiment 2 are executed, so that the terminal can be switched to the mobile network in time when the wireless local area network cannot access the internet. Because the time required for the terminal to switch the route and detect the wireless local area network is very short, the ongoing data service of the terminal can be ensured not to be interrupted, and the smoothness of the network can be kept.
As shown in fig. 3, in this embodiment 2, after the terminal connects to the wireless lan and acquires the routing information of the wireless lan in step 203, step 210 may also be performed.
210. And judging whether the wireless local area network is an exceptional network or not.
The exception network is a network that allows the terminal to automatically access, and the terminal directly disconnects the mobile network after automatically accessing the network. The user or the system can set an exception network table in the terminal, the exception network table contains information of the exception network, when the wireless local area network is judged to be the exception network, the exception network table can be traversed, if the wireless local area network is not in the exception network table, the wireless local area network is judged not to be the exception network, and if the wireless local area network is in the exception network table, the wireless local area network is judged to be the exception network.
When the wlan is determined to belong to the exception network, go to step 211; when the wlan is determined not to belong to the exception network, step 212 is executed.
211. And the terminal disconnects the mobile network and sets the default route as the wireless local area network.
212. The terminal judges whether to access the network manually.
When it is determined that manual access to the network is required, step 213 is performed.
When it is determined that manual access to the network is not required, step 204 is performed.
213. And prompting the user to perform the operation of manually accessing the wireless local area network.
As shown in steps 210 to 213, when the wlan is an exceptional network or needs to be manually accessed, the terminal may directly disconnect the mobile network, and set the default route as the route of the wlan, without continuing additional execution steps.
As shown in fig. 4, embodiment 3 of the present invention provides a terminal 304, including:
an access unit 301, configured to access a wireless local area network;
a determining unit 302, configured to determine whether the wireless local area network can access the internet after the access unit 301 accesses the wireless local area network;
a switching unit 303, configured to disconnect the access unit 301 from the wireless local area network and use a mobile network if the determining unit 302 determines that the wireless local area network cannot access the internet.
The terminal provided by the embodiment can automatically switch from the wireless local area network to the mobile network when the terminal cannot access the internet through the wireless local area network, so that the network of the terminal is kept smooth.
As shown in fig. 5, embodiment 4 of the present invention provides a terminal 404, including:
an access unit 401, configured to access a wireless local area network;
a determining unit 402, configured to determine whether the wireless local area network can access the internet after the accessing unit 401 accesses the wireless local area network;
a switching unit 403, configured to disconnect the access unit 401 from the wireless local area network and use a mobile network if the determining unit 402 determines that the wireless local area network cannot access the internet.
A detecting unit 405, configured to detect an accessible wireless local area network when the terminal uses a mobile network before the accessing unit 401 accesses the terminal to the wireless local area network.
Preferably, the accessing unit 401 is configured to access the terminal 404 to a wireless local area network, and includes:
for: connecting the wireless local area network and acquiring the routing information of the wireless local area network; and setting a default route as the route of the wireless local area network according to the acquired route information of the wireless local area network, so that the access unit 401 accesses the wireless local area network.
Preferably, the accessing unit 401 is configured to set a default route as the route of the wireless local area network according to the obtained route information of the wireless local area network, and includes:
for setting a default route as the route of the wireless local area network while maintaining the route of the mobile network in a routing table.
Preferably, the switching unit 403 is configured to disconnect the access unit 401 from the wireless local area network and use a mobile network if the determining unit 402 determines that the wireless local area network cannot access the internet, and includes: for setting a default route as the route of the mobile network so that the access unit 401 accesses the mobile network.
Preferably, the access unit 401 is further configured to set the wireless local area network as a restricted network that prohibits automatic access after the switching unit 403 disconnects the access unit 401 from the wireless local area network.
Preferably, the accessing unit 401 is further configured to determine, when the detecting unit 405 detects the wireless local area network, whether the wireless local area network is a restricted network to which the terminal 404 prohibits automatic access, and access the wireless local area network when the wireless local area network is not the restricted network to which the terminal 404 prohibits automatic access.
As shown in fig. 6, embodiment 5 of the present invention provides a terminal 501, including:
a transceiver 502 for accessing a wireless local area network;
the processor 503 is connected to the transceiver 502, and is configured to determine whether the wireless local area network can access the internet after the transceiver 502 accesses the wireless local area network;
the transceiver 502 is further configured to disconnect the transceiver 502 from the wlan and use a mobile network if the processor 503 determines that the wlan cannot access the internet.
Preferably, the transceiver 502 is further configured to detect an accessible wireless local area network when a mobile network is used before accessing the wireless local area network.
Preferably, the accessing of the terminal 501 to the wireless local area network includes:
the transceiver 502 is connected to the wlan, and obtains routing information of the wlan;
the processor 503 sets a default route as the route of the wireless local area network according to the route information of the wireless local area network acquired by the transceiver 502, so that the transceiver 502 accesses the wireless local area network.
Preferably, the setting, by the processor 503, a default route to the route of the wireless local area network according to the route information of the wireless local area network acquired by the transceiver 502 specifically includes:
the processor 503 is configured to set a default route as the route of the wireless local area network, and maintain the route of the mobile network in a routing table.
Preferably, the processor 503 is configured to set a default route as the route of the mobile network if the wireless local area network cannot access the internet, so that the transceiver 502 accesses the mobile network.
Preferably, the processor 503 is further configured to set the wireless local area network as a restricted network that prohibits automatic access after the transceiver 502 is disconnected from the wireless local area network.
Preferably, the processor 503 is further configured to determine, before the transceiver 502 accesses the wireless local area network, whether the wireless local area network is a restricted network to which the terminal 501 prohibits automatic access when the transceiver 502 detects the wireless local area network;
the transceiver 502 is further configured to access the wireless local area network when the wireless local area network is not a restricted network to which the terminal 501 prohibits automatic access.
In a specific implementation, the present invention further provides a computer storage medium, where the computer storage medium may store a program, and when the program is executed, the computer storage medium may include some or all of the steps in each embodiment of the switch configuration method based on virtual networking provided by the present invention. The storage medium may be a magnetic disk, an optical disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), or the like.
The method and terminal for network handover provided by the embodiment of the present invention are described in detail above, and a specific example is applied in the description to explain the principle and the embodiment of the present invention, and the description of the above embodiment is only used to help understanding the method and the core idea of the present invention; meanwhile, for a person skilled in the art, according to the idea of the present invention, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present invention.