TCP vs UDP

TCP & UDP are two of the most important Transport Layer protocols used for error-free end to end data delivery. Understanding these and some of the relevant important concepts is vital. Below is a summary of these:

There are two main Transport Layer protocols namely TCP and UDP. Transport Layer is the 4th in OSI 7 Layer Model. Both are very important because all IP transactions use any one of these two.

TCP: Transmission Control Protocol, defined in 1974 and has many RFCs.

UDP: User Datagram Protocol, defined in 1980 in RFC 768

OSI Model with Examples of Protocols & Devices - Click to Enlarge

There are three important binary properties that serve as the basis for the classification of transport layer protocols:

1. Connection-oriented vs. Connectionless

2. Stateful vs. Stateless

3. Reliable vs. Unreliable

Let’s review these briefly. The first & most important distinction between transport layer protocols is Connection-oriented vs. Connectionless:

 1-       Connection-Oriented Protocols: With connection-oriented protocols, one must establish a logical connection with the communication partner before exchanging data. This method of connection:

  • is highly reliable (because of acknowledgement for each packet exchange)
  • Requires more computational processing
  • Has more overhead because of connection establishment and termination
  • It is recommended where accuracy is important e.g. data transfer where a single wrong or missing bit would corrupt the entire file.

 Connectionless Protocols:  With connectionless protocols, establishing a connection before sending data is not necessary. It uses self-contained messages that:

  • Include the full message
  • Do not require any response or acknowledgement
  • Has lower overhead because it has no connection and no setup requirements.
  • Has no built-in reliability features, and therefore is best suited for use in highly reliable networks or when application itself can retransmit packets based on some other criteria (timeout, etc), or retransmit/acknowledgement is not required, e.g. Voice where retransmitting a missing or wrong part is useless.

 2-       Stateful vs. Stateless Protocols:

  • A stateless protocol is one that does not maintain a relationship between requests. Each request is un-related to any previous requests. (An example of a stateless protocol is HTTP. Neither the client nor the server system has an obligation to keep track of the state of the communication session. A stateless protocol does not support most reliability features; and data that were sent can be lost or delivered out-of-sequence. The main advantages are lower overhead and a degree of isolation between the client and the server. Connectionless protocols are typically stateless.
  •  
  • Stateful Protocols A stateful protocol is a protocol in which part of the data that is exchanged between the client and the server systems includes state information. Both systems keep track of the state of the communication session.

3-       Reliable vs Unreliable:

  • Reliable Protocols A reliable protocol requires that each transmission is acknowledged by the receiving host. The sender retransmits, if necessary.
  • Unreliable Protocols. An unreliable protocol does not require that each transmission is acknowledged by the receiving host.

TCP Window: TCP uses a data flow control concept called Window. It is the size of data that receiver is willing to accept in one TCP data frame or transaction. This window size keeps changing during the session.

 Based on the above classification, UDP and TCP looks like complete opposites:

  • UDP is connectionless, StateLess and Unreliable
  • TCP is connection-oriented, StateFul and Reliable

 

UDP & TCP were primarily designed for data. But popularity of carrying Voice over IP networks forced engineers to design a new transport layer protocol called SCTP (Stream Control Transmission Protocol).

Read How & Why SCTP and Issues with it Here.

0 0 votes
Article Rating

Related Post

0 0 votes
Article Rating
Subscribe
Notify of
guest
1 Comment
Inline Feedbacks
View all comments
Ratheeh
Ratheeh
12 years ago

simple and nice explanation Mr. Kashif