Channel switching method, electronic device and storage medium
A channel switching method, an electronic device and a storage medium are provided. The electronic device includes a first network channel and a second network channel, and a use priority of the second network channel is higher than a use priority of the first network channel. The method includes: starting a first application, where the first application includes a first data flow, and the first data flow is carried on the first network channel; and when it is detected that the second network channel is enabled and it is detected that the first data flow is a data flow of a preset type, keeping the first data flow still carried on the first network channel.
1 . A channel switching method, applied to an electronic device, wherein the electronic device is configured to communicate using a first network channel and a second network channel, a use priority of the second network channel is higher than a use priority of the first network channel, and the method comprises:
starting a first application, wherein the first application comprises a first data flow, and the first data flow is carried on the first network channel;
when it is detected that the second network channel is enabled, detecting whether the first data flow is a delay-sensitive flow based on at least one of the following parameters: a protocol type, a port number, a packet transmission feature, or a preset string in a packet, wherein the packet transmission feature comprises at least one of the following: a packet size, a quantity of packets within a preset duration, or a packet transmission speed, and wherein detecting whether the first data flow is a delay-sensitive flow comprises sequentially performing protocol type matching, port number matching, matching of whether a data packet of the first data flow includes the preset string, and data packet transmission feature matching on the data packet of the first data flow;
when it is detected that the first data flow is a delay-sensitive flow, keeping the first data flow still carried on the first network channel; and
detecting that transmission of the first data flow carried on the first network channel ends and no data flow is carried on the first network channel, and disabling the first network channel.
2 . The method according to claim 1 , further comprising:
when it is detected that the second network channel is enabled and it is detected that the first data flow is not a delay-sensitive flow, switching the first network channel carrying the first data flow to the second network channel.
3 . The method according to claim 2 , wherein before the switching the first network channel carrying the first data flow to the second network channel, the method further comprises:
determining that a network quality of the enabled second network channel meets a transmission requirement of the first data flow.
4 . The method according to claim 1 , wherein before the keeping the first data flow still carried on the first network channel, the method further comprises:
determining that network quality of the first network channel meets a transmission requirement of the first data flow.
5 . The method according to claim 1 , further comprising:
determining that a network quality of the enabled first network channel does not meet a transmission requirement of the first data flow, and switching the first network channel carrying the first data flow to the second network channel.
6 . The method according to claim 1 , further comprising:
when determining that a network quality of the enabled second network channel does not meet a transmission requirement of the first data flow, keeping the first data flow still carried on the first network channel.
7 . The method according to claim 1 , further comprising:
obtaining a packet of the first application from a packet carried on the first network channel; and
obtaining a packet of the first data flow from the packet of the first application.
8 . The method according to claim 1 , wherein before it is detected that the second network channel is enabled, the method further comprises:
determining that the first application is an application in a preset whitelist.
9 . The method according to claim 1 , wherein the first network channel is a cellular channel, and the second network channel is a WiFi channel; or
the first network channel is a secondary WiFi channel, and the second network channel is a primary WiFi channel.
10 . An electronic device, comprising a memory, wherein the memory stores computer program code, the computer program code comprises instructions, and when the electronic device reads the instructions from the memory, the electronic device is enabled to perform operations comprising:
starting a first application, wherein the first application comprises a first data flow, and the first data flow is carried on a first network channel, and wherein the electronic device is configured to communicate using the first network channel and a second network channel, and a use priority of the second network channel is higher than a use priority of the first network channel;
when it is detected that the second network channel is enabled, detecting whether the first data flow is delay-sensitive flow based on at least one of the following parameters: a protocol type, a port number, a packet transmission feature, or a preset string in a packet, wherein the packet transmission feature comprises at least one of the following: a packet size, a quantity of packets within a preset duration, or a packet transmission speed, and wherein detecting whether the first data flow is a delay-sensitive flow comprises sequentially performing protocol type matching, port number matching, matching of whether a data packet of the first data flow includes the preset string, and data packet transmission feature matching on the data packet of the first data flow;
when it is detected that the first data flow is a delay-sensitive flow, keeping the first data flow still carried on the first network channel; and
detecting that transmission of the first data flow carried on the first network channel ends and no data flow is carried on the first network channel, and disabling the first network channel.
11 . The electronic device according to claim 10 , wherein when the electronic device reads the instructions from the memory, the electronic device is enabled to perform operations further comprising:
when it is detected that the second network channel is enabled and it is detected that the first data flow is not a delay-sensitive flow, switching the first network channel carrying the first data flow to the second network channel.
12 . The electronic device according to claim 10 , wherein when the electronic device reads the instructions from the memory, the electronic device is enabled to perform operations further comprising:
before keeping the first data flow still carried on the first network channel, determining that a network quality of the first network channel meets a transmission requirement of the first data flow.
13 . The electronic device according to claim 10 , wherein when the electronic device reads the instructions from the memory, the electronic device is enabled to perform operations further comprising:
when it is determined that a network quality of the enabled first network channel does not meet a transmission requirement of the first data flow, switching the first network channel carrying the first data flow to the second network channel.
14 . The electronic device according to claim 10 , wherein the first network channel is a cellular channel, and the second network channel is a WiFi channel.
15 . A non-transitory computer-readable storage medium, comprising computer instructions, wherein when the computer instructions are run on an electronic device, the electronic device is enabled to perform operations comprising:
starting a first application, wherein the first application comprises a first data flow, and the first data flow is carried on a first network channel, wherein the electronic device is configured to communicate using the first network channel and a second network channel, and a use priority of the second network channel is higher than a use priority of the first network channel;
when it is detected that the second network channel is enabled, detecting whether the first data flow is a delay-sensitive flow based on at least one of the following parameters: a protocol type, a port number, a packet transmission feature, or a preset string in a packet, wherein the packet transmission feature comprises at least one of the following: a packet size, a quantity of packets within a preset duration, or a packet transmission speed, and wherein detecting whether the first data flow is a delay-sensitive flow comprises sequentially performing protocol type matching, port number matching, matching of whether a data packet of the first data flow includes the preset string, and data packet transmission feature matching on the data packet of the first data flow;
when it is detected that the first data flow is a delay-sensitive flow, keeping the first data flow still carried on the first network channel; and
detecting that transmission of the first data flow carried on the first network channel ends and no data flow is carried on the first network channel, and disabling the first network channel.
16 . The non-transitory computer-readable storage medium according to claim 15 , wherein when the computer instructions are run on the electronic device, the electronic device is enabled to perform operations comprising:
when it is detected that the second network channel is enabled and it is detected that the first data flow is not a delay-sensitive flow, switching the first network channel carrying the first data flow to the second network channel.
17 . The non-transitory computer-readable storage medium according to claim 15 , wherein when the computer instructions are run on the electronic device, the electronic device is enabled to perform operations comprising:
before keeping the first data flow still carried on the first network channel, determining that a network quality of the first network channel meets a transmission requirement of the first data flow.
18 . The non-transitory computer-readable storage medium according to claim 15 , wherein when the computer instructions are run on the electronic device, the electronic device is enabled to perform operations comprising:
when it is determined that a network quality of the enabled first network channel does not meet a transmission requirement of the first data flow, switching the first network channel carrying the first data flow to the second network channel.
19 . The non-transitory computer-readable storage medium according to claim 15 , wherein the first network channel is a cellular channel, and the second network channel is a WiFi channel.
20 . The non-transitory computer-readable storage medium according to claim 15 , wherein the first network channel is a secondary WiFi channel, and the second network channel is a primary WiFi channel.