pankaj kushwaha
pankaj kushwaha

Reputation: 379

Why UDP behave well compare to TCP in a lossy network

I was going through following link. Why is SNMP usually run over UDP and not TCP/IP? I don't understand that why UDP perform well compare to TCP in lossy network? Can someone please clarify?

Upvotes: 2

Views: 1908

Answers (3)

rajashekar
rajashekar

Reputation: 3765

TCP: At the lower levels of the protocol stack, due to network congestion, traffic load balancing, or other unpredictable network behavior, IP packets may be lost, duplicated, or delivered out of order. TCP detects these problems, requests retransmission of lost data, rearranges out-of-order data, and even helps minimize network congestion to reduce the occurrence of the other problems. If the data still remains undelivered, its source is notified of this failure. Once the TCP receiver has reassembled the sequence of octets originally transmitted, it passes them to the receiving application. Thus, TCP abstracts the application's communication from the underlying networking details. TCP is optimized for accurate delivery rather than timely delivery, and therefore, TCP sometimes incurs relatively long delays (on the order of seconds) while waiting for out-of-order messages or retransmissions of lost messages. It is not particularly suitable for real-time applications such as Voice over IP. For such applications, protocols like the Real-time Transport Protocol (RTP) running over the User Datagram Protocol (UDP) are usually recommended instead. (source wikipedia)

SNMP does real time monitoring hence over UDP.

For an explaination more in context http://confessionsofalinuxpenguin.blogspot.in/2012/11/udp-or-tcp-for-lossy-networks.html

for snmp data details. some graphs about tcp vs udp in a lossy network http://www.ietf.org/proceedings/72/slides/opsarea-2.pdf

Upvotes: 0

Steffen Ullrich
Steffen Ullrich

Reputation: 123380

UDP does not behave well in a lossy network by itself. UDP is simply used for a different kind of applications:

  • If a small loss of data is not the main problem you can use UDP. That's why UDP is used for real time audio where latency is bad but a small loss of data can be worked around. It is used for things like syslog or SNMP where you can risk to loose a few data.
  • If you instead need a reliable data transport, i.e. no loss of data then TCP is better because it acknowledges all the received data and will retransmit lost packets. Thus TCP is used for the Web, for mail transport etc.

Apart from that neither TCP nor UDP are designed for networks with a high packet loss. They both expect a small packet loss because of congestion etc and expect the underlying layers (i.e. ethernet, WLAN..) take care of major delivery problems.

Upvotes: 7

A. Abramov
A. Abramov

Reputation: 1865

First of all, since this question is about networks and not programming, It doesn't belong here - anyhow;

TCP is a slower, more reliable protocol than UDP is. In comparison, UDP is much faster and efficient. For example, TCP has much more flags (window-length, syn, ack, etc) - And also starts and ends a connection in a very stable way - the Three way handshake - while all UDP has is Source IP, dest IP, length, Source port, dest port, and checksum.

In order to send all those extra packets to start and end a connection, and the verficiation process for each single packet takes time - while UDP is a stream of data, which doesn't mind the loss of a few bytes here and there, TCP is a reliable protocol - which in turn takes longer and is less efficient.

That's a very general explanation - I highly suggest you read more.

Upvotes: 1

Related Questions