Data transmission method and device for user datagram protocol, and storage medium
By using the target sequence number and retransmission request mechanism in UDP data transmission, the problems of out-of-order and loss of UDP data packets are solved, ensuring that data is processed and retransmitted in sequence, improving the reliability and efficiency of data transmission, and adapting to complex networks environment.
Patent Information
- Application Number
- CN202411854353.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-17
- Publication Date
- 2025-01-14
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The reliability of UDP when transmitting data cannot be guaranteed, which may impair data integrity, especially in complex network environments, due to the lack of retransmission mechanism and the problem of out-of-order data packets.
The receiving end generates the target sequence number and searches for the corresponding data packets in the receiving cache queue, and sends a retransmission request to the sending end if necessary, ensuring that the data packets are processed and retransmitted in the correct order, using a unique serial number and a confirmation reception signal mechanism to manage packet transmission.
It improves the accuracy and completeness of data, reduces unnecessary processing time and resource consumption, improves the efficiency and system performance of data processing, adapts to changes in complex network environments, and ensures the continuity and real-timeness of data transmission.
Smart Images

Figure CN119316095A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data transmission, and in particular to a data transmission method, device and storage medium of a user datagram protocol. Background Art
[0002] UDP (User Datagram Protocol) does not have a retransmission mechanism like TCP (Transmission Control Protocol) when transmitting data. Under poor network conditions, such as congestion, link failures, or router buffer overflows, UDP packets may be discarded during transmission. Furthermore, UDP lacks a mechanism to identify and handle duplicate packets. In complex network environments, failures in network devices (such as routers) or erratic behavior of certain network protocols can cause packets to be sent repeatedly. Furthermore, UDP does not guarantee that packets arrive at the receiving end in the order they were sent. During network transmission, packets may reach the receiving end via different paths, each with varying characteristics such as latency and bandwidth.
[0003] Therefore, the reliability of UDP cannot be guaranteed when transmitting data, which may cause data integrity to be damaged. Summary of the Invention
[0004] The present invention provides a data transmission method, device and storage medium of the User Datagram Protocol, aiming to solve the technical problem that the reliability of UDP cannot be guaranteed when transmitting data, which may cause damage to data integrity.
[0005] In order to achieve the above-mentioned object of the invention, the first aspect of the present invention provides a data transmission method of the User Datagram Protocol, comprising the steps of: The receiving end generates a target sequence number; Searching a preset receiving buffer queue for a target data packet corresponding to the target sequence number, wherein the receiving buffer queue temporarily stores a data packet with a unique sequence number sent by a sending end, and the target sequence number generated by the receiving end corresponds to the unique sequence number assigned to the data packet by the sending end; If the target data packet is found, the target data packet is processed and removed from the receiving buffer queue; If the target data packet is not found, a retransmission request is sent to the sending end.
[0006] Furthermore, after the step of sending a retransmission request to the transmitting end, the method further includes: Determine whether a command to continue processing the next data packet is received from the sender; If so, generate the next target sequence number; If not, wait to receive the target data packet sent by the sending end.
[0007] Furthermore, before the step of searching the preset receiving buffer queue for the target data packet corresponding to the target sequence number, the method further includes: When receiving a current data packet with a sequence number, obtaining the current sequence number of the current data packet; Searching a preset processed cache queue for a processed sequence number that matches the current sequence number; wherein the processed sequence number is a sequence number corresponding to a temporarily stored data packet that has been processed; If the processed sequence number that matches the current sequence number is found, the current data packet is discarded.
[0008] Furthermore, the data transmission method of the User Datagram Protocol further includes the steps of: If the receiving end receives the data packet sent by the sending end, it feeds back a corresponding confirmation reception signal to the sending end.
[0009] A second aspect of the present invention provides a method for transmitting data using a user datagram protocol, comprising the steps of: The sender assigns a unique sequence number to the data packet to be sent; Sending a data packet with a unique sequence number to a receiving end so that the receiving end can search for the data packet with the unique sequence number based on a target sequence number generated by the receiving end, wherein the unique sequence number assigned to the data packet by the sending end corresponds to the target sequence number generated by the receiving end; The receiving end caches the data packet in a preset receiving cache queue, generates a target sequence number when a data packet needs to be processed, and searches the receiving cache queue for a target data packet corresponding to the target sequence number.
[0010] Furthermore, after the step of assigning a unique sequence number to the data packet to be sent, the sending end further includes: Cache the data packets with unique sequence numbers into a preset sending buffer queue.
[0011] Furthermore, the data transmission method of the User Datagram Protocol further includes the steps of: When receiving a retransmission request fed back by the receiving end, determining whether to retransmit, wherein the retransmission request carries a retransmission sequence number of the data packet to be retransmitted; If retransmission is required, searching the sending buffer queue for a retransmission data packet corresponding to the retransmission sequence number and sending the retransmission data packet to the receiving end; If retransmission is not required, a command to continue processing the next data packet is fed back.
[0012] Furthermore, after the step of sending the data packet with the unique sequence number to the receiving end, the method further includes: The transmitting end determines whether a reception confirmation signal fed back by the receiving end is received within a preset time; If the confirmation reception signal is not received, resending the data packet with the unique sequence number to the receiving end; If the reception confirmation signal is received, the next data packet is sent to the receiving end.
[0013] A third aspect of the present invention provides a computer device comprising a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the steps of the user datagram protocol data transmission method as described in any one of the above items are implemented.
[0014] A fourth aspect of the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the user datagram protocol data transmission method as described in any one of the above items.
[0015] Beneficial effects: The present invention provides a data transmission method, device and storage medium for a user datagram protocol, wherein the method first generates a target sequence number at a receiving end and searches for a corresponding target data packet in a receiving cache queue, thereby ensuring that the data packets are processed in the correct order. In a complex network environment, data packets may arrive at the receiving end out of order due to various reasons, and this method can effectively solve this problem, ensure the sequentiality of data processing, and thus improve the accuracy and integrity of the data. In addition, the receiving end only needs to focus on the target data packet that currently needs to be processed, without having to indiscriminately process the data packets in the entire receiving cache queue, thereby reducing unnecessary processing time and resource consumption. At the same time, by accurately finding the target data packet and processing it, the misprocessing of duplicate data packets or data packets that do not need to be processed is avoided, further improving the efficiency and accuracy of data processing. In large-scale data transmission scenarios, this efficiency improvement is particularly obvious, which can greatly reduce the time cost of data processing and improve the performance of the entire system. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] Figure 1 A flowchart of a method for transmitting data using the User Datagram Protocol according to an embodiment of the invention is provided; Figure 2 A flowchart of a method for transmitting data using the User Datagram Protocol according to an embodiment of the invention is provided; Figure 3 A flowchart of a method for transmitting data using the User Datagram Protocol according to an embodiment of the invention is provided; Figure 4 A flowchart of a method for transmitting data using the User Datagram Protocol according to an embodiment of the invention is provided; Figure 5 A schematic structural diagram of a computer device according to an embodiment of the invention.
[0017] The purpose, features and advantages of the present invention will be further described with reference to the accompanying drawings and in conjunction with the embodiments. DETAILED DESCRIPTION
[0018] In order to make the purpose, technical solutions and advantages of this application more clear, the following further describes this application in detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain this application and are not intended to limit this application.
[0019] Those skilled in the art will appreciate that, unless expressly stated otherwise, the singular forms "a", "an", "above", and "the" used herein may also include plural forms. It should be further understood that the term "comprising" used in the specification of the present invention refers to the presence of features, integers, steps, operations, elements, modules, modules and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, modules, components and / or groups thereof. It should be understood that when we refer to an element as being "connected" or "coupled" to another element, it may be directly connected or coupled to the other element, or there may be intermediate elements. In addition, "connected" or "coupled" as used herein may include wireless connections or wireless couplings. The term "and / or" used herein includes all or any module and all combinations of one or more associated listed items.
[0020] Those skilled in the art will understand that, unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as commonly understood by those skilled in the art in the art to which this invention belongs. It should also be understood that terms such as those defined in common dictionaries should be understood to have meanings consistent with their meanings in the context of the prior art and, unless specifically defined as such, will not be interpreted in an idealized or overly formal sense.
[0021] Reference Figure 1 The embodiment of the present invention provides a method for transmitting data using a user datagram protocol, comprising the steps of: S11, the receiving end generates a target sequence number; S12. Searching a preset receiving buffer queue for a target data packet corresponding to the target sequence number, wherein the receiving buffer queue temporarily stores a data packet with a unique sequence number sent by the sending end, and the target sequence number generated by the receiving end corresponds to the unique sequence number assigned to the data packet by the sending end; S13: If the target data packet is found, process the target data packet and remove the target data packet from the receiving buffer queue.
[0022] The receiving end is the device or program module responsible for receiving data packets during data transmission. It has functions such as receiving and processing data, and interacting with the sending end. The sending end is the device or program module responsible for generating or forwarding data packets during data transmission. It has functions such as receiving and processing data, and interacting with the receiving end.
[0023] The target sequence number (DSN) is a unique sequence number generated by the receiver to accurately locate the packet it needs to process from the receive buffer queue. Its generation logic is the same as the unique sequence number assigned by the sender to each transmitted packet. Specifically, the sender assigns a sequence number to each packet that increments from 0 until it reaches a preset maximum value (e.g., 10,000), after which it resets cyclically. Similarly, the target sequence number (DSN) also increments from 0 until it reaches its maximum value (the same as the maximum value of the sender's sequence number), after which it resets cyclically. In other words, for each unique sequence number assigned by the sender to a packet, the receiver generates a corresponding DSN. However, the unique sequence number and the target sequence number do not increment indefinitely, but instead reset cyclically after reaching their maximum value.
[0024] The receiving buffer queue is a pre-set storage area for temporarily storing packets with unique sequence numbers sent by the sender. It stores the packets in the order they arrive or according to other pre-set rules so that the receiver can search and process them later.
[0025] The unique sequence number is a unique identifier assigned by the sender to each data packet. This sequence number is used to distinguish different data packets, ensuring the order and accuracy of data packets during transmission, and ensuring that they can be correctly identified and processed by the receiver.
[0026] During the User Datagram Protocol (UDP) data transmission process, the receiving end first generates a target sequence number based on its own processing flow and requirements. This target sequence number acts as a "key" that the receiving end uses to locate the corresponding target packet in the receive buffer queue. The receive buffer queue contains packets previously sent from the sender with unique sequence numbers. After the receiving end generates the target sequence number, it searches the receive buffer queue. If it finds the target packet corresponding to the target sequence number, it indicates that this packet is the one the receiving end needs to process. The receiving end then processes the target packet accordingly. This processing may include data parsing, storage, and forwarding, depending on the specific application scenario and requirements. After processing is complete, the receiving end removes the target packet from the receive buffer queue to free up space and avoid reprocessing already processed packets. This ensures that the receive buffer queue always contains unprocessed packets, improving data processing efficiency and accuracy.
[0027] The data transmission method of this embodiment has several beneficial effects. First, the target sequence number generated by the receiving end corresponds to the unique sequence number assigned to the data packet by the transmitting end. Therefore, by generating the target sequence number and searching the receive buffer queue for the corresponding target data packet, the receiving end can ensure that the data packets are processed in the correct order. In complex network environments, data packets may arrive at the receiving end out of order for various reasons. This method effectively solves this problem, ensuring the sequential processing of data, thereby improving data accuracy and integrity. For example, in video transmission applications, the order of video frames is crucial for smooth video playback. If data packets are processed out of order, problems such as video freezes and screen distortion can occur. This method can avoid such problems and ensure smooth video playback. Second, by removing processed target data packets from the receive buffer queue, the receive buffer queue can be effectively managed. As data is continuously transmitted and processed, if processed data packets are not removed promptly, the receive buffer queue may fill up, making it impossible to store newly arriving data packets, thus affecting the continuity of data transmission. By promptly removing processed data packets, the receive buffer queue can always have sufficient space to store new data packets, improving system stability and reliability. In addition, this method improves data processing efficiency. The receiving end only needs to focus on the target packet that needs to be processed, rather than indiscriminately processing all packets in the entire receive buffer queue, reducing unnecessary processing time and resource consumption. Furthermore, by accurately finding and processing the target packet, it avoids mishandling duplicate or unnecessary packets, further improving data processing efficiency and accuracy. This efficiency improvement is particularly significant in large-scale data transmission scenarios, significantly reducing data processing time and improving overall system performance.
[0028] Reference Figure 2 In one embodiment, after the step S12 of searching the preset receiving buffer queue for the target data packet corresponding to the target sequence number, the method further includes: S14: If the target data packet is not found, a retransmission request is sent to the sending end.
[0029] A retransmission request is a request signal sent by the receiver to the sender when the receiver does not find the target data packet in the receive buffer queue. This signal tells the sender that the corresponding data packet needs to be resent to ensure the integrity of the data transmission.
[0030] Specifically, the receiving end searches a preset receive buffer queue for the target data packet corresponding to the target sequence number. If the target data packet is not found after the search, this may be due to data packet loss, delay, or other reasons during transmission. To ensure the integrity and accuracy of data transmission, the receiving end sends a retransmission request to the sending end. Upon receiving the retransmission request, the sending end knows that it needs to take appropriate measures to resend the data packet. This mechanism is very important in unstable network environments or when interference exists. For example, in a wireless network environment, signal interference may cause data packet loss. Retransmission requests can promptly compensate for this loss and ensure that data is transmitted intact to the receiving end. It is important to note that the sending end sets up a send buffer queue, which temporarily stores the N most recently sent data packets (N is a positive integer greater than 3), preferably 1000. When the send buffer queue is full, the oldest data packet is removed. The retransmission request typically includes the target sequence number to be retransmitted. The send buffer queue then searches for the corresponding target data packet based on the target sequence number and resends it.
[0031] When the receiving end fails to locate the target data packet, promptly sending a retransmission request effectively prevents the impact of data loss on the entire system. Furthermore, this mechanism is adaptable to changes in the network environment. The probability of packet loss may vary under different network conditions. By sending timely retransmission requests, the system can automatically adjust its data transmission strategy to adapt to varying network conditions. For example, in times of network congestion, the likelihood of packet loss increases. The retransmission request mechanism ensures that data is transmitted as completely as possible in such conditions, improving the system's adaptability and stability in complex network environments. Furthermore, from the perspective of overall data transmission efficiency, while retransmissions increase transmission time, compared to the costs incurred by subsequent processing errors or data inconsistencies caused by data loss, this retransmission mechanism improves the efficiency and quality of the entire data transmission process while ensuring data reliability. The target sequence numbers can be used to accurately identify the target data packets that need to be retransmitted.
[0032] In one embodiment, after the step of sending a retransmission request to the transmitting end, the following steps are included: S15, determining whether a command to continue processing the next data packet sent by the transmitting end is received; S16. If yes, generate the next target sequence number; S17: If not, wait to receive the target data packet sent by the sending end.
[0033] The "continue processing next packet" command is a signal sent by the transmitter to the receiver after receiving a retransmission request from the receiver, based on its own processing logic and current transmission status. This signal indicates that the receiver can proceed to process the next packet without waiting for the currently retransmitted packet to arrive. The next target sequence number is generated by the receiver based on its own processing order and requirements after receiving the "continue processing next packet" command from the transmitter, and is used to search for the next packet to be processed.
[0034] After the receiver sends a retransmission request to the sender, it does not wait for the retransmitted packet to arrive before proceeding. Instead, it continuously checks whether it has received a command from the sender to continue processing the next packet. Upon receiving the retransmission request, the sender evaluates its own situation. If the sender determines that the current network conditions or other factors allow the receiver to process the next packet without waiting for the retransmission to complete, it sends a command to the receiver to continue processing the next packet. Upon receiving this command, the receiver knows it can proceed. At this point, the receiver generates the next target sequence number according to its own processing flow. This sequence number is used to search the receive buffer queue for the next target packet to be processed. This mechanism provides high flexibility and efficiency for data transmission. For example, in real-time applications such as online video conferencing, if the receiver waits for retransmitted packets to arrive, video freezes or the conference is interrupted, impacting the user experience. This mechanism allows the receiver to continue processing the next packet at the appropriate time, ensuring continuous and real-time data processing while fully utilizing network resources and improving data transmission efficiency.
[0035] By determining whether to receive a command to continue processing the next packet after sending a retransmission request and generating the next target sequence number upon receiving the command, the receiving end can flexibly respond to packet loss and retransmissions without impacting the overall data processing flow. This ensures a smooth user experience in applications with high real-time requirements. Even if a packet is lost and needs to be retransmitted, the receiving end can continue processing subsequent packets without stalling data processing while waiting for retransmissions, thereby improving the system's real-time responsiveness. Furthermore, because the receiving end no longer idles waiting for retransmitted packets, it can continue processing other packets, improving its efficiency. The sending end can rationally schedule retransmissions and the timing of processing the next packet based on actual conditions, resulting in more efficient allocation and utilization of network resources, further improving the efficiency and performance of the entire data transmission system. This mechanism also enhances system stability and reliability. In complex network environments, packet loss can occur frequently. If the receiving end must always wait for retransmissions to complete before proceeding to the next step, this can cause frequent system freezes or interruptions, impacting normal operation. Through this flexible processing method, the system can better adapt to changes in the network environment, reduce the impact of data packet loss and retransmission on the system, and improve the stability and reliability of the system.
[0036] In one embodiment, before the step of searching the preset receiving buffer queue for the target data packet corresponding to the target sequence number, the following steps are included: S18. When a current data packet with a sequence number is received, obtaining the current sequence number of the current data packet; S19, searching a preset processed cache queue for a processed sequence number that matches the current sequence number; wherein the processed sequence number is a sequence number corresponding to a temporarily stored processed data packet; S20: If the processed sequence number that matches the current sequence number is found, the current data packet is discarded.
[0037] The "current data packet" mentioned above refers to the data packet received during the current data transmission process. This data packet may be newly arrived or have been previously sent but are arriving again due to network delays or other factors. The "current sequence number" is the sequence number carried by the current data packet, which can be used to identify the data packet throughout the data transmission process. The "processed buffer queue" is a pre-set storage area for temporarily storing the sequence numbers of processed data packets. Its function is to record the information of processed data packets so that subsequent data packets with the same sequence number can be identified and processed.
[0038] Before searching a preset receive buffer queue for a target data packet corresponding to the target sequence number, the receiving end first performs a step of repeatedly determining and processing the newly received data packet. When the receiving end receives a current data packet with a sequence number, it first obtains the current sequence number of the data packet. Then, the receiving end searches a preset processed buffer queue for a processed sequence number that matches the current sequence number. If a processed sequence number matching the current sequence number is found in the processed buffer queue, it indicates that the data packet has already been processed and may have been received again by the receiving end due to network delay or other reasons. To avoid repeated processing of duplicate data packets, the receiving end discards the current data packet. This mechanism is very important in the data transmission process. In a network environment, data packets may be transmitted repeatedly for various reasons. If the receiving end reprocesses duplicate data packets, it not only wastes processing resources but may also lead to data processing errors or data inconsistencies. By setting up a processed buffer queue and determining the matching of the current data packet's sequence number, duplicate data packets can be effectively filtered out, ensuring that the receiving end only processes new, unprocessed data packets, thereby improving the accuracy and efficiency of data processing.
[0039] This embodiment accurately determines whether a packet has already been processed by first obtaining its sequence number upon receiving the current packet and then searching for a match in the processed buffer queue. This avoids the repeated processing of duplicate packets, thereby reducing unnecessary resource consumption. In large-scale data transmission scenarios, the number of packets can be enormous. If every packet is processed indiscriminately, significant computing resources and time would be wasted. This method, however, allows duplicate packets to be quickly filtered out and discarded, allowing only new packets to be processed, improving data processing efficiency. From the perspective of data accuracy, avoiding the processing of duplicate packets ensures data consistency and accuracy. Reprocessing duplicate packets can lead to problems such as duplicate data entry and calculation errors, impacting data quality and reliability. This mechanism ensures that the data processed by the receiving end is unique and valid, improving the accuracy and reliability of data processing. Furthermore, this method can reduce network burden to a certain extent. If the receiving end processes duplicate packets, it may send unnecessary confirmation information or other feedback to the sending end, increasing network traffic. By discarding duplicate packets, this unnecessary network interaction is reduced, improving overall network performance and stability. This advantage is particularly evident in complex network environments or when bandwidth is limited, effectively improving the efficiency and quality of data transmission and ensuring the normal operation of the system.
[0040] In one embodiment, the above-mentioned method for transmitting data using the User Datagram Protocol further includes the steps of: If the receiving end receives the data packet sent by the sending end, it feeds back a corresponding confirmation reception signal to the sending end.
[0041] The above-mentioned confirmation signal is a feedback signal sent by the receiving end to the sending end after successfully receiving the data packet sent by the sending end. This signal is used to inform the sending end that the data packet has been successfully received by the receiving end, and the sending end can perform subsequent processing and operations based on this signal.
[0042] During the User Datagram Protocol (UDP) data transmission process, the receiving end performs a crucial step: upon receiving a data packet from the sender, it must send back a corresponding acknowledgment of receipt signal. After sending a data packet, the sender needs to know whether the packet has been successfully received by the receiver. The acknowledgment of receipt signal sent by the receiver fulfills this purpose. Once the receiver successfully receives a data packet, it immediately sends a acknowledgment of receipt signal to the sender. This signal can be a simple data packet or a specific signal format. Its purpose is to ensure that the sender has received the data packet and that it has been correctly received. This mechanism is crucial for data transmission. It ensures communication reliability and data transmission integrity between the sender and receiver. For example, during a file transfer, if the sender sends partial data of a file but does not receive an acknowledgment of receipt from the receiver, the sender cannot be sure whether the data has been successfully received, potentially leading to data duplication or loss. Acknowledgment of receipt signals allow the sender to adjust its transmission strategy based on the receiver's feedback, ensuring accurate data transmission.
[0043] Reference Figure 3 , the embodiment of the present application also provides a method for transmitting data using the User Datagram Protocol, comprising the steps of: S21. The sending end assigns a unique sequence number to the data packet to be sent; S22. Send the data packet with the unique sequence number to the receiving end, so that the receiving end can search for the data packet with the unique sequence number according to the target sequence number generated by the receiving end, wherein the unique sequence number assigned to the data packet by the sending end corresponds to the target sequence number generated by the receiving end.
[0044] The target sequence number (DSN) is a unique sequence number generated by the receiver to accurately locate the packet it needs to process from the receive buffer queue. Its generation logic is the same as the unique sequence number assigned by the sender to each packet to be sent. Specifically, the sender assigns a sequence number to each packet that increments from 0 until it reaches a preset maximum value (e.g., 10,000), after which it resets cyclically. Similarly, the target sequence number (DSN) also increments from 0 until it reaches its maximum value (the same as the maximum value of the sender's sequence number), after which it resets cyclically. In other words, for each unique sequence number assigned by the sender to a packet, the receiver generates a corresponding DSN. Both the DSN and DSN do not increment indefinitely, but instead reset cyclically after reaching their maximum value.
[0045] During the User Datagram Protocol (UDP) data transmission process, the sender first processes the incoming data packets. A key step is to assign a unique sequence number to each packet. This unique sequence number acts like a "personal identification number" for each packet, ensuring that each packet is uniquely identified during transmission, making it easier for the receiver to identify, sort, and process the packets. After assigning the unique sequence number, the sender sends the packet with the unique sequence number to the receiver. Upon receiving the packets, the receiver buffers them in a pre-set receive buffer queue. This receive buffer queue serves as temporary storage, storing received packets in a specific order until they are ready for further processing by the receiver. When the receiver needs to process a packet, it generates a target sequence number based on its processing needs and then searches the receive buffer queue for the target packet corresponding to this target sequence number. If a corresponding target packet is found, the receiver processes it accordingly and may remove it from the receive buffer queue to make room for subsequent packets. This data transmission method achieves orderly data transmission and efficient processing under the User Datagram Protocol by assigning unique sequence numbers to the sender, managing the receive buffer queue, and searching for target sequence numbers on the receiver. It can adapt to different network environments and data processing requirements, ensuring data accuracy and integrity.
[0046] Specifically: First, the sender assigns unique sequence numbers to data packets to ensure data order and accuracy. In complex network environments, data packets may travel through different paths and arrive at the receiver at different times. Using unique sequence numbers, the receiver can accurately identify the order of each packet. Even if packets arrive out of order, they can be processed in the correct order, thus ensuring data integrity and accuracy. This is crucial for applications with strict data order requirements, such as real-time video streaming and file transfer. For example, in video streaming, if packets arrive out of order, they can cause video freezes and artifacts. Using unique sequence numbers effectively prevents this, ensuring smooth video playback and high quality. Second, the receiver's receive buffer queue effectively coordinates data reception and processing speeds. Network transmission speeds and receiver processing speeds may differ. Without an appropriate buffering mechanism, packets may be lost or processed in a timely manner. The receive buffer queue temporarily stores received packets, allowing the receiver to process them at the appropriate time, avoiding data loss and backlogs. Furthermore, the receiver's method of searching and processing packets based on target sequence numbers improves data processing efficiency and accuracy. It focuses only on the packets that need to be processed, avoiding indiscriminate processing of all packets, saving processing time and resources. In large-scale data transmission scenarios, this approach can significantly improve data processing efficiency and reduce system load. Furthermore, this data transmission method offers excellent scalability and adaptability. It can be flexibly adjusted based on actual network conditions and data processing requirements. For example, if the network bandwidth is large, the packet transmission rate can be appropriately increased; if the receiving end has limited processing power, the data processing flow can be optimized by adjusting the target sequence number generation strategy and the management of the receive buffer queue. This flexibility allows this method to be applied to a variety of different network environments and application scenarios, improving the reliability and stability of the entire data transmission system.
[0047] Reference Figure 4 In one embodiment, after the step S22 of assigning a unique sequence number to the data packet to be sent, the method further includes: S23: Cache the data packet with the unique sequence number into a preset sending cache queue.
[0048] The sending buffer queue is a storage area preset by the sending end for temporarily storing data packets that have been assigned unique serial numbers and have been sent.
[0049] During data transmission according to claim 6, the transmitting end assigns a unique sequence number to a data packet to be sent and then sends it. However, after sending, the data packet is not directly discarded. Instead, the data packet is placed in a send buffer queue, which temporarily stores the N most recently sent data packets (N is a positive integer greater than 3), preferably 1000. When the send buffer queue is full, the oldest data packet is removed. When a retransmission request is received, the corresponding target data packet is searched in the send buffer queue based on the target sequence number to be retransmitted, and then resent.
[0050] In one embodiment, the above-mentioned method for transmitting data using the User Datagram Protocol further includes the steps of: S24. When receiving a retransmission request fed back by the receiving end, determining whether to retransmit, wherein the retransmission request carries a retransmission sequence number of the data packet to be retransmitted; S25. If retransmission is required, searching the sending buffer queue for a retransmission data packet corresponding to the retransmission sequence number and sending the retransmission data packet to the receiving end; S26. If retransmission is not required, a command to continue processing the next data packet is fed back.
[0051] The retransmission request is a signal sent by the receiver to the sender requesting the retransmission of a specific data packet when the receiver finds that the data packet is lost or damaged. This request contains relevant information about the data packet to be retransmitted, such as the retransmission sequence number.
[0052] The retransmission sequence number uniquely identifies the data packet that needs to be retransmitted. The receiver includes this sequence number in the retransmission request to inform the sender which data packet needs to be retransmitted.
[0053] The retransmitted packet is a packet that the sender retrieves from the send buffer queue and resends to the receiver based on the receiver's retransmission request. This packet is identical to the previously sent packet that needs to be retransmitted, but needs to be sent again to ensure that the receiver can correctly receive it.
[0054] When the sender receives a retransmission request from the receiver, it enters the retransmission process. First, the sender evaluates the retransmission request to determine whether retransmission is necessary. This determination may take into account various factors, such as current network conditions, the number of packets in the send buffer queue, and the overall system policy. If the sender determines that retransmission is necessary, it searches the pre-set send buffer queue for a retransmitted packet corresponding to the retransmission sequence number carried in the retransmission request. Because the sender previously cached packets with unique sequence numbers in the send buffer queue, it can easily locate the packet to be retransmitted from the send buffer queue. After locating the retransmitted packet, the sender resends it to the receiver to ensure that the receiver ultimately receives the complete data. This retransmission mechanism is crucial in data transmission. In a network environment, packets may be lost or corrupted due to various reasons, such as network interference and signal attenuation. The receiver's retransmission request and the sender's retransmission response mechanism effectively compensate for this data loss and ensure the reliability and integrity of data transmission. For example, during a file transfer, if a packet is lost, the receiving end cannot correctly parse the file contents. Retransmission requests and the sender's retransmission operation ensure that the file is transmitted intact to the receiving end, avoiding file corruption or transmission failure caused by data loss. If the sender determines that retransmission is not necessary, it responds with a command to continue processing the next packet, allowing the receiving end to proceed. This command allows the receiving end to continue processing the next packet without waiting for the currently retransmitted packet to arrive.
[0055] This embodiment improves data transmission reliability and fault tolerance. When the receiving end responds with a retransmission request, the sending end can accurately locate the data packet requiring retransmission based on the retransmission sequence number in the request and resend it to the receiving end. This mechanism effectively addresses data packet loss or corruption during transmission, ensuring that data reaches the receiving end intact, thereby improving data transmission reliability. In applications requiring high data accuracy, such as financial transaction data transmission and medical data transmission, data integrity is crucial. Even the loss of a small number of data packets can have serious consequences. The retransmission mechanism minimizes this risk, ensuring data accuracy and reliability. From an efficiency perspective, the sending end caches data packets in a send buffer queue. When retransmission is required, it can directly retrieve and send the packet from the queue, saving the time and resources required to regenerate the packet. This improves retransmission efficiency and reduces data transmission delays caused by retransmission. This advantage is particularly evident in unstable network environments where data packet loss is frequent. The receiving end's retransmission request can be quickly responded to, restoring data transmission integrity as quickly as possible, and minimizing the impact on the overall data transmission process. Furthermore, this retransmission mechanism enhances the system's fault tolerance. In complex network environments, various factors can cause data packet transmission problems. The retransmission mechanism allows the system to automatically correct errors without requiring human intervention. This enables the data transmission system to operate more stably and adapt to diverse network conditions and application scenarios. Even in poor network conditions, data transmission is guaranteed to be correct, improving overall system performance and user experience.
[0056] In one embodiment, after the step S22 of sending the data packet with the unique sequence number to the receiving end, the method further includes: S27, the transmitting end determines whether a reception confirmation signal fed back by the receiving end is received within a preset time; S28: If the confirmation signal is not received, resend the data packet with the unique sequence number to the receiving end. S29: If the reception confirmation signal is received, continue to send the next data packet to the receiving end.
[0057] The preset time is a pre-set interval during data transmission. After sending a data packet, the sender waits for this interval to determine whether it has received a confirmation signal from the receiver. This interval should be adjusted appropriately based on factors such as the specific network environment, data transmission requirements, and system performance.
[0058] The aforementioned ACK signal is a feedback signal sent by the receiver to the sender after successfully receiving a data packet from the sender. It notifies the sender that the data packet has been successfully received. As mentioned above, this signal is crucial for communication reliability and data transmission integrity between the sender and receiver.
[0059] After the sender sends a data packet with a unique sequence number to the receiver, it initiates a confirmation monitoring mechanism. The sender determines whether it receives an acknowledgment signal from the receiver within a preset time. This preset time is a critical parameter and should be appropriately set based on actual network conditions and data transmission requirements. If network latency is high, the preset time may need to be set relatively long to ensure the sender has sufficient time to receive feedback from the receiver. If data transmission requires high real-time performance, the preset time may need to be set relatively short to promptly detect packet loss and take appropriate action. If the sender does not receive an acknowledgment signal from the receiver within the preset time, this may indicate that the packet was lost, damaged, or otherwise affected during transmission, preventing the receiver from correctly receiving the packet or from sending an acknowledgment signal in a timely manner. In this case, the sender will resend the packet. It will resend the previously sent packet with the unique sequence number to the receiver to ensure that the packet is ultimately received. This mechanism provides automatic error correction and ensures data integrity during data transmission. Packet loss is common in network environments due to various factors. This sender-side confirmation, monitoring, and retransmission mechanism effectively compensates for packet loss and improves the reliability and stability of data transmission. For example, in a remote monitoring system, sensor data must be accurately transmitted to the monitoring center in real time. If a packet is lost, the monitoring data may be incomplete, affecting accurate assessment of the monitored object. This mechanism allows the sender to promptly detect packet loss and retransmit it, ensuring the continuity and integrity of the monitoring data and the proper operation of the remote monitoring system. Of course, if a confirmation signal is received, the next packet can be sent to the receiver.
[0060] Reference Figure 5 The embodiment of the present invention further provides a computer device, the internal structure of which can be as follows Figure 5As shown. The computer device includes a processor, memory, a network interface, and a database connected via a system bus. The processor of the computer device is designed to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating device, a computer program, and a database. The internal memory provides an environment for the operation of the operating system and computer program in the non-volatile storage medium. The database of the computer device is used to store data packets, etc. The network interface of the computer device is used to communicate with an external terminal via a network connection. Furthermore, the computer device may also be provided with an input device and a display screen. When executed by the processor, the computer program implements a user datagram protocol data transmission method, comprising the following steps: a receiving end generates a target sequence number; searching a preset receive buffer queue for a target data packet corresponding to the target sequence number, wherein the receive buffer queue temporarily stores data packets with unique sequence numbers sent by the sending end; if the target data packet is found, processing the target data packet and removing the target data packet from the receive buffer queue. Alternatively, the sending end assigns a unique serial number to the data packet to be sent; and sends the data packet with the unique serial number to the receiving end; wherein the receiving end caches the data packet in a preset receiving cache queue, and when the data packet needs to be processed, generates a target serial number and searches the receiving cache queue for a target data packet corresponding to the target serial number and processes it.
[0061] Those skilled in the art will understand that Figure 5 The structure shown in is merely a block diagram of a portion of the structure related to the present application solution and does not constitute a limitation on the computer device to which the present application solution is applied.
[0062] One embodiment of the present application also provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, a method for transmitting data using the User Datagram Protocol is implemented, comprising the following steps: a receiving end generates a target sequence number; searches a preset receiving cache queue for a target data packet corresponding to the target sequence number, wherein the receiving cache queue temporarily stores data packets with unique sequence numbers sent by the sending end; if the target data packet is found, the target data packet is processed and removed from the receiving cache queue. Alternatively, the sending end assigns a unique sequence number to the data packet to be sent; the data packet with the unique sequence number is sent to the receiving end; wherein the receiving end caches the data packet in a preset receiving cache queue, and when a data packet needs to be processed, generates a target sequence number, searches the receiving cache queue for the target data packet corresponding to the target sequence number, and processes the data packet.
[0063] Those skilled in the art will understand that all or part of the processes in the above-mentioned embodiment methods can be implemented by instructing the relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media provided in this application and used in the embodiments may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in many forms such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (SSRSDRAM), enhanced SDRAM (ESDRAM), Synchronous Link DRAM (SLDRAM), Rambus direct RAM (RDRAM), direct RAM bus dynamic RAM (DRDRAM), and RAM bus dynamic RAM (RDRAM).
[0064] It should be noted that, in this document, the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, apparatus, article, or method comprising a series of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such process, apparatus, article, or method. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, apparatus, article, or method comprising the element.
[0065] The above description is only a preferred embodiment of the present invention and does not limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made by using the contents of the present invention description and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.
Claims
1. A method for transmitting data using a user datagram protocol, characterized in that: Includes steps: The receiving end generates a target sequence number; Searching a preset receiving cache queue for a target data packet corresponding to the target sequence number, wherein the receiving cache queue temporarily stores a data packet with a unique sequence number sent by a sending end, and the target sequence number generated by the receiving end corresponds to the unique sequence number assigned to the data packet by the sending end; If the target data packet is found, the target data packet is processed and removed from the receiving buffer queue; If the target data packet is not found, a retransmission request is sent to the sending end.
2. The method for transmitting data using the user datagram protocol according to claim 1, characterized in that: After the step of sending a retransmission request to the transmitting end, the method further comprises: Determine whether a command to continue processing the next data packet is received from the sender; If yes, then generate the next target sequence number; If not, wait to receive the target data packet sent by the sending end.
3. The method for transmitting data using the user datagram protocol according to claim 1, characterized in that: Before the step of searching the preset receiving buffer queue for the target data packet corresponding to the target sequence number, the method includes: When receiving a current data packet with a sequence number, obtaining the current sequence number of the current data packet; Searching a preset processed cache queue for a processed sequence number that matches the current sequence number; wherein the processed sequence number is a sequence number corresponding to a temporarily stored data packet that has been processed; If the processed sequence number matching the current sequence number is found, the current data packet is discarded.
4. The method for transmitting data using the user datagram protocol according to any one of claims 1 to 3, characterized in that: Also includes the steps: If the receiving end receives the data packet sent by the sending end, the receiving end feeds back a corresponding confirmation reception signal to the sending end.
5. A method for transmitting data using a user datagram protocol, characterized in that: Includes steps: The sender assigns a unique sequence number to the data packet to be sent; A data packet with a unique sequence number is sent to a receiving end so that the receiving end can search for the data packet with a unique sequence number according to a target sequence number generated by the receiving end, wherein the unique sequence number assigned to the data packet by the sending end corresponds to the target sequence number generated by the receiving end.
6. The method for transmitting data using the user datagram protocol according to claim 5, characterized in that: After the sending end assigns a unique sequence number to the data packet to be sent, the step further includes: The data packets with unique sequence numbers are cached in a preset sending cache queue.
7. The method for transmitting data using the user datagram protocol according to claim 6, characterized in that: Also includes the steps: When receiving a retransmission request fed back by the receiving end, determining whether to retransmit, wherein the retransmission request carries a retransmission sequence number of a data packet to be retransmitted; If retransmission is required, searching the sending buffer queue for a retransmission data packet corresponding to the retransmission sequence number and sending it to the receiving end; If retransmission is not required, a command to continue processing the next data packet is fed back.
8. The method for transmitting data using the user datagram protocol according to any one of claims 5 to 7, characterized in that: After the step of sending the data packet with the unique sequence number to the receiving end, the method further includes: The sending end determines whether a confirmation reception signal fed back by the receiving end is received within a preset time; If the confirmation reception signal is not received, resending the data packet with the unique sequence number to the receiving end; If the confirmation reception signal is received, the next data packet is sent to the receiving end.
9. A computer device comprising a memory and a processor, wherein a computer program is stored in the memory, wherein: When the processor executes the computer program, the processor implements the steps of the data transmission method of the user datagram protocol according to any one of claims 1 to 8.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the data transmission method of the user datagram protocol according to any one of claims 1 to 8 are implemented.
Citation Information
Patent Citations
Data transmission method and device based on UDP (User Datagram Protocol)
CN105791154A
Data transmission method, device and server
CN109787722A
Data transmission method, device, electronic equipment and storage medium
CN110430024A
Cited By
Data transmission method and device, computer equipment, storage medium and program product
CN121173771A