Channel switching method, electronic device, and storage medium
Embodiments of this application provide a channel switching method, an electronic device, and a storage medium, and relate to the field of communication technologies. The method includes: in response to a monitored scenario change, detecting a second network channel based on a service type of the first application, and determining a path of the second network channel based on a detection result; obtaining packets of the first application on the first network channel; and determining a characteristic packet flow from a plurality of packet flows of the first application, collecting statistics on packets in the characteristic packet flow to obtain a first statistical result, and switching the characteristic packet flow to the second network channel based on the first statistical result. The method provided by the embodiments of this application can improve switching efficiency of the network channel, thereby ensuring running smoothness of an application.
1 . An electronic device, comprising: an acceleration sensor, a memory and a processor, wherein the memory is configured to store instructions that, when executed by the processor, causes the electronic device to:
in response to a monitored scenario change that is associated with a movement of the electronic device, detect a second network channel based on a service type of a first application, and determine a path of the second network channel based on a detection result, wherein the monitored scenario change is determined by detecting a movement of the electronic device in a vertical direction by the acceleration sensor;
obtain packets of the first application on a first network channel; and
determine a characteristic packet flow from a plurality of packet flows of the first application, collecting statistics on packets in the characteristic packet flow to obtain a first statistical result, and switch the characteristic packet flow to the path of the second network channel based on the first statistical result.
2 . The electronic device according to claim 1 , wherein the first network channel or the second network channel comprises at least a primary Wi-Fi channel, a secondary Wi-Fi channel, a primary cellular channel, or a secondary cellular channel.
3 . The electronic device according to claim 1 , wherein the characteristic packet flow comprises at least one of a download flow, a video flow, or a gaming flow.
4 . The electronic device according to claim 1 , wherein the first application is an insensitive application, and the electronic device is further to:
collect statistics on packets of the characteristic packet flow of the first application to obtain a second statistical result, and determining quality of the first network channel based on the second statistical result;
detect the second network channel based on the quality of the first network channel, and determining the path of the second network channel based on a detection result; and
switch the characteristic packet flow to the second network channel.
5 . The electronic device according to claim 4 , wherein the electronic device is further to:
collect statistics on the packets that are in the characteristic packet flow of the first application and that are received within preset first duration, to obtain the second statistical result.
6 . The electronic device according to claim 1 , wherein the first application is a sensitive application.
7 . The electronic device according to claim 6 , wherein the electronic device is further to:
obtain the packets of the first application on the first network channel within a preset second duration.
8 . The electronic device according to claim 6 , wherein the electronic device is further to:
detect a round-trip delay of a packet of the second network channel based on the service type of the first application to obtain a detection result, wherein the detection result comprises the round-trip delay of a packet of each network channel; and
determine the path of the second network channel based on the detection result.
9 . The electronic device according to claim 8 , wherein the detection result further comprises a historical record of each network channel.
10 . The electronic device according to claim 1 , wherein the electronic device is further to:
after switching the characteristic packet flow to the second network channel based on the first statistical result, carry a non-characteristic packet flow of the first application on the first network channel.
11 . The electronic device according to claim 10 , wherein the electronic device is further to:
after switching the characteristic packet flow to the second network channel based on the first statistical result,
switch the non-characteristic packet flow in the first application to the second network channel, and disable the first network channel.
12 . The electronic device according to claim 1 , wherein the electronic device is further to:
delete the path of the second network channel based on the first statistical result.
13 . The electronic device according to claim 12 , wherein the electronic device is further to:
delete the path of the second network channel after preset fourth duration based on the first statistical result.
14 . The electronic device according to claim 1 , wherein the electronic device is further to:
collect statistics on a delay or a packet loss rate of the packets in the characteristic packet flow to obtain the first statistical result, wherein the first statistical result is used to indicate whether the characteristic packet flow meets a preset delay requirement or a preset packet loss rate requirement.
15 . A method, applied to an electronic device, wherein the electronic device has an acceleration sensor and a plurality of network channels, a first application runs on the electronic device, the first application is carried on a first network channel, the first application comprises a plurality of packet flows, and the method comprises:
in response to a monitored scenario change that is associated with a movement of the electronic device, detecting a second network channel based on a service type of the first application, and determining a path of the second network channel based on a detection result, wherein the monitored scenario change is determined by detecting a movement of the electronic device in a vertical direction by the acceleration sensor;
obtaining packets of the first application on the first network channel; and
determining a characteristic packet flow from a plurality of packet flows of the first application, collecting statistics on packets in the characteristic packet flow to obtain a first statistical result, and switching the characteristic packet flow to the path of the second network channel based on the first statistical result.
16 . The method according to claim 15 , wherein the characteristic packet flow comprises at least one of a download flow, a video flow, or a gaming flow.
17 . A non-transitory computer readable storage medium, storing an instruction, and when the instruction is run on an electronic device that has an acceleration sensor and a plurality of network channels, the electronic device is enabled to:
run a first application that is being carried on a first network channel, the first application comprises a plurality of packet flows;
in response to a monitored scenario change that is associated with a movement of the electronic device, detect a second network channel based on a service type of the first application, and determine a path of the second network channel based on a detection result, wherein the monitored scenario change is determined by detecting a movement of the electronic device in a vertical direction by the acceleration sensor;
obtaining packets of the first application on the first network channel; and
determining a characteristic packet flow from a plurality of packet flows of the first application, collecting statistics on packets in the characteristic packet flow to obtain a first statistical result, and switching the characteristic packet flow to the path of the second network channel based on the first statistical result.
18 . The computer readable storage medium according to claim 17 , wherein the characteristic packet flow comprises at least one of a download flow, a video flow, or a gaming flow.