Message transmission method and device
By splicing messages in remote control application scenarios and sending them based on unreliable transmission protocols, the problem of difficult real-time, orderly and reliable transmission of messages in the prior art is solved, and efficient and low-latency message transmission is achieved.
Patent Information
- Application Number
- CN202510076728.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-17
- Publication Date
- 2025-05-16
AI Technical Summary
The existing transmission protocols are difficult to meet the needs of real-time, orderly and reliable transmission of messages in remote control application scenarios, and it is also difficult to effectively reduce transmission delay.
The message to be sent is generated at the sending end and the message splicing process is performed according to the maximum transmission unit (MTU), thereby forming the splicing message. Then, based on the unreliable transmission protocol, the splicing message is sent to the receiving end and parsed on the receiving end to ensure the orderly and reliability of the message.
It realizes that while meeting orderly and reliable transmission, it effectively reduces transmission delay and meets the high real-time requirements of remote control application scenarios.
Smart Images

Figure CN120017231A_ABST
Abstract
Description
Technical Field
[0001] One or more embodiments of the present specification relate to the field of communication technology, and in particular, to a message transmission method and device. Background Art
[0002] In the current information age, remote control application scenarios are becoming increasingly widespread, covering cloud applications, cloud games, robot remote control and other fields. A core requirement of these scenarios is to achieve real-time message transmission. These messages are usually used for instant operations, so the real-time requirements are extremely high. At the same time, in order to ensure the accuracy and continuity of operations, the transmission of messages must also meet the requirements of orderly and reliable.
[0003] However, existing transmission protocols are difficult to meet the above requirements. Therefore, it is necessary to provide a message transmission method that can ensure orderly and reliable transmission of messages and can effectively reduce transmission delays. Summary of the invention
[0004] In order to meet the requirements of orderly, reliable and low-delay transmission of messages, one or more embodiments of this specification provide a message transmission method and device.
[0005] In a first aspect, one or more embodiments of the present specification provide a message transmission method, which is applied to a sending end, and the method includes: generating a message to be sent; determining the maximum transmission unit MTU of a transmission link used to transmit the message to be sent; when the data volume of the message to be sent is less than or equal to the MTU, caching the message to be sent as a cache message in a sending message queue of the sending end; wherein the sending message queue is used to cache messages that have been generated and have not yet been notified by the receiving end that they have been successfully received; when the sending message queue includes multiple cached messages, and the total data volume of the first cached message and the second cached message in the sending message queue is less than or equal to the maximum transmission unit, the first N cached messages in the sending message queue are processed by message splicing to obtain a spliced message; N is the maximum number of cached messages that the spliced message can contain, and the total data volume of the first N cached messages is less than or equal to the MTU; and the spliced message is sent to the receiving end based on an unreliable transmission protocol.
[0006] In one possible implementation, each cached message in the sending message queue has an ordered message number, and the method also includes: receiving a confirmation message fed back by the receiving end; wherein the confirmation message is used to notify the receiving end of the maximum message number among the messages that have been successfully received; and deleting the cached messages whose message numbers are less than or equal to the maximum message number from the sending message queue.
[0007] In a possible implementation, the method also includes: when the data volume of the message to be sent is greater than the MTU, splitting the message to be sent into M message fragments, wherein the data volume of each message fragment is less than or equal to MTU / n, wherein n is an integer greater than 1, and M is an integer greater than n; and caching the M message fragments as a cache message in the sending message queue of the sender.
[0008] In one possible implementation, the message packet header of each cached message includes a message type field and a message number field; wherein the message type field is used to identify the type of the cached message as a message fragment of a message to be sent or a complete message to be sent, and multiple message fragments of the same message to be sent have the same message number; for cached messages that are message fragments, their message packet header also includes a field for the total number of message fragments contained in the message to be sent to which the message fragment belongs and a message fragment sequence number field corresponding to the message fragment.
[0009] In a possible implementation, the method further includes: when the total data volume of the first buffered message and the second buffered message in the sending message queue is greater than the MTU, sending the first buffered message to the receiving end based on an unreliable transmission protocol.
[0010] In a possible implementation, the method also includes: estimating the network bandwidth used to transmit cached messages in a sending message queue at the current moment; obtaining a first frequency of sending cached messages in a sending message queue and a data volume of cached messages sent each time within a first preset time period before the current moment; determining a total data volume of cached messages sent within the first preset time period based on the first frequency and the data volume of cached messages sent each time; sending cached messages in the sending message queue at a second frequency within a second preset time period after the current moment when the total data volume of cached messages sent within the first preset time period is greater than or equal to the network bandwidth; wherein the second preset time period is the same length as the first preset time period, and the second frequency is less than the first frequency; and sending cached messages in the sending message queue at a third frequency within the second preset time period when the total data volume of cached messages sent within the first preset time period is less than the network bandwidth; wherein the third frequency is greater than the first frequency.
[0011] In a possible implementation, the message to be sent is at least one of a control instruction, an operation instruction, and status data.
[0012] In one possible implementation, the unreliable transport protocol includes the unreliable mode of the User Datagram Protocol UDP and the Quick UDP Internet Connection QUIC protocol.
[0013] In a second aspect, one or more embodiments of the present specification provide a message transmission method, which is applied to a receiving end, and the method includes: receiving a message sent by a sending end based on an unreliable transmission protocol; when the message is a spliced message and the spliced message does not include message fragments, parsing and processing the spliced message to obtain multiple continuous independent messages; and feeding back a confirmation message to the sending end, the confirmation message is used to notify the receiving end of the message that has been successfully received, so that the sending end deletes the successfully received message from the sending message queue based on the confirmation message.
[0014] In a possible implementation, the method also includes: when the message is a spliced message and the spliced message includes message fragments, parsing the spliced message to obtain at least one message fragment; determining the message number of at least one message fragment, the total number of message fragments contained in the message to be sent, and the message fragment sequence number; based on the message number of at least one message fragment, the total number of message fragments contained in the message to be sent, and the message fragment sequence number, determining whether all message fragments belonging to the same message number are received; when all message fragments belonging to the same message number are received, restoring all message fragments belonging to the same message number into an independent message.
[0015] In one possible implementation, a receiving end includes a transport layer and an application layer; a confirmation message is fed back to a sending end, including: when the transport layer parses and obtains at least one independent message, a target independent message is sent to the application layer through the transport layer, and the target independent message is an independent message that has not been sent to the application layer before; a maximum message number in the target independent message is determined; and a confirmation message is fed back to the sending end, and the confirmation message includes the maximum message number, so that the sending end deletes cached messages whose message numbers are less than or equal to the maximum message number from the sending message queue.
[0016] In one possible implementation, the unreliable transport protocol includes the unreliable mode of the User Datagram Protocol UDP and the Quick UDP Internet Connection QUIC protocol.
[0017] In a third aspect, one or more embodiments of the present specification also provide a message transmission device, which is applied to a sending end, and the device includes: a generation module, which is used to generate a message to be sent; a determination module, which is used to determine the maximum transmission unit MTU of the transmission link used to transmit the message to be sent; a cache module, which is used to cache the message to be sent as a cache message to the sending message queue of the sending end when the data volume of the message to be sent is less than or equal to the MTU; wherein the sending message queue is used to cache messages that have been generated and have not yet been notified by the receiving end that they have been successfully received; a splicing module, which is used to include multiple cached messages in the sending message queue, and when the total data volume of the first cached message and the second cached message in the sending message queue is less than or equal to the maximum transmission unit, the first N cached messages in the sending message queue are processed to obtain a spliced message; N is the maximum number of cached messages that the spliced message can contain, and the total data volume of the first N cached messages is less than or equal to the MTU; a sending module is used to send the spliced message to the receiving end based on an unreliable transmission protocol.
[0018] In a fourth aspect, one or more embodiments of the present specification also provide a message transmission device, which is applied to a receiving end, and the device includes: a receiving module, which is used to receive a message sent by a sending end based on an unreliable transmission protocol; a parsing module, which is used to parse and process the spliced message when the message is a spliced message and the spliced message does not include message fragments, so as to obtain multiple continuous independent messages; a feedback module, which is used to feed back a confirmation message to the sending end, and the confirmation message is used to notify the receiving end of the message that has been successfully received, so that the sending end can delete the successfully received message from the sending message queue based on the confirmation message.
[0019] In a fifth aspect, one or more embodiments of the present specification also provide an electronic device, comprising a memory and a processor; the memory is used to store a computer program product; the processor is used to execute the computer program product stored in the memory, and when the computer program product is executed, the message transmission method of the first aspect or the second aspect mentioned above is implemented.
[0020] In a sixth aspect, one or more embodiments of the present specification further provide a computer-readable storage medium, wherein the computer-readable storage medium stores computer program instructions, and when the computer program instructions are executed, the message transmission method of the first aspect or the second aspect described above is implemented.
[0021] In summary, one or more embodiments of the present specification provide a message transmission method and device. In this method, on the one hand, the sending end actively retransmits the message that has been sent and has not yet been notified by the receiving end that it has been successfully received. In this way, compared with the confirmation retransmission mechanism in the reliable transmission protocol, it can effectively reduce the transmission delay in the lossy network. On the other hand, the sending end transmits the message to the receiving end by splicing multiple messages into a spliced message. In this way, if the receiving end receives the spliced message, it is equivalent to receiving all the continuous independent messages contained in the spliced message, and there will be no loss of one or more independent messages in the spliced message, thereby ensuring the orderly and reliable transmission of messages. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] In order to more clearly illustrate the technical solutions of one or more embodiments of the present specification, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of one or more embodiments of the present specification. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0023] Figure 1 A schematic diagram of transmitting a message based on a reliable transmission protocol provided for one or more embodiments of this specification;
[0024] Figure 2 A flowchart of a message transmission method provided for one or more embodiments of this specification;
[0025] Figure 3 A schematic diagram illustrating changes in a message sending queue provided in one or more embodiments of this specification;
[0026] Figure 4 A schematic diagram of transmitting a message based on an unreliable transmission protocol provided for one or more embodiments of this specification;
[0027] Figure 5 A structural block diagram of a message transmission device provided for one or more embodiments of this specification;
[0028] Figure 6 A structural block diagram of another message transmission device provided for one or more embodiments of this specification;
[0029] Figure 7 A structural block diagram of an electronic device provided for one or more embodiments of this specification. DETAILED DESCRIPTION
[0030] One or more embodiments of the present invention are further described in detail below through the accompanying drawings and examples. Through these descriptions, the features and advantages of one or more embodiments of the present invention will become clearer and more specific.
[0031] The word "exemplary" is used exclusively herein to mean "serving as an example, embodiment, or illustration." Any embodiment described herein as "exemplary" is not necessarily to be construed as preferred or advantageous over other embodiments. Although various aspects of the embodiments are shown in the drawings, the drawings are not necessarily drawn to scale unless otherwise noted.
[0032] In addition, the technical features involved in different implementations of one or more embodiments of this specification described below can be combined with each other as long as they do not conflict with each other.
[0033] To facilitate understanding, some technical terms involved in one or more embodiments of this specification are explained below.
[0034] The transmission protocol plays a vital role in computer networks. It defines the rules and conventions for data transmission and communication. For example, the transmission protocol can specify the format of the data, the transmission method, error handling, and data confirmation.
[0035] One or more embodiments of the present specification classify transmission protocols into reliable transmission protocols and unreliable transmission protocols based on whether the transmission protocols themselves can handle orderly and reliable transmission of messages.
[0036] 1. Reliable transport protocol: refers to a transport protocol that can handle the orderly and reliable transmission of messages. For example, reliable transport protocols include: transmission control protocol (TCP), network socket (WebSocket) and stream control transmission protocol (SCTP) and other transport protocols.
[0037] Among them, WebSocket is a protocol for full-duplex communication over a single TCP connection.
[0038] SCTP is the underlying protocol of the data channel (DataChannel) of web real-time communication (WebRTC). It is responsible for encapsulating data packets into SCTP messages for network transmission and ensuring reliable transmission and sequence of data. WebRTC is an API that supports web browsers to conduct real-time voice or video conversations. DataChannel specifically refers to the data channel in WebRTC, which is used to transmit real-time data between browsers.
[0039] 2. Unreliable transport protocol: refers to a transport protocol that cannot handle the orderly and reliable transmission of messages. For example, unreliable transport protocols include: User Datagram Protocol (UDP), unreliable mode of quick UDP internet connections (QUIC), and other transport protocols.
[0040] The following describes the application scenarios of the technical solutions provided by one or more embodiments of this specification.
[0041] In the current information age, remote control application scenarios are becoming increasingly widespread, covering multiple fields such as cloud applications, cloud games, and robot remote control. A core requirement of these scenarios is to achieve real-time message transmission. These messages are usually used for instant operations, so the real-time requirements are extremely high. At the same time, in order to ensure the accuracy and continuity of operations, the transmission of messages must also meet the requirements of orderliness and reliability. In short, these application scenarios require that the transmission of messages be orderly and reliable with low latency.
[0042] The message transmission scenario includes a sender and a receiver. Take the remote control scenario as an example. For example, in cloud applications and cloud games, the sender of the message can be the user's terminal device, such as a smartphone, tablet or computer. The message sent by the user through these terminal devices can be an operation instruction, such as clicking, sliding, key input, etc. Correspondingly, the receiver can be one or more servers such as a cloud server and a game server. These servers can execute the corresponding application logic based on the received operation instructions.
[0043] For another example, in a robot remote control scenario, the sending end can be a control end device such as a remote control, a handheld control terminal, or a specific control computer. The messages sent by the operator through these devices can be control instructions, such as move, stop, perform specific actions, etc., to achieve remote control of the robot. Correspondingly, the receiving end can be the robot or the controlled device itself, which receives the control instructions from the control end device and performs corresponding actions or tasks accordingly.
[0044] It should be noted that one or more embodiments of this specification only use the above-mentioned application scenarios as examples to exemplify the sender and the receiver, and do not limit the specific forms of the sender and the receiver. For example, in some embodiments, the sender may be a server, and the receiver may be a terminal device, etc.
[0045] The sending end of the message transmission may include an application layer and a transport layer. The application layer of the sending end may generate a corresponding message in response to the user's operation and send the generated message to the transport layer of the sending end. Afterwards, the transport layer of the sending end transmits the message to the receiving end based on the transmission protocol.
[0046] For example, when a user clicks a control (such as a button, text box, etc.), the corresponding event processing code will be triggered. At the application layer of the sending end, this usually causes an event processing function (also called an event handler) to be called. In the event processing function, the application layer of the sending end will encapsulate the user's click operation into a specific message format, and then send it to the transport layer of the sending end. These messages may contain user input data, operation instructions, and related metadata.
[0047] The receiving end of the message transmission may also include an application layer and a transport layer. The transport layer of the receiving end receives the message based on the same transmission protocol and sends the received message to the application layer of the receiving end for processing. For example, the application layer of the receiving end triggers the corresponding event processing logic based on the received message.
[0048] In reliable transmission protocols such as TCP, WebSocket, and SCTP, it is stipulated that confirmation and retransmission mechanisms and other means are used to ensure the orderly and reliable transmission of messages.
[0049] For example, taking the DataChannel in WebRTC based on the SCTP transmission protocol as an example, SCTP uses sequence numbers and confirmation numbers to ensure the orderly transmission and reliable reception of messages, and supports a confirmation retransmission mechanism to ensure the retransmission of lost data.
[0050] For example, Figure 1 As shown, the sender and the receiver send and receive messages based on the SCTP transmission protocol. At time T0, the sender sends message #1 to the receiver; at time T2, the receiver receives message #1 sent by the sender. At time T1, the sender sends message #2 to the receiver. At time T2, the sender sends message #3 to the receiver. At time T4, the receiver receives message #3 sent by the sender, and finds that message #2 has not been received.
[0051] When the transport layer of the receiving end receives messages #1 and #3 but does not receive message #2, in order to ensure the orderly and reliable reception of messages, the transport layer of the receiving end will not send message #3 to the application layer of the receiving end, but will request to resend message #2 through the confirmation retransmission mechanism, and after receiving message #2, send message #2 and message #3 to the application layer of the receiving end for processing.
[0052] Thus, at time T4, the receiving end sends a retransmission request to the sending end to request the retransmission of message #2. At time T6, the sending end receives the retransmission request from the receiving end and retransmits message #2 to the receiving end. At time T8, the transport layer of the receiving end receives message #2 sent by the sending end and sends message #2 and message #3 to the application layer of the receiving end.
[0053] Among them, the time when the receiver normally receives message #2 should be T3-T1, but the actual time when message #2 is received is T8-T1, and the transmission delay is relatively long. It can be seen that for reliable transmission protocols such as TCP, WebSocket, and SCTP, although they can ensure the orderly and reliable transmission of messages through confirmation and retransmission mechanisms, when encountering abnormal transmission situations such as packet loss, the transmission delay increases significantly due to the need to wait for retransmission confirmation, and cannot meet the real-time requirements.
[0054] As for unreliable transmission protocols, such as the UDP protocol, although the transmission delay is small, it does not provide orderliness and reliability guarantees for messages. Therefore, it cannot be used directly in scenarios that require orderly and reliable transmission.
[0055] In view of the limitations of the above transmission protocols in meeting the requirements of orderly, reliable and low-latency message transmission, one or more embodiments of this specification provide a new message transmission method. This method can ensure orderly and reliable message transmission and can effectively reduce transmission latency, thereby meeting the high real-time requirements of remote control application scenarios.
[0056] The following describes an embodiment of a message transmission method provided by one or more embodiments of this specification.
[0057] Figure 2 A flowchart of a message transmission method provided in one or more embodiments of this specification. Figure 2 As shown, the method may include the following steps:
[0058] Step S102: The sending end generates a message to be sent.
[0059] Step S104: The sending end determines a maximum transmission unit (MTU) of a transmission link used to transmit the message to be sent.
[0060] Step S106A: When the data volume of the message to be sent is less than or equal to the MTU, the sender caches the message to be sent as a cache message in the send message queue of the sender.
[0061] Step S106B: when the data volume of the message to be sent is greater than the MTU, the message to be sent is split into M message fragments, and the M message fragments are cached as a cache message in the sending message queue of the sending end.
[0062] Step S108: When the sending message queue includes multiple cached messages and the total data volume of the first cached message and the second cached message in the sending message queue is less than or equal to the maximum transmission unit, the sending end will splice the first N cached messages in the sending message queue to obtain a spliced message.
[0063] Step S110: The sending end sends a splicing message to the receiving end based on an unreliable transmission protocol.
[0064] Step S112: When the receiving end receives the splicing message, the receiving end parses the splicing message.
[0065] Step S114: The receiving end feeds back a confirmation message to the sending end, where the confirmation message is used to notify the receiving end of the message that has been successfully received.
[0066] Step S116: When the sending end receives the confirmation message, the sending end deletes the successfully received message from the sending message queue based on the confirmation message.
[0067] In one or more embodiments of the present specification, the sending end creates a sending message queue, which can be used to cache messages that have been generated but have not yet been notified by the receiving end that they have been successfully received.
[0068] Exemplarily, after the sender generates the first message #1, it caches the first message #1 in the send message queue. Afterwards, after the sender generates the second message #2, it also caches the second message #2 in the send message queue. In this way, the send message queue includes two cached messages.
[0069] When the receiving end receives message #1, the receiving end can feed back a confirmation message to the sending end, and the confirmation message is used to notify the receiving end of the message that has been successfully received. For example, the confirmation message is used to notify the receiving end that the to-be-sent message #1 has been successfully received. After receiving the above confirmation message, the sending end deletes the cached message #1 from the sending message queue.
[0070] It should be noted that one or more embodiments of the present specification do not limit the maximum buffer quantity of the sending message queue, which can be set according to the storage capacity or processing capacity of the receiving end.
[0071] In one or more embodiments of the present specification, before caching the message to be sent as a cached message in the sending message queue, it can be determined whether the data volume of the message to be sent is less than or equal to the MTU. In the case where the data volume of the message to be sent is less than or equal to the MTU, the message to be sent can be directly cached as a cached message in the sending message queue of the sending end. In the case where the data volume of the message to be sent is greater than the MTU, the message to be sent can be split into M message fragments, wherein the data volume of each message fragment is less than or equal to MTU / n, wherein n is an integer greater than 1, and M is an integer greater than n; then, the M message fragments are each cached as a cached message in the sending message queue of the sending end.
[0072] For example, if the MTU is 1200 bytes, the value of n is 4, and the data volume of the message to be sent is 1500 bytes, then the data volume of each message fragment after the message to be sent is split is less than or equal to 300 bytes. For example, the message to be sent can be split into 5 message fragments, and the data volume of each message fragment is 300 bytes. After that, these 5 message fragments can be cached as 5 cached messages to the sending message queue.
[0073] It should be noted that in order to avoid splitting too many message fragments and affecting transmission efficiency, the minimum value of M can be determined when the data amount of each message fragment is less than or equal to MTU / n.
[0074] It should also be noted that in one or more embodiments of the present specification, a packetization module may be included between the application layer and the transport layer of the sending end, wherein the application layer may be used to generate a message to be sent, the packetization module may be used to split the message to be sent into multiple message fragments, and the transport layer may be used to send the message to the receiving end.
[0075] In this way, each cached message cached in the sending message queue is a "small message" with a small data volume to adapt to subsequent message splicing processing.
[0076] In step S102, the sending end uniquely and sequentially numbers each of the messages to be sent. For example, the messages to be sent are numbered in sequence according to the order of the time when the messages to be sent are generated. For example, the message number of the first message to be sent is #1, the message number of the second message to be sent is #2, and so on, which are not listed here one by one. Correspondingly, in the sending message queue, the message number of each message to be sent can be retained.
[0077] For multiple message fragments of the same message to be sent, the message numbers corresponding to the multiple message fragments are the same. For example, the message to be sent is divided into three message fragments, and the message numbers of the three message fragments are all #3. Correspondingly, in the sending message queue, the message number of the cached message before the three message fragments is #2, and the message number of the first cached message after the three message fragments is #4.
[0078] The sender can periodically send messages to the receiver. Before sending messages to the receiver, the sender can first determine whether there are multiple cached messages cached in the send message queue. If there are multiple cached messages cached in the send message queue, it can be further determined whether the total data volume of the first cached message and the second cached message in the send message queue is less than or equal to the MTU.
[0079] When the total data volume of the first cached message and the second cached message is less than or equal to the MTU, the first N cached messages in the send message queue can be concatenated to obtain a concatenated message, where N is the maximum number of cached messages that can be included in the concatenated message, and the total data volume of the first N cached messages is less than or equal to the MTU.
[0080] Correspondingly, when the sending message queue only buffers one buffered message or the total data volume of the first buffered message and the second buffered message is greater than the MTU, the first buffered message can be sent to the receiving end based on the unreliable transmission protocol.
[0081] That is to say, when the sending message queue includes multiple cached messages, the first cached message in the sending message queue must be sent. After that, the subsequent cached messages can be accumulated in sequence based on the first cached message according to the order of the cached messages until the total data volume of the accumulated N+1 cached messages is equal to or greater than the MTU, and then the accumulation of cached messages is stopped. In this way, it can be determined that the first N cached messages in the sending message queue will be spliced.
[0082] In this way, it can be ensured that the spliced message matches the transmission capacity of the corresponding transmission link to improve transmission efficiency and transmission reliability.
[0083] Exemplarily, at time Ti, the message queue includes cached message #3, cached message #4, cached message #5, and cached message #6. It can be first determined whether the total data volume of cached message #3 and cached message #4 is greater than MTU. If the total data volume of cached message #3 and cached message #4 is greater than MTU, cached message #3 is sent alone this time without message splicing. If the total data volume of cached message #3 and cached message #4 is less than MTU, it is further determined whether the total data volume of cached message #3, cached message #4, and cached message #5 is greater than MTU. If the total data volume of cached message #3, cached message #4, and cached message #5 is greater than MTU, cached message #3 and cached message #4 are spliced into a spliced message, and the spliced message is sent. If the total data volume of cached message #3, cached message #4, and cached message #5 is less than MTU, it is further determined whether the total data volume of cached message #3, cached message #4, cached message #5, and cached message #6 is greater than MTU. If the total data volume of cached message #3, cached message #4, cached message #5 and cached message #6 is greater than the MTU, cached message #3, cached message #4 and cached message #5 are concatenated into one concatenated message and the concatenated message is sent. If the total data volume of cached message #3, cached message #4, cached message #5 and cached message #6 is less than the MTU, cached message #3, cached message #4, cached message #5 and cached message #6 are concatenated into one concatenated message and the concatenated message is sent.
[0084] It should be understood that the spliced N cache messages may include the following four situations:
[0085] The first case: the N cached messages spliced are all complete messages to be sent;
[0086] The second case: the N cached messages to be spliced are all message fragments, and the N message fragments are message fragments of the same message to be sent;
[0087] The third case: the N cached messages to be spliced are all message fragments, and the N message fragments include message fragments of different messages to be sent;
[0088] The fourth situation: some of the N cached messages that are spliced are complete messages to be sent, and some are message fragments.
[0089] In order to enable the receiving end to distinguish whether the received message is a message fragment, each cached message may include a message header. The message header may include multiple different fields for indicating cached message characteristics.
[0090] Exemplarily, the message packet header may include a message type field, a message number field, a field for the total number of message fragments included in the message to be sent to which the message fragment belongs, a message fragment sequence number field, and the like.
[0091] For example, the message type field may include 0 and 1, where 0 indicates that the cached message is a message fragment, and 1 indicates that the cached message is a complete message to be sent.
[0092] For multiple message fragments of the same message to be sent, the message numbers corresponding to the multiple message fragments are the same.
[0093] For a cached message that belongs to a message fragment, its message header may include the total number of message fragments and the message fragment sequence number contained in the message to be sent. For a cached message that does not belong to a message fragment, its message header may not include the total number of message fragments field and the message fragment sequence number field, or the total number of message fragments field and the message fragment sequence number field in its message header are both null values.
[0094] For example, a message to be sent is split into three message fragments. The message packet headers corresponding to the three message fragments are:
[0095] The first message fragment: 0, #3, 3, 1;
[0096] The second message fragment: 0, #3, 3, 2;
[0097] The third message fragment: 0, #3, 3, 3.
[0098] Among them, the first field 0 indicates that the message type is a message fragment, the second field #3 indicates the message number, the third field 3 indicates the total number of message fragments contained in the message to be sent to which the message fragment belongs, and the fourth fields 1, 2, and 3 respectively indicate the sequence numbers of each message fragment.
[0099] One or more embodiments of this specification do not limit the specific message splicing processing method.
[0100] For example, the concatenation of multiple cached messages can be implemented in the following manner: the messages in the multiple cached messages can be concatenated in sequence, and an end tag is added at the end of the first concatenated message and a start tag is added at the beginning of the second concatenated message and each subsequent message. The end tag and the start tag will not appear in the normal message content. For example, " <eof1>", add " to the beginning of the second message in the concatenated message <start2>", add " at the beginning of the third message in the concatenated message <start3>"wait.
[0101] In this way, the boundary of each cached message in the spliced message can be determined by the end tag and the start tag, so that after the receiving end receives the spliced message, it can parse the spliced message through the end tag and the start tag to obtain each independent message in the spliced message.
[0102] In another exemplary embodiment, the message splicing processing of multiple cached messages can also be implemented in the following manner: a fixed message format is agreed in advance, which includes a message header, a message body, and a message footer. When splicing, the multiple cached messages are spliced together according to the agreed format. In this way, the receiving end can parse the original messages according to the agreed message format.
[0103] The spliced message may include message contents corresponding to each cached message, message headers corresponding to each cached message, and a message header of the spliced message.
[0104] It should be noted that the data volume of the message to be sent in one or more embodiments of the present specification includes the data volume of the message to be sent itself and the sum of the data volume of the message packet header corresponding to the message to be sent.
[0105] In steps S110 and S114, the sender and the receiver transmit messages based on an unreliable transport protocol, wherein the unreliable transport protocol may be a transport protocol such as UDP, QUIC's unreliable mode, etc., which cannot ensure orderly and reliable transmission of messages. Since the sender and the receiver do not transmit messages based on a reliable transport protocol, conflicts between the active retransmission method provided in one or more embodiments of this specification and the retransmission request method in the reliable transport protocol can be avoided.
[0106] In addition, in one or more embodiments of the present specification, the sending end may periodically transmit messages to the receiving end based on an unreliable transmission protocol. For example, at preset intervals, the sending end transmits messages to the receiving end based on an unreliable transmission protocol. In this way, even if the sending end does not generate a new message to be sent, the sending end may actively resend the cached message in the message queue to the receiving end to ensure that in the event of packet loss of the sent message, the lost message can be resent.
[0107] The following takes the example of the transmission of message #1, message #2 and message #3 by the sender and the receiver based on the UDP protocol as an example to illustrate the message transmission process, wherein message #1, message #2 and message #3 are all complete messages to be sent.
[0108] Combination Figure 3 and Figure 4 At time T0, the sending message queue is empty, the sender generates a to-be-sent message #1, and adds the to-be-sent message #1 to the sending message queue. In this way, the sending message queue includes a cached message #1, and then the sender sends the cached message #1 to the receiving end. At time T1, the sending message queue includes the cached message #1, the sender generates a to-be-sent message #2, and adds the to-be-sent message #2 to the sending message queue. In this way, the sending message queue includes the cached message #1 and the cached message #2, and then the sender splices the cached message #1 and the cached message #2 into a spliced message, and sends the spliced message containing the cached message #1 and the cached message #2 to the receiving end.
[0109] At time T2, the sending message queue includes cached message #1 and cached message #2, and the sender generates a to-be-sent message #3 and adds the to-be-sent message #3 to the sending message queue. In this way, the sending message queue includes cached message #1, cached message #2, and cached message #3. After that, the sender splices the cached message #1, cached message #2, and cached message #3 into a spliced message, and sends the spliced message containing the cached message #1, cached message #2, and cached message #3 to the receiving end.
[0110] At time T2, the receiving end receives the cached message #1 and feeds back a confirmation message to the sending end to inform the receiving end that the cached message #1 has been successfully received. At time T4, the sending end receives the confirmation message fed back by the sending end and deletes message #1 from the sending message queue.
[0111] At time T4, the receiving end receives the concatenated message containing cached message #1, cached message #2, and cached message #3, and feeds back a confirmation message to the sending end to inform the receiving end of the successful receipt of cached message #2 and cached message #3. At time T6, the sending end receives the confirmation message fed back by the sending end, and the sending end deletes cached message #2 and cached message #3 from the sending message queue.
[0112] It can be seen that, if the concatenated message containing cached message #1 and cached message #2 is not lost, the time when the receiving end normally receives cached message #2 should be T3-T1. If the concatenated message containing cached message #1 and cached message #2 is lost, the time when the receiving end actually receives cached message #2 is T4-T1. In other words, compared with the time when cached message #2 is normally received, the time when cached message #2 is actually received is slightly increased, and the delay is very small.
[0113] In addition, by actively retransmitting cached message #2 and cached message #3, and splicing cached message #1, cached message #2 and cached message #3 into a spliced message and sending it, in the event that the spliced message containing cached message #1 and cached message #2 is lost, the receiving end can receive cached message #1, cached message #2 and cached message #3 in an orderly and reliable manner, and will not receive cached message #1 and cached message #3 first but not cached message #2, thereby ensuring the orderly and reliable reception of messages.
[0114] In one or more embodiments of the present specification, when the network bandwidth changes, the sending frequency can be dynamically adjusted to reduce the risk of network congestion.
[0115] In a possible implementation, the following method can be used to dynamically adjust the sending frequency to reduce the risk of network congestion: first, use the existing network bandwidth estimation method to estimate the network bandwidth used to transmit the cached messages in the sending message queue at the current moment. Then, obtain the first frequency of sending the cached messages in the sending message queue and the data volume of the cached messages sent each time in the first preset time period before the current moment. Then, based on the first frequency and the data volume of the cached messages sent each time, determine the total data volume of the cached messages sent in the first preset time period.
[0116] When the total data volume of cached messages sent within a first preset time period is greater than or equal to the network bandwidth, the cached messages in the message queue are sent at a second frequency within a second preset time period after the current moment; wherein the second preset time period is the same as the first preset time period, and the second frequency is less than the first frequency.
[0117] When the total data volume of the cached messages sent within the first preset time period is less than the network bandwidth, the cached messages in the message queue are sent at a third frequency within the second preset time period; wherein the third frequency is greater than the first frequency.
[0118] The first preset time period refers to a time period starting from the current moment and moving forward by the first preset time period. The second preset time period refers to a time period starting from the current moment and moving backward by the second preset time period. For example, the first preset time period refers to one second before the current moment, and the second preset time period refers to one second after the current moment.
[0119] For example, the current network bandwidth is x Bps, the message sending frequency in the previous second is y1 times, and the size of each message sent is z Bytes.
[0120] If y1×z>x, the transmission frequency can be reduced in the second preset time period, so that y2×z≤x in the second preset time period, where y2 represents the second frequency.
[0121] If y1×z≤x, the transmission frequency may be increased in the second preset time period, so that y3×z>x in the second preset time period, where y3 represents the third frequency.
[0122] In this way, when the network bandwidth becomes smaller, the network congestion can be alleviated by reducing the sending frequency; when the network bandwidth becomes larger, the sending efficiency can be improved and the network delay can be reduced by increasing the sending frequency.
[0123] Based on the above description, it can be known that the message received by the receiving end may be a spliced message or a non-spliced message.
[0124] In one or more embodiments of the present specification, the specific implementation method for the receiving end to determine whether the received message is a spliced message or a non-spliced message is not limited.
[0125] Exemplarily, when the message to be sent is a spliced message, the sender may set a splicing mark in the message header of the spliced message, and the splicing mark is used to identify the message as a spliced message. When the message to be sent is a non-spliced message, the sender may not set it in the spliced message. In this way, the receiving end can confirm whether the received message is a spliced message or a non-spliced message based on whether the message carries the splicing mark.
[0126] In another exemplary embodiment, when the message to be sent is a spliced message, the sending end may set a first mark in the spliced message, and the first mark is used to identify the message as a spliced message. When the message to be sent is a non-spliced message, the sending end may set a second mark in the spliced message, and the second mark is used to identify the message as a non-spliced message. In this way, the receiving end can confirm whether the received message is a spliced message or a non-spliced message based on the first mark or the second mark carried in the message.
[0127] In one or more embodiments of the present specification, when the message received by the receiving end is a spliced message, the spliced message can be parsed and processed by the transport layer of the receiving end.
[0128] When the concatenated message does not include message fragments, multiple continuous independent messages can be obtained after parsing the concatenated message.
[0129] For example, Figure 4 As shown, at time T4, the concatenated message received by the transport layer of the receiving end is a concatenated message obtained by concatenating message #1, message #2 and message #3. In this way, the transport layer of the receiving end can parse the concatenated message to obtain three independent messages, namely, the three independent messages are message #1, message #2 and message #3.
[0130] Afterwards, the transport layer of the receiving end may determine the independent message that has not been previously sent to the application layer of the receiving end among the multiple independent messages parsed. For ease of description, in one or more embodiments of this specification, the independent message that has not been previously sent to the application layer of the receiving end among the multiple independent messages parsed may be referred to as a target independent message. Afterwards, the target independent message may be sent to the application layer of the receiving end through the transport layer of the receiving end to avoid the application layer from repeatedly receiving the same message.
[0131] For example, Figure 4 As shown, at time T2, the transport layer of the receiving end receives independent message #1 and sends independent message #1 to the application layer. At time T4, after the transport layer of the receiving end receives the concatenated message and parses it to obtain three independent messages, message #1, message #2, and message #3, the transport layer of the receiving end confirms that independent message #1 was previously sent to the application layer. In this way, the transport layer of the receiving end sends the parsed independent messages #2 and #3 to the application layer of the receiving end, but does not send independent message #1. In this way, the application layer of the receiving end can receive messages #1, #2, and #3 in an orderly and reliable manner.
[0132] It should be noted that one or more embodiments of this specification do not limit the specific implementation method of the transport layer of the receiving end to determine the target independent message. For example, the transport layer of the receiving end records the message number that has been sent to the application layer, so that the transport layer of the receiving end can determine the target independent message based on the recorded message number. For another example, the transport layer of the receiving end records the message number that was last sent to the application layer, so that the transport layer of the receiving end can determine the target independent message based on the recorded message number that was last sent to the application layer.
[0133] In step S114, after receiving the message, the receiving end can feed back a confirmation message to the sending end to notify the receiving end of the message that has been successfully received. In this way, after receiving the confirmation message, the sending end can delete the successfully received message from the sending message queue based on the confirmation message, thereby avoiding repeated sending and receiving of the received message.
[0134] In the case where the concatenated message includes message fragments, the receiving end may obtain at least one message fragment after parsing the concatenated message, and may also include at least one independent message.
[0135] Each parsed message includes its own corresponding message header. In this way, the receiving end can determine whether each parsed message is a message fragment or an independent message based on the message header. For message fragments, the receiving end can also determine the message number of each message fragment, the total number of message fragments contained in the message to be sent, and the message fragment sequence number based on the message header; and can determine whether all message fragments belonging to the same message number are received based on the message number of at least one message fragment, the total number of message fragments contained in the message to be sent, and the message fragment sequence number.
[0136] Exemplarily, the total number of different message fragments with the same message number received may be counted, and if the total number is the same as the total number recorded in the message packet header of the message fragments, it can be determined that all message fragments with the same message number have been received. Otherwise, it can be determined that all message fragments with the same message number have not been received.
[0137] When all message fragments belonging to the same message number are received, the receiving end can restore all message fragments belonging to the same message number into an independent message. When all message fragments belonging to the same message number have not been received, the receiving end can continue to wait for receiving other message fragments until all message fragments belonging to the same message number are received, and then restore all message fragments belonging to the same message number into an independent message. The message number corresponding to each message fragment in the independent message is the message number of the restored independent message.
[0138] In a possible implementation, a packet assembly module may be included between the transport layer and the application layer of the receiving end. The transport layer is used to receive a message sent by the sending end. When the received message includes message fragments, the packet assembly module may restore all message fragments belonging to the same message number into an independent message. Afterwards, the independent message is sent to the application layer.
[0139] One or more embodiments of this specification do not limit the specific implementation method of the receiving end feeding back the confirmation message to the sending end.
[0140] Exemplarily, after the transport layer of the receiving end sends a message to the application layer, it can confirm the maximum message number among the messages sent to the application layer. Then, the maximum message number can be carried in the confirmation message. Correspondingly, after receiving the confirmation message, the sending end extracts the maximum message number carried in the confirmation message, and deletes the cached messages whose message numbers are less than or equal to the maximum message number from the sending message queue.
[0141] Combination Figure 3 and Figure 4 At time T4, the confirmation message fed back by the receiving end to the sending end carries the message number #3. Correspondingly, after receiving the confirmation message, the sending end deletes the cached messages #2 and #3 from the sending message queue.
[0142] In another exemplary embodiment, after the transport layer of the receiving end sends a message to the application layer, the message numbers of all messages currently sent to the application layer may be confirmed. Then, the message numbers of all messages may be carried in the confirmation message. Correspondingly, after the sending end receives the confirmation message, it extracts the message number carried in the confirmation message, and deletes the cached message corresponding to the message number carried in the confirmation message from the sending message queue.
[0143] It should be noted that in one or more embodiments of this specification, the message sent by the sender to the receiver may be a message with a small amount of data, such as a control instruction, an operation instruction, or status data. In this way, message splicing and active retransmission can be performed based on the small amount of data of the message to be sent.
[0144] Thus, in the message transmission method provided by one or more embodiments of the present specification, on the one hand, the sending end actively retransmits a message that has been sent and has not yet been notified by the receiving end that it has been successfully received. In this way, compared with mechanisms such as confirmation retransmission in reliable transmission protocols, it can effectively reduce the transmission delay in a lossy network. On the other hand, the sending end transmits a message to the receiving end by splicing multiple messages with small data volumes into a spliced message. In this way, the receiving end may receive the spliced message, or may not receive the spliced message. If the receiving end receives the spliced message, the receiving end is equivalent to receiving all the continuous messages contained in the spliced message, and there will be no loss of one or more messages in the spliced message, thereby ensuring the orderly and reliable transmission of messages.
[0145] It can be understood that the above embodiments are only examples and can be modified in actual implementation. Those skilled in the art can understand that the modification methods of the above embodiments without creative labor fall within the protection scope of one or more embodiments of this specification and will not be repeated in the embodiments.
[0146] Based on the same inventive concept, one or more embodiments of the present specification also provide a message transmission device. Since the principle of solving the problem by the message transmission device is similar to that of the aforementioned message transmission method, the implementation of the message transmission device can refer to the implementation of the aforementioned message transmission method, and the repeated parts will not be repeated.
[0147] See also Figure 5 , Figure 5 This is a structural block diagram of a message transmission device provided in one or more embodiments of this specification. Figure 5 As shown, the message transmission device 200 can be applied to a sending end, and the message transmission device 200 may include: a generating module 201, a determining module 202, a buffering module 203, a splicing module 204 and a sending module 205. Among them,
[0148] A generating module 201, used for generating a message to be sent;
[0149] A determination module 202, configured to determine a maximum transmission unit MTU of a transmission link used to transmit a message to be sent;
[0150] The cache module 203 is used to cache the message to be sent as a cache message to the send message queue of the sender when the data volume of the message to be sent is less than or equal to the MTU; wherein the send message queue is used to cache messages that have been generated and have not yet been notified by the receiver that they have been successfully received;
[0151] The splicing module 204 is used to splice the first N cached messages in the sending message queue to obtain a spliced message when the sending message queue includes multiple cached messages and the total data volume of the first cached message and the second cached message in the sending message queue is less than or equal to the maximum transmission unit; N is the maximum number of cached messages that can be included in the spliced message, and the total data volume of the first N cached messages is less than or equal to the MTU;
[0152] The sending module 205 is used to send the splicing message to the receiving end based on the unreliable transmission protocol.
[0153] In a possible implementation, the message transmission device 200 further includes: a receiving module and a deleting module.
[0154] The receiving module can be used to receive the confirmation message fed back by the receiving end; wherein the confirmation message is used to notify the receiving end of the maximum message number among the messages that have been successfully received, and the messages to be sent and the cached messages in the spliced message have orderly message numbers;
[0155] The deletion module can be used to delete cached messages whose message numbers are less than or equal to the maximum message number from the sending message queue.
[0156] In a possible implementation, the cache module 203 is also used to split the message to be sent into M message fragments when the data volume of the message to be sent is greater than the MTU, wherein the data volume of each message fragment is less than or equal to MTU / n, wherein n is an integer greater than 1, and M is an integer greater than n; and cache the M message fragments as a cache message in the sending message queue of the sender.
[0157] In one possible implementation, the message packet header of each cached message includes a message type field and a message number field; wherein the message type field is used to identify the type of the cached message as a message fragment of a message to be sent or a complete message to be sent, and multiple message fragments of the same message to be sent have the same message number; for cached messages that are message fragments, their message packet header also includes a field for the total number of message fragments contained in the message to be sent to which the message fragment belongs and a message fragment sequence number field corresponding to the message fragment.
[0158] In a possible implementation, the sending module 205 is further configured to send the first buffered message to the receiving end based on an unreliable transmission protocol when the total data volume of the first buffered message and the second buffered message in the sending message queue is greater than the MTU.
[0159] In a possible implementation, the sending module 205 is also used to estimate the network bandwidth used to transmit the cached messages in the sending message queue at the current moment; obtain the first frequency of sending the cached messages in the sending message queue and the data volume of the cached messages sent each time in a first preset time period before the current moment; determine the total data volume of the cached messages sent in the first preset time period based on the first frequency and the data volume of the cached messages sent each time; when the total data volume of the cached messages sent in the first preset time period is greater than or equal to the network bandwidth, send the cached messages in the sending message queue at a second frequency in a second preset time period after the current moment; wherein the second preset time period is the same as the first preset time period in length, and the second frequency is less than the first frequency; when the total data volume of the cached messages sent in the first preset time period is less than the network bandwidth, send the cached messages in the sending message queue at a third frequency in the second preset time period; wherein the third frequency is greater than the first frequency.
[0160] In one possible implementation, the message to be sent is at least one of a control instruction, an operation instruction, and status data; the unreliable transmission protocol includes an unreliable mode of the User Datagram Protocol UDP and the Fast UDP Internet Connection QUIC protocol.
[0161] See also Figure 6 , Figure 6 This is a structural block diagram of another message transmission device provided in one or more embodiments of this specification. Figure 6 As shown, the message transmission device 300 can be applied to a receiving end, and the message transmission device 300 can include: a receiving module 301 , a parsing module 302 and a feedback module 303 .
[0162] in,
[0163] A receiving module 301, configured to receive a message sent by a sending end based on an unreliable transmission protocol;
[0164] The parsing module 302 is used to parse the spliced message to obtain multiple continuous independent messages when the message is a spliced message and the spliced message does not include message fragments;
[0165] The feedback module 303 is used to feed back a confirmation message to the sending end, where the confirmation message is used to notify the receiving end of the message that has been successfully received, so that the sending end can delete the successfully received message from the sending message queue based on the confirmation message.
[0166] In one possible implementation, the parsing module 302 is further used to: when the message is a spliced message and the spliced message includes message fragments, parse the spliced message to obtain at least one message fragment; determine the message number of at least one message fragment, the total number of message fragments contained in the message to be sent, and the message fragment sequence number; based on the message number of at least one message fragment, the total number of message fragments contained in the message to be sent, and the message fragment sequence number, determine whether all message fragments belonging to the same message number are received; when all message fragments belonging to the same message number are received, restore all message fragments belonging to the same message number into an independent message.
[0167] In one possible implementation, the receiving end includes a transport layer and an application layer, and the feedback module 303 is specifically used to: when the transport layer parses and obtains at least one independent message, send a target independent message to the application layer through the transport layer, where the target independent message is an independent message that has not been sent to the application layer before; determine the maximum message number in the target independent message; and feed back a confirmation message to the sending end, where the confirmation message includes the maximum message number, so that the sending end deletes the cached messages whose message numbers are less than and equal to the maximum message number from the sending message queue.
[0168] In one possible implementation, the unreliable transport protocol includes the unreliable mode of the User Datagram Protocol UDP and the Quick UDP Internet Connection QUIC protocol.
[0169] See also Figure 7 , Figure 7 This is a structural block diagram of an electronic device provided in one or more embodiments of this specification. Figure 7 As shown, the electronic device 400 may include a processor 401 and a memory 402; the memory 402 may be coupled to the processor 401. It is worth noting that the Figure 7 is exemplary; other types of structures may also be used to supplement or replace this structure to implement telecommunication functions or other functions.
[0170] In a possible implementation, the functions of the message transmission device 200 or the message transmission device 300 may be integrated into the processor 401. The processor 401 may be configured to perform the following operations:
[0171] Generate a message to be sent;
[0172] Determine the maximum transmission unit MTU of the transmission link used to transmit the message to be sent;
[0173] When the data volume of the message to be sent is less than or equal to the MTU, the message to be sent is cached as a cache message in the send message queue of the sender; wherein the send message queue is used to cache messages that have been generated and have not yet been notified by the receiver that they have been successfully received;
[0174] When a sending message queue includes multiple cached messages and the total data volume of the first cached message and the second cached message in the sending message queue is less than or equal to the maximum transmission unit, the first N cached messages in the sending message queue are spliced to obtain a spliced message; N is the maximum number of cached messages that can be included in the spliced message, and the total data volume of the first N cached messages is less than or equal to the MTU;
[0175] The spliced message is sent to the receiving end based on an unreliable transmission protocol.
[0176] Alternatively, the processor 401 may be configured to perform the following operations:
[0177] Receive messages sent by the sender based on an unreliable transport protocol;
[0178] When the message is a concatenated message and the concatenated message does not include message fragments, the concatenated message is parsed to obtain multiple continuous independent messages;
[0179] A confirmation message is fed back to the sender, and the confirmation message is used to notify the receiver of the message that has been successfully received, so that the sender can delete the successfully received message from the sending message queue based on the confirmation message.
[0180] In another possible implementation, the message transmission device 200 or the message transmission device 300 may be configured separately from the processor 401 . For example, the message transmission device 200 or the message transmission device 300 may be configured as a chip connected to the processor 401 , and message transmission is implemented under the control of the processor 401 .
[0181] In addition, in some optional implementations, the electronic device 400 may also include: a communication module, an input unit, an audio processor, a display, a power supply, etc. It is worth noting that the electronic device 400 does not necessarily include Figure 7 In addition, the electronic device 400 may also include Figure 7 For components not shown, reference may be made to the prior art.
[0182] In some optional implementations, the processor 401 is sometimes also referred to as a controller or an operation control, and may include a microprocessor or other processor device and / or logic device, which receives input and controls the operation of various components of the electronic device 400.
[0183] The memory 402 may be, for example, a cache, a flash memory, a hard drive, a removable medium, a volatile memory, a non-volatile memory or other suitable devices. The memory may store the information related to the message transmission device 200 or the message transmission device 300, and may also store a program for executing the related information. The processor 401 may execute the program stored in the memory 402 to implement information storage or processing.
[0184] The input unit can provide input to the processor 401. The input unit is, for example, a key or a touch input device. The power supply can be used to provide power to the electronic device 400. The display can be used to display display objects such as images and text. The display can be, for example, an LCD display, but is not limited thereto.
[0185] The memory 402 may be a solid-state memory, such as a read-only memory (ROM), a random access memory (RAM), a SIM card, etc. It may also be a memory that saves information even when the power is off, can be selectively erased, and is provided with more data, examples of which are sometimes referred to as EPROMs, etc. The memory 402 may also be some other type of device. The memory 402 includes a buffer memory (sometimes referred to as a buffer). The memory 402 may include an application / function storage unit for storing application programs and function programs or processes for executing the operation of the electronic device 400 by the processor 401.
[0186] The memory 402 may also include a data storage unit for storing data, such as contacts, digital data, pictures, sounds, and / or any other data used by the electronic device. The driver storage unit of the memory 402 may include various drivers for the communication function of the computer device and / or for executing other functions of the computer device (such as a messaging application, a contact book application, etc.).
[0187] The communication module is a transmitter / receiver that sends and receives signals via an antenna. The communication module (transmitter / receiver) is coupled to the processor 401 to provide input signals and receive output signals, which may be the same as in a conventional mobile communication terminal.
[0188] Based on different communication technologies, multiple communication modules may be provided in the same computer device, such as a cellular network module, a Bluetooth module and / or a wireless local area network module, etc. The communication module (transmitter / receiver) is also coupled to a speaker and a microphone via an audio processor to provide an audio output via the speaker and receive an audio input from the microphone, thereby realizing a common telecommunication function. The audio processor may include any suitable buffer, decoder, amplifier, etc. In addition, the audio processor is also coupled to the processor 401, so that recording can be performed on the machine through the microphone, and the sound stored on the machine can be played through the speaker.
[0189] One or more embodiments of the present specification also provide a computer-readable storage medium capable of implementing all the steps of the message transmission method in the above embodiments. The computer-readable storage medium stores a computer program. When the computer program is executed by a processor, all the steps of the message transmission method in the above embodiments are implemented. For example, when the processor executes the computer program, the following steps are implemented:
[0190] Generate a message to be sent;
[0191] Determine the maximum transmission unit MTU of the transmission link used to transmit the message to be sent;
[0192] When the data volume of the message to be sent is less than or equal to the MTU, the message to be sent is cached as a cache message in the send message queue of the sender; wherein the send message queue is used to cache messages that have been generated and have not yet been notified by the receiver that they have been successfully received;
[0193] When a sending message queue includes multiple cached messages and the total data volume of the first cached message and the second cached message in the sending message queue is less than or equal to the maximum transmission unit, the first N cached messages in the sending message queue are spliced to obtain a spliced message; N is the maximum number of cached messages that can be included in the spliced message, and the total data volume of the first N cached messages is less than or equal to the MTU;
[0194] The spliced message is sent to the receiving end based on an unreliable transmission protocol.
[0195] Alternatively, the processor implements the following steps when executing the computer program:
[0196] Receive messages sent by the sender based on an unreliable transport protocol;
[0197] When the message is a concatenated message and the concatenated message does not include message fragments, the concatenated message is parsed to obtain multiple continuous independent messages;
[0198] A confirmation message is fed back to the sender, and the confirmation message is used to notify the receiver of the message that has been successfully received, so that the sender can delete the successfully received message from the sending message queue based on the confirmation message.
[0199] Although one or more embodiments of this specification provide method operation steps such as embodiments or flowcharts, more or fewer operation steps may be included based on conventional or non-creative work. The order of steps listed in the embodiments is only one way of executing the order of many steps and does not represent the only execution order. When the actual device or client product is executed, it can be executed in the order of the method shown in the embodiments or the drawings or in parallel (for example, in a parallel processor or multi-threaded processing environment).
[0200] It should be understood by those skilled in the art that the embodiments of this specification may be provided as methods, devices (systems) or computer program products. Therefore, the embodiments of this specification may take the form of complete hardware embodiments, complete software embodiments or embodiments combining software and hardware. Moreover, one or more embodiments of this specification may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.
[0201] One or more embodiments of the present specification are described with reference to flowcharts and / or block diagrams of methods, apparatus (systems), and computer program products according to one or more embodiments of the present specification. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0202] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0203] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0204] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device and system embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiments.
[0205] In this article, relational terms such as first and second, etc. are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "comprise", "include" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. For those of ordinary skill in the art, the specific meaning of the above terms in one or more embodiments of this specification can be understood according to the specific circumstances.
[0206] It should be noted that, in the absence of conflict, one or more embodiments of this specification and the features in the embodiments may be combined with each other. One or more embodiments of this specification are not limited to any single aspect, nor to any single embodiment, nor to any combination and / or replacement of these aspects and / or embodiments. Moreover, each aspect and / or embodiment of one or more embodiments of this specification may be used alone or in combination with one or more other aspects and / or embodiments thereof.
[0207] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of one or more embodiments of this specification, rather than to limit them. Although one or more embodiments of this specification have been described in detail with reference to the aforementioned embodiments, a person of ordinary skill in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some or all of the technical features may be replaced by equivalents. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the scope of the technical solutions of one or more embodiments of this specification, and they should all be included in the scope of the claims and the specification of one or more embodiments of this specification.
[0208] One or more embodiments of this specification are described above in conjunction with optional implementation methods, but these implementation methods are only exemplary and serve only as an illustration. On this basis, multiple replacements and improvements can be made to one or more embodiments of this specification, all of which fall within the scope of protection of one or more embodiments of this specification.
Claims
1. A message transmission method, characterized in that: Applied to the sending end, the method includes: Generate a message to be sent; Determine a maximum transmission unit MTU of a transmission link used to transmit the message to be sent; When the data volume of the message to be sent is less than or equal to the MTU, the message to be sent is cached as a cache message in the sending message queue of the sending end; wherein the sending message queue is used to cache messages that have been generated and have not yet been notified by the receiving end that they have been successfully received; When the sending message queue includes multiple cached messages and the total data volume of the first cached message and the second cached message in the sending message queue is less than or equal to the MTU, the first N cached messages in the sending message queue are subjected to message splicing processing to obtain a spliced message; N is the maximum number of cached messages that can be included in the spliced message, and the total data volume of the first N cached messages is less than or equal to the MTU; The splicing message is sent to a receiving end based on an unreliable transmission protocol.
2. The method according to claim 1, characterized in that Each cached message in the send message queue has an ordered message number, and the method further includes: Receive a confirmation message fed back by the receiving end; wherein the confirmation message is used to notify the receiving end of the maximum message number among the messages that have been successfully received; The cached messages whose message numbers are less than or equal to the maximum message number are deleted from the sending message queue.
3. The method according to claim 1, characterized in that The method further comprises: When the data volume of the message to be sent is greater than the MTU, split the message to be sent into M message fragments, wherein the data volume of each message fragment is less than or equal to MTU / n, where n is an integer greater than 1 and M is an integer greater than n; The M message fragments are cached as a cache message respectively in the sending message queue of the sending end.
4. The method according to claim 3, characterized in that The message packet header of each cached message includes a message type field and a message number field; wherein the message type field is used to identify the type of the cached message as a message fragment of a message to be sent or a complete message to be sent, and multiple message fragments of the same message to be sent have the same message number; For a cached message belonging to a message fragment, its message packet header also includes a field for the total number of message fragments included in the message to be sent to which the message fragment belongs and a field for the message fragment sequence number corresponding to the message fragment.
5. The method according to any one of claims 1 to 4, characterized in that: The method further comprises: When the total data volume of the first buffered message and the second buffered message in the sending message queue is greater than the MTU, the first buffered message is sent to the receiving end based on an unreliable transmission protocol.
6. The method according to any one of claims 1 to 4, characterized in that: The method further comprises: estimating the network bandwidth currently used to transmit the cached messages in the send message queue; Acquire a first frequency of sending the cached messages in the sending message queue and a data volume of the cached messages sent each time within a first preset time period before the current moment; Determine a total data volume of the buffered messages sent within the first preset time period based on the first frequency and the data volume of the buffered messages sent each time; When the total data volume of the cached messages sent within the first preset time period is greater than or equal to the network bandwidth, within a second preset time period after the current moment, the cached messages in the sent message queue are sent at a second frequency; wherein the second preset time period is the same as the first preset time period, and the second frequency is less than the first frequency; When the total data volume of the cached messages sent within the first preset time period is less than the network bandwidth, the cached messages in the message sending queue are sent at a third frequency within the second preset time period; wherein the third frequency is greater than the first frequency.
7. The method according to claim 1, characterized in that The message to be sent is at least one of a control instruction, an operation instruction, and status data; the unreliable transmission protocol includes an unreliable mode of the User Datagram Protocol UDP and the Fast UDP Internet Connection QUIC protocol.
8. A message transmission method, characterized in that: Applied to the receiving end, the method includes: Receive messages sent by the sender based on an unreliable transport protocol; When the message is a concatenated message and the concatenated message does not include message fragments, the concatenated message is parsed to obtain a plurality of continuous independent messages; Feedback a confirmation message to the sending end, wherein the confirmation message is used to notify the receiving end of the message that has been successfully received, so that the sending end deletes the successfully received message from the sending message queue based on the confirmation message.
9. The method according to claim 8, characterized in that The method further comprises: When the message is a concatenated message and the concatenated message includes message fragments, parsing the concatenated message to obtain at least one message fragment; Determine the message number of the at least one message fragment, the total number of message fragments contained in the to-be-sent message, and the message fragment sequence number; Determining whether all message fragments belonging to the same message number are received based on the message number of the at least one message fragment, the total number of message fragments contained in the message to be sent, and the message fragment sequence number; When all message fragments belonging to the same message number are received, all message fragments belonging to the same message number are restored into an independent message.
10. The method according to claim 8 or 9, characterized in that The receiving end includes a transport layer and an application layer; the step of feeding back a confirmation message to the sending end includes: In a case where the transport layer parses and obtains at least one independent message, sending a target independent message to the application layer through the transport layer, where the target independent message is an independent message that has not been sent to the application layer before; Determining a maximum message number among the target independent messages; Feedback a confirmation message to the sending end, wherein the confirmation message includes the maximum message number, so that the sending end deletes the cached messages whose message numbers are less than or equal to the maximum message number from the sending message queue.
11. A message transmission device, characterized in that: The device is applied to a transmitting end, and the device includes: A generation module, used for generating messages to be sent; A determination module, used to determine a maximum transmission unit MTU of a transmission link used to transmit the message to be sent; A cache module, configured to cache the message to be sent as a cache message in a sending message queue of the sending end when the data volume of the message to be sent is less than or equal to the MTU; wherein the sending message queue is used to cache messages that have been generated and have not yet been notified by the receiving end that they have been successfully received; A splicing module, configured to perform message splicing processing on the first N cached messages in the sending message queue to obtain a spliced message when the sending message queue includes multiple cached messages and the total data volume of the first cached message and the second cached message in the sending message queue is less than or equal to the maximum transmission unit; N is the maximum number of cached messages that can be included in the spliced message, and the total data volume of the first N cached messages is less than or equal to the MTU; The sending module is used to send the splicing message to the receiving end based on an unreliable transmission protocol.
12. A message transmission device, characterized in that: The device is applied to a receiving end, and the device comprises: A receiving module, used for receiving a message sent by a sending end based on an unreliable transmission protocol; A parsing module, configured to parse the spliced message to obtain a plurality of continuous independent messages when the message is a spliced message and the spliced message does not include message fragments; The feedback module is used to feed back a confirmation message to the sending end, wherein the confirmation message is used to notify the receiving end of the message that has been successfully received, so that the sending end deletes the successfully received message from the sending message queue based on the confirmation message.
13. An electronic device, characterized in that: The electronic device comprises: a memory for storing a computer program product; A processor, configured to execute a computer program product stored in the memory, and when the computer program product is executed, implements the method described in any one of claims 1 to 7 or 8 to 10.
14. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer program instructions, which, when executed, implement the method described in any one of claims 1-7 or 8-10.