UDT协议详细分析
UDT協議的主要特性有哪些?
-
基于UDP的應用層協議: 有基本網絡知識的朋友都知道TCP和UDP的區別和使用場景,但是有沒有一種協議能同時兼顧TCP協議的安全可靠和UDP協議的高效,那么UDT就是一種。
-
面向連接的協議:面向連接意味著兩個使用協議的應用在彼此交換數據之前必須先建立一個連接,當然UDT是邏輯上存在的連接通道。這種連接的維護是基于握手、Keep-alive(保活)以及關閉連接。
-
可靠的協議:依靠包序號機制、接收者的ACK響應和丟包報告、ACK序號機制、重傳機制(基于丟包報告和超時處理)來實現數據傳輸的可靠性。
-
雙工的協議:每個UDT實例包含發送端和接收端的信息。
-
單播的數據流。
-
新的擁塞算法,并且具有可擴展的擁塞控制框架:新的擁塞控制算法不同于基于窗口的TCP擁塞控制算法(慢啟動和擁塞避免),是混合的基于窗口的、基于速率的擁塞控制算法。可擴展的擁塞控制框架開源的代碼和擁塞控制的C++類架構,可支持開發者派生專用的擁塞控制算法。
-
帶寬估計:UDT使用對包(PP -- Packet pair)的機制來估計帶寬值。即每16個包為一組,最后一個是對包,即發送方不用等到下一個發送周期內再發送。接收方接收到對包后對其到達時間進行記錄,可結合上次記錄的值計算出鏈路的帶寬(計算的方法稱為中值過濾法), 并在下次ACK中進行反饋。
UDT一些主要特性的實現
UDT包確認機制是基于時間的定時器實現的。原理:
uses timer-based selective acknowledgement, which generates an acknowledgement at a fixed interval. This means that the faster the transfer speed, the smaller the ratio of bandwidth consumed by control traffic. Meanwhile, at very low bandwidth, UDT acts like protocols using cumulative acknowledgement.
The ACK interval of UDT is the same as the rate control interval (SYN).
To support this scheme, nega tive acknowledgement (NAK) is used to explicitly feed back packet loss. NAK is generated once a loss is detected so that the sender can react to congestion as quickly as possible. The loss information (sequence numbers of lost packets) will be resent after an increasing interval if there are timeouts indicating that the retr ansmission or NAK itself has been lost.
UDT流量控制是基于以下三個機制實現的。
-
new congestion control
-
DAIMD rate control
-
dynamic window control
詳細說明在這:http://www.jenkinssoftware.com/raknet/manual/congestioncontrol.html
UDT支持哪些數據傳輸類型
-
基于流的send, recv。
-
基于數據報sendmsg,recvmsg。
-
文件傳輸sendfile,recvfile。
下面我們結合UDT version 4版本來給大家分析下這個版本的UDT所擁有的一些新的特性。
-
使用了UDP multiplexer(UDP多路復用)機制,這樣做的好處是:
therefore it is possible (and by default) all UDT sockets in one process will share one UDP port. This scheme makes it easier for firewall traversing.
-
UDT流控采用可配置的擁塞控制算法,你可以關閉它、配置它,改良它來實現自己需要的流控策略。
-
采用新的資源管理(內存管理)和共享的擁塞控制方法來支持更多并發的UDT連接。有關內存管理的介紹如下:
-
UDT4 has a new buffer management module that enables all UDT sockets in one process can share protocol buffer. The goodness it brings is the much less memory usage for multiple UDT connections compared to previous versions.
-
UDT4 can automatically resize its buffer in order to reduce memory usage while providing maximum throughput.
-
Because of the new memory management scheme, overlapped IO has been removed from UDT4. If your existing code uses overlapped IO, you need to modify it to use regular IO. This is the only change needed for exiting code to move from UDT3 to UDT4.
-
-
其他的特點:
-
不和原生socket api沖突;
-
線程安全;
-
進程間不共享句柄;
-
錯誤處理;
-
防火墻穿透;
-
安全性好;
-
建立連接快速;
-
總結
- 上一篇: Linux社区关于链表的bug讨论我们要
- 下一篇: 绝地求生最新服务器维护,绝地求生更新维护