CN116846791A - Connection switching method and device, electronic equipment and storage medium - Google Patents

Connection switching method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN116846791A
CN116846791A CN202310642209.7A CN202310642209A CN116846791A CN 116846791 A CN116846791 A CN 116846791A CN 202310642209 A CN202310642209 A CN 202310642209A CN 116846791 A CN116846791 A CN 116846791A
Authority
CN
China
Prior art keywords
connection
data transmission
mode
devices
frame rate
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202310642209.7A
Other languages
Chinese (zh)
Inventor
郝勇
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Core Ruishi Technology Co ltd
Original Assignee
Shenzhen Core Ruishi Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen Core Ruishi Technology Co ltd filed Critical Shenzhen Core Ruishi Technology Co ltd
Priority to CN202310642209.7A priority Critical patent/CN116846791A/en
Publication of CN116846791A publication Critical patent/CN116846791A/en
Pending legal-status Critical Current

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L43/00Arrangements for monitoring or testing data switching networks
    • H04L43/08Monitoring or testing based on specific metrics, e.g. QoS, energy consumption or environmental parameters
    • H04L43/0805Monitoring or testing based on specific metrics, e.g. QoS, energy consumption or environmental parameters by checking availability
    • H04L43/0811Monitoring or testing based on specific metrics, e.g. QoS, energy consumption or environmental parameters by checking availability by checking connectivity
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L41/00Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
    • H04L41/06Management of faults, events, alarms or notifications
    • H04L41/0654Management of faults, events, alarms or notifications using network fault recovery
    • H04L41/0663Performing the actions predefined by failover planning, e.g. switching to standby network elements

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Environmental & Geological Engineering (AREA)
  • Communication Control (AREA)

Abstract

The application provides a connection switching method, a device, electronic equipment and a storage medium, and relates to the technical field of communication. According to the method, the data transmission condition between two devices is monitored in the current connection mode, then when the data transmission condition does not meet the set requirement, connection between the two devices is re-selected to be established in other connection modes, the re-established connection mode is the mode of establishing connection fastest, connection can be ensured to be carried out in the connection mode of establishing connection fastest when connection is switched every time, real-time requirement of data transmission is ensured, and the connection mode can be switched in time when the data transmission condition does not meet the set requirement, so that data transmission quality is ensured, and further data transmission performance can be effectively improved.

Description

Connection switching method and device, electronic equipment and storage medium
Technical Field
The present application relates to the field of communications technologies, and in particular, to a connection switching method, a device, an electronic apparatus, and a storage medium.
Background
Two devices may communicate via a network connection, which generally supports multiple different connection modes, where each connection mode may pass through a completely different network link and may respectively exhibit different transmission conditions, such as a connection speed and a transmission efficiency.
In the related art, one of the connection modes is adopted to establish connection between two devices, and the connection mode is maintained in the subsequent communication process, but sometimes the connection mode cannot meet the communication requirement due to the influence of external factors (such as a network and the like), so that the data transmission performance between the two devices becomes poor.
Disclosure of Invention
An embodiment of the application aims to provide a connection switching method, a device, electronic equipment and a storage medium, which are used for solving the problem that the data transmission performance is influenced by maintaining a connection mode in the communication between two devices in the existing mode.
In a first aspect, an embodiment of the present application provides a connection switching method, where the method includes:
under the current connection mode, monitoring the data transmission condition between two devices;
and when the data transmission condition does not meet the set requirement, reselecting to establish the connection between the two devices through other connection modes, wherein the reestablished connection mode is the mode of establishing the connection fastest.
In the implementation process, the data transmission condition between two devices is monitored in the current connection mode, then when the data transmission condition does not meet the set requirement, the connection between the two devices is re-selected to be established in other connection modes, the re-established connection mode is the mode of establishing the connection fastest, so that the connection mode of establishing the connection fastest is adopted for connection when the connection is switched each time, the real-time requirement of the data transmission is ensured, the connection mode is switched in time when the data transmission condition does not meet the set requirement, the data transmission quality is ensured, and the data transmission performance is further effectively improved.
Optionally, the data transmission condition includes a data transmission frame rate, and determining whether the data transmission condition meets a set requirement by:
judging whether the current data transmission frame rate is smaller than the lowest data transmission frame rate;
if yes, determining that the data transmission condition does not meet the set requirement;
if not, determining that the data transmission condition meets the set requirement.
In the implementation process, the data transmission condition is judged by judging whether the data transmission frame rate reaches the lowest data transmission frame rate, so that the switching of the connection can be dynamically controlled according to the data transmission frame rate, and the data transmission quality is ensured.
Optionally, the data transmission condition includes a data transmission frame rate, and determining whether the data transmission condition meets a set requirement by:
judging whether the current data transmission frame rate is smaller than the lowest data transmission frame rate;
if the current data transmission frame rate is smaller than the lowest data transmission frame rate, acquiring the duration time of the current data transmission frame rate smaller than the lowest data transmission frame rate;
and if the duration exceeds the set duration, determining that the data transmission condition does not meet the set requirement.
In the implementation process, the data transmission condition is judged by acquiring the duration time that the current data transmission frame rate is smaller than the lowest data transmission frame rate, so that the problem of high resource consumption caused by frequent switching of connection can be avoided.
Optionally, before the monitoring of the data transmission situation between the two devices, the method further includes:
creating a connection thread corresponding to each connection mode in a plurality of connection modes;
and establishing connection between the two devices according to the respective connection mode through each connection thread.
In the implementation process, the connection is established by establishing the connection threads corresponding to various connection modes, so that the connection establishment process of each connection thread is not affected, and the optimal connection mode is ensured to be established.
Optionally, after the connection between the two devices is established through each connection thread according to the respective connection mode, the method further includes:
when a connection thread successfully establishes connection between two devices, the connection mode corresponding to the connection thread is used as a current connection mode, and connection success signals are sent to other connection threads. Thus, the problem that other connecting threads consume resources because the other connecting threads continue to execute the connecting process can be avoided.
Optionally, after the sending the connection success signal to the other connection threads, the method further includes:
ending the connection operation of the other connection threads, and setting other connection modes corresponding to the other connection threads to be in a disabled state. Thus, the problem that other connecting threads consume resources because the other connecting threads continue to execute the connecting process can be avoided.
Optionally, the reselecting establishes a connection between the two devices through other connection modes, including:
restoring the other connection modes from the disabled state to the enabled state, and setting the current connection mode to the disabled state;
and selecting to establish the connection between the two devices through other connection modes.
In the implementation process, the connection is selected by setting the disabled or enabled state for the connection mode, so that connection switching from the unused connection mode can be conveniently performed each time.
Optionally, the plurality of connection modes include at least two of: local area network connections, P2P-UDP connections, P2P-TCP connections, service forwarding connections, and device forwarding connections.
In a second aspect, an embodiment of the present application provides a connection switching apparatus, including:
the monitoring module is used for monitoring the data transmission condition between the two devices in the current connection mode;
and the switching module is used for reselecting to establish the connection between the two devices through other connection modes when the data transmission condition does not meet the set requirement, wherein the reestablished connection mode is the fastest connection establishment mode.
In a third aspect, an embodiment of the present application provides an electronic device comprising a processor and a memory storing computer readable instructions which, when executed by the processor, perform the steps of the method as provided in the first aspect above.
In a fourth aspect, embodiments of the present application provide a computer readable storage medium having stored thereon a computer program which when executed by a processor performs the steps of the method as provided in the first aspect above.
Additional features and advantages of the application will be set forth in the description which follows, and in part will be apparent from the description, or may be learned by practice of the embodiments of the application. The objectives and other advantages of the application will be realized and attained by the structure particularly pointed out in the written description and claims thereof as well as the appended drawings.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are needed in the embodiments of the present application will be briefly described below, it should be understood that the following drawings only illustrate some embodiments of the present application and should not be considered as limiting the scope, and other related drawings can be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1 is a flowchart of a connection switching method according to an embodiment of the present application;
FIG. 2 is a schematic diagram of an execution flow of a connection task and an adaptive control task according to an embodiment of the present application;
fig. 3 is a block diagram of a connection switching device according to an embodiment of the present application;
fig. 4 is a schematic structural diagram of an electronic device for performing a connection switching method according to an embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application.
It should be noted that the terms "system" and "network" in embodiments of the present application may be used interchangeably. "plurality" means two or more, and "plurality" may also be understood as "at least two" in this embodiment of the present application. "and/or", describes an association relationship of an association object, and indicates that there may be three relationships, for example, a and/or B, and may indicate: a exists alone, A and B exist together, and B exists alone. The character "/", unless otherwise specified, generally indicates that the associated object is an "or" relationship.
The embodiment of the application provides a connection switching method, which monitors the data transmission condition between two devices in the current connection mode, and then reselects to establish the connection between the two devices in other connection modes when the data transmission condition does not meet the set requirement, wherein the reestablished connection mode is the fastest connection establishment mode, so that the connection is ensured by adopting the connection mode of the fastest connection establishment mode when the connection is switched each time, the real-time requirement of the data transmission is ensured, the connection mode is switched in time when the data transmission condition does not meet the set requirement, the data transmission quality is ensured, and the data transmission performance is further effectively improved.
Referring to fig. 1, fig. 1 is a flowchart of a connection switching method according to an embodiment of the present application, where the method includes the following steps:
step S110: and under the current connection mode, monitoring the data transmission condition between the two devices.
The application scenario of the embodiment of the application can be that one of the two devices can be a data receiving end, such as a client, and the other device can be a data transmitting end, such as an audio and video provider, such as a camera and other audio and video acquisition devices, under the information transmission scenario of audio and video data, images and the like. It will be appreciated that in different application scenarios, the specific reference to two devices is different and is not explicitly listed here. The execution body of the method in the embodiment of the present application may refer to a device for implementing active connection, and may be a data receiving end (for example, the data receiving end actively establishes a connection with the data sending end), or may be a data sending end (for example, the data sending end actively establishes a connection with the data receiving end), for convenience of description, in the following embodiment, the execution body is described by taking the data receiving end as an example, where the data receiving end may implement switching of connection modes.
Before the two devices perform data transmission, a connection between the two devices needs to be established to enable the data transmission between the two devices through the connection. The connection between two devices generally supports multiple connection modes, each connection mode can pass through different network links, and the connection speed and the data transmission efficiency are different. The plurality of connection modes comprise at least two of the following: local area network connections, P2P-UDP (Peer to Peer-User Datagram Protocol, point-to-Point User datagram protocol) connections, P2P-TCP (Peer to Peer-User-Transmission Control Protocol, point-to-Point Transmission control protocol) connections, server forwarding connections, and device forwarding connections.
The local area network connection means that the data receiving end and the data sending end are in the same local area network, and are directly connected through the IP address of the local area network and perform data transmission, and the data transmission speed is influenced by the speed of the local area network;
the P2P-UDP connection and the P2P-TCP connection refer to two modes supported by the P2P connection, and under the two connection modes, a data receiving end and a data sending end are directly connected and transmit data in different local area networks through a public network IP, and the transmission speed is limited by the uplink and downlink speeds of equipment at two ends and is limited by a transmission intermediate node;
the server forwarding connection is that a data receiving end and a data sending end are simultaneously connected with a server, the data sending end transmits data to the server, the server transmits the data to the data receiving end, at the moment, the transmission speed is limited by the uplink speed of the data sending end, the downlink bandwidth of the server and the downloading speed of the data receiving end;
the equipment forwarding connection is to connect the data receiving end and the data transmitting end with another idle equipment supporting the forwarding function, the data transmitting end uploads data to the forwarding equipment, the forwarding equipment transmits the data to the data receiving end, at the moment, the transmission speed is limited by the uplink speed of the data transmitting end, is limited by the uplink and downlink bandwidths of the forwarding equipment, and is limited by the downloading speed of the data receiving end.
The current connection mode refers to a connection mode of establishing connection at the fastest speed, for example, when two devices establish connection, the connection is established in parallel by adopting the multiple connection modes, for example, the multiple connection modes are started at the data receiving end at the same time, and the mode of establishing connection at the fastest speed is kept. That is, which connection mode is established successfully first, the two devices are in data communication by adopting the connection mode, namely, the connection mode established each time by the two devices is the connection mode with the fastest connection success, so that the data between the devices can be ensured to be transmitted in time.
After the two devices are successfully connected, the data transmission condition between the two devices can be monitored so as to monitor whether the data transmission condition of the two devices meets the requirement in real time in the current connection mode.
Step S120: and when the data transmission condition does not meet the set requirement, the connection between the two devices is established in other connection modes.
The data transmission condition can be used for representing the influence of the current connection mode on data transmission, such as low transmission speed, small data volume and the like, if the data transmission condition is monitored to not meet the set requirement, the current connection mode is indicated to not meet the data transmission between two devices, and at the moment, the connection between the two devices needs to be established through other connection modes again.
The other connection modes refer to other connection modes besides the current connection mode, for example, if the current connection mode is a P2P-TCP connection, the other connection modes can be four connection modes of a local area network connection, a P2P-UDP connection, a server forwarding connection and a device forwarding connection.
That is, when the data transmission condition does not meet the set requirement, the current connection mode can be disconnected, then the other four connection modes are started, parallel connection is performed through the other four connection modes, and if which connection mode of the other four connection modes is successful at first, the two devices adopt the connection mode of successful at first connection to perform data transmission. In other words, the connection mode established again is the fastest connection mode, namely, the connection mode selected each time between two devices is the fastest connection mode, so that timeliness can be ensured, smoothness of audio and video transmission can be ensured under an audio and video transmission scene, and the problem of blocking caused by delayed connection due to too long disconnection is avoided.
It can be understood that the current connection mode may refer to a connection mode in which the two devices initially establish a connection and the connection is established fastest, or may be a mode in which the two devices reestablish the connection fastest after performing a connection switch. That is, regardless of whether the two devices were previously initially connected or re-connected, the connection mode selected each time may be the fastest way to establish a connection.
In the implementation process, the data transmission condition between two devices is monitored in the current connection mode, then when the data transmission condition does not meet the set requirement, the connection between the two devices is re-selected to be established in other connection modes, the re-established connection mode is the mode of establishing the connection fastest, so that the connection mode of establishing the connection fastest is adopted for connection when the connection is switched each time, the real-time requirement of the data transmission is ensured, the connection mode is switched in time when the data transmission condition does not meet the set requirement, the data transmission quality is ensured, and the data transmission performance is further effectively improved.
On the basis of the above embodiment, the data transmission condition may include a data transmission frame rate, and at this time, it may be determined whether the data transmission condition satisfies the set requirement by: judging whether the current data transmission frame rate is smaller than the lowest data transmission frame rate, if yes, determining that the data transmission condition does not meet the set requirement, and if not, determining that the data transmission condition meets the set requirement.
Wherein, the data transmission frame rate can be obtained by calculation by the following formula: f= (current time-T)/N, T represents time when the current connection mode is successfully connected, and N represents the number of frames.
The lowest data transmission frame rate is the lowest data transmission frame rate of the data receiving end, is a parameter configured in advance, and can be obtained by reading configuration information when needed. It can be appreciated that the lowest data transmission frame rates configured by different data receiving ends are different, and of course, the same lowest data transmission frame rate may be configured for different data receiving ends.
Alternatively, the lowest data transmission frame rate may be configured for different data, such as different lowest data transmission frame rates for transmitting different data configurations. Alternatively, the lowest data transmission frame rate may be configured for different data transmitters, i.e. the lowest data transmission frame rates configured for different data transmitters are different.
If the current data transmission frame rate is smaller than the lowest data transmission frame rate, the network transmission speed of the two devices in the current connection mode is lower, and the transmission requirement cannot be met, so that the two devices need to be switched to other connection modes for reconnection; if the current data transmission frame rate is greater than or equal to the lowest data transmission frame rate, the data transmission condition is indicated to meet the set requirement, and the connection mode is not required to be switched at this time, but the current connection mode is continuously maintained.
In the implementation process, the data transmission condition is judged by judging whether the data transmission frame rate reaches the lowest data transmission frame rate, so that the switching of the connection can be dynamically controlled according to the data transmission frame rate, and the data transmission quality is ensured.
On the basis of the above embodiment, in order to avoid the problem that the switching manner frequently causes frequent interruption of connection and further affects data transmission, and the problem that frequent switching may cause large resource consumption, the duration of the current data transmission frame rate smaller than the lowest data transmission frame rate may be obtained when the current data transmission frame rate is smaller than the lowest data transmission frame rate, and if the duration exceeds the set duration, it is determined that the data transmission condition does not meet the set requirement.
The specific value of the set duration can be set according to the need, for example, 40 seconds, if the duration is longer than the set duration, it is indicated that the data transmission condition is worse in the current connection mode, normal communication between two devices is affected, and connection switching can be performed at this time.
In the implementation process, the data transmission condition is judged by acquiring the duration time that the current data transmission frame rate is smaller than the lowest data transmission frame rate, so that the problem of high resource consumption caused by frequent switching of connection can be avoided.
It can be understood that the above data transmission situation may further include other data, that is, whether the data transmission situation meets the set requirement may be determined by other data, for example, the data transmission situation may further include a transmission speed, a code rate, and the like, when determining whether the data transmission situation meets the set requirement, whether the transmission speed exceeds the set speed may be determined, if yes, the data transmission situation meets the set requirement, and if not, the data transmission situation is determined not to meet the set requirement. Or judging whether the code rate is larger than the set code rate, if so, determining that the data transmission condition meets the set requirement, and if not, determining that the data transmission condition does not meet the set requirement.
Of course, in different application scenarios, the data transmission situation may be further represented by other data, and for determining whether the data transmission situation meets the set requirement, different data have different determination criteria, which are not illustrated here.
On the basis of the above embodiment, when the connection between two devices is initially established, a connection thread corresponding to each connection mode of multiple connection modes may be first established, and then the connection between the two devices is established according to the respective connection mode through each connection thread.
For example, 5 connection modes are listed above, and a corresponding connection thread is created for each connection mode, such as creating a local area network connection thread, creating a P2P-TCP connection thread, creating a P2P-UDP connection thread, creating a server forwarding connection thread, and creating a device forwarding connection thread when starting a connection process.
And then each connecting thread detects whether the corresponding connecting mode is in an enabling state or not, if not, the connection is not established, and if so, the connection process of the corresponding connecting mode is attempted to be executed, so that the connection between the two devices is established.
The connection threads are executed in parallel when the connection process of the connection mode is executed, and the execution processes of the connection threads are not affected to ensure that the optimal connection mode is established.
In order to avoid the problem of resource waste caused by the fact that other connecting threads continue to be connected after one connecting thread is successfully connected, when the connecting thread successfully establishes the connection between two devices, the connecting mode corresponding to the connecting thread is used as the current connecting mode, and a connecting success signal is sent to the other connecting threads so as to inform the other connecting threads of ending the connecting process.
When each connecting thread executes the connecting process of the connecting mode, the connecting thread can detect the signals of the connection success of other connecting threads, namely, detect whether the connecting success signals sent by other connecting threads are received, if the connecting success signals are received, the connecting thread is indicated to have the connection success of other connecting threads, the connecting thread does not need to be connected, and the connecting process can be ended by self.
That is, after receiving the connection success signal, the other connection threads end the connection operation of the other connection threads, and set other connection modes corresponding to the other connection threads to be in a disabled state.
For example, the current connection thread is a P2P-TCP connection thread, and at this time, the connection thread sends connection success signals to other connection threads, and after receiving the connection success signals, the other connection threads set other connection modes to a disabled state. The disabled state refers to that other connection modes are disabled between the two devices, and only the current P2P-TCP connection is maintained.
Setting to the disabled state herein may be understood as setting other connection threads to the disabled state, such as turning off other connection threads, and not enabling itself without releasing the disabled state. Or, it may be understood that the corresponding forbidden mark is added to other connection modes, for example, when the connection thread is created by initial connection, the states corresponding to the various connection modes are searched first, for example, whether the forbidden mark exists or not, if the forbidden mark is set, the connection mode is the forbidden state, at this time, the connection thread corresponding to the connection mode in the forbidden state is not required to be created, so that the connection mode in the forbidden state is not used for connection, and only the connection thread corresponding to the connection mode in the enabled state is required to be created. The connection mode of the enabling state can be understood as a connection mode without a disabling mark or with a marking enabling mark.
On the basis of the embodiment, after the two devices successfully establish connection, the current connection mode is adopted for communication, the other connection modes are set to be in a disabled state, then when the other connection modes are reselected to establish connection, the other connection modes can be restored to an enabled state from the disabled state, the current connection mode is set to be in the disabled state, and then the connection between the two devices is selectively established through the other connection modes.
In this case, the connection threads corresponding to the other connection modes are re-established, and then each connection thread executes the connection process of the respective connection mode, if which connection mode is successful first, the connection mode which is successful first is maintained, and the other connection modes are disabled, and the process is similar to the above process and will not be repeated here.
It will be appreciated that when a connection is established by selecting another connection, the old connection may be disconnected after the connection of the other connection is successful, so that the problem of communication interruption may be avoided.
In principle, each time another connection mode is reselected to establish a connection, the old connection needs to be set to a disabled state, for example, 5 connection modes described above, when the connection is established for the first time, connection mode 1 is selected to establish a connection, the remaining 4 connection modes are disabled at this time, and after the connection is switched, connection mode 2 is selected to establish a connection, the remaining 3 connection modes are disabled at this time, when the connection is switched again, connection mode 1 is still in a disabled state, but the connection mode is selected from the remaining 3 connection modes to switch, after all connection modes are switched once, the previously disabled connection mode can be restored to an enabled state, so that the next connection switching is selected from the 5 connection modes.
In some other embodiments, the connection mode disabled before is not required to be enabled after all connection modes are switched once, but the connection mode disabled before is automatically restored to the enabled state after a certain period of time. The certain time period can be set according to actual requirements.
Alternatively, when the connection method is not connected after the switching is performed for the set number of times and the remaining connection methods are not connected, the connection method which is disabled before may be enabled, for example, when the connection method is performed for 5 connection methods as described above, the set number of times may be 4, that is, when the switching is performed for the fourth time, the 2 connection methods which are disabled before are restored to the enabled state.
On the basis of the above embodiment, in order to avoid the problem of data loss in the switching process, the current connection mode is continuously maintained between the two devices before the switching is successful, and the current connection mode is disconnected after the switching is successful, so that the communication is performed by the connection mode after the switching is maintained.
Or, when switching, the data receiving end sends a sending suspension instruction to the data sending end, after receiving the sending suspension instruction, the data sending end suspends sending data, waits for the data receiving end to switch connection, after the data receiving end successfully switches connection, the data receiving end can send a continuing sending instruction to the data sending end, and after receiving the continuing sending instruction, the data sending end can continue sending data; or after the data receiving end is successfully switched and connected, the data transmitting end can sense that the connection mode is switched, and at the moment, the data transmitting end can automatically continue to transmit data, so that the data cannot be lost in the switching process, and the data integrity is ensured.
The above process is described in one specific embodiment.
Two tasks are created at the data receiving end to respectively realize a connection creation process and a connection switching process, for example, the connection creation process is realized by creating a connection task, the connection switching process is realized by creating an adaptive control task, and the specific implementation process is shown in fig. 2.
When two devices initially create a connection, all connection modes are initialized to an enabled state.
(1) The main work of the connection task is as follows:
a) Starting a connection process;
b) Creating a local area network connection thread;
c) Creating a P2P-UDP connection thread;
d) Creating a P2P-TCP connection thread;
e) Creating a server forwarding connection thread;
f) Creating a device forwarding connection thread;
g) Each connecting thread respectively detects whether the corresponding connecting mode is in an enabling state or not, and returns if not;
h) Each connecting thread tries to execute the connecting process of the corresponding connecting mode, and simultaneously detects signals of successful connection of other connecting threads;
i) When the connection of the connection thread is successful, the trigger signal informs other connection threads to finish the connection process, namely, a connection success signal is sent to the other connection threads;
j) The connection thread which is successfully connected continues to execute the data transmission process, and simultaneously records the time of the connection success and the connection mode of the current connection success;
k) After receiving the frame data, accumulating and recording the number N of frames;
l) maintaining the current connection and repeatedly performing step k.
(2) The main work of the adaptive control task is as follows:
a) Monitoring the connection state of each connection thread, and if the connection of the connection thread is not successful, re-monitoring after a certain period of dormancy; or waiting for a connection success signal sent by a connection thread with a connection success;
b) If the connection thread is monitored to be connected successfully or a connection success signal is received, the stored lowest data transmission frame rate M is read;
c) Acquiring connection success time T recorded in step j in a connection task;
d) Acquiring the number N of frames recorded in the step k in the connection task;
e) Calculating the current data transmission frame rate: (current time-T)/n=f;
f) If the lowest data transmission frame rate M is less than the current data transmission frame rate F, the step a is re-executed after dormancy for a certain period of time;
g) If the lowest data transmission frame rate M > = the current data transmission frame rate F, temporarily disabling the connection mode recorded in the step j in the connection task;
h) Checking the disabled state of all the connection modes, and resetting all the connection modes to be enabled if all the connection modes are disabled;
i) Continuing execution if there is a connection mode whose status is enabled;
j) Attempting to create a new connection, ending the old connection after the new connection is successful, namely executing a connection switching process;
k) And (c) repeating the step a in the adaptive control task after sleeping for a certain period of time.
In the embodiment of the application, when multiple connection modes exist between two devices and the data transmission condition does not meet the set requirement after the connection is successful, the starting and forbidden states of the connection modes are dynamically controlled according to the data transmission condition, and reconnection by using other connection modes is tried to achieve the connection modes with high avoidance connection speed and low transmission frame rate, and the effect of smooth playing of video streams can be ensured under the audio and video transmission scene.
Referring to fig. 3, fig. 3 is a block diagram illustrating a connection switching apparatus 200 according to an embodiment of the present application, where the apparatus 200 may be a module, a program segment, or a code on an electronic device. It should be understood that the apparatus 200 corresponds to the above embodiment of the method of fig. 1, and is capable of performing the steps involved in the embodiment of the method of fig. 1, and specific functions of the apparatus 200 may be referred to in the above description, and detailed descriptions thereof are omitted herein as appropriate to avoid redundancy.
Optionally, the apparatus 200 includes:
the monitoring module 210 is configured to monitor a data transmission condition between two devices in a current connection manner;
and the switching module 220 is configured to reselect to establish a connection between the two devices through other connection modes when the data transmission condition does not meet the set requirement, where the reestablished connection mode is a mode of establishing a connection fastest.
Optionally, the data transmission case includes a data transmission frame rate, and the switching module 220 is further configured to determine whether the current data transmission frame rate is less than the lowest data transmission frame rate; if yes, determining that the data transmission condition does not meet the set requirement; if not, determining that the data transmission condition meets the set requirement.
Optionally, the data transmission case includes a data transmission frame rate, and the switching module 220 is further configured to determine whether the current data transmission frame rate is less than the lowest data transmission frame rate; if the current data transmission frame rate is smaller than the lowest data transmission frame rate, acquiring the duration time of the current data transmission frame rate smaller than the lowest data transmission frame rate; and if the duration exceeds the set duration, determining that the data transmission condition does not meet the set requirement.
Optionally, the apparatus 200 further includes:
the connection module is used for creating a connection thread corresponding to each connection mode in the plurality of connection modes; and establishing connection between the two devices according to the respective connection mode through each connection thread.
Optionally, the connection module is further configured to, when a connection thread successfully establishes connection between two devices, take a connection mode corresponding to the connection thread as a current connection mode, and send a connection success signal to other connection threads.
Optionally, the connection module is further configured to end the connection operation of the other connection threads, and set other connection modes corresponding to the other connection threads to a disabled state.
Optionally, the switching module 220 is configured to restore the other connection mode from the disabled state to the enabled state, and set the current connection mode to the disabled state; and selecting to establish the connection between the two devices through other connection modes.
Optionally, the plurality of connection modes include at least two of: local area network connections, P2P-UDP connections, P2P-TCP connections, service forwarding connections, and device forwarding connections.
It should be noted that, for convenience and brevity, a person skilled in the art will clearly understand that, for the specific working procedure of the apparatus described above, reference may be made to the corresponding procedure in the foregoing method embodiment, and the description will not be repeated here.
Referring to fig. 4, fig. 4 is a schematic structural diagram of an electronic device for performing a connection switching method according to an embodiment of the present application, where the electronic device may include: at least one processor 310, such as a CPU, at least one communication interface 320, at least one memory 330, and at least one communication bus 340. Wherein the communication bus 340 is used to enable direct connection communication of these components. The communication interface 320 of the device in the embodiment of the present application is used for performing signaling or data communication with other node devices. The memory 330 may be a high-speed RAM memory or a nonvolatile memory (non-volatile memory), such as at least one disk memory. Memory 330 may also optionally be at least one storage device located remotely from the aforementioned processor. The memory 330 has stored therein computer readable instructions which, when executed by the processor 310, perform the method process described above in fig. 1.
It will be appreciated that the configuration shown in fig. 4 is merely illustrative, and that the electronic device may also include more or fewer components than shown in fig. 4, or have a different configuration than shown in fig. 4. The components shown in fig. 4 may be implemented in hardware, software, or a combination thereof.
Embodiments of the present application provide a computer readable storage medium having stored thereon a computer program which, when executed by a processor, performs a method process performed by an electronic device in the method embodiment shown in fig. 1.
The present embodiment discloses a computer program product comprising a computer program stored on a non-transitory computer readable storage medium, the computer program comprising program instructions which, when executed by a computer, are capable of performing the methods provided by the above-described method embodiments, for example, comprising:
under the current connection mode, monitoring the data transmission condition between two devices;
and when the data transmission condition does not meet the set requirement, reselecting to establish the connection between the two devices through other connection modes, wherein the reestablished connection mode is the mode of establishing the connection fastest.
In summary, the embodiments of the present application provide a connection switching method, apparatus, electronic device, and storage medium, which monitor a data transmission condition between two devices in a current connection manner, and then, when the data transmission condition does not meet a set requirement, reselect to establish a connection between two devices in other connection manners, where the reestablished connection manner is a manner of establishing a connection fastest, so that it is ensured that the connection is performed by adopting the connection manner of establishing the connection fastest at each time of switching the connection, thereby ensuring a real-time requirement of data transmission, and also, when the data transmission condition does not meet the set requirement, it is ensured that the connection manner is switched in time, thereby effectively improving data transmission performance.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be implemented in other manners. The above-described apparatus embodiments are merely illustrative, for example, the division of the units is merely a logical function division, and there may be other manners of division in actual implementation, and for example, multiple units or components may be combined or integrated into another system, or some features may be omitted, or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed with each other may be through some communication interface, device or unit indirect coupling or communication connection, which may be in electrical, mechanical or other form.
Further, the units described as separate units may or may not be physically separate, and units displayed as units may or may not be physical units, may be located in one place, or may be distributed over a plurality of network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
Furthermore, functional modules in various embodiments of the present application may be integrated together to form a single portion, or each module may exist alone, or two or more modules may be integrated to form a single portion.
In this document, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions.
The above description is only an example of the present application and is not intended to limit the scope of the present application, and various modifications and variations will be apparent to those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the protection scope of the present application.

Claims (11)

1. A method of connection switching, the method comprising:
under the current connection mode, monitoring the data transmission condition between two devices;
and when the data transmission condition does not meet the set requirement, reselecting to establish the connection between the two devices through other connection modes, wherein the reestablished connection mode is the mode of establishing the connection fastest.
2. The method of claim 1, wherein the data transmission condition comprises a data transmission frame rate, and wherein the determination of whether the data transmission condition meets a set requirement is performed by:
judging whether the current data transmission frame rate is smaller than the lowest data transmission frame rate;
if yes, determining that the data transmission condition does not meet the set requirement;
if not, determining that the data transmission condition meets the set requirement.
3. The method of claim 1, wherein the data transmission condition comprises a data transmission frame rate, and wherein the determination of whether the data transmission condition meets a set requirement is performed by:
judging whether the current data transmission frame rate is smaller than the lowest data transmission frame rate;
if the current data transmission frame rate is smaller than the lowest data transmission frame rate, acquiring the duration time of the current data transmission frame rate smaller than the lowest data transmission frame rate;
and if the duration exceeds the set duration, determining that the data transmission condition does not meet the set requirement.
4. The method of claim 1, wherein prior to the monitoring of the data transmission between the two devices, the method further comprises:
creating a connection thread corresponding to each connection mode in a plurality of connection modes;
and establishing connection between the two devices according to the respective connection mode through each connection thread.
5. The method of claim 4, wherein after the connection between the two devices is established by each connection thread in a respective connection manner, the method further comprises:
when a connection thread successfully establishes connection between two devices, the connection mode corresponding to the connection thread is used as a current connection mode, and connection success signals are sent to other connection threads.
6. The method of claim 5, wherein after sending a connection success signal to the other connection thread, the method further comprises:
ending the connection operation of the other connection threads, and setting other connection modes corresponding to the other connection threads to be in a disabled state.
7. The method of claim 6, wherein the reselecting establishes a connection between the two devices through other connection means, comprising:
restoring the other connection modes from the disabled state to the enabled state, and setting the current connection mode to the disabled state;
and selecting to establish the connection between the two devices through other connection modes.
8. The method of claim 4, wherein the plurality of connection means comprises at least two of: local area network connections, P2P-UDP connections, P2P-TCP connections, service forwarding connections, and device forwarding connections.
9. A connection switching apparatus, the apparatus comprising:
the monitoring module is used for monitoring the data transmission condition between the two devices in the current connection mode;
and the switching module is used for reselecting to establish the connection between the two devices through other connection modes when the data transmission condition does not meet the set requirement, wherein the reestablished connection mode is the fastest connection establishment mode.
10. An electronic device comprising a processor and a memory storing computer readable instructions that, when executed by the processor, perform the method of any of claims 1-8.
11. A computer readable storage medium, on which a computer program is stored, characterized in that the computer program, when being executed by a processor, performs the method according to any of claims 1-8.
CN202310642209.7A 2023-06-01 2023-06-01 Connection switching method and device, electronic equipment and storage medium Pending CN116846791A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310642209.7A CN116846791A (en) 2023-06-01 2023-06-01 Connection switching method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310642209.7A CN116846791A (en) 2023-06-01 2023-06-01 Connection switching method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN116846791A true CN116846791A (en) 2023-10-03

Family

ID=88168001

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310642209.7A Pending CN116846791A (en) 2023-06-01 2023-06-01 Connection switching method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN116846791A (en)

Similar Documents

Publication Publication Date Title
US9270524B2 (en) Method and device for LACP link switching and data transmission
JP5828954B2 (en) Packet processing method and router during server failure
JP2005347943A (en) Network relay device and its control method
WO2017124791A1 (en) Link detecting method and device
CN113382026B (en) Data processing method, device, related equipment and storage medium
CN110943878A (en) Heartbeat packet transmission method, terminal and device with storage function
CN103686854A (en) Method and device for controlling AP
CN111147573A (en) Data transmission method and device
CN111343019A (en) Reconnection method, reconnection device and storage medium
CN116048538A (en) Service grid deployment method and device for DPU
CN101909006A (en) BFD (Bidirectional Forwarding Detection) message sending and receiving methods as well as device and communication system thereof
CN117395715A (en) Multilink data transmission method, device, equipment, storage medium and product
CN115801642B (en) RDMA communication management module, method, equipment and medium based on state control
CN116846791A (en) Connection switching method and device, electronic equipment and storage medium
CN102136936B (en) Method, node and system for preventing control plane faults from influencing operation of forward data plane
CN110661836B (en) Message routing method, device and system, and storage medium
WO2014082211A1 (en) Method and apparatus for processing residual information
US11811900B2 (en) Packet processing method and first network device
CN113098709B (en) Network recovery method and device based on distributed networking system and computer equipment
CN101848165A (en) Method for controlling recovery of interrupted communication link and interface board
CN105007143A (en) Call preservation and recovery method and system
CN115086617A (en) Video stream storage method, device, system, equipment and medium
CN109818870B (en) Multicast routing method, device, service board and machine readable storage medium
JP4099773B2 (en) IP multicast distribution source switching control system and method therefor, switching control server, switching control program, and recording medium recording the program
CN111224803B (en) Multi-master detection method in stacking system and stacking system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination