CN116545948A - Reliable communication method based on UDP protocol - Google Patents

Reliable communication method based on UDP protocol Download PDF

Info

Publication number
CN116545948A
CN116545948A CN202310578636.3A CN202310578636A CN116545948A CN 116545948 A CN116545948 A CN 116545948A CN 202310578636 A CN202310578636 A CN 202310578636A CN 116545948 A CN116545948 A CN 116545948A
Authority
CN
China
Prior art keywords
data
packet
numbers
kcp
retransmission
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202310578636.3A
Other languages
Chinese (zh)
Inventor
王红梅
李建华
周世东
陈翔
陈江
刘伟
潘智超
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Easy Times Digital Technology Co ltd
Original Assignee
Beijing Easy Times Digital Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Easy Times Digital Technology Co ltd filed Critical Beijing Easy Times Digital Technology Co ltd
Priority to CN202310578636.3A priority Critical patent/CN116545948A/en
Publication of CN116545948A publication Critical patent/CN116545948A/en
Pending legal-status Critical Current

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L47/00Traffic control in data switching networks
    • H04L47/10Flow control; Congestion control
    • H04L47/34Flow control; Congestion control ensuring sequence integrity, e.g. using sequence numbers
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L1/00Arrangements for detecting or preventing errors in the information received
    • H04L1/12Arrangements for detecting or preventing errors in the information received by using return channel
    • H04L1/16Arrangements for detecting or preventing errors in the information received by using return channel in which the return channel carries supervisory signals, e.g. repetition request signals
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/16Implementation or adaptation of Internet protocol [IP], of transmission control protocol [TCP] or of user datagram protocol [UDP]
    • H04L69/164Adaptation or special uses of UDP protocol
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/26Special purpose or proprietary protocols or architectures
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D30/00Reducing energy consumption in communication networks
    • Y02D30/50Reducing energy consumption in communication networks in wire-line communication networks, e.g. low power modes or reduced link rate

Abstract

The invention discloses a reliable communication method based on UDP protocol, which is based on UDP protocol, the data packet is numbered before data transmission, the numbers are assembled into the data packet at the same time during transmission, KCP protocol is used as an auxiliary port of a main communication port for transmitting retransmission instructions. The method has the following advantages: the data packets are numbered before transmission, the receiving end receives each data packet, and after unpacking, the data packet numbers are analyzed to quickly determine whether the data packets are lost. After the receiving end judges that the packet is lost, the receiving end returns a data retransmission instruction through KCP, so that the transmission of the retransmission instruction is reliable. When the network is severely congested, the data of the retransmission instruction is very small, and when the data transmitting end receives the retransmission instruction returned by the KCP, the network can be assumed to be unblocked, and the unnecessary bandwidth waste can be effectively reduced by retransmitting the data again.

Description

Reliable communication method based on UDP protocol
Technical Field
The invention relates to the technical field of computer networks and applications, in particular to a reliable communication method based on UDP protocol.
Background
In the network application development process, a TCP protocol or a UDP protocol may be used.
TCP is a connection-oriented communication protocol, and before data transmission, there is a three-way handshake to establish connection, and when data is transmitted, there is a mechanism of acknowledgement, window, retransmission, congestion control, so that the correctness of data can be ensured, and the TCP is more reliable, and after data transmission is completed, the TCP is disconnected to save system resources. But its transmission speed is slow, its efficiency is low, and its occupied system resource is high. TCP requires a connection to be established before data is transferred, which consumes a lot of time, and during data transfer, an acknowledgement mechanism, a retransmission mechanism, a congestion control mechanism, etc. consume a lot of time, and all transmission connections are maintained on each device, and in fact, each connection occupies hardware resources such as CPU and memory of the system.
UDP is a connectionless communication protocol, and UDP data comprises destination port number and source port number information, so that the speed is high, the operation is simple, less system resources are required, and broadcast transmission can be realized because communication does not need connection. Because there is no mechanism for handshaking, acknowledgement, window, retransmission, congestion control, etc. of TCP, it is very fast in delivering data. However, the transmission is unreliable and unstable, because UDP does not have a reliable mechanism such as TCP, and when data is transferred, if the network quality is poor, packets are easily lost, resulting in data loss.
KCP is a fast and reliable protocol, which does not specify an underlying transport protocol, but is an implementation of a pure algorithm, but generally uses UDP as the underlying protocol, so that it can be said that KCP is a fast and reliable UDP in general, at the cost of 10% -20% of the bandwidth wasted by TCP, with a 30% -40% reduction in average delay, and a three-fold reduction in maximum delay. In view of the above drawbacks, it is necessary to design a reliable communication method based on the UDP protocol.
Disclosure of Invention
The technical problems to be solved by the invention are as follows: a reliable communication method based on UDP protocol is provided to solve the problems set forth in the background art.
In order to solve the technical problems, the technical scheme of the invention is as follows: a reliable communication method based on UDP protocol is carried out according to the following steps:
(1) UDP communication instance creation: two UDP protocol ports are respectively opened by two communication parties, one of the ports is used as a data port, the other port is used as a transmission control port by adopting a KCP encapsulation protocol, and the process requires a client program to create two UDP communication examples and bind the two ports, wherein one port is used for data transmission, and the other port is used for KCP encapsulation and is used for transmission instruction transmission;
(2) Initializing data numbers: before the data port transmits data, the data are numbered and the numbers are assembled into data packets, in the process, a data transmitting end and a data receiving end need to initialize a data number for recording the number of the data packets and checking the number of the data packets and the two sides, and the data packets can be transmitted after the numbers and the data are assembled and coded;
(3) Checking the data number: the receiving end unpacks the received data packet and performs data number verification, the process is that the data receiving end receives the data packet, the data number is identified after decoding, and whether the local data number is consistent with the data packet number is verified;
(4) Data transfer: if the packet loss or the packet error is judged, a retransmission instruction is sent to a data sender through the KCP, the data sender retransmits the data packet from the packet error number after receiving the retransmission instruction, the process normally receives and retransmits the processed data, and if the numbers of the two are inconsistent, a retransmission instruction is sent through the KCP port.
Further, the creation of a data number, the process will instantiate a variable with a value of 0; data encapsulation, wherein the process encapsulates the data number and the data, and can adopt JSON format encapsulation; data coding, wherein the data is coded into a byte array according to a contracted coding mode in the process; and data is sent, and the process transmits the data packet through a data channel.
Further, the process receives data packets through the data channel; identifying a data number, decoding the data packet according to a contracted encoding mode, and reading the data number in the data packet after decoding and comparing with a local number; if the numbers are not consistent, entering a retransmission flow, and if the numbers are consistent, updating the data numbers; and sending a retransmission command, wherein the retransmission command and the data number which should be received are packaged in the process, and the data sending end is informed to carry out data retransmission through a KCP channel.
Compared with the prior art, the reliable communication method based on the UDP protocol is based on the UDP protocol, the data packet is numbered before data transmission, the numbers are simultaneously assembled into the data packet during transmission, and the KCP protocol is used as an auxiliary port of the main communication port and used for transmitting retransmission instructions. The method has the following advantages: the data packets are numbered before transmission, the receiving end receives each data packet, and after unpacking, the data packet numbers are analyzed to quickly determine whether the data packets are lost. After the receiving end judges that the packet is lost, the receiving end returns a data retransmission instruction through KCP, so that the transmission of the retransmission instruction is reliable. When the network is severely congested, the data of the retransmission instruction is very small, and when the data transmitting end receives the retransmission instruction returned by the KCP, the network can be assumed to be unblocked, and the unnecessary bandwidth waste can be effectively reduced by retransmitting the data again.
Drawings
FIG. 1 is a schematic workflow diagram of the present invention;
FIG. 2 is a schematic diagram of a data transmission flow of the present invention;
fig. 3 is a schematic diagram of a data receiving process according to the present invention.
Detailed Description
In the following, numerous specific details are set forth in order to provide a thorough understanding of the concepts underlying the described embodiments. It will be apparent, however, to one skilled in the art that the described embodiments may be practiced without some or all of these specific details. In other instances, well known process steps have not been described in detail.
Examples
The reliable communication method based on the UDP protocol listed in the embodiment is carried out by the following steps that two UDP protocol ports are respectively opened by two communication parties, one of the two UDP protocol ports is used as a data port, the other one of the two UDP protocol ports adopts KCP encapsulation protocol as a transmission control port, a client program is required to create two UDP communication examples and bind the two ports, one port is used for data transmission, and the other port is used for KCP encapsulation and is used for transmission of transmission instructions; before the data port transmits data, the data are numbered and the numbers are assembled into data packets, in the process, a data transmitting end and a data receiving end need to initialize a data number for recording the number of the data packets and checking the number of the data packets and the two sides, and the data packets can be transmitted after the numbers and the data are assembled and coded; the receiving end unpacks the received data packet and performs data number verification, the process is that the data receiving end receives the data packet, the data number is identified after decoding, and whether the local data number is consistent with the data packet number is verified; if the packet loss or the packet error is judged, a retransmission instruction is sent to a data sender through the KCP, the data sender retransmits the data packet from the packet error number after receiving the retransmission instruction, the process normally receives and retransmits the processed data, and if the numbers of the two are inconsistent, a retransmission instruction is sent through the KCP port.
Creating a data number, which instantiates a variable with a value of 0; data encapsulation, wherein the process encapsulates the data number and the data, and can adopt JSON format encapsulation; data coding, wherein the data is coded into a byte array according to a contracted coding mode in the process; and data is sent, and the process transmits the data packet through a data channel.
Receiving data, the process receiving data packets via a data channel; identifying a data number, decoding the data packet according to a contracted encoding mode, and reading the data number in the data packet after decoding and comparing with a local number; if the numbers are not consistent, entering a retransmission flow, and if the numbers are consistent, updating the data numbers; and sending a retransmission command, wherein the retransmission command and the data number which should be received are packaged in the process, and the data sending end is informed to carry out data retransmission through a KCP channel.
The reliable communication method based on the UDP protocol is characterized in that the data packet is numbered before data transmission based on the UDP protocol, the numbers are simultaneously assembled into the data packet during transmission, and the KCP protocol is used as an auxiliary port of a main communication port for transmitting retransmission instructions. The method has the following advantages: the data packets are numbered before transmission, the receiving end receives each data packet, and after unpacking, the data packet numbers are analyzed to quickly determine whether the data packets are lost. After the receiving end judges that the packet is lost, the receiving end returns a data retransmission instruction through KCP, so that the transmission of the retransmission instruction is reliable. When the network is severely congested, the data of the retransmission instruction is very small, and when the data transmitting end receives the retransmission instruction returned by the KCP, the network can be assumed to be unblocked, and the unnecessary bandwidth waste can be effectively reduced by retransmitting the data again.

Claims (3)

1. A reliable communication method based on UDP protocol, characterized in that: the method comprises the following steps:
(1) UDP communication instance creation: two UDP protocol ports are respectively opened by two communication parties, one of the ports is used as a data port, the other port is used as a transmission control port by adopting a KCP encapsulation protocol, and the process requires a client program to create two UDP communication examples and bind the two ports, wherein one port is used for data transmission, and the other port is used for KCP encapsulation and is used for transmission instruction transmission;
(2) Initializing data numbers: before the data port transmits data, the data are numbered and the numbers are assembled into data packets, in the process, a data transmitting end and a data receiving end need to initialize a data number for recording the number of the data packets and checking the number of the data packets and the two sides, and the data packets can be transmitted after the numbers and the data are assembled and coded;
(3) Checking the data number: the receiving end unpacks the received data packet and performs data number verification, the process is that the data receiving end receives the data packet, the data number is identified after decoding, and whether the local data number is consistent with the data packet number is verified;
(4) Data transfer: if the packet loss or the packet error is judged, a retransmission instruction is sent to a data sender through the KCP, the data sender retransmits the data packet from the packet error number after receiving the retransmission instruction, the process normally receives and retransmits the processed data, and if the numbers of the two are inconsistent, a retransmission instruction is sent through the KCP port.
2. A reliable communication method based on the UDP protocol as claimed in claim 1, wherein said creating data numbers instantiates a variable with a value of 0; data encapsulation, wherein the process encapsulates the data number and the data, and can adopt JSON format encapsulation; data coding, wherein the data is coded into a byte array according to a contracted coding mode in the process; and data is sent, and the process transmits the data packet through a data channel.
3. A reliable communication method based on UDP according to claim 1, wherein said receiving data receives data packets via a data channel; identifying a data number, decoding the data packet according to a contracted encoding mode, and reading the data number in the data packet after decoding and comparing with a local number; if the numbers are not consistent, entering a retransmission flow, and if the numbers are consistent, updating the data numbers; and sending a retransmission command, wherein the retransmission command and the data number which should be received are packaged in the process, and the data sending end is informed to carry out data retransmission through a KCP channel.
CN202310578636.3A 2023-05-22 2023-05-22 Reliable communication method based on UDP protocol Pending CN116545948A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310578636.3A CN116545948A (en) 2023-05-22 2023-05-22 Reliable communication method based on UDP protocol

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310578636.3A CN116545948A (en) 2023-05-22 2023-05-22 Reliable communication method based on UDP protocol

Publications (1)

Publication Number Publication Date
CN116545948A true CN116545948A (en) 2023-08-04

Family

ID=87455920

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310578636.3A Pending CN116545948A (en) 2023-05-22 2023-05-22 Reliable communication method based on UDP protocol

Country Status (1)

Country Link
CN (1) CN116545948A (en)

Similar Documents

Publication Publication Date Title
US7912064B2 (en) System and method for handling out-of-order frames
US7817634B2 (en) Network with a constrained usage model supporting remote direct memory access
US8023520B2 (en) Signaling packet
US8549152B2 (en) System and method for TCP/IP offload independent of bandwidth delay product
US7899925B2 (en) System and method for fast, reliable byte stream transport
US6920501B2 (en) Communication socket migration among different devices
WO2019144836A1 (en) Data transmission method, apparatus and system
US20060248582A1 (en) One-way proxy system
US20120005369A1 (en) System and method of tcp tunneling
US20060101225A1 (en) Method and system for a multi-stream tunneled marker-based protocol data unit aligned protocol
JP2014509483A (en) Mechanisms to improve the performance of transmission control protocols in wireless networks
US20060101090A1 (en) Method and system for reliable datagram tunnels for clusters
US10757032B2 (en) Methods, apparatuses and computer-readable storage mediums for communication via user services platform
CN102055774B (en) Based on http server and the data processing method thereof of bag process
US8578040B2 (en) Method, system and article for client application control of network transmission loss tolerance
CN114500528A (en) Data transmission method and device based on cloud platform
Farber et al. Thinwire protocol for connecting personal computers to the Internet
EP1460804B1 (en) System and method for handling out-of-order frames (fka reception of out-of-order tcp data with zero copy service)
EP1562115A2 (en) Socket connections over a serial link
CN116545948A (en) Reliable communication method based on UDP protocol
CN112468513B (en) Terminal management communication method for enterprise network
CN112073435B (en) Method for reducing transmission delay of transmission channel in TOE
Chen et al. An improved rudp for data transmission in embedded real-time system
CN114449057A (en) Data transmission method and device
Sauer et al. Towards a flexible network processor interface for RapidIO, Hypertransport, and PCI-Express

Legal Events

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