Wednesday , 26 October 2016

What is differences between TCP and UDP

What-is-differences-between-TCP-and-UDPWhat is differences between TCP and UDP?

In my previous article i wrote about What is Transmission Control Protocol (TCP ) and The OSI Model’s Seven Layers Defined and Functions Explained. Today i am going to show you What is UDP ? and what is differences between TCP and UDP ?

What is User Datagram Protocol ( UDP) :-

User Datagram protocol is a protocol that is used at the Transport layer for connectionless , non-guaranteed communications. Unlike TCP, UDP does not setup a connection and does not use acknowledgments. UDP is given the Internet Protocol number of 17 and is defined in RFC 768 .

UDP uses 16-bit port numbers similar TCP. When a UDP packet is sent to a port that is not listening, it will respond with an ICMP port unreachable message to the packet sender.


Common network applications that use UDP include Domain Name System (DNS) , Streaming Media Applications , Voice over IP , Trival File Transfer Protocol ( TFTP) and online Games .

UDP Header Format :-


The UDP header consists of four 16-bit fields ( 4 * 16), which makes a total of 8-bytes in total length. The UDP header comes immediately after the IP header. Th details of individual fields are as follows :-

Source Port :- A 16-bit field whose values can range from 0 to 65,535 specifying the source port.

Destination Port :- A 16-bit field whose values can range from 0 to 65,535 specifying the destination port.

Length :- A 16-bit field whose values can range from 0 to 65,535. it is the length of the UDP header and the UDP data in bytes. The minimum value for this field is 8 bytes.

UDP Checksum :- A 16-bit field whose values can range from 0 to 65,535. The UDP checksum covers the UDP header and the UDP data. With UDP the checksum is optional, while the TCP it is mandatory.

 Differences between TCP and UDP :-

Sequenced Unsequenced
Reliable Unreliable
Connection-oriented Connectionless
Virtual Circuit Low Overhead
Acknowledgments No Acknowledgments
Windowing flow control No Windowing of flow control

Brief Explanation of Differences between TCP and UDP :-

Attributes TCP UDP
Acronym for Transmission Control Protocol User Datagram Protocol or Universal Datagram Protocol
Function As a message makes its way across the internet from one computer to another. This is connection based. UDP is also a protocol used in message transport or transfer. This is not connection based which means that one program can send a load of packets to another and that would be the end of the relationship.
Usage TCP is used in case of non-time critical applications. UDP is used for games or applications that require fast transmission of data. UDP’s stateless nature is also useful for servers that answer small queries from huge numbers of clients.
Examples HTTP, HTTPs, FTP, SMTP Telnet etc… DNS, DHCP, TFTP, SNMP, RIP, VOIP etc…
Ordering of data packets TCP rearranges data packets in the order specified. UDP has no inherent order as all packets are independent of each other. If ordering is required, it has to be managed by the application layer.
Speed of transfer The speed for TCP is slower than UDP. UDP is faster because there is no error-checking for packets.
Reliability There is absolute guarantee that the data transferred remains intact and arrives in the same order in which it was sent. There is no guarantee that the messages or packets sent would reach at all.
Header Size TCP header size is 20 bytes UDP Header size is 8 bytes.
Common Header Fields Source port, Destination port, Check Sum Source port, Destination port, Check Sum
Streaming of data Data is read as a byte stream, no distinguishing indications are transmitted to signal message (segment) boundaries. Packets are sent individually and are checked for integrity only if they arrive. Packets have definite boundaries which are honored upon receipt, meaning a read operation at the receiver socket will yield an entire message as it was originally sent.
Weight TCP requires three packets to set up a socket connection, before any user data can be sent. TCP handles reliability and congestion control. UDP is lightweight. There is no ordering of messages, no tracking connections, etc. It is a small transport layer designed on top of IP.
Data Flow Control TCP does Flow Control. TCP requires three packets to set up a socket connection, before any user data can be sent. TCP handles reliability and congestion control. UDP does not have an option for flow control
Error Checking TCP does error checking UDP does error checking, but no recovery options.
Fields 1. Sequence Number, 2. AcK number, 3. Data offset, 4. Reserved, 5. Control bit, 6. Window, 7. Urgent Pointer 8. Options, 9. Padding, 10. Check Sum, 11. Source port, 12. Destination port 1. Length, 2. Source port, 3. Destination port, 4. Check Sum
Acknowledgement Acknowledgement segments No Acknowledgment

Source for brief Explanation :-

Popular Protocols that are  supporting both TCP and UDP :-

DNS :-  DNS uses TCP for Zone excahnges between server and UDP when a clients is trying to resolve a hostname to an IP-address.

 LDAP :- LDAP always uses TCP – this is true and why not UDP because a secure connection is established between client and server to send the data and this can be done only using TCP not UDP. UDP is only used when finding a domain controller (Kerberos) for authentication. For example, a domain client finding a domain controller using DNS.

List of TCP and UDP port numbers

Hope you like my post.What is differences between TCP and UDP. please Share with others.

Use Facebook to Comment on this Post

About Syed Balal Rumy

A 27 year Tech Geek and a blogger from India ( Bihar ) , live in New Delhi. I am MCITP , CEHv8 , CCNA , CCNA Security , CCNP Security , Security + and CCSA certified. Loves to write tech articles based on my real experiences.

Powered by