Using UDP instead of TCP

 < Day Day Up > 



For developers who are implementing new protocols, the trade-offs of using UDP rather than TCP should be considered. TCP requires connection establishment; therefore, the start-up time for a connection can be considerably longer than that of UDP. TCP also includes a number of features for reliability that weigh down the protocol and its ability to perform. These include congestion avoidance and retransmit. This is not to say that these features are not useful; they provide a very necessary function, but may be too heavy weight for certain applications.

The advantages of UDP over TCP are primarily in performance. Because UDP does not provide retransmit or reliable communication, these elements of the protocol are not provided in UDP and, therefore, a more efficient protocol implementation results. UDP also provides message framing, which can be a great benefit to applications. Rather than the application trying to deal with framing issues, the protocol automatically returns data in the granularity in which it was sent. Therefore, protocols that require message boundaries can yield significant performance benefits over TCP.

One particular arena in which UDP can play a great role is in applications that communicate only over LAN connections. The Internet is a hostile environment for UDP packets and the probability of packet loss increases dramatically compared to communicating over a local LAN. Therefore, if the application communicates solely over LAN connections, then UDP provides a number of advantages over TCP.

Another area in which UDP is important involves applications that can support some loss of data. Streaming audio applications are an interesting example. In TCP, when data is lost, the protocol backs off sending (for congestion avoidance) and then retransmits the old data. For audio, this presents a problem because what is important may not be in the past, but in the present (current audio, rather than audio in the past). With UDP, there is no reliability, and, therefore, lost data is simply lost. Protocols that utilize UDP commonly include sequence numbers within their higher-level protocol to identify when packet loss occurs, but typically do nothing about it from a lower-level protocol perspective.



 < Day Day Up > 



BSD Sockets Programming from a Multi-Language Perspective
Network Programming for Microsoft Windows , Second Edition (Microsoft Programming Series)
ISBN: 1584502681
EAN: 2147483647
Year: 2003
Pages: 225
Authors: Jim Ohlund

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net