Subscribe by Email


Monday, July 1, 2013

What is the difference between TCP and UDP?

TCP (transmission control protocol) and UDP (user datagram protocol) are two very important protocols. These two protocols are transportation protocol.  These two protocols are counted in the core protocols of the IP suite. 
These two protocols operate at the 4th layer i.e., the transport layer of the TCP/ IP model but the usage of the both the protocols is used very differently.

1. Reliability: 
- UDP is a connection-less protocol whereas TCP is a protocol that is connection  oriented. 
- Whenever a message is sent, it will not get delivered if there is a connection failure. 
- If during the delivery of the message the connection gets lost, the server will send a request to get the lost part. 
- During the transfer of a message, there is no corruption. 
- The reliability of the UDP is less and if a message is sent, there is no guarantee that it will get delivered, it may get lost on the way. 
- The message might get corrupted during transfer.

2. Ordered: 
- If at the same time two messages are sent along the same connection, one after the other, it is sure that the message which is the first in the line will get delivered there first. 
- The data is therefore delivered always in the same order. 
- You do not have to worry about the order of the arriving data. 
- In the case of UDP, the order of the arrival of data is not sure. 
- The second one can arrive there first before the first one. 

3. Heavyweight: 
- When the order of arrival of the low level parts of the transmission stream is wrong, the requests have to be sent again and again. 
- All the lost parts of the message have to be put together in a proper sequence. 
- So it takes some time for putting back the parts together. 
- On the other hand, UDP is lightweight.
- After sending the message, the user cannot think about tracking connections or ordering of the messages etc. 
- This indeed makes it lot quicker and therefore there is very less work for the network or the OS card for translating the data obtained from the data packets.

4. Streaming: 
- In TCP, the data is read in form of a stream.
- There is nothing that distinguishes one data from another. 
- Per read call there can be a number of packets. 
- In UDP each of the data packets is sent individually and if they arrive, they do so in whole form. 
- Here per read call, only one packet is sent.

5. Some examples of the TCP are FTP or file transfer protocol, World Wide Web (such as Apache TCP port 80), secure shell such as open SSH port 22 and so on. Examples of UDP are TFTP (trivial file transfer protocol), VoIP (voice over IP), IPTV, online multiplayer games, domain name system (such as DNS UDP port 53) etc.

6. Error-checking: 
- The TCP protocol offers extensive error checking mechanisms for the acknowledgement of the data, flow control and so on. 


In TCP, a connection is a must to be established in order to transfer data. Datagram mode is the mode in which the user data gram protocol operates. You can choose between the two protocols depending up on the requirements. If the guaranteed delivery of data is required, then the transmission control protocol must be chosen. The user data gram protocol comes only with the basic error checking mechanism. It checks the data by the means of the check sums. 


No comments:

Facebook activity