Click here to Skip to main content
15,881,559 members
Articles / Desktop Programming / MFC
Article

A UDP-based Reliable Data Transfer Library

Rate me:
Please Sign up or sign in to vote.
4.85/5 (58 votes)
21 Mar 20064 min read 351.2K   10K   118   66
Introduces an open source UDP-based data transfer library.

Introduction

This article introduces an open source UDP-based data transfer library, namely UDT (UDP-based Data Transfer).

Currently, there are two major Internet transport protocols, TCP and UDP. TCP provides connection oriented reliable data streaming service, whereas UDP provides connection-less unreliable messaging service. Most applications use TCP to transfer data because they require data reliability.

However, when using TCP some applications suffer from two problems. First, TCP demonstrates poor performance in long distance links, especially when the bandwidth is high (e.g., 1GB/s or higher). Second, when incorporating multiple concurrent TCP flows with different RTTs in the same application, different TCP flows may have different data transfer rates (also known as RTT bias).

There are other situations where people do not want to use either TCP or UDP. For example, an application may require data reliability (so cannot use UDP directly) but also wants data to arrive at a user-controlled rate or the message boundaries to be conserved. Furthermore, sometimes it is easier to use UDP to traverse firewalls than TCP.

It may be helpful to build an open source user space transport protocol above UDP, but with the data reliability control and network flow/congestion control. Because it is at user space, it is easy to get installed. Because it is open source, it can be easily modified to meet various requirements from applications.

Example applications

Here we present two example applications in which you may need UDT.

a. Bulk data transfer and online streaming data processing

Suppose a company has their data stored in multiple branches around the world, each branch having its own part of the dataset. The datasets are very large (terabytes) and the company has a 1GB/s intranet to deliver them. Now one of its departments at Chicago branch wants to analyze its own dataset and the dataset of the London branch. This data analysis application will need to read two datasets (at London and Chicago, respectively) using the company's 1GB/s intranet to a computer at Chicago.

Recall the two problems of TCP mentioned above. First, the link must be extremely clean (very little packet loss) for TCP to fully utilize the 1GB/s bandwidth between London and Chicago. Second, when the two TCP streams (London->Chicago, Chicago->Chicago) start at the same time, the London-Chicago stream will be starved due to the RTT bias problem, thus the data analysis process will have to wait for the slower data stream.

b. Application awareness

A streaming video server is sending data to many clients. The server may choose a specific sending rate for each client during any specific period. You may have trouble asking TCP to send data at a fixed rate. And using UDP you have to do most of the data reliability control work by yourself. In addition, video frames are time sensitive data, if the frame is delayed too long, it will not be needed any more. That is, complete data reliability is not desired in this situation.

Using the UDT library, the programming work is simply several lines of option setting code.

UDT

UDT is a transport protocol with its own reliability control and flow/congestion control built above UDP. UDT provides both reliable data streaming service quite similar to TCP and partial reliable messaging. The latter allows users to send data as messages with specified delivery order and time-to-live value.

The position of UDT in the layered architecture of internet reference model is shown in the figure below. Applications use UDT socket to transfer their data, which is passed to the UDP socket. (Effort was made to avoid one time memory copy here.) A congestion control (CC) algorithm can be provided by applications; otherwise the default control algorithm is used. If user-defined control algorithm is provided, UDT will call the callback functions in CC once a control event occurs:

The default UDT control algorithm is designed for high performance data transfer over wide area high speed networks (e.g. in the case of example a). However, UDT's congestion control algorithm is configurable such that you can add your own control algorithm with ease (e.g., in the case of example b).

UDT provides a set of socket-like API. Using UDT in your application is simple as long as you are familiar with BSD socket. For example: With BSD socket, you write:

int s = socket(AF_INET, SOCK_STREAM, 0);

Its counterpart in UDT is:

UDTSOCKET u = UDT::socket(AF_INET, SOCK_STREAM, 0);

UDT is currently implemented using C++ and it supports Linux, Windows (2000, XP and above), and OS X. The current version is 3.0 Beta. After you download UDT, please read the "readme" file or the documentation for detailed installation and usage information. Note that if you are using Windows, you will need VC7 to get it compiled. With VC6, you will have to fix several incompatible C++ grammar by yourself.

If you are interested in the project, please refer to this site for more information.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
Praisehelp a lot Pin
Member 848968527-Mar-19 17:51
Member 848968527-Mar-19 17:51 
QuestionASP.NET Pin
Volodymyr Sergio Kalinchuk18-Sep-15 3:59
Volodymyr Sergio Kalinchuk18-Sep-15 3:59 
Questionerror code 1001 Pin
Member 107820505-May-14 3:11
Member 107820505-May-14 3:11 
GeneralMy vote of 5 Pin
Member 432084428-Jun-12 22:47
Member 432084428-Jun-12 22:47 
GeneralConnecting to a wireless pc from a pc inside a network trough a server. Pin
lukekando1-Jul-10 3:12
lukekando1-Jul-10 3:12 
GeneralRe: Connecting to a wireless pc from a pc inside a network trough a server. Pin
Member 432084428-Jun-12 22:44
Member 432084428-Jun-12 22:44 
QuestionDoes anyone know how to port and compile as a module? Pin
hookarm3-Mar-10 3:54
hookarm3-Mar-10 3:54 
QuestionUDT::select doesn't work? Pin
thunder5400726-Sep-07 2:31
thunder5400726-Sep-07 2:31 
AnswerRe: UDT::select doesn't work? Pin
realscan28-Mar-11 22:58
realscan28-Mar-11 22:58 
NewsHint: UDT v3.3 works good, the UDT-m/UDT v4 did not work well at the moment. Pin
Jens.Schneeweiss17-Jul-07 0:02
Jens.Schneeweiss17-Jul-07 0:02 
Generalconflict with the Queue and Multithreading Pin
Jens.Schneeweiss16-Jul-07 23:52
Jens.Schneeweiss16-Jul-07 23:52 
Generalbreaking protocol from applications Pin
Geode8511-Nov-06 3:58
Geode8511-Nov-06 3:58 
Questionmultiple UDT sockets Pin
Wee Lio31-Oct-06 19:58
Wee Lio31-Oct-06 19:58 
QuestionIs UDT Support Punching Firewall/NAT only in Rendezvous mode? Pin
China_Boy31-Aug-06 16:22
China_Boy31-Aug-06 16:22 
QuestionHow to add multiple connection support in Rendezvous mode Pin
Hing17-Jul-06 16:54
Hing17-Jul-06 16:54 
AnswerRe: How to add multiple connection support in Rendezvous mode Pin
lilyco17-Jul-06 17:12
lilyco17-Jul-06 17:12 
QuestionRe: How to add multiple connection support in Rendezvous mode Pin
Hing17-Jul-06 22:22
Hing17-Jul-06 22:22 
GeneralRedezvous connection again Pin
Hing16-Jul-06 21:36
Hing16-Jul-06 21:36 
Sorry, as the thread is becoming large so, I post my question here:

Problem:
While in rendezvous mode, when you do connect in a separate thread and the connect is blocking (waiting another to connect in), and you do UDT::close to close the socket which is being used in that thread by the "connect" function, the close function just blocked until the connection timeout in that thread.

Is that normal? Because I expect that whenever I call UDT::close, any socket operation should be abandoned and return immediately.

Also, are you working on the problem in the thread below?
http://www.codeproject.com/internet/udt.asp?msg=1577366#xx1577366xx[^]

Thanks for your kind attention and I am looking forward to you.

Hing
GeneralRe: Redezvous connection again Pin
lilyco17-Jul-06 5:48
lilyco17-Jul-06 5:48 
GeneralQuestion on broken client [modified] Pin
Hing12-Jul-06 17:19
Hing12-Jul-06 17:19 
GeneralRe: Question on broken client Pin
lilyco12-Jul-06 17:47
lilyco12-Jul-06 17:47 
GeneralRe: Question on broken client [modified] Pin
Hing12-Jul-06 18:45
Hing12-Jul-06 18:45 
GeneralRe: Question on broken client Pin
lilyco13-Jul-06 13:17
lilyco13-Jul-06 13:17 
GeneralRe: Question on broken client Pin
Hing13-Jul-06 23:21
Hing13-Jul-06 23:21 
GeneralRe: Question on broken client Pin
lilyco17-Jul-06 5:07
lilyco17-Jul-06 5:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.