Developing Multimedia Applications with DCCP
Total Page:16
File Type:pdf, Size:1020Kb
BEFN$?FN DCCP ;\m\cfg`e^dlck`d\[`XXggc`ZXk`fejn`k_;::G :FE><JK@FE :FEKIFC 8eeX#=fkfc`X The DCCP protocol gives multimedia developers a powerful alternative to TCP and UDP. BY LEANDRO MELO DE SALES ver the past few years, develop- In this article, I examine the DCCP DCCP inherits the connection-oriented ers have unveiled a new genera- protocol and show how to enable DCCP and congestion-control features from Ftion of network applications that in Linux. Also, I will explain how to use TCP, and, from UDP, DCCP inherits unre- transmit and receive multimedia content the GStreamer DCCP plugin to create a liable transmission. over the Internet. New multimedia appli- simple client-server DCCP application. In addition to connection-oriented and cations based on technologies such as DCCP was first introduced by Kohler congestion-control features, TCP provides Voice over IP, Internet radio, online gam- et al. in July 2001 at the IETF transport reliable data transfer. This reliability fea- ing, and video conferencing are becom- group. The DCCP protocol provides spe- ture limits the transmission rate for a ing increasingly popular thanks to the cific features designed to address some given connection. When packets are lost, availability of development libraries and of the problems developers have faced TCP decreases its transmission rate, and it the abundance of high-speed networks. writing multimedia applications with increases the transmission rate again In the past, most Internet applications TCP and UDP, such as delay and jitter when it sends packets successfully. To have used either the Transmission Con- caused by network congestion. DCCP implement reliable data transfer, when trol Protocol (TCP) or the User Datagram offers a connection-oriented transport TCP loses packets, it retransmits them. In Protocol (UDP) to manage communica- layer for congestion-controlled but unre- this case, new data generated by the ap- tion at the Transport layer of the TCP/ IP liable data transmission. Also, DCCP plication is queued until all lost packets protocol stack, but multimedia develop- provides a framework that enables the are sent. Because of this way of imple- ers now have an alternative to TCP and addition of new congestion-control menting reliable data transfer, TCP might UDP. IETF recently standardized the mechanisms, either added during the lead to a high level flow delay. Conse- Datagram Congestion Control Protocol connection handshake or negotiated quently, the user might experience inter- (DCCP) (RFC4340) [1], a new transport during an established connection. DCCP ruptions in multimedia content. protocol designed to transmit conges- also provides a mechanism for getting On the other hand, UDP is a simple tion-controlled multimedia content. connection statistics, a congestion-con- protocol, implementing minimal func- DCCP is becoming very popular for trol mechanism with Explicit Congestion tions to transport data from one com- multimedia data transmission, mainly Notification (ECN) support, and a puter to another. It is a connectionless because it is more effective than UDP at method for Path Maximum Transmission protocol and does not care about data sharing the available bandwidth. Unit (PMTU) discovery. packet delivery or network congestion 56 ISSUE 93 AUGUST 2008 DCCP BEFN$?FN control. Also, UDP does not provide 4341) [3] is better for applications that gestion-control mechanisms, making it packet reordering on the receiver end. use the maximum bandwidth available more suitable for applications such as Because of the lack of any type of con- at the network, but it can easily be telephony or streaming media, for which gestion control, UDP might lead to net- adapted to sudden bandwidth changes. a relatively smooth sending rate is work congestion collapse. Hence, a UDP It is similar to TCP congestion control, important. application can send data as much as it which is based on the congestion win- wants, but much of this data might be dow concept. The congestion window J\kLgk_\<em`ifed\ek lost or discarded by the routers because size dictates how many packets the To start exploring the world of DCCP on of network congestion. sender is allowed to transmit over the Linux, you first need to enable DCCP in Before DCCP, multimedia application network. This means that the bigger the the Linux kernel and then install some developers had to choose between TCP congestion window size, the more pack- applications to test your environment. and UDP. If they used TCP, end users ets TCP sends over the network. When Because DCCP is a new protocol, it is in might experience high streaming delays DCCP CCID-2 detects a packet loss, it constant development. If you want the because of packet retransmission. If they halves the congestion window, which latest available changes for the DCCP used UDP, the result might be a network is an abrupt change in the transmission implementation in the Linux kernel, you collapse or bad streaming quality. DCCP rate, especially for multimedia applica- must fetch the kernel from the DCCP git puts together the best features of TCP tions. test tree repository [6], which is man- and UDP to provide higher quality multi- In the initial transmission state, the aged by the git tool, a version control media data streaming and better sharing congestion window size increases in an system used by kernel developers. After of bandwidth [2]. exponential fashion as the sent packets you have installed git – it is available are acknowledged, until it reaches the from package managers such as emerge, ;::G:fe^\jk`fe:fekifc congestion-avoidance phase. At this apt-get, and urpmi – you can fetch the DCCP offers two congestion-control al- point, CCID-2 increases the congestion entire kernel source tree, including the gorithms, called CCIDs (Congestion Con- window size by 1 when the receiver DCCP source subtree, as follows: trol IDentifiers). The CCIDs are the com- acknowledges a packet. ponents responsible for providing con- On the other hand, CCID-3 (RFC 4342) git-clone git://5 gestion control for a DCCP connection. [4] implements a receiver-based conges- eden-feed.erg.abdn.ac.uk/5 In Linux, CCIDs are kernel modules tion control algorithm in which the dccp_exp my_dccp working on top of the DCCP core imple- sender is rate-limited by the receiver. mentation. Because they are kernel mod- Periodically, the receiver sends feedback The my_dccp argument is the directory ules, the CCIDs can be loaded or un- packets to the sender containing lost where git will put the fetched Linux ker- loaded at any time, and applications can event information and other connection nel source code. This directory must not select a CCID appropriate for the task. statistics that are plugged into the TCP- exist. If you have a fairly recent git ker- For instance, a Voice over IP (VoIP) ap- Friendly Rate Control equation (TFRC) nel source, you can speed up the fetch- plication is characterized by bursts of (RFC 3448) [5]. ing process by passing to the git-clone small packets followed by periods of TFRC is reasonably fair when compet- command the directory as a reference: silence, whereas a Video on Demand ing for bandwidth with TCP flows, but (VoD) application generally transmits it has a lower variation of throughput git-clone --reference 5 multimedia content at a constant bit over time compared with other TCP con- old_git_kernel git://5 rate. In this case, it is better for a VoIP eden-feed.erg.abdn.ac.uk/5 application to use a congestion-control Listing 1: Python DCCP dccp_exp my_dccp technique tailored to VoIP. Server (dccp_server.py) Currently there are two standardized 01 import socket Listing 2: Python DCCP CCIDs: CCID-2 and CCID-3. CCID-2 (RFC 02 Client (dccp_client.py) 01 import socket Leandro Melo de Sales has enjoyed 03 socket.SOCK_DCCP = 6 Linux since 1997 and has contrib- 04 socket.IPPROTO_DCCP = 33 02 uted to DCCP in Linux since 2006, 05 address = (socket. 03 socket.SOCK_DCCP = 6 focusing mainly on embedded devices. He maintains DCCP for the gethostname(),12345) 04 socket.IPPROTO_DCCP = 33 Nokia maemo platform and is work- 06 05 address = (socket. ing on DCCP CCID-4 congestion con- 07 server = socket.socket(socket. gethostname(),12345) trol and a DCCP-based VoIP client. Leandro works at the Embedded AF_INET, socket.SOCK_DCCP, 06 Systems and Pervasive Computing socket.IPPROTO_DCCP) 07 client = socket.socket(socket. Lab/UFCG, which is supported by 08 AF_INET, socket.SOCK_DCCP, Nokia Institute of Technology, Brazil. THE AUTHOR THE Thanks to the other authors who 09 server.bind(address) socket.IPPROTO_DCCP) contributed: Angelo Perkusich, 10 server.listen(1) 08 Arnaldo Carvalho, Erivaldo Xavier, 09 client.connect(address) Felipe Coutinho, Hyggo Almeida , 11 s,a = server.accept() Marcello Júnior, and Thiago Santos. 12 print s.recv(1024) 10 client.send("Hello World") AUGUST 2008 ISSUE 93 57 BEFN$?FN DCCP In both cases, git-clone will take a while kernel options; DCCP is enabled under all connections started by DCCP. Note to fetch the kernel source from over the the Networking option as follows: that you also can specify these parame- network. While you wait for the end of ters through a programming language the fetch process, you can read about Networking --> using the setsockopt socket function. DCCP on Linux wiki [7] to learn more Network options --> about DCCP. Once git has downloaded The DCCP Protocol --> K\jk`e^;::G the Linux kernel containing the latest IPerf is a network measurement tool that available version of DCCP, enter in the Inside this option, you can specify the was originally designed to work over newly created directory (in my example, CCIDs and some other DCCP options. TCP and UDP. But thanks to a patchset the my_dccp directory) and check out After you select everything you need, provided by Gerrit Renker, it also sup- the DCCP branch: just compile the kernel using instruc- ports the DCCP protocol, wherein you tions specified in the documentation [8].