14 Difference Between TCP and UDP Protocol
TCP and UDP both are the transport layer protocol from 7 layer OSI model architecture. I am not going to describe here all these layers as it is not within the scope of difference between TCP and UDP protocol. You can read 7 Layers of OSI Model in Networking for more detail. I have explained it with layered architecture.
The Difference Between TCP and UDP Protocol:
So let’s begin with the topic.
#1 Acronym:
TCP acronym for Transmission Control Protocol. UDP is an acronym for User Datagram Protocol, some either call it as Universal Datagram Protocol.
#2 Connection Type:
TCP is connection oriented protocol. The connection is established by sending handshaking messages before sending actual data.
In the case of UDP, no connection is established. Rather it sends data with no more hustle.
#3 Reliability:
TCP is considered to be a most reliable connection. Both sender and client check the connection and trust before making data transmission. UDP is not reliable. It does not authorize and check the connection.
UDP provides an unreliable connection. It does not authorize peer and not even check the connection before sending the data.
#4 Speed of data transfer:
As there are initial handshaking and authorization before sending data, TCP is slower than UDP. One of the reasons for faster UDP is, it does not attempt any recovery on failure.
#5 Payload:
UDP carries less payload with messages. It’s obvious as it does not require any authentication and handshaking data. TCP need to send more data to assist reliable communication.
TCP need to send more data to assist reliable communication.
#6 Functionality on Server Side:
Where client sends data to the server, UDP server does not save any client data to identify client for next transmission. It treats every request as new even though getting the same request from the same client. There will be no more relationship between user and server once data transmission is over.
TCP saves client data on the server to identify the customer in case if the client sends data again. It maintains the session for each client request.
Role associated with TCP and UDP Protocol in OSI Layers:
#7 Data Packet ordering:
Before sending data over the network, packets can be fragmented. In TCP every data packet has a sequence number, which identifies the order of each fragmented packet.
In UDP, there is no provision to determine the order of UDP message packet. So after receiving all disordered packets, it is not possible to order them. In any case, if there is need ordering of packets, the only way is to handle by the application layer.
#8 Header for TCP:
TCP header size is 28 bytes. So total size of the packet will be 28 Bytes plus the size of the payload.
TCP header includes following 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
#9 Header for UDP:
UDP has a header of size 8 bytes only.
UDP header includes only four fields which are as follows.
1. Length, 2. Source port, 3. Destination port, 4. Check Sum
#10 Weight:
TCP is heavy weight protocol. It needs three packets for handshaking or to connect before sending data packets.
UDP is lightweight, and it does not require any packet to create a connection as its connectionless protocol.
#11 Acknowledge:
TCP sends an acknowledgment for every request from the receiver (vice-versa).
UDP does not send any acknowledges for any successful or failure data transmission.
#12 Data flow control:
TCP support data flow mechanism. It ensures data reliability and takes action if any glitches occur during congestion.
UDP does not have any data flow control mechanism associated with it.
Difference Between TCP and UDP Protocol for its Uses:
TCP and UDP both have their advantages depending on the circumstances it is going to use.
#13 Top Layer Protocol:
What are the Top layer protocols that use TCP?
- For web browsing, HTTP and HTTPS use TCP protocol.
- For server file management FTP uses TCP.
- Messaging protocol SMTP uses TCP.
- TCP transport layer protocol is also useful for connecting the server using Telnet or ssh.
What are the Top layer protocols that use UDP?
- DNS is domain name server portal to find the IP associated with the domain name. It used UDP as underline protocol.
- Dynamic host configuration portal DHCP use UDP.
- TFTP is trivial FTP protocol which less secure than FTP, uses UDP.
- Some other top layer protocol includes SNMP, RIP, VOIP.
#14 TCP and UDP Uses:
Where is TCP useful?
TCP is useful where you need reliability and authorisation. It is useful where security is a primary concern. It is useful when reliability is more important than transmission time.
Where to use UDP protocol?
UDP is useful when the network needs fast data transmission over reliability.
Conclusion:
These are all 14 points to put Difference Between TCP and UDP Protocol. All these points revolve around connection oriented and reliable TCP, and connectionless and unreliable UDP protocol.
Other differences you would like to read from Computer Network:
- Difference between IPv4 and IPv6 IP addresses
- 12 Advantages and Disadvantages of OSI model Layered Architecture
- Difference Between Subnetting and Supernetting
I tried to cover every aspect to Difference Between TCP and UDP Protocol. If you have any doubt, write below in the comment section.