TECHNICAL FIELD

Embodiments of the present disclosure relate to the communications field, and more specifically, to a method for data transmission based on a plurality of types of networks, and a related device.

BACKGROUND

With the development of the mobile internet, an electronic device may access a fixed network using a wireless network, such as a WI-FI network and a mobile network, and then perform data transmission with a peer device to obtain various services. Quality of the wireless network has great impact on service experience. However, transmission quality of the wireless network is usually unstable. In order to provide better experience for a user, switching between the WI-FI network and the mobile network can be performed based on a signal strength in other approaches, to ensure better data transmission. For example, when a strength of a WI-FI signal is lower than a particular specified threshold, switching to the mobile network is performed for data transmission. However, when respective signal strengths of the WI-FI network and the mobile network are not good, transmission quality cannot be improved through switching between the WI-FI network and the mobile network, and a “ping-pong effect”, namely, frequent switching between the WI-FI network and the mobile network, may occur, increasing power consumption of a device.

SUMMARY

Embodiments of this application provide a network switching method, a system on chip (SOC), and an electronic device, to improve user experience and reduce unnecessary switching overheads in a scenario of transmitting data based on a plurality of types of wireless networks.

To achieve the foregoing objectives of the present disclosure, according to a first aspect, an embodiment of this application provides a network switching method, where the method includes transmitting, by an electronic device, data using a wireless local area network, when a data transmission delay of the wireless local area network is greater than a first threshold, switching, by the electronic device, to transmitting data using both the wireless local area network and a mobile network, and when the electronic device transmits data using both the wireless local area network and the mobile network, if the data transmission delay of the wireless local area network is greater than a second threshold, switching, by the electronic device, to transmitting data using the mobile network, where the first threshold is less than the second threshold.

The data transmission delay may be specifically a round-trip time (RTT) or a jitter parameter of a delay (reflecting a status of delay fluctuation). When the data transmission delay of the wireless local area network is greater than the first threshold, it indicates that a delay of transmitting a data packet of an application using the wireless local area network is lower than a delay threshold of optimal user experience. In this case, on the basis of establishing a mobile network connection, the electronic device switches to transmitting data using both the wireless local area network and the mobile network. Transmitting data using both the wireless local area network and the mobile network means that a data packet is redundantly sent on respective paths of the wireless local area network and the mobile network. A same data packet is transmitted on both paths of the wireless local area network and the mobile network. Different from switching between two states, namely, the mobile network and the wireless local area network when a preset threshold is reached in other approaches, according to the network switching method provided in this embodiment of this application, two thresholds are set for the data transmission delay, to implement switching of three network states the mobile network, the mobile network and the wireless local area network, and the wireless local area network. When the data transmission delay of the wireless local area network gradually increases, and a data transmission effect is poor, switching to a state of transmitting data using both the wireless local area network and the mobile network may be performed, to avoid unnecessary switching overheads caused by poor data transmission quality of both the mobile network and the wireless local area network, and ensure use experience of a user. In addition, when the electronic device transmits data using both the wireless local area network and the mobile network, if data transmission quality of either of the wireless local area network and the mobile network improves, switching to this network may be performed. Such a flexible network switching method can ensure data transmission quality, improve user experience, and reduce unnecessary overheads.

In a possible implementation, the method further includes, when the electronic device transmits data using the mobile network, if it is detected that the data transmission delay of the wireless local area network is greater than the first threshold, and a data transmission delay of the mobile network is greater than the first threshold, switching, by the electronic device, to transmitting data using both the wireless local area network and the mobile network.

In a possible implementation, the method further includes, when the electronic device transmits data using the mobile network, if it is detected that the data transmission delay of the wireless local area network is less than the first threshold, switching, by the electronic device, to transmitting data using the wireless local area network.

In a possible implementation, the method further includes, when the electronic device transmits data using the mobile network, detecting the data transmission delay of the wireless local area network. Specifically, the data transmission delay of the wireless local area network may be periodically detected.

In a possible implementation, after the electronic device switches to transmitting data using both the wireless local area network and the mobile network, when the electronic device transmits data using both the wireless local area network and the mobile network, the method further includes, if the data transmission delay of the wireless local area network is less than the first threshold, switching, by the electronic device, to transmitting data using the wireless local area network.

In a possible implementation, the method further includes, when the electronic device transmits data using both the wireless local area network and the mobile network, if the data transmission delay of the wireless local area network is greater than the second threshold, and a data transmission delay of the mobile network is less than the second threshold, switching, by the electronic device, to transmitting data using the mobile network.

In a possible implementation, when the electronic device transmits data using both the wireless local area network and the mobile network, the method further includes, if the data transmission delay of the wireless local area network is greater than the first threshold and less than the second threshold, and a data transmission delay of the mobile network is less than the first threshold, switching, by the electronic device, to transmitting data using the mobile network.

In a possible implementation, the detecting the data transmission delay of the wireless local area network includes transmitting a probe message using the wireless local area network, receiving a response message corresponding to the probe message, and determining the data transmission delay of the wireless local area network based on a sending time of the probe message and a receiving time of the response message.

In a possible implementation, the data transmitted by the electronic device includes a data packet of a first application, and the data transmission delay is a delay of transmitting the data packet of the first application. The data transmission delay is a delay of transmitting a data packet of each application or each type of application.

In a possible implementation, the first threshold and the second threshold are preconfigured for the first application.

In a possible implementation, the method further includes, when data is transmitted using the mobile network, if it is detected that the data transmission delay of the wireless local area network is greater than the second threshold, and a data transmission delay of the mobile network is greater than the first threshold and less than the second threshold, transmitting, by the electronic device, the data packet of the application still using the mobile network.

In a possible implementation, the method further includes, when data is transmitted using the mobile network, if it is detected that the data transmission delay of the wireless local area network is greater than the first threshold, and a data transmission delay of the mobile network is less than the first threshold, transmitting, by the electronic device, data still using the mobile network.

In a possible implementation, the method further includes, after the terminal switches to transmitting data using both the wireless local area network and the mobile network, when the electronic device transmits data using both the wireless local area network and the mobile network, if the data transmission delay of the wireless local area network is greater than the first threshold, and a data transmission delay of the mobile network is greater than the first threshold, transmitting, by the electronic device, data still using both the wireless local area network and the mobile network.

In a possible implementation, the method further includes, when the electronic device transmits data using the wireless local area network, if the data transmission delay of the wireless local area network is less than the first threshold, transmitting, by the electronic device, data still using the wireless local area network.

In a possible implementation, the transmitted data packet includes a first header, and the first header carries a sending timestamp of the data packet. A data transmission delay of the data packet is a time difference between a receiving timestamp of a response message of the data packet and the sending timestamp of the data packet.

In a possible implementation, the method further includes modifying, by the electronic device, a value of a maximum segment size (MSS), where a modified value of the MSS is less than or equal to a difference between a fragment length limit and a length of the first header.

According to the network switching method provided in this embodiment of this application, a to-be-switched-to network may be selected based on changes of data transmission delays of networks, to switch to the network that can provide better data transmission quality to improve user experience. In addition, setting two thresholds for a same parameter of different applications makes the network switching method more flexible, to better adapt to a change of a network environment.

According to a second aspect, an embodiment of this application provides an electronic device, and the electronic device includes a scheduling module, and a wireless local area network transmission module and a mobile network transmission module that are configured to transmit data, where the scheduling module is configured to, when a data transmission delay of the wireless local area network transmission module is greater than a first threshold, switch to transmitting data using both the wireless local area network transmission module and the mobile network transmission module, and when data is transmitted using both the wireless local area network transmission module and the mobile network transmission module, if the data transmission delay of the wireless local area network transmission module is greater than a second threshold, switch to transmitting data using the mobile network transmission module, where the first threshold is less than the second threshold.

In a possible implementation, the scheduling module is further configured to, when data is transmitted using the mobile network transmission module, if it is detected that the data transmission delay of the wireless local area network transmission module is greater than the first threshold, and a data transmission delay of the mobile network transmission module is greater than the first threshold, switch to transmitting data using both the wireless local area network transmission module and the mobile network transmission module.

In a possible implementation, the scheduling module is further configured to, when data is transmitted using the mobile network transmission module, if it is detected that the data transmission delay of the wireless local area network transmission module is less than the first threshold, switch to transmitting data using the wireless local area network transmission module.

In a possible implementation, the scheduling module is further configured to, when data is transmitted using the mobile network transmission module, detect the data transmission delay of the wireless local area network transmission module.

In a possible implementation, the scheduling module is configured to, when data is transmitted using both the wireless local area network transmission module and the mobile network transmission module, if the data transmission delay of the wireless local area network transmission module is less than the first threshold, switch to transmitting data using the wireless local area network transmission module.

In a possible implementation, the scheduling module is configured to, when data is transmitted using both the wireless local area network transmission module and the mobile network transmission module, if the data transmission delay of the wireless local area network transmission module is greater than the second threshold, and a data transmission delay of the mobile network transmission module is less than the second threshold, switch to transmitting data using the mobile network transmission module.

In a possible implementation, the scheduling module is configured to, when data is transmitted using both the wireless local area network transmission module and the mobile network transmission module, if the data transmission delay of the wireless local area network transmission module is greater than the first threshold and less than the second threshold, and a data transmission delay of the mobile network transmission module is less than the first threshold, switch to transmitting data using the mobile network transmission module.

In a possible implementation, the wireless local area network transmission module is further configured to receive a response message corresponding to a probe message, and the scheduling module is further configured to transmit the probe message using the wireless local area network transmission module, and determine the data transmission delay of the wireless local area network based on a sending time of the probe message and a receiving time of the response message.

In a possible implementation, the transmitted data includes a data packet of a first application, and the data transmission delay is a delay of transmitting the data packet of the first application.

In a possible implementation, the first threshold and the second threshold are preconfigured for the first application.

According to a third aspect, an embodiment of this application provides a SOC, and the SOC includes an application processor, and a modem and a WI-FI module that are configured to transmit data, where the application processor is configured to, when a data transmission delay of the WI-FI module is greater than a first threshold, switch to transmitting data using both the WI-FI module and the modem, and when data is transmitted using both the WI-FI module and the modem, if the data transmission delay of the WI-FI module is greater than a second threshold, switch to transmitting data using the modem, where the first threshold is less than the second threshold.

In a possible implementation, the application processor is further configured to, when data is transmitted using the modem, if it is detected that the data transmission delay of the WI-FI module is greater than the first threshold, and a data transmission delay of the modem is greater than the first threshold, switch to transmitting data using both the WI-FI module and the modem.

In a possible implementation, the application processor is further configured to, when data is transmitted using the modem, if it is detected that the data transmission delay of the WI-FI module is less than the first threshold, switch to transmitting data using the WI-FI module.

In a possible implementation, the application processor is further configured to, when data is transmitted using the modem, detect the data transmission delay of the WI-FI module.

In a possible implementation, the application processor is further configured to, when data is transmitted using both the WI-FI module and the modem, if the data transmission delay of the WI-FI module is less than the first threshold, switch to transmitting data using the WI-FI module.

In a possible implementation, the application processor is further configured to, when data is transmitted using both the WI-FI module and the modem, if the data transmission delay of the WI-FI module is greater than the second threshold, and a data transmission delay of the modem is less than the second threshold, switch to transmitting data using the modem.

In a possible implementation, the application processor is further configured to, when data is transmitted using both the WI-FI module and the modem, if the data transmission delay of the WI-FI module is greater than the first threshold and less than the second threshold, and a data transmission delay of the modem is less than the first threshold, switch to transmitting data using the modem.

In a possible implementation, the WI-FI module is further configured to receive a response message corresponding to the probe message, and the application processor is further configured to transmit the probe message using the WI-FI module, and determine the data transmission delay of the wireless local area network based on a sending time of the probe message and a receiving time of the response message.

In a possible implementation, the transmitted data includes a data packet of a first application, and the data transmission delay is a delay of transmitting the data packet of the first application.

In a possible implementation, the first threshold and the second threshold are preconfigured for the first application.

According to a fourth aspect, an embodiment of this application provides an electronic device, including the SOC according to any one of the third aspect and the possible implementations of the third aspect.

According to a fifth aspect, an embodiment of this application provides an electronic device, and the electronic device includes a processor and a computer readable storage medium that stores a computer program. The processor is coupled to the computer readable storage medium. When the computer program is executed by the processor, the network switching method according to any one of the first aspect and the possible implementations of the first aspect is implemented.

According to a sixth aspect, an embodiment of this application provides a computer readable storage medium, where a computer program is stored in the computer readable storage medium. When the computer program is executed by a processor, the network switching method according to any one of the first aspect and the possible implementations of the first aspect is implemented.

According to a seventh aspect, an embodiment of this application provides a computer program product, including a computer program. When the computer program is executed by a processor, the network switching method according to any one of the first aspect and the possible implementations of the first aspect is implemented.

