Data transmission method and device, electronic equipment and computer program product

By using target session identification and multiple UDP data transmission channels independently controlled in the UDP protocol, the problems of TCP connection disconnection and low UDP transmission efficiency are solved, and stable and efficient data transmission is achieved.

CN119172425APending Publication Date: 2024-12-20GUANGDONG OPPO MOBILE TELECOMMUNICATIONS CORP LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411341249.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-24
Publication Date
2024-12-20

AI Technical Summary

Technical Problem

The TCP protocol will disconnect when the IP address of an electronic device changes, affecting the stability of data transmission, and the lack of reliability mechanism of the UDP protocol leads to low transmission efficiency.

Method used

By introducing target session identifiers in the UDP protocol, a weak coupling relationship with the underlying network is established to ensure that the UDP data transmission channel remains stable when the network changes. The independent control and retransmission mechanism of multiple UDP data transmission channels is adopted to improve transmission efficiency and stability sex.

Benefits of technology

It realizes the stability of UDP data transmission channels when the underlying network changes, improves the flexibility and efficiency of data transmission, independently controls each UDP data transmission channel, and enhances the reliability of transmission.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119172425A_ABST
    Figure CN119172425A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a data transmission method and device, electronic equipment and a computer program product. The method is applied to first electronic equipment and comprises the steps that a target user datagram protocol UDP data transmission channel is established with second electronic equipment, the target UDP data transmission channel corresponds to a target session identifier, and the target session identifier is used for identifying the target UDP data transmission channel; uDP data packet transmission with the second electronic equipment is carried out through the target UDP data transmission channel, and a UDP data packet transmitted by the target UDP data transmission channel carries the target session identifier. According to the data transmission method and device, the electronic equipment and the computer program product, the strong coupling relation between the UDP protocol and the network of the bottom layer can be weakened, when the network of the bottom layer changes, a UDP data transmission channel between the two pieces of electronic equipment can still be kept, and the stability of data transmission is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of communication technology, and in particular to a data transmission method, device, electronic device and computer program product. Background Art

[0002] TCP (Transmission Control Protocol) is a connection-oriented, reliable, byte-stream-based transport layer communication protocol. The TCP protocol has a reliability mechanism, so upper-layer applications do not need to consider packet loss and retransmission when using the TCP protocol for data transmission, and the cost of use is very low. Currently, most data transmission between electronic devices is based on the TCP protocol. Since the TCP protocol is connection-oriented, once the IP (Internet Protocol) address of the electronic device changes, the TCP connection will be disconnected, affecting data transmission.

[0003] Therefore, how to improve the stability of data transmission has become a technical problem that needs to be solved urgently. Summary of the invention

[0004] The embodiments of the present application provide a data transmission method, device, electronic device and computer program product, which can weaken the strong coupling relationship between the UDP protocol and the underlying network. When the underlying network changes, the UDP data transmission channel between the two electronic devices can still be maintained, thereby improving the stability of data transmission.

[0005] The embodiment of the present application discloses a data transmission method, which is applied to a first electronic device, and the method includes:

[0006] Establishing a target User Datagram Protocol (UDP) data transmission channel with the second electronic device, wherein the target UDP data transmission channel corresponds to a target session identifier, and the target session identifier is used to identify the target UDP data transmission channel;

[0007] UDP data packets are transmitted with the second electronic device via the target UDP data transmission channel, and the UDP data packets transmitted via the target UDP data transmission channel carry the target session identifier.

[0008] The present application embodiment discloses a data transmission method, which is applied to a second electronic device, and the method includes:

[0009] Establishing a target UDP data transmission channel with the first electronic device, wherein the target UDP data transmission channel corresponds to a target session identifier, and the target session identifier is used to identify the target UDP data transmission channel;

[0010] UDP data packets are transmitted with the first electronic device via the target UDP data transmission channel, and the UDP data packets transmitted by the target UDP data transmission channel carry the target session identifier.

[0011] The embodiment of the present application discloses a data transmission device, which is applied to a first electronic device, and the device includes:

[0012] A first channel establishment module, used to establish a target User Datagram Protocol UDP data transmission channel with a second electronic device, wherein the target UDP data transmission channel corresponds to a target session identifier, and the target session identifier is used to identify the target UDP data transmission channel;

[0013] The first transmission module is used to transmit UDP data packets with the second electronic device through the target UDP data transmission channel, and the UDP data packets transmitted by the target UDP data transmission channel carry the target session identifier.

[0014] The embodiment of the present application discloses a data transmission device, which is applied to a second electronic device, and the device includes:

[0015] A second channel establishment module, used to establish a target UDP data transmission channel with the first electronic device, wherein the target UDP data transmission channel corresponds to a target session identifier, and the target session identifier is used to identify the target UDP data transmission channel;

[0016] The second transmission module is used to transmit UDP data packets with the first electronic device through the target UDP data transmission channel, and the UDP data packets transmitted by the target UDP data transmission channel carry the target session identifier.

[0017] An embodiment of the present application discloses an electronic device, including a memory, a processor, and a transceiver unit. The memory stores a computer program. When the computer program is executed by the processor, the electronic device implements the method described in any of the above embodiments.

[0018] An embodiment of the present application discloses a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor in an electronic device, the electronic device implements the method described in any of the above embodiments.

[0019] An embodiment of the present application discloses a computer program product, including a computer program. When the computer program is executed by a processor in an electronic device, the electronic device implements the method described in any of the above embodiments.

[0020] The data transmission method, device, electronic device and computer program product disclosed in the embodiment of the present application, a first electronic device and a second electronic device establish a target UDP data transmission channel, the target UDP data transmission channel corresponds to a target session identifier, the target session identifier is used to identify the target UDP data transmission channel, the first electronic device and the second electronic device can transmit UDP data packets through the target UDP data transmission channel, and the UDP data packet transmitted by the target UDP data transmission channel carries the target session identifier. In the embodiment of the present application, a UDP data transmission channel corresponding to the session identifier can be established between different electronic devices, and UDP communication can be performed based on the session identifier. As long as the session identifier remains unchanged, UDP data packet transmission can be achieved through the UDP data transmission channel corresponding to the session identifier, which can weaken the strong coupling relationship between the UDP protocol and the underlying network. When the underlying network changes, the UDP data transmission channel between the two electronic devices can still be maintained, thereby improving the stability of data transmission.

[0021] In addition, different UDP data transmission channels between two electronic devices can correspond to different session identifiers, and different UDP data transmission channels will not affect each other. Independent transmission control of each UDP data transmission channel can be achieved, thereby improving the flexibility and efficiency of data transmission. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0023] Figure 1 An application scenario diagram of a data transmission method in an embodiment;

[0024] Figure 2 is a flow chart of a data transmission method in one embodiment;

[0025] Figure 3 A schematic diagram of a UDP data transmission channel established between a first electronic device and a second electronic device in one embodiment;

[0026] Figure 4 A flowchart of establishing a target UDP data transmission channel between a first electronic device and a second electronic device in one embodiment;

[0027] Figure 5 A timing diagram of establishing a UDP data transmission channel in one embodiment;

[0028] Figure 6A flowchart of a first electronic device performing data retransmission in one embodiment;

[0029] Figure 7 A schematic diagram of UDP data packet retransmission in one embodiment;

[0030] Figure 8 A schematic diagram of submitting a UDP data packet in an embodiment;

[0031] Fig. 9 A schematic diagram of UDP data packet retransmission in another embodiment;

[0032] Fig.10 A schematic diagram of independently performing flow control on multiple UDP data transmission channels in one embodiment;

[0033] Fig.11 A flowchart for implementing connection migration in one embodiment;

[0034] Fig.12 A timing diagram of implementing connection migration between two electronic devices in one embodiment;

[0035] Fig.13A A timing diagram of two electronic devices establishing a UDP data transmission channel for the first time in an example;

[0036] Fig. 13B It is a timing diagram of two electronic devices establishing a UDP data transmission channel in an example which is not the first time;

[0037] Fig.14 is a flow chart of a data transmission method in another embodiment;

[0038] Fig.15 is a block diagram of a data transmission device in one embodiment;

[0039] Fig.16 is a block diagram of a data transmission device in another embodiment;

[0040] Fig.17 FIG. 4 is a structural block diagram of an electronic device in an embodiment. DETAILED DESCRIPTION

[0041] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0042] It should be noted that the terms "including" and "having" and any variations thereof in the embodiments of the present application and the accompanying drawings are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device including a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to these processes, methods, products or devices.

[0043] It is understood that the terms "first", "second", etc. used in this application can be used to describe various elements in this article, but these elements are not limited by these terms. These terms are only used to distinguish the first element from another element. For example, without departing from the scope of this application, the first UDP socket can be referred to as the second UDP socket, and similarly, the second UDP socket can be referred to as the first UDP socket. Both the first UDP socket and the second UDP socket are UDP sockets, but they are not the same UDP socket. The term "multiple" used in this application refers to two or more. The term "and / or" used in this application refers to one of the schemes, or any combination of multiple schemes.

[0044] The following are some explanations and descriptions of some terms that may be involved in this application:

[0045] TCP / IP (Transmission Control Protocol / Internet Protocol) protocol: refers to a protocol suite that can realize information transmission between multiple different networks, which includes not only TCP protocol and IP protocol, but also FTP (File Transfer Protocol), SMTP (Simple Mail Transfer Protocol), UDP (User Datagram Protocol) and other protocols.

[0046] IP address: A unified address format provided by the IP protocol, which specifies the communication address for each device on the Internet. Different network interfaces on a device are assigned different IP addresses.

[0047] TCP protocol: It is a connection-oriented, reliable, byte stream-based transport layer communication protocol with a complete reliability mechanism.

[0048] UDP protocol: It is a connectionless, message-oriented transport layer communication protocol. The UDP protocol only makes its best effort to deliver, but does not guarantee reliable delivery.

[0049] Physical connection: refers to a connection established through physical media (such as cables, wireless signals, etc.), which enables communication between different electronic devices. Optionally, the physical connection may include but is not limited to Wi-Fi connection, Bluetooth connection, Ethernet, etc.

[0050] Logical connection: It can be understood as a virtual connection abstracted from a physical connection, which can be used to transmit data, so that there is no need to pay attention to the underlying physical implementation details when transmitting data.

[0051] Socket: refers to the abstract endpoint for two-way communication between processes of different electronic devices in the network. A socket is one end of process communication in the network, providing a mechanism for application layer processes to exchange data using network protocols.

[0052] UDP data transmission channel: refers to the path used to implement UDP data packet transmission. In the embodiment of the present application, different UDP data transmission channels may correspond to different session identifiers, and different UDP data transmission channels are independent of each other and do not affect each other.

[0053] Session ID: can be used to identify the UDP data transmission channel. Different UDP data transmission channels can correspond to different session IDs.

[0054] Application: A computer program that is designed to complete one or more specific tasks. Applications usually run in user mode and can usually interact with users.

[0055] Services provided by an application: refers to the functions or capabilities that an application can provide.

[0056] Unicast: Only two entities communicate with each other, and both the sender and the receiver are uniquely identified.

[0057] Broadcast: A one-to-many communication method in which the sender can send data to all devices in the network segment.

[0058] Multicast: A one-to-many communication method in which the sender can send data to all devices added to a group.

[0059] At present, the transmission protocol commonly used to achieve mutual connection between different electronic devices is the TCP protocol. The connection established between different electronic devices can be a P2P (point-to-point) connection and a LAN connection, etc. When two electronic devices need to transmit data (such as file transfer or screen projection, etc.), a P2P connection or a LAN connection can be established, and data transmission can be performed based on the TCP protocol.

[0060] The TCP protocol itself has a relatively complete reliability mechanism. When using the TCP protocol for data transmission, the upper-layer application does not need to consider issues such as packet loss and retransmission, and the cost of use is very low. However, the header of the TCP data packet is large, which squeezes the bandwidth occupied by the load carried by the TCP data packet, so the transmission efficiency is low. In addition, the congestion control mechanism adopted by the TCP protocol is additive increase and multiplicative reduction, that is, when it is perceived that there is no congestion on the transmission path, the sending speed is additively increased, and when it is perceived that congestion occurs on the transmission path, the sending rate is multiplicatively reduced. As a result, in the actual transmission process, it is difficult to restore the original transmission capacity after the sending rate is reduced. The original intention of the TCP protocol is to prevent the upper-layer application from being aware of the existence of the network, but in actual use, the sender usually needs to know more about the network status to gain greater initiative, which is contrary to the original intention of the TCP protocol.

[0061] In addition, since the TCP protocol is connection-oriented, once the IP address of the electronic device changes, the TCP connection will be disconnected, affecting data transmission.

[0062] Compared with TCP, under the same transmission conditions, the data transmission speed based on UDP is often faster than that based on TCP, and UDP data packets occupy a higher rate of effective bandwidth, so the transmission efficiency is higher. However, the current UDP protocol does not have a reliability mechanism and does not meet the requirements for transmission quality.

[0063] The embodiments of the present application provide a data transmission method, device, electronic device and computer program product, which can weaken the strong coupling relationship between the UDP protocol and the underlying network. When the underlying network changes, the UDP data transmission channel between the two electronic devices can still be maintained, thereby improving the stability of data transmission.

[0064] Figure 1 FIG. 1 is an application scenario diagram of a data transmission method in an embodiment. Figure 1 As shown, a communication connection can be established between the first electronic device 110 and the second electronic device 120, and the first electronic device 110 and the second electronic device 120 may include but are not limited to mobile phones, wearable devices (such as smart watches, smart glasses, etc.), vehicle terminals, tablet computers, laptops, PCs (Personal Computers), smart home devices (such as TVs, speakers, etc.), etc. Optionally, any one of the first electronic device 1110 and the second electronic device 120 may also be a server.

[0065] The communication connection mode between the first electronic device 110 and the second electronic device 120 may include, but is not limited to, Wi-Fi connection, Bluetooth connection, etc. Optionally, the first electronic device 110 and the second electronic device 120 may be directly connected, or both may be connected to the same local area network, and data may be transmitted between the first electronic device 110 and the second electronic device 120.

[0066] The first electronic device 110 can establish a target UDP data transmission channel with the second electronic device 120. The target UDP data transmission channel corresponds to a target session identifier, and the target session identifier can be used to identify the target UDP data transmission channel. The first electronic device 110 can transmit UDP data packets with the second electronic device 120 through the target UDP data transmission channel. The UDP data packets transmitted by the target UDP data transmission channel carry the target session identifier.

[0067] In some embodiments, multiple UDP data transmission channels may be established between the first electronic device 110 and the second electronic device 120, different UDP data transmission channels may correspond to different session identifiers, and different UDP data transmission channels may be independently controlled without affecting each other.

[0068] It should be noted that the first electronic device 110 can be a data sender or a data receiver, and the second electronic device 120 can be a data sender or a data receiver, and their roles are not limited here.

[0069] In an embodiment of the present application, UDP communication based on session identification is implemented. When the upper-layer application is transmitting data, it does not need to perceive the changes in the underlying network. Even if the IP address changes, as long as the session identification remains unchanged, the UDP data transmission channel perceived by the upper-layer application will not be disconnected. The UDP data transmission channel between the two electronic devices can still be maintained, and UDP data packets can continue to be transmitted through the UDP data transmission channel corresponding to the session identification, thereby improving the stability of data transmission.

[0070] like Figure 2 As shown, in one embodiment, a data transmission method is provided, which can be applied to the first electronic device mentioned above, and the method may include the following steps:

[0071] Step 210: establish a target UDP data transmission channel with the second electronic device, where the target UDP data transmission channel corresponds to a target session identifier, and the target session identifier is used to identify the target UDP data transmission channel.

[0072] At least one UDP data transmission channel may be established between the first electronic device and the second electronic device, each UDP data transmission channel may have a corresponding session identifier, the session identifier may be used to identify the corresponding UDP data transmission channel, and the session identifiers corresponding to different UDP data transmission channels may be different. Exemplarily, the session identifier may be composed of one or more of numbers, letters, symbols, etc.

[0073] The target UDP data transmission channel may be one of the at least one UDP data transmission channel, and the target UDP data transmission channel may correspond to the target session identifier.

[0074] The UDP data transmission channel can represent a data transmission channel between one end of the first electronic device and one end of the second electronic device. Optionally, one end of the first electronic device can be an application running on the first electronic device, and one end of the second electronic device can be an application running on the second electronic device; one end of the first electronic device can be a process running on the first electronic device, and the other end of the second electronic device can be a process running on the second electronic device; one end of the first electronic device can be a service provided by an application running on the first electronic device, and the other end of the second electronic device can be a service provided by an application running on the second electronic device, but is not limited thereto.

[0075] Furthermore, the UDP data transmission channel can be understood as a logical connection abstracted from the physical connection between the first electronic device and the second electronic device, which can be used to transmit UDP data packets. Different UDP data transmission channels correspond to different logical connections. One logical connection can correspond to one UDP data transmission channel, that is, one logical connection can correspond to one session identifier.

[0076] In some embodiments, the target session identifier may be determined based on the target service provided by the target application. The target application may refer to the application responsible for data transmission. The target service may be a service declared or used by the target application. For example, the target service may include but is not limited to file exchange services, screen projection services, etc., but is not limited to these. Further, the target service may be a service in the target application that is responsible for data transmission on the target UDP data transmission channel. For example, the target service may be a service in the target application that is responsible for sending data through the target UDP data transmission channel, or a service in the target application that is responsible for processing data received through the target UDP data transmission channel, etc.

[0077] Optionally, the session identifier can be used to characterize different services provided by different applications. Different session identifiers indicate that the UDP data transmission channel corresponds to different applications and / or provides different services. UDP communication based on session identifiers can ensure that data is correctly delivered to the services provided by the upper-layer application, thereby improving the accuracy of data transmission.

[0078] As an implementation mode, the target session identifier may be generated by the first electronic device, and the target application may be an application running in the first electronic device; as another implementation mode, the target session identifier may also be generated by the second electronic device, and the target application may be an application running in the second electronic device.

[0079] Furthermore, the target session identifier may be generated according to the application identifier of the target application program, the service identifier of the target service, and a random number.

[0080] The application identifier of the target application can be used to identify the target application, and the application identifier may include but is not limited to the package name of the installation package of the target application, the number of the target application, etc. The service identifier of the target service can be used to identify the target service, and the service identifier of the target service may include but is not limited to the service name of the target service, the number of the target service, etc.

[0081] As a specific implementation, the target session identifier can be obtained by performing a hash calculation on the application identifier of the target application and the service identifier of the target service according to the random number. Exemplarily, the calculation formula of the target session identifier can be as follows: SessionId = hash (pakageName + ServiceName), where SessionId represents the target session identifier, pakageName represents the application identifier of the target application, and ServiceName represents the service identifier of the target service.

[0082] In an embodiment of the present application, the target session identifier is generated based on the application identifier of the target application, the service identifier of the target service and a random number, which can ensure that the session identifier generated each time is different, thereby ensuring the uniqueness of the UDP data transmission channel between different electronic devices and further improving the accuracy of data transmission.

[0083] It should be noted that other methods may also be used to generate a session identifier, and are not limited to the above implementation.

[0084] In some embodiments, for the same service used by the same application, if there are multiple data transmission tasks, or the amount of data to be transmitted is relatively large, multiple session identifiers can be generated based on the application identifier of the application, the service identifier of the service, and multiple random numbers, thereby establishing multiple UDP data transmission channels between the first electronic device and the second electronic device. Concurrent data transmission can be achieved through multiple UDP data transmission channels, thereby improving data transmission efficiency.

[0085] Step 220: UDP data packets are transmitted with the second electronic device through the target UDP data transmission channel. The UDP data packets transmitted through the target UDP data transmission channel carry the target session identifier.

[0086] UDP data packets can be transmitted between the first electronic device and the second electronic device through the target UDP data transmission channel, and the UDP data packets transmitted by the target UDP data transmission channel all carry the target session identifier, thereby realizing UDP communication based on the session identifier. Furthermore, the first electronic device can send a UDP data packet to the second electronic device through the target UDP data transmission channel, or the second electronic device can send a UDP data packet to the first electronic device through the target UDP data transmission channel.

[0087] In some embodiments, the UDP data packet may be sent between the first electronic device and the second electronic device by broadcasting, multicasting, unicasting, or the like.

[0088] Exemplarily, taking the broadcast of a UDP data packet by a first electronic device as an example, the first electronic device can use the broadcast address in the local area network to broadcast the UDP data packet to each electronic device in the local area network. When the second electronic device receives the UDP data packet broadcast by the first electronic device, since the UDP data packet carries a target session identifier, it can determine that it is the receiving end based on the target session identifier carried in the UDP data packet, and can then upload the UDP data packet to the upper-layer application based on the target session identifier.

[0089] Exemplarily, taking the example of a first electronic device sending a UDP data packet in unicast mode, the first electronic device can obtain the IP address and port number corresponding to the second electronic device, bind the IP address and port number to the target UDP data transmission channel, and use the IP address and port number to accurately send UDP data packets to the second electronic device. After receiving the UDP data packet, the second electronic device can upload the UDP data packet to the upper-layer application according to the target session identifier carried by the UDP data packet.

[0090] For the upper-layer applications in the first electronic device and the second electronic device, since UDP communication is based on the session identifier, there is no need to worry about network changes at the physical layer, such as IP address changes. As long as the target session identifier remains unchanged, the target UDP data transmission channel can be maintained for the upper-layer applications, which can weaken the strong coupling relationship between the UDP protocol and the underlying network.

[0091] In the related technology, the TCP protocol has a high reliability mechanism and does not expect data packet loss and disorder. If there are multiple data packets that need to be transmitted on a TCP connection at the same time, if the TCP connection is blocked, the transmitted data packets will be blocked, seriously affecting the data transmission efficiency.

[0092] In some embodiments of the present application, multiple UDP data transmission channels can be established between the first electronic device and the second electronic device, and the multiple UDP data transmission channels established between the first electronic device and the second electronic device can share the same physical connection, that is, the multiple UDP data transmission channels established between the first electronic device and the second electronic device can share the bandwidth of the same physical connection, and different UDP data transmission channels are independent of each other and will not affect each other, and each UDP data transmission channel can independently control the transmission rate and reliability, etc. For example, if a UDP data packet transmitted by a certain UDP data transmission channel is lost or out of order, it does not affect the normal data transmission of other UDP data transmission channels. Thus, a multiplexed transmission mechanism can be implemented, which can improve data transmission efficiency.

[0093] For example, Figure 3 FIG. 1 is a schematic diagram of a UDP data transmission channel established between a first electronic device and a second electronic device in one embodiment. Figure 3 As shown, multiple UDP data transmission channels can be established between the first electronic device and the second electronic device, and different UDP data transmission channels correspond to different session identifiers. For example, the session identifier corresponding to UDP data transmission channel 302 is Session 1, the session identifier corresponding to UDP data transmission channel 304 is Session 2, and the session identifier corresponding to UDP data transmission channel 306 is Session 3, etc., but not limited to this.

[0094] In some embodiments, the target UDP data transmission channel can use multiple physical connections for UDP data transmission. Optionally, the physical connection with the highest transmission rate among the multiple physical connections can be selected, and the transmission of the UDP data packet corresponding to the target UDP data transmission channel can be achieved through the physical connection with the highest transmission rate. Optionally, multiple physical connections can also be used at the same time to transmit the UDP data packets corresponding to the target UDP data transmission channel in parallel.

[0095] As an implementation method, one of the multiple physical connections can be selected to transmit the UDP data packets corresponding to the target UDP data transmission channel. If the physical connection is blocked, it can be switched to another physical connection to continue transmitting the UDP data packets corresponding to the target UDP data transmission channel.

[0096] In an embodiment of the present application, a UDP data transmission channel can use multiple physical connections for UDP data transmission, further improving the flexibility and efficiency of data transmission.

[0097] In an embodiment of the present application, a UDP data transmission channel corresponding to a session identifier can be established between different electronic devices, and UDP communication can be performed based on the session identifier. As long as the session identifier remains unchanged, UDP data packet transmission can be achieved through the UDP data transmission channel corresponding to the session identifier, which can weaken the strong coupling relationship between the UDP protocol and the underlying network. When the underlying network changes, the UDP data transmission channel between the two electronic devices can still be maintained, thereby improving the stability of data transmission.

[0098] like Figure 4 As shown, in one embodiment, the step of establishing a target UDP data transmission channel with the second electronic device may include the following steps:

[0099] Step 402: Obtain the target session identifier.

[0100] The first electronic device may obtain a target session identifier, which may be generated by the first electronic device or the second electronic device.

[0101] In some embodiments, before establishing a UDP data transmission channel, the first electronic device and the second electronic device can interact through the target communication connection to generate session identifiers generated by both parties, so that the first electronic device stores the session identifier generated by the second electronic device, and the second electronic device stores the session identifier generated by the first electronic device, thereby achieving information sharing. The first electronic device and the second electronic device can then establish UDP data transmission channels corresponding to each session identifier based on the session identifiers interacted by both parties.

[0102] As an implementation method, the target session identifier can be generated by the second electronic device. The first electronic device can receive the target session identifier sent by the second electronic device through the target communication connection between the first electronic device and the second electronic device, and then establish a target UDP data transmission channel based on the target session identifier.

[0103] As another implementation, the first electronic device may also generate a target session identifier, and then send the generated target session identifier to the second electronic device through a target communication connection with the second electronic device, and then establish a target UDP data transmission channel based on the target session identifier.

[0104] The target communication connection may include but is not limited to a Bluetooth connection, a Wi-Fi connection, etc.

[0105] Optionally, it can be pre-agreed that the data sending end in the first electronic device and the second electronic device generates a session identifier, or it can be pre-agreed that the data receiver in the first electronic device and the second electronic device generates a session identifier. Which end generates the session identifier can be flexibly set according to actual needs and is not limited here.

[0106] Before establishing the target UDP data transmission channel, the first electronic device and the second electronic device may exchange target session identifiers, thereby ensuring accurate establishment of the subsequent target UDP data transmission channel.

[0107] It should be noted that the specific method of generating the target session identifier can be referred to the relevant description in the above embodiment, and will not be repeated here.

[0108] Step 404: Create a first UDP socket based on the target session identifier.

[0109] Step 406: Establish a target UDP data transmission channel with a second UDP socket of a second electronic device through the first UDP socket, where the second UDP socket is created by the second electronic device based on the target session identifier.

[0110] The first electronic device may create a first UDP socket based on the target session identifier. The first UDP socket may correspond to the target session identifier and may be used to implement communication with a second UDP socket of the second electronic device.

[0111] The second electronic device may also create a second UDP socket based on the target session identifier. The second UDP socket may correspond to the target session and may be used to implement communication with the first UDP socket of the first electronic device.

[0112] Exemplarily, the first UDP socket created by the first electronic device can be described as: SeekerSocket(AF_INTENT, SOCK_DGRAM, SessionId). Among them, AF_INTENT can be used to characterize the communication protocol or the protocol family to which the communication protocol belongs. For example, the AF_INTENT can characterize that the communication protocol used by the first UDP socket can be the customized UDP protocol provided in the embodiment of the present application. SOCK_DGRAM can be used to characterize the socket type. For example, the SOCK_DGRAM characterizes that the first UDP socket belongs to the datagram socket type. SessionId can be used to characterize the session identifier. For example, the SessionId characterizes the target session identifier corresponding to the first UDP socket.

[0113] Exemplarily, the second UDP socket created by the second electronic device can be described as providerSocket(AF_INTENT, SOCK_DGRAM, SessionId). Among them, AF_INTENT can be used to characterize the communication protocol or the protocol family to which the communication protocol belongs. For example, the AF_INTENT can characterize that the communication protocol used by the second UDP socket can be the customized UDP protocol provided in the embodiment of the present application. SOCK_DGRAM can be used to characterize the socket type. For example, the SOCK_DGRAM characterizes that the second UDP socket belongs to the datagram socket type. SessionId can be used to characterize the session identifier. For example, the SessionId characterizes the target session identifier corresponding to the second UDP socket.

[0114] Among them, the SessionId in the first UDP socket is the same as the SessionId in the second UDP socket, so that a target UDP data transmission channel can be established between the first UDP socket and the second UDP socket, and the transmission of UDP data packets between the first UDP socket and the second UDP socket can be realized. The application in the first electronic device can send a UDP data packet carrying a target session identifier through the first UDP socket, and the UDP data packet can be received by the second electronic device, and the application of the second electronic device can read the data carried in the UDP data packet through the second UDP socket. Similarly, the application in the second electronic device can also send a UDP data packet carrying a target session identifier through the second UDP socket, and the UDP data packet can be received by the first electronic device, and the application of the first electronic device can read the data carried in the UDP data packet through the first UDP socket. .

[0115] In some embodiments, after creating the first UDP socket, the first electronic device may send a first request signal through the first UDP socket, and the first request signal may be used to instruct the second electronic device to receive the first request signal through the second UDP socket and feed back a first response signal. The second electronic device may receive the first request signal sent by the first electronic device through the first UDP socket through the second UDP socket, and send a first response signal to the first electronic device through the second UDP socket. The first electronic device may receive the first response signal sent by the second electronic device through the first UDP socket, and establish a target UDP data transmission channel between the first UDP socket and the second UDP socket.

[0116] As an implementation mode, after creating the first UDP socket, the first electronic device may generate a first request signal carrying the first IP address and the first port number of the second electronic device and the target session identifier, and send the first request signal to the second UDP socket of the second electronic device via the first UDP socket. The first port number may be bound to an application in the second electronic device (such as the target application in the above embodiment) or to the process of the application. The first port number may be customized by the application of the second electronic device, or may be allocated by the system, and the first port number may also be a fixed port number, which is not limited here.

[0117] Since the first request signal carries the first IP address and the first port number of the second electronic device and the target session identifier, the second electronic device can accurately receive the first request signal through the second UDP socket. The second electronic device can read the first request signal sent by the first electronic device from the second UDP socket, and send a first response signal to the first UDP socket through the second UDP socket.

[0118] Furthermore, the first request signal sent by the first electronic device may also carry the second IP address and the second port number of the first electronic device. The second electronic device may obtain the second IP address and the second port number of the first electronic device according to the first request signal, generate a first response signal carrying the second IP address and the second port number of the first electronic device and the target session identifier, and send the first response signal to the first UDP socket via the second UDP socket. Since the first response signal carries the second IP address and the second port number of the first electronic device and the target session identifier, the first electronic device can accurately receive the first response signal through the first UDP socket.

[0119] As an implementation method, after the first electronic device reads the first response signal from the first UDP socket, it can initiate a logical connection based on the target session identifier to the second electronic device. In the process of establishing the logical connection corresponding to the target session identifier, the two parties can perform identity authentication, service synchronization, information synchronization and negotiation, thereby completing the establishment of the target UDP data transmission channel.

[0120] It should be noted that any UDP data transmission channel between the first electronic device and the second electronic device can be established in the manner of establishing a target UDP data transmission channel as described in the above embodiment. Different UDP data transmission channels can create different UDP sockets based on corresponding session identifiers, thereby achieving independent control of each UDP data transmission channel.

[0121] For example, Figure 5 FIG. 1 is a timing diagram of establishing a UDP data transmission channel in an embodiment. Figure 5 As shown, the second electronic device can generate a session identifier SessionId=hash(pakageName+ServiceName) and send the session identifier to the first electronic device. The second electronic device can determine the port number port=x, which can be customized by the application. The second electronic device can create a UDP socket providerSocket(AF_INTENT, SOCK_DGRAM, SessionId). The first electronic device can create a UDP socket SeekerSocket(AF_INTENT, SOCK_DGRAM, SessionId). The first electronic device can create a datagram with the IP address providerIP of the second electronic device and the port number port=x, and send the datagram to the providerSocket of the second electronic device via SeekerSocket. The second electronic device can read the UDP message segment from the providerSocket and send a response message to the SeekerSocket of the first electronic device through the providerSocket. The first electronic device can read the datagram (i.e., the response message) from the SeekerSocket and send a logical connection based on SessionId.

[0122] The first electronic device sends a first request signal through the created first UDP socket, and receives the first request signal and feeds back a first response signal through the second UDP socket created by the second electronic device, thereby ensuring the accuracy of subsequent data transmission through the target UDP data transmission channel between the first UDP socket and the second UDP socket.

[0123] In an embodiment of the present application, the first electronic device can create a first UDP socket based on the target session identifier, and the second electronic device can create a second UDP socket based on the target session identifier. The first electronic device can establish a target UDP data transmission channel through the first UDP socket and the second UDP socket of the second electronic device. Different UDP data transmission channels correspond to different UDP sockets, and different UDP data transmission channels will not affect each other. Independent transmission control of each UDP data transmission channel can be achieved, and multiplexing can also be achieved, thereby improving the flexibility and efficiency of data transmission.

[0124] In the related art, the TCP protocol stipulates that when the sender sends a data packet, the receiver correctly receives the data packet and replies with an ACK signal (confirmation information). After receiving the ACK signal replied by the receiver, the sender continues to send the next data packet. The TCP protocol also adopts a sliding window data transmission method. The sender can send multiple data packets contained in the current window. Each time the receiver correctly receives a data packet, it replies with a corresponding ACK signal. The sender will wait for the ACK signals of all data packets in the current window before sliding to the next window and continuing the data packet transmission of the next window.

[0125] Although this communication mechanism ensures the reliability of data transmission, it also has ambiguity. For example, the sender first sends a data packet with sequence number 3, and then sends a data packet with sequence number 5. During the transmission process, disorder or packet loss occurs. The receiver first receives the data packet with sequence number 5, but does not receive the data packet with sequence number 3. The sender does not receive the ACK signal corresponding to the data packet with sequence number 3 due to timeout, and will retransmit the data packet with sequence number 3. The receiver receives the data packet with sequence number 3 at a certain moment and will reply with the corresponding ACK signal. However, the receiver does not know whether the received data packet with sequence number 3 is the first data packet with sequence number 3 sent by the sender, or the retransmitted data packet with sequence number 3. The sender also cannot distinguish whether the ACK signal corresponds to the first data packet with sequence number 3 sent or the retransmitted data packet with sequence number 3, so there is ambiguity. Moreover, the RTT (Round-Trip Time) calculated by the sender based on the ACK signal is also inaccurate.

[0126] The UDP protocol provided in the embodiment of the present application can customize the transmission mechanism and reliability mechanism of the UDP protocol. The UDP protocol provided in the embodiment of the present application can retain the transmission confirmation mechanism and retransmit the UDP data packets that have been lost to ensure the reliability of data transmission.

[0127] like Figure 6 As shown, in some embodiments, the above method may further include the following steps:

[0128] Step 602, determining the target UDP data packet that needs to be retransmitted.

[0129] The first electronic device may be a data transmitter, and the second electronic device may be a data receiver.

[0130] When the first electronic device sends a UDP data packet to the second electronic device through the target UDP data transmission channel, it can determine the target UDP data packet that needs to be retransmitted. The target UDP data packet that needs to be retransmitted may refer to a UDP data packet sent by the first electronic device but not received by the second electronic device, such as a UDP data packet lost due to network conditions.

[0131] In the embodiment of the present application, the UDP protocol may have a transmission confirmation mechanism. After the second electronic device receives the UDP data packet sent by the first electronic device, it may reply a confirmation signal to the first electronic device, so that the first electronic device determines that the second electronic device has received the UDP data packet sent by the first electronic device based on the confirmation signal. Therefore, the target UDP data packet that needs to be retransmitted may be the UDP data packet for which the first electronic device has not received the corresponding confirmation signal.

[0132] Step 604, assigning a target packet sequence number to the target UDP data packet, where the target packet sequence number may be the next packet sequence number of the packet sequence number carried by the most recently sent UDP data packet.

[0133] In some embodiments, in order to achieve reliable transmission, the UDP data packet sent by the first electronic device may also carry a packet sequence number, which can be used to characterize the transmission order corresponding to the UDP data packet. For example, the UDP data packet transmitted by the target UDP data transmission channel may carry a target session identifier and a packet sequence number, which can be used to characterize the transmission order corresponding to the UDP data packet in the target UDP data transmission channel. Exemplarily, packet sequence numbers can be assigned in sequence starting from 1 to the UDP data packets transmitted by the target UDP data transmission channel. By assigning packet sequence numbers to UDP data packets, the reliability of data transmitted by the UDP data transmission channel can be improved. Furthermore, each UDP data transmission channel can independently assign packet sequence numbers to the transmitted UDP data packets without affecting each other, thereby further ensuring the accuracy of data transmission.

[0134] Furthermore, when a UDP data packet is retransmitted, the repeated packet sequence number is not used, but is accumulated in order. After determining the target UDP data packet that needs to be retransmitted, the next packet sequence number of the packet sequence number corresponding to the most recently sent UDP data packet of the target UDP data transmission channel can be determined as the target packet sequence number, and the target packet sequence number is assigned to the target UDP data packet.

[0135] Step 606: Send the target UDP data packet carrying the target packet sequence number to the second electronic device through the target UDP data transmission channel.

[0136] The first electronic device can send the target UDP data packet carrying the target packet sequence number to the second electronic device through the target UDP data transmission channel. Furthermore, the first electronic device can send the target UDP data packet carrying the target packet sequence number to the second UDP socket of the second electronic device through the first UDP socket, thereby realizing the retransmission of the target UDP data packet.

[0137] As an implementation mode, the transmission confirmation mechanism of the UDP protocol of the present application may be that the data receiving end replies with a confirmation signal to each received UDP data packet. The first electronic device sends a first UDP data packet through a target UDP data transmission channel. If a confirmation signal sent by a second electronic device is not received within a first time period of sending the first UDP data packet, the first UDP data packet is determined to be a target UDP data packet that needs to be retransmitted; the confirmation signal is used to indicate that the second electronic device has received the first UDP data packet. The first electronic device may assign a target packet sequence number to the target UDP data packet, and send a target UDP data packet carrying the target packet sequence number to the second electronic device through the target UDP data transmission channel to implement data packet retransmission, thereby ensuring the reliability of data transmission.

[0138] For example, Figure 7 FIG. 1 is a schematic diagram of UDP data packet retransmission in one embodiment. Figure 7 As shown, the first electronic device sends UDP data packet 1 to the second electronic device through the target UDP data transmission channel. After receiving UDP data packet 1, the second electronic device feeds back confirmation signal 1 through the target UDP data transmission channel. The first electronic device receives the confirmation signal 1 through the target UDP data transmission channel and continues to send UDP data packet 2. Due to packet loss, the second electronic device does not receive UDP data packet 2, and does not feed back confirmation signal 2. The second electronic device times out and does not receive confirmation signal 2, and resends UDP data packet 2 through the target UDP data transmission channel.

[0139] In some embodiments, the transmission confirmation mechanism of the UDP protocol of the present application may be that the data receiving end replies with a confirmation signal after each target number of UDP data packets are received. The confirmation signal is not used to drive the sliding window to slide, but is only used to inform the data sending end whether there is packet loss.

[0140] The target number can be understood as the number of UDP data packets corresponding to the confirmation signal sent by the data receiving end, or it can refer to the number of received UDP data packets that the data receiving end submits to the upper-layer application each time. When the second electronic device successfully receives the target number of UDP data packets sent by the first electronic device through the target UDP data transmission channel, the target number of UDP data packets can be submitted to the target application corresponding to the target UDP data transmission channel.

[0141] Optionally, the target number of UDP packets submitted to the target application at the upper layer may be out of order, and the order accuracy of the UDP packets does not need to be guaranteed. Figure 8 The figure is a schematic diagram of submitting UDP data packets in one embodiment. For example, the target number is 4. If the 6th UDP data packet between the 4th UDP data packet and the 7th UDP data packet is out of order or lost, and the 6th UDP data packet is not received, but the 8th UDP data packet is received, the received 4th UDP data packet, 5th UDP data packet, 7th UDP data packet and 8th UDP data packet can be submitted to the upper-layer target application together, and the 6th UDP data packet can be submitted with other UDP data packets in the next batch. In this way, there is no need to wait like TCP transmission, which can reduce transmission congestion and improve data transmission efficiency.

[0142] Furthermore, since the transmission and submission of UDP data packets may be out of order, in order to ensure that the upper-layer target application accurately unpacks and assembles the UDP data packets, data information may be added to the header of the UDP data packet. This data information may be used to indicate the data position or data sequence number corresponding to the payload carried by the UDP data packet, thereby helping to restore the data received by the target application of the second electronic device.

[0143] In some embodiments, the confirmation signal fed back by the data receiving end can be used to confirm the reception of the target number of UDP data packets, thereby changing the transmission from streaming to block transmission. The first electronic device can send the target number of second UDP data packets to the second electronic device through the target UDP data transmission channel. The target number of second UDP data packets can be understood as a data packet group or data block. If the second electronic device successfully receives the target number of UDP data packets sent by the first electronic device through the target UDP data transmission channel, it can send a confirmation signal to the first electronic device, and the confirmation signal can be used to indicate that the second electronic device has received the target number of second UDP data packets. If the first electronic device receives the confirmation signal, it can send the next group of target number of UDP data packets.

[0144] In the event of packet loss in the target number of UDP data packets, the second electronic device may not send a confirmation signal to the first electronic device. If the first electronic device does not receive a confirmation signal sent by the second electronic device within the first time period after sending the target number of second UDP data packets, the target number of second UDP data packets is determined to be the target UDP data packet that needs to be retransmitted. The target number of target UDP data packets may be assigned corresponding target packet sequence numbers in turn, and the target packet sequence numbers corresponding to the target number of target UDP data packets may be accumulated in sequence based on the packet sequence number corresponding to the most recently sent UDP data packet (such as the packet sequence number of the last second UDP data packet sent in the target number of second UDP data packets), and shall not be repeated with the packet sequence number of the second data packet sent previously.

[0145] The first electronic device can send the target number of target UDP data packets to the second electronic device through the target UDP data transmission channel, and the second electronic device can discard the second UDP data packet received previously. After successfully receiving the target number of target UDP data packets, the second electronic device can submit the target number of target UDP data packets to the target application, and can also feedback a confirmation signal to the first electronic device.

[0146] For example, Fig. 9 FIG. 1 is a schematic diagram of UDP data packet retransmission in another embodiment. Fig. 9 As shown, the first electronic device sends a target number of UDP data packets to the second electronic device through the target UDP data transmission channel. For example, the target number is 4, and the first electronic device sends UDP data packets 1 to UDP data packets 4. After the second electronic device receives UDP data packets 1 to UDP data packets 4, it feeds back a confirmation signal 1 through the target UDP data transmission channel. The first electronic device receives the confirmation signal 1 through the target UDP data transmission channel, and continues to send the target number of UDP data packets (UDP data packets 5 to UDP data packets 8). Due to packet loss, the second electronic device does not receive all of UDP data packets 5 to UDP data packets 8, and does not feed back a confirmation signal 2. If the second electronic device times out and does not receive the confirmation signal 2, it resends UDP data packets 5 to UDP data packets 8 through the target UDP data transmission channel.

[0147] In an embodiment of the present application, a confirmation signal is used to confirm whether the target number of UDP data packets have been delivered, and retransmission is performed in the event of packet loss. This can improve the stability of data transmission, and there is no need to confirm each UDP data packet. This can reduce information exchange between two electronic devices, reduce overhead, and improve data transmission efficiency.

[0148] In some embodiments, the target number can be determined based on the latency requirement corresponding to the target UDP data transmission channel. When the latency requirement corresponding to the target UDP data transmission channel is high, that is, the transmission service corresponding to the target UDP data transmission channel has high real-time requirements, the target number can be smaller to ensure the real-time performance of data transmission. If the latency requirement corresponding to the target UDP data transmission channel is small, that is, the transmission service corresponding to the target UDP data transmission channel has low real-time requirements, the target number can be appropriately increased, thereby reducing transmission overhead.

[0149] When multiple UDP data transmission channels are established between the first electronic device and the second electronic device, the target number corresponding to different UDP data transmission channels can be determined according to the delay requirements corresponding to each UDP data transmission channel, and each UDP data transmission channel can flexibly perform flow control. For example, Fig.10 FIG. 1 is a schematic diagram of an embodiment in which multiple UDP data transmission channels independently perform flow control. Fig.10 As shown, three UDP data transmission channels can be established between the first electronic device and the second electronic device, and the corresponding session identifiers are Session 1, Session 2, and Session 3. Among them, the target number of UDP data transmission channels corresponding to Session 1 can be 4, the target number of UDP data transmission channels corresponding to Session 2 can be 6, the target number of UDP data transmission channels corresponding to Session 3 can be 2, etc., but not limited to this.

[0150] As an implementation method, the target number can be determined by an upper-layer application. Taking the target number corresponding to the target UDP data transmission channel as an example, the target number can be determined by the target application and transmitted to the other end when the target UDP data transmission channel is established. As another implementation method, the target number can also be determined by negotiation between the electronic devices of both parties when the target UDP data transmission channel is established, so that the determined target number meets the data transmission capabilities of the electronic devices of both parties.

[0151] In the embodiment of the present application, when a UDP data packet is retransmitted, a repeated packet sequence number is not used, but is accumulated in sequence, thereby avoiding the ambiguity problem. Neither the first electronic device nor the second electronic device needs to pay attention to whether the UDP data packet is sent for the first time or is retransmitted, and the accuracy of the RTT calculated using the confirmation signal can be guaranteed.

[0152] In some embodiments, the customized UDP protocol provided in the embodiments of the present application can realize connection migration, and the upper-layer application does not need to care about the changes in the underlying network, but only needs to pay attention to the session identifier corresponding to the UDP data transmission channel. When the network changes, the upper-layer application only needs to pay attention to the data sent before the network changes (such as abnormal network disconnection, IP address change causing communication connection disconnection, etc.), and continue to send data after the underlying network is restored.

[0153] like Fig.11 As shown, the above method may further include the following steps:

[0154] Step 1102: Send a broadcast signal when the communication connection between the first electronic device and the second electronic device is disconnected.

[0155] In some embodiments, the connection unit of the customized UDP protocol provided in the embodiment of the present application may include a session identifier. Compared with the connection units of the four-tuple, sextuple, etc. in the TCP protocol, the customized UDP protocol provided in the embodiment of the present application, as long as the session identifier remains unchanged, even if the underlying IP address changes, the upper-layer application will not perceive that the UDP data transmission channel is disconnected.

[0156] The communication connection between the first electronic device and the second electronic device is disconnected, which may be caused by an abnormality in the underlying network, or by a change in the IP address of the first electronic device or the second electronic device, or by the distance between the first electronic device and the second electronic device being too far, etc. The situations in which the communication connection is disconnected are not limited here.

[0157] As an implementation, the first electronic device may detect whether the physical connection with the second electronic device is disconnected. If it is detected that the physical connection with the second electronic device is disconnected, it may be determined that the communication connection between the first electronic device and the second electronic device is disconnected.

[0158] As another implementation, when the number of retransmissions of the UDP data packet through the target UDP data transmission channel reaches a preset threshold, the first electronic device may indicate that the UDP data packet sent by the first electronic device through the target UDP data transmission channel cannot be successfully received by the second electronic device, and it may be determined that the communication connection between the first electronic device and the second electronic device is disconnected.

[0159] When the communication connection between the first electronic device and the second electronic device is disconnected, the first electronic device may send a broadcast signal, which may carry a target session identifier, so that when the communication connection between the first electronic device and the second electronic device is restored, the second electronic device may feedback a second response signal.

[0160] When the communication connection between the first electronic device and the second electronic device is disconnected, since the first electronic device is not sure whether the network information (such as IP address, etc.) of the second electronic device has changed, the first electronic device can send a broadcast signal carrying the target session identifier in a broadcasting manner. The broadcast signal can be used to search for the second electronic device, and when the communication connection between the first electronic device and the second electronic device is restored, the second electronic device can receive the broadcast signal sent by the first electronic device.

[0161] The second electronic device may compare the target session identifier carried in the broadcast signal with multiple session identifiers existing in itself, and if the comparison is successful, it may send a second response signal to the first electronic device.

[0162] Step 1104: Receive a second response signal sent by a second electronic device.

[0163] When the communication connection between the first electronic device and the second electronic device is restored, the second electronic device can receive the broadcast signal sent by the first electronic device. The second electronic device can parse the received broadcast signal to extract the target session identifier carried in the broadcast signal. The second electronic device can compare the target session identifier with the session identifiers corresponding to the multiple existing UDP sockets. If the comparison is successful, it means that the second electronic device has previously established a target UDP data transmission channel corresponding to the target session identifier with the first electronic device, and then a second response signal can be sent to the first electronic device.

[0164] Step 1106, continue to transmit UDP data packets with the second electronic device through the target UDP data transmission channel.

[0165] After the first electronic device receives the second response signal sent by the second electronic device, it can confirm that the communication connection between the first electronic device and the second electronic device is re-established, and can continue to transmit UDP data packets with the second electronic device through the target UDP data transmission channel.

[0166] For example, Fig.12 FIG. 1 is a timing diagram of implementing connection migration between two electronic devices in one embodiment. Fig.12As shown, the first electronic device sends part of the data to the second electronic device through the target UDP data transmission channel. In the case where the communication connection between the first electronic device and the second electronic device is disconnected, the first electronic device can broadcast a Seekerhello message, which carries the target session identifier SessionId corresponding to the target UDP data transmission channel. In the case where the first electronic device successfully restores the communication connection with the second electronic device, the second electronic device can successfully receive the Seekerhello message broadcast by the first electronic device, and can traverse the existing session identifiers of itself with the SessionId carried in the Seekerhello message. If the comparison is successful, the second response signal can be replied to the first electronic device. Further, if the comparison is successful, the second electronic device can save the current second IP address and second port number of the first electronic device and other information. The first electronic device receives the second response signal, and can also obtain the current first IP address and first port number of the second electronic device and other information according to the second response signal, and continue the previously interrupted data transmission through the target UDP data transmission channel.

[0167] In an embodiment of the present application, when the communication connection between two electronic devices is disconnected, the first electronic device can send a broadcast signal, which carries a target session identifier. As long as the communication connection between the two electronic devices is restored, the second electronic device can receive the broadcast signal and identify the target session identifier, and continue to communicate based on the target session identifier. Even if the underlying IP address and other information changes, it can be updated in time. For the upper-level application, the UDP data transmission channel between the two electronic devices is still maintained, thereby being able to strip away the strong coupling relationship with the underlying layer in the original transmission protocol and improve the stability of data transmission.

[0168] In some embodiments, the customized UDP protocol provided in the embodiments of the present application also has an encryption mechanism to achieve secure transmission of data. Before the first electronic device transmits a UDP data packet with the second electronic device through the target UDP data transmission channel, it can negotiate with the second electronic device the transmission key corresponding to the target UDP data transmission channel. The transmission key can be used to encrypt and decrypt data transmitted through the target UDP data transmission channel.

[0169] Optionally, an asymmetric encryption algorithm may be used to encrypt and decrypt data transmitted through the target UDP data transmission channel. Exemplarily, the transmission key may include a target public key and a target symmetric key. The target public key can be used to decrypt data transmitted through the target UDP data transmission channel, and the target symmetric key can be used to encrypt data transmitted through the target UDP data transmission channel.

[0170] In some embodiments, when a first electronic device and a second electronic device establish a UDP data transmission channel for the first time, a temporary key can be negotiated with the second electronic device, and then based on the temporary key, a transmission key corresponding to the target UDP data transmission channel can be negotiated with the second electronic device.

[0171] The situation where the first electronic device and the second electronic device establish a UDP data transmission channel for the first time may mean that the first electronic device has not established a UDP data transmission channel with the second electronic device before, or it may mean that although the first electronic device and the second electronic device have established a UDP data transmission channel with each other before, the device information corresponding to the second electronic device is not saved or the saved device information is invalid.

[0172] When the first electronic device and the second electronic device establish a UDP data transmission channel for the first time, two rounds of encryption negotiation can be performed between the first electronic device and the second electronic device, wherein the first round can generate a temporary key, and the second round can generate a transmission key based on the temporary key generated in the first round.

[0173] As a specific implementation, when the first electronic device and the second electronic device establish a UDP data transmission channel for the first time, the second electronic device can randomly generate a prime number p and a primitive root q of the prime number p, and can be within a preset value range (for example, 1 to 2 32 Randomly generate a random number C pro , according to the prime number p, the primitive root q and the random number C pro Generate the first key C pub , illustratively, The first electronic device may use the first key C pub , prime number p and primitive root q are packaged and sent to the first electronic device as configuration information (config).

[0174] Further, after creating the first UDP socket, the first electronic device may send a first request signal to the second electronic device. For example, the first request signal may be a Seeker hello message. After receiving the first request signal, the second electronic device confirms that it is the first time to establish a UDP data transmission channel with the first electronic device, and then generates a first key C pub , prime number p and primitive root q, and sends a first response signal carrying the configuration information to the second electronic device.

[0175] After the first electronic device receives the configuration information sent by the second electronic device, it can 32 Randomly generate a random number C se , and according to the first key C pub , prime number p, primitive root q and random number C seGenerate a temporary public key C c_pub And the temporary symmetric key C1. Exemplarily, the temporary public key Temporary symmetric key

[0176] The first electronic device may obtain the interaction data, which may include device information and connection information of the first electronic device, such as the device model, MAC (Media Access Control Address) address, IP address, etc. of the first electronic device, but is not limited thereto. The first electronic device may encrypt the interaction data using a temporary symmetric key, and its encryption function may be represented as encryption(C1, data), where data represents the interaction data. The first electronic device may store the encrypted interaction data and the temporary public key C1. c_nub Sent to the second electronic device.

[0177] The second electronic device receives the encrypted interactive data and the temporary public key C c_pub After that, the temporary public key C c_pub For verification, for example, the following formula can be used to verify the temporary public key C c_pub To verify:

[0178]

[0179] When the verification is successful, the encrypted interaction data can be decrypted using the temporary public key to obtain the interaction data, and the interaction data can be saved.

[0180] The first electronic device can then regenerate a new random number C t_se , the target public key and target symmetric key can be generated in the same way as the temporary public key and temporary symmetric key, and the newly generated target public key can be sent to the second electronic device. In the process of the first electronic device transmitting data with the second electronic device through the target UDP data transmission channel, the first electronic device can encrypt the UDP data packet according to the target symmetric key, and send the encrypted UDP data packet to the second electronic device through the target UDP data transmission channel. The second electronic device can use the target public key to decrypt the encrypted UDP data packet, thereby realizing secure data transmission.

[0181] For example, Fig.13A This is a timing diagram of two electronic devices establishing a UDP data transmission channel for the first time in an example. Fig.13AAs shown, when the first electronic device and the second electronic device establish a UDP data transmission channel for the first time, the first electronic device can send a Seekerhello message to the second electronic device, the second electronic device can receive the Seekerhello message, and reply with configuration information (config), the first electronic device can generate a temporary public key and a temporary symmetric key according to the configuration information, and encrypt the interactive data according to the temporary symmetric key, and then send the encrypted interactive data and the temporary public key to the second electronic device. The second electronic device can verify the temporary public key, decrypt the encrypted interactive data, and save the decrypted interactive data. The first electronic device can regenerate the target public key and the target symmetric key according to the configuration information, the first electronic device can send the target public key to the second electronic device, and the two can realize secure data transmission in the UDP data transmission channel based on the target public key and the target symmetric key.

[0182] In the above-mentioned embodiment, when the first electronic device and the second electronic device establish a UDP data transmission channel for the first time, two rounds of key negotiation can be performed. The temporary key of the first round of negotiation can be used to encrypt and decrypt the interactive data, and the transmission key of the second round of negotiation can be used to encrypt and decrypt the transmitted UDP data packets, thereby ensuring the security of data transmission.

[0183] In some embodiments, when it is not the first time that the first electronic device and the second electronic device establish a UDP data transmission channel, the first electronic device can negotiate with the second electronic device a transmission key corresponding to the target UDP data transmission channel based on the stored temporary key.

[0184] In the case where the first electronic device and the second electronic device are not establishing a UDP data transmission channel for the first time, the first electronic device stores the configuration information corresponding to the second electronic device, and the first electronic device and the second electronic device store each other's device information, connection information, etc., so there is no need to regenerate the temporary key. The first electronic device regenerates a new random number, and can generate a target public key and a target symmetric key in the same way as generating a temporary public key and a temporary symmetric key, and sends the newly generated target public key to the second electronic device.

[0185] Furthermore, after creating the first UDP socket, the first electronic device may send a first request signal to the second electronic device. For example, the first request signal may be a Seeker hello message, and the first request signal may carry a target public key generated by the first electronic device.

[0186] Optionally, the second electronic device may verify the received target public key. The method of verifying the target public key is similar to the method of verifying the temporary public key described in the above embodiment, and will not be repeated here.

[0187] When the target public key is successfully verified, the two can realize secure data transmission in the UDP data transmission channel based on the target public key and the target symmetric key. The first electronic device can encrypt the UDP data packet according to the target symmetric key, and send the encrypted UDP data packet to the second electronic device through the target UDP data transmission channel, and the second electronic device can use the target public key to decrypt the encrypted UDP data packet.

[0188] For example, Fig. 13B This is a timing diagram of two electronic devices establishing a UDP data transmission channel in an example. Fig. 13B As shown, when the first electronic device and the second electronic device do not establish a UDP data transmission channel for the first time, the first electronic device can generate a target public key and a target symmetric key according to the stored configuration information, and the first electronic device can send a Seeker hello message to the second electronic device, and the Seeker hello message carries the target public key. The second electronic device receives the Seeker hello message and can save the target public key. The two can realize secure data transmission in the UDP data transmission channel based on the target public key and the target symmetric key.

[0189] In this embodiment, when the first electronic device and the second electronic device are not establishing a UDP data transmission channel for the first time, a round of key negotiation can be directly performed to determine the transmission key corresponding to the target UDP data transmission channel. While ensuring secure data transmission, it can reduce overhead and the time spent in establishing the target UDP data transmission channel.

[0190] In some embodiments, for different UDP data transmission channels, corresponding transmission keys can be generated, and the generated transmission keys can be bound to the session identifiers of the UDP data transmission channels, thereby achieving secure data transmission for each UDP data transmission channel.

[0191] In an embodiment of the present application, an encryption mechanism of the UDP protocol is provided, which can realize secure data transmission through the UDP data transmission channel.

[0192] like Fig.14 As shown, in one embodiment, another data transmission method is provided, which can be applied to the second electronic device mentioned above, and the method may include the following steps:

[0193] Step 1410: establish a target UDP data transmission channel with the first electronic device, where the target UDP data transmission channel corresponds to a target session identifier, and the target session identifier is used to identify the target UDP data transmission channel.

[0194] Step 1420: UDP data packets are transmitted with the first electronic device through the target UDP data transmission channel. The UDP data packets transmitted through the target UDP data transmission channel carry the target session identifier.

[0195] In some embodiments, step 1410 may include: obtaining a target session identifier; creating a second UDP socket based on the target session identifier; establishing a target UDP data transmission channel with a first UDP socket of a first electronic device through the second UDP socket, the first UDP socket being created by the first electronic device based on the target session identifier.

[0196] In some embodiments, the step of establishing a target UDP data transmission channel with the first UDP socket of the first electronic device through the second UDP socket includes: receiving, through the second UDP socket, a first request signal sent by the first electronic device through the first UDP socket; sending a first response signal to the first electronic device through the second UDP socket, so that the first electronic device receives the first response signal through the first UDP socket, and establishing a target UDP data transmission channel between the first UDP socket and the second UDP socket.

[0197] In some embodiments, the step of obtaining the target session identifier includes: receiving the target session identifier sent by the first electronic device through the target communication connection between the first electronic device, and the target session identifier is generated by the first electronic device. Alternatively, the step of obtaining the target session identifier includes: generating the target session identifier, and the method further includes: sending the generated target session identifier to the first electronic device through the target communication connection between the first electronic device and the first electronic device.

[0198] In some embodiments, the method also includes: upon successfully receiving a target number of UDP data packets sent by the first electronic device through the target UDP data transmission channel, submitting the target number of UDP data packets to a target application corresponding to the UDP data transmission channel.

[0199] In some embodiments, the method also includes: sending a confirmation signal to the first electronic device when a target number of UDP data packets sent by the first electronic device are successfully received through the target UDP data transmission channel; and / or, when there is packet loss among the target number of UDP data packets, not sending a confirmation signal to the first electronic device, so that the first electronic device resends the target number of UDP data packets.

[0200] In some embodiments, the method also includes: receiving a broadcast signal sent by the first electronic device, the broadcast signal carrying a target session identifier, the broadcast signal being sent by the first electronic device when the communication connection between the first electronic device and the second electronic device is disconnected; comparing the target session identifier with multiple session identifiers existing in the second electronic device; if the comparison is successful, sending a second response signal to the first electronic device, so that the first electronic device, upon receiving the second response signal, continues to transmit UDP data packets with the second electronic device through the target UDP data transmission channel.

[0201] In some embodiments, before step 1420, the method also includes: negotiating with the first electronic device a transmission key corresponding to the target UDP data transmission channel; the step 1420 may include: receiving an encrypted UDP data packet sent by the first electronic device through the target UDP data transmission channel; and decrypting the UDP data packet based on the transmission key.

[0202] In some embodiments, the step of negotiating with the first electronic device a transmission key corresponding to a target UDP data transmission channel includes: when establishing a UDP data transmission channel with the first electronic device for the first time, negotiating a temporary key with the first electronic device; based on the temporary key, negotiating with the first electronic device a transmission key corresponding to the target UDP data transmission channel.

[0203] It should be noted that the description of the data transmission method applied to the second electronic device provided in the embodiments of the present application can refer to the relevant description of the data transmission method applied to the first electronic device provided in the above embodiments, and will not be repeated here.

[0204] In an embodiment of the present application, a UDP data transmission channel corresponding to a session identifier can be established between different electronic devices, and UDP communication can be performed based on the session identifier. As long as the session identifier remains unchanged, UDP data packet transmission can be achieved through the UDP data transmission channel corresponding to the session identifier, which can weaken the strong coupling relationship between the UDP protocol and the underlying network. When the underlying network changes, the UDP data transmission channel between the two electronic devices can still be maintained, thereby improving the stability of data transmission. In addition, different UDP data transmission channels between two electronic devices can correspond to different session identifiers, and different UDP data transmission channels will not affect each other, and independent transmission control of each UDP data transmission channel can be achieved, thereby improving the flexibility and efficiency of data transmission.

[0205] like Fig.15 As shown, in one embodiment, a data transmission device 1500 is provided, which can be applied to the first electronic device mentioned above. The data transmission device 1500 may include: a first channel establishing module 1510 and a first transmission module 1520.

[0206] The first channel establishing module 1510 is used to establish a target UDP data transmission channel with the second electronic device, where the target UDP data transmission channel corresponds to a target session identifier, and the target session identifier is used to identify the target UDP data transmission channel;

[0207] The first transmission module 1520 is used to transmit UDP data packets with the second electronic device through a target UDP data transmission channel, and the UDP data packets transmitted through the target UDP data transmission channel carry a target session identifier.

[0208] In one embodiment, the target session identifier is determined according to a target service provided by a target application.

[0209] In one embodiment, the target session identifier is generated based on the application identifier of the target application program, the service identifier of the target service, and a random number.

[0210] In one embodiment, the first channel establishing module 1510 includes a first identification obtaining unit, a first socket creating unit and a first establishing unit.

[0211] The first identifier acquisition unit is used to acquire a target session identifier.

[0212] The first socket creation unit is used to create a first UDP socket based on the target session identifier.

[0213] The first establishing unit is used to establish a target UDP data transmission channel with a second UDP socket of a second electronic device through the first UDP socket, where the second UDP socket is created by the second electronic device based on a target session identifier.

[0214] In one embodiment, the first establishing unit is also used to send a first request signal through the first UDP socket, and the first request signal is used to instruct the second electronic device to receive the first request signal through the second UDP socket and feed back a first response signal; receive the first response signal sent by the second electronic device through the first UDP socket; and establish a target UDP data transmission channel between the first UDP socket and the second UDP socket.

[0215] In one embodiment, the first identifier acquisition unit is further configured to receive a target session identifier sent by the second electronic device through a target communication connection with the second electronic device, where the target session identifier is generated by the second electronic device.

[0216] The first identifier acquisition unit is further configured to generate a target session identifier.

[0217] The data transmission device 1500 also includes a first identification sending module.

[0218] The first identifier sending module is used to send the generated target session identifier to the second electronic device through the target communication connection between the second electronic device and the second electronic device.

[0219] In one embodiment, the UDP data packet also carries a packet sequence number, and the packet sequence number is used to indicate the transmission order corresponding to the UDP data packet.

[0220] In one embodiment, the data transmission device 1500 further includes a retransmission determination module and an allocation module.

[0221] The retransmission determination module is used to determine the target UDP data packet that needs to be retransmitted.

[0222] The allocation module is used to allocate a target packet sequence number to a target UDP data packet, where the target packet sequence number is the next packet sequence number of the packet sequence number carried by the most recently sent UDP data packet.

[0223] The first transmission module 1520 is further configured to send the target UDP data packet carrying the target packet sequence number to the second electronic device through the target UDP data transmission channel.

[0224] In one embodiment, the retransmission determination module is also used to determine that the first UDP data packet is a target UDP data packet that needs to be retransmitted if a confirmation signal sent by the second electronic device is not received within a first time length of sending the first UDP data packet; the confirmation signal is used to indicate that the second electronic device has received the first UDP data packet.

[0225] In one embodiment, the first transmission module 1520 is further configured to send a target number of second UDP data packets to the second electronic device through a target UDP data transmission channel.

[0226] The retransmission determination module is also used to determine that the target number of second UDP data packets are target UDP data packets that need to be retransmitted if no confirmation signal sent by the second electronic device is received within a first time period after sending the target number of second UDP data packets; the confirmation signal is used to indicate that the second electronic device has received the target number of second UDP data packets.

[0227] In one embodiment, the target number is determined according to the delay requirement corresponding to the target UDP data transmission channel.

[0228] In one embodiment, multiple UDP data transmission channels established between the first electronic device and the second electronic device share the same physical connection, and the multiple UDP data transmission channels correspond to different session identifiers respectively; and / or,

[0229] The target UDP data transmission channel uses multiple physical connections to transmit UDP data packets.

[0230] In one embodiment, the data transmission device 1500 further includes a broadcast module and a response receiving module.

[0231] The broadcast module is used to send a broadcast signal when the communication connection between the first electronic device and the second electronic device is disconnected, and the broadcast signal carries a target session identifier so that the second electronic device can feedback a second response signal when the communication connection is restored.

[0232] The response receiving module is used to receive a second response signal sent by the second electronic device.

[0233] The first transmission module 1520 is further configured to continue transmitting UDP data packets with the second electronic device through the target UDP data transmission channel.

[0234] In one embodiment, the data transmission device 1500 further includes a first key negotiation module.

[0235] The first key negotiation module is used to negotiate with the second electronic device a transmission key corresponding to a target UDP data transmission channel.

[0236] The first transmission module 1520 is further configured to encrypt the UDP data packet based on the transmission key, and send the encrypted UDP data packet to the second electronic device through the target UDP data transmission channel.

[0237] In one embodiment, the first key negotiation module is also used to negotiate a temporary key with the second electronic device when a UDP data transmission channel is established with the second electronic device for the first time; based on the temporary key, negotiate with the second electronic device a transmission key corresponding to the target UDP data transmission channel.

[0238] In one embodiment, the first key negotiation module is further used to negotiate with the second electronic device a transmission key corresponding to the target UDP data transmission channel based on the stored temporary key when the UDP data transmission channel is not established with the second electronic device for the first time.

[0239] In an embodiment of the present application, a UDP data transmission channel corresponding to a session identifier can be established between different electronic devices, and UDP communication can be performed based on the session identifier. As long as the session identifier remains unchanged, UDP data packet transmission can be achieved through the UDP data transmission channel corresponding to the session identifier, which can weaken the strong coupling relationship between the UDP protocol and the underlying network. When the underlying network changes, the UDP data transmission channel between the two electronic devices can still be maintained, thereby improving the stability of data transmission. In addition, different UDP data transmission channels between two electronic devices can correspond to different session identifiers, and different UDP data transmission channels will not affect each other, and independent transmission control of each UDP data transmission channel can be achieved, thereby improving the flexibility and efficiency of data transmission.

[0240] like Fig.16 As shown, in one embodiment, a data transmission device 1600 is provided, which can be applied to the second electronic device mentioned above. The data transmission device 1600 includes: a second channel establishing module 1610 and a second transmission module 1620.

[0241] The second channel establishing module 1610 is used to establish a target UDP data transmission channel with the first electronic device, where the target UDP data transmission channel corresponds to a target session identifier, and the target session identifier is used to identify the target UDP data transmission channel.

[0242] The second transmission module 1620 is used to transmit UDP data packets with the first electronic device through a target UDP data transmission channel, and the UDP data packets transmitted by the target UDP data transmission channel carry a target session identifier.

[0243] In one embodiment, the second channel establishing module 1610 may include a second identification obtaining unit, a second socket creating unit and a second establishing unit.

[0244] The second identifier obtaining unit is used to obtain a target session identifier.

[0245] The second socket creation unit is used to create a second UDP socket based on the target session identifier.

[0246] The second establishing unit is used to establish a target UDP data transmission channel with a first UDP socket of a first electronic device through a second UDP socket, where the first UDP socket is created by the first electronic device based on a target session identifier.

[0247] In one embodiment, the second establishing unit is also used to receive, through the second UDP socket, a first request signal sent by the first electronic device through the first UDP socket; send a first response signal to the first electronic device through the second UDP socket, so that the first electronic device receives the first response signal through the first UDP socket, and establish a target UDP data transmission channel between the first UDP socket and the second UDP socket.

[0248] In one embodiment, the second identifier acquisition unit is further configured to receive a target session identifier sent by the first electronic device through a target communication connection with the first electronic device, where the target session identifier is generated by the first electronic device.

[0249] The second identifier acquisition unit is further configured to generate a target session identifier.

[0250] The data transmission device 1600 also includes a second identification sending module.

[0251] The second identifier sending module is used to send the generated target session identifier to the first electronic device through the target communication connection between the first electronic device and the first electronic device.

[0252] In one embodiment, the data transmission device 1600 further includes a handover module.

[0253] The handover module is used to hand over the target number of UDP data packets to the target application corresponding to the UDP data transmission channel when the target number of UDP data packets sent by the first electronic device are successfully received through the target UDP data transmission channel.

[0254] In one embodiment, the data transmission device 1600 further includes a confirmation module.

[0255] A confirmation module is used to send a confirmation signal to the first electronic device when a target number of UDP data packets sent by the first electronic device are successfully received through a target UDP data transmission channel; and / or, when there is packet loss among the target number of UDP data packets, not send a confirmation signal to the first electronic device, so that the first electronic device resends the target number of UDP data packets.

[0256] In one embodiment, the data transmission device 1600 further includes a broadcast receiving module, a comparison module and a response sending module.

[0257] The broadcast receiving module is used to receive a broadcast signal sent by a first electronic device, the broadcast signal carries a target session identifier, and the broadcast signal is sent by the first electronic device when the communication connection between the first electronic device and the second electronic device is disconnected.

[0258] The comparison module is used to compare the target session identifier with multiple session identifiers existing in the second electronic device.

[0259] The response sending module is used to send a second response signal to the first electronic device if the comparison is successful, so that the first electronic device continues to transmit UDP data packets with the second electronic device through the target UDP data transmission channel after receiving the second response signal.

[0260] In one embodiment, the data transmission device 1600 further includes a second key negotiation module.

[0261] The second key negotiation module is used to negotiate with the first electronic device a transmission key corresponding to a target UDP data transmission channel.

[0262] The second transmission module 1620 is further configured to receive the encrypted UDP data packet sent by the first electronic device through the target UDP data transmission channel; and decrypt the UDP data packet based on the transmission key.

[0263] In one embodiment, the second key negotiation module is also used to negotiate a temporary key with the first electronic device when a UDP data transmission channel is established with the first electronic device for the first time; based on the temporary key, negotiate with the first electronic device a transmission key corresponding to the target UDP data transmission channel.

[0264] In an embodiment of the present application, a UDP data transmission channel corresponding to a session identifier can be established between different electronic devices, and UDP communication can be performed based on the session identifier. As long as the session identifier remains unchanged, UDP data packet transmission can be achieved through the UDP data transmission channel corresponding to the session identifier, which can weaken the strong coupling relationship between the UDP protocol and the underlying network. When the underlying network changes, the UDP data transmission channel between the two electronic devices can still be maintained, thereby improving the stability of data transmission. In addition, different UDP data transmission channels between two electronic devices can correspond to different session identifiers, and different UDP data transmission channels will not affect each other, and independent transmission control of each UDP data transmission channel can be achieved, thereby improving the flexibility and efficiency of data transmission.

[0265] Fig.17 FIG. 1 is a structural block diagram of an electronic device in an embodiment. Fig.17 As shown, the electronic device 1700 may include one or more of the following components: a processor 1710, a memory 1720 coupled to the processor 1710, and a transceiver unit, wherein the memory 1720 may store one or more computer programs, and the one or more computer programs may be configured to be executed by one or more processors 1710, so that the electronic device 1700 implements the data transmission method applied to the first electronic device as described in the above embodiments.

[0266] The processor 1710 may include one or more processing cores. The processor 1710 uses various interfaces and lines to connect various parts of the entire electronic device 1700, and executes various functions and processes data of the electronic device 1700 by running or executing instructions, programs, code sets or instruction sets stored in the memory 1720, and calling data stored in the memory 1720. Optionally, the processor 1710 can be implemented in at least one hardware form of digital signal processing (DSP), field-programmable gate array (FPGA), and programmable logic array (PLA). The processor 1710 can integrate one or a combination of a central processing unit (CPU), a graphics processing unit (GPU), and a modem. Among them, the CPU mainly processes the operating system, user interface, and application programs; the GPU is responsible for rendering and drawing display content; and the modem is used to process wireless communications. It can be understood that the above-mentioned modem may not be integrated into the processor 1710, but may be implemented separately through a communication chip.

[0267] The memory 1720 may include a random access memory (RAM) or a read-only memory (ROM). The memory 1720 may be used to store instructions, programs, codes, code sets or instruction sets. The memory 1720 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for implementing at least one function (such as a touch function, a sound playback function, an image playback function, etc.), instructions for implementing the above-mentioned various method embodiments, etc. The data storage area may also store data created by the electronic device 1700 during use, etc.

[0268] The transceiver unit may include but is not limited to a Bluetooth module, a Wi-Fi module, etc., which may be used to provide communication functions.

[0269] An embodiment of the present application discloses an electronic device, including a memory, a processor, and a transceiver unit. The memory stores a computer program. When the computer program is executed by the processor, the headphone device implements the data transmission method applied to a second electronic device as described in the above embodiments.

[0270] An embodiment of the present application discloses a computer-readable storage medium storing a computer program, wherein when the computer program is executed by a processor in an electronic device, the electronic device implements the data transmission method applied to a first electronic device as described in the above embodiments.

[0271] An embodiment of the present application discloses a computer-readable storage medium storing a computer program, wherein when the computer program is executed by a processor in an electronic device, the electronic device implements the data transmission method applied to a second electronic device as described in the above embodiments.

[0272] An embodiment of the present application discloses a computer program product, which includes a computer program. When the computer program can be executed by a processor in an electronic device, the electronic device implements the data transmission method applied to a first electronic device as described in the above embodiments.

[0273] An embodiment of the present application discloses a computer program product, which includes a computer program. When the computer program can be executed by a processor in an electronic device, the electronic device implements the data transmission method applied to a second electronic device as described in the above embodiments.

[0274] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing related hardware through a computer program, and the program can be stored in a non-volatile computer-readable storage medium, and when the program is executed, it can include the processes of the embodiments of the above-mentioned methods. The storage medium can be a disk, an optical disk, a ROM, etc.

[0275] As used herein, any reference to memory, storage, database, or other medium may include nonvolatile and / or volatile memory. Suitable nonvolatile memory may include ROM, programmable ROM (Programmable ROM, PROM), erasable PROM (Erasable PROM, EPROM), electrically erasable PROM (Electrically Erasable PROM, EEPROM), or flash memory. Volatile memory may include random access memory (RAM), which is used as an external cache memory. By way of illustration and not limitation, RAM may be in a variety of forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), memory bus direct RAM (RDRAM) and direct memory bus dynamic RAM (DRDRAM).

[0276] It should be understood that "one embodiment" or "an embodiment" mentioned throughout the specification means that specific features, structures or characteristics related to the embodiment are included in at least one embodiment of the present application. Therefore, "in one embodiment" or "in an embodiment" appearing throughout the specification does not necessarily refer to the same embodiment. In addition, these specific features, structures or characteristics can be combined in one or more embodiments in any suitable manner. Those skilled in the art should also be aware that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily required by the present application. It should be noted that "multiple" in the present application includes "two or more".

[0277] In the various embodiments of the present application, it should be understood that the size of the serial numbers of the above-mentioned processes does not necessarily mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.

[0278] The units described above as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple 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.

[0279] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0280] The technical features of the above-described embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above-described embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0281] The above is a detailed introduction to a data transmission method, device, electronic device and computer program product disclosed in the embodiments of the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method and core idea of ​​the present application. At the same time, for those of ordinary skill in the art, according to the idea of ​​the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.

Claims

1. A data transmission method, characterized in that: Applied to a first electronic device, the method includes: Establishing a target User Datagram Protocol (UDP) data transmission channel with the second electronic device, wherein the target UDP data transmission channel corresponds to a target session identifier, and the target session identifier is used to identify the target UDP data transmission channel; UDP data packets are transmitted with the second electronic device via the target UDP data transmission channel, and the UDP data packets transmitted via the target UDP data transmission channel carry the target session identifier.

2. The method according to claim 1, characterized in that The target session identifier is determined according to the target service provided by the target application.

3. The method according to claim 2, characterized in that The target session identifier is generated according to the application identifier of the target application program, the service identifier of the target service, and a random number.

4. The method according to claim 1, characterized in that The step of establishing a target User Datagram Protocol (UDP) data transmission channel with the second electronic device includes: Get the target session ID; Based on the target session identifier, create a first UDP socket; A target UDP data transmission channel is established with a second UDP socket of a second electronic device through the first UDP socket, where the second UDP socket is created by the second electronic device based on the target session identifier.

5. The method according to claim 4, characterized in that The step of establishing a target UDP data transmission channel with a second UDP socket of a second electronic device through the first UDP socket includes: Sending a first request signal through the first UDP socket, where the first request signal is used to instruct the second electronic device to receive the first request signal through the second UDP socket and feed back a first response signal; receiving, through the first UDP socket, the first response signal sent by the second electronic device; Establish a target UDP data transmission channel between the first UDP socket and the second UDP socket.

6. The method according to claim 4, characterized in that The step of obtaining the target session identifier includes: Receiving, through a target communication connection with a second electronic device, a target session identifier sent by the second electronic device, wherein the target session identifier is generated by the second electronic device; or, Generate a target session ID, The method further comprises: The generated target session identifier is sent to the second electronic device through the target communication connection with the second electronic device.

7. The method according to claim 1, characterized in that The UDP data packet also carries a packet sequence number, and the packet sequence number is used to characterize the transmission order corresponding to the UDP data packet.

8. The method according to claim 7, characterized in that The method further comprises: Determine the target UDP data packet that needs to be retransmitted; Assign a target packet sequence number to the target UDP data packet, wherein the target packet sequence number is the next packet sequence number of the packet sequence number carried by the most recently sent UDP data packet; The target UDP data packet carrying the target packet sequence number is sent to the second electronic device through the target UDP data transmission channel.

9. The method according to claim 8, characterized in that Determining the target UDP data packet that needs to be retransmitted includes: If a confirmation signal sent by the second electronic device is not received within the first time period of sending the first UDP data packet, it is determined that the first UDP data packet is a target UDP data packet that needs to be retransmitted; the confirmation signal is used to indicate that the second electronic device has received the first UDP data packet.

10. The method according to claim 8, characterized in that Before determining the target UDP data packet that needs to be retransmitted, the method further includes: Sending a target number of second UDP data packets to the second electronic device through the target UDP data transmission channel; Determining the target UDP data packet that needs to be retransmitted includes: If a confirmation signal sent by the second electronic device is not received within the first time period after sending the target number of second UDP data packets, it is determined that the target number of second UDP data packets are target UDP data packets that need to be retransmitted; the confirmation signal is used to indicate that the second electronic device has received the target number of second UDP data packets.

11. The method according to claim 10, characterized in that The target quantity is determined according to the delay requirement corresponding to the target UDP data transmission channel.

12. The method according to any one of claims 1 to 11, characterized in that: The multiple UDP data transmission channels established between the first electronic device and the second electronic device share the same physical connection, and the multiple UDP data transmission channels correspond to different session identifiers respectively; and / or, The target UDP data transmission channel uses multiple physical connections to transmit UDP data packets.

13. The method according to any one of claims 1 to 11, characterized in that: The method further comprises: When the communication connection between the first electronic device and the second electronic device is disconnected, sending a broadcast signal carrying the target session identifier, so that when the communication connection is restored, the second electronic device feeds back a second response signal; receiving the second response signal sent by the second electronic device; Continue to transmit UDP data packets with the second electronic device through the target UDP data transmission channel.

14. The method according to any one of claims 1 to 11, characterized in that: Before transmitting the UDP data packet with the second electronic device through the target UDP data transmission channel, the method further includes: Negotiate with the second electronic device a transmission key corresponding to the target UDP data transmission channel; The transmitting of UDP data packets with the second electronic device through the target UDP data transmission channel includes: Encrypting the UDP data packet based on the transmission key; The encrypted UDP data packet is sent to the second electronic device through the target UDP data transmission channel.

15. The method according to claim 14, characterized in that The negotiating with the second electronic device a transmission key corresponding to the target UDP data transmission channel includes: When establishing a UDP data transmission channel with the second electronic device for the first time, negotiating a temporary key with the second electronic device; Based on the temporary key, negotiate with the second electronic device a transmission key corresponding to the target UDP data transmission channel.

16. The method according to claim 15, characterized in that The step of negotiating with the second electronic device a transmission key corresponding to the target UDP data transmission channel further includes: In case that it is not the first time to establish the UDP data transmission channel with the second electronic device, based on the stored temporary key, a transmission key corresponding to the target UDP data transmission channel is negotiated with the second electronic device.

17. A data transmission method, characterized in that: Applied to a second electronic device, the method includes: Establishing a target UDP data transmission channel with the first electronic device, wherein the target UDP data transmission channel corresponds to a target session identifier, and the target session identifier is used to identify the target UDP data transmission channel; UDP data packets are transmitted with the first electronic device via the target UDP data transmission channel, and the UDP data packets transmitted by the target UDP data transmission channel carry the target session identifier.

18. The method according to claim 17, characterized in that The step of establishing a target UDP data transmission channel with the first electronic device includes: Get the target session ID; Based on the target session identifier, create a second UDP socket; A target UDP data transmission channel is established with a first UDP socket of a first electronic device through the second UDP socket, where the first UDP socket is created by the first electronic device based on the target session identifier.

19. The method according to claim 18, characterized in that The step of establishing a target UDP data transmission channel with the first UDP socket of the first electronic device through the second UDP socket includes: Receiving, through the second UDP socket, a first request signal sent by the first electronic device through the first UDP socket; A first response signal is sent to the first electronic device through the second UDP socket, so that the first electronic device receives the first response signal through the first UDP socket, and a target UDP data transmission channel is established between the first UDP socket and the second UDP socket.

20. The method according to claim 18, characterized in that The step of obtaining the target session identifier includes: Receiving, through a target communication connection with a first electronic device, a target session identifier sent by the first electronic device, wherein the target session identifier is generated by the first electronic device; or, Generate a target session ID, The method further comprises: The generated target session identifier is sent to the first electronic device through the target communication connection with the first electronic device.

21. The method according to claim 17, characterized in that The method further comprises: When the target number of UDP data packets sent by the first electronic device are successfully received through the target UDP data transmission channel, the target number of UDP data packets are submitted to the target application corresponding to the target UDP data transmission channel.

22. The method according to claim 17, characterized in that The method further comprises: When the target number of UDP data packets sent by the first electronic device are successfully received through the target UDP data transmission channel, sending a confirmation signal to the first electronic device; and / or, In the case that there is packet loss among the target number of UDP data packets, no confirmation signal is sent to the first electronic device, so that the first electronic device resends the target number of UDP data packets.

23. The method according to any one of claims 17 to 22, characterized in that: The method further comprises: receiving a broadcast signal sent by a first electronic device, the broadcast signal carrying the target session identifier, the broadcast signal being sent by the first electronic device when a communication connection between the first electronic device and the second electronic device is disconnected; Comparing the target session identifier with multiple session identifiers existing in the second electronic device; If the comparison is successful, a second response signal is sent to the first electronic device, so that the first electronic device continues to transmit UDP data packets with the second electronic device through the target UDP data transmission channel when receiving the second response signal.

24. The method according to any one of claims 17 to 22, characterized in that: Before transmitting the UDP data packet with the first electronic device through the target UDP data transmission channel, the method further includes: Negotiate with the first electronic device a transmission key corresponding to the target UDP data transmission channel; The transmitting of UDP data packets with the first electronic device through the target UDP data transmission channel includes: Receiving, via the target UDP data transmission channel, an encrypted UDP data packet sent by the first electronic device; Based on the transport key, the UDP data packet is decrypted.

25. The method according to claim 24, characterized in that The negotiating with the first electronic device a transmission key corresponding to the target UDP data transmission channel includes: When establishing a UDP data transmission channel with the first electronic device for the first time, negotiating a temporary key with the first electronic device; Based on the temporary key, negotiate with the first electronic device a transmission key corresponding to the target UDP data transmission channel.

26. A data transmission device, characterized in that: Applied to a first electronic device, the device comprises: A first channel establishment module, used to establish a target User Datagram Protocol UDP data transmission channel with a second electronic device, wherein the target UDP data transmission channel corresponds to a target session identifier, and the target session identifier is used to identify the target UDP data transmission channel; The first transmission module is used to transmit UDP data packets with the second electronic device through the target UDP data transmission channel, and the UDP data packets transmitted by the target UDP data transmission channel carry the target session identifier.

27. A data transmission device, characterized in that: Applied to a second electronic device, the device comprises: A second channel establishment module, used to establish a target UDP data transmission channel with the first electronic device, wherein the target UDP data transmission channel corresponds to a target session identifier, and the target session identifier is used to identify the target UDP data transmission channel; The second transmission module is used to transmit UDP data packets with the first electronic device through the target UDP data transmission channel, and the UDP data packets transmitted by the target UDP data transmission channel carry the target session identifier.

28. An electronic device, characterized in that: The electronic device comprises a memory, a processor and a transceiver unit. The memory stores a computer program. When the computer program is executed by the processor, the electronic device implements the method according to any one of claims 1 to 16 or 17 to 25.

29. A computer program product, characterized in that The method comprises a computer program, and when the computer program is executed by a processor in an electronic device, the electronic device implements the method according to any one of claims 1 to 16 or 17 to 25.

Citation Information

Cited By

  • Data transmission method and system in Internet of Things environment and storage medium

    CN120935210A