一个基于UDP的可靠数据传输库

A UDP-based Reliable Data Transfer Library

一个基于UDP的可靠数据传输库

 

Introduces an open source UDP-based data transfer library.

介绍了一个开源的基于UDP的输出传输库。

Introduction

简介

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

本文章介绍了一个开源的基于UDP的数据传输库,即UDT(基于UDP的数据传输)。

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.

目前,有两个主要的网络传输协议,TCPUDPTCP提供面向连接的可靠数据流服务,而UDP提供无连接的不可靠消息服务。大部分应用程序使用TCP传输数据,因为它们需要数据的可靠性。

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).

然而,当使用TCP时,一些应用程序苦于如下两个问题。首先,TCP在远程连接方面显示出性能不佳,尤其当带宽相当高时(例如,1GbB/s或者更高)。其次,当在一个应用程序中包含多个并发的TCP流具有不同的RTTs时,不同的TCP流可能具有不同的数据传输速率(也称谓RTT偏差)。

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.

在其它情况下,人们既不希望使用TCP,也不希望使用UDP。例如,一个应用程序可能需要数据的可靠性(所以不能直接使用UDP),但是也想要数据以一个用户控制速率到达,或者消息边界是保守的。此外,与TCP比起来,使用UDP更容易穿越防火墙。

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.

它可以帮助在UDP之上建立一个开源的用户空间传输协议,但是具有数据可靠性控制和网络流量/拥塞控制。因为它是在用户空间,它很容易进行安装。因为它是开源的,它可以方便地进行修改,以满足各种应用的要求。

Example applications

应用示例

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

在这里,我们提出了两个示例应用程序,在它们中您可能需要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.

假设一个公司将自己的数据存储在世界各地的多个分支,每个分支都有自己的数据集的一部分。该数据集非常大(TB),并且公司具有1GB/s的企业内部网去传递它们。现在,它的一个在芝加哥的分公司的部门想要分析它自己的数据集,以及伦敦分公司的数据集。该数据分析应用程序将需要通过使用该公司的1GB/s的企业内部网读取两个数据集(分别在伦敦及芝加哥)到芝加哥的一台电脑上。

 

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.

记得上面提到的TCP的两个问题。首先,该链接必须非常的干净(很小的数据包丢失),以便于TCP充分利用该位于伦敦与芝加哥之间的1GB/s的带宽。其次,当两个TCP流(伦敦->芝加哥,芝加哥->芝加哥)同时开始,由于RTT问题,伦敦-芝加哥的流将处于饥饿状态,因此,数据分析过程将不得不等待慢速数据流。

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.

一个流式视频服务器向许多客户端发送数据。在任何特定时期,服务器可能为每位客户选择一个特定的发送速率。你可能困扰于请求TCP在一个固定的速率发送数据。并且,使用UDP时,您不得不自行实现大部分的数据可靠性控制工作。此外,视频帧是时间敏感的数据,如果帧延迟的时间过长,它将不再被需要。也就是说,在这种情况下,不需要完整的数据可靠性。

 

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

当使用UDT库时,所有的编程工作仅仅是几行简单的选项设置代码。

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.

UDT是一个传输协议,具有它自己的可靠性控制及流量/拥塞控制,建立于UDP之上。UDT同时提供了可靠的数据流服务(十分类似于TCP)与部分可靠的消息服务。后者允许用户将数据作为消息进行发送,具有特定的传输顺序与存留时间值。

 

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:

UDT在互联网参考模型的分层体系结构中的位置如下图所示。应用程序使用UDT套接字传输它们的数据,它们被传递给UDP套接字。(在这里已经尽力避免了一次内存复制情况的存在)。应用程序可以提供拥塞控制(CC)算法;否则,将使用默认的控制算法。如果提供了用户自定义的控制算法,一旦发送控制事件,UDT将在拥塞控制算法中调用回调函数:

 一个基于UDP的可靠数据传输库_第1张图片

 

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控制算法是专为通过高速广域网络进行高性能数据传输的(例如,在示例a的情况下)。然而,UDT的拥塞控制算法是可配置的,在这种情况下,你可以轻松地添加您自己的控制算法(例如,在示例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:

UDT提供了一组类似套接字的API。在你的应用程序中,使用UDT是很简单的,只要您熟悉BSD套接字。例如,使用BSD套接字时,你编码为:

Hide   Copy Code

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

Its counterpart in UDT is:

UDT上,对应的是:

 

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.

UDT目前使用C++进行实现,并且,它支持LinuxWindows2000XP及以上),以及OS X。当前版本是3.0 Beta。在您下载UDT之后,请仔细阅读readme文件或文档,以获取详细的安装及使用信息。请注意,如果您使用的是Windows,您需要VC7才能编译。使用VC6时,您必须自己去解决一些C++语法的不兼容问题。

 

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.

本文没有任何明确的授权附加到它上面,但可能包含文章文本或者下载文件本身的使用条款。如有任何疑问,请通过下面的讨论板联系作者。

译自

http://www.codeproject.com/Articles/11046/A-UDP-based-Reliable-Data-Transfer-Library

 

译者

百恼

[email protected]

你可能感兴趣的:(file,transfer)