TCP & UDP: What are the Differences & similarities?

TCP & UDP: What are the Differences & similarities?

Some of you may have seen a port-forwarding feature on your home or office router by the settings to pick up a protocol, TCP or UDP; these are both layer 4 (Transport Layer) protocols.

Both protocols are used in order to transfer data over the internet or a local networking environment. As they belong to the same layer they have similarities and differences.

 

66

 

How does the TCP work?

When you visit a website, your computer sends TCP packets to the website server address which is then requested to send the webpage back to your computer. The website server replies back with TCP packets, where a browser is put together in order to appear. Once you click a button, the web browser then sends back a TCP request for information.

 

TCP guarantees the packets will be received in the order that they were received by numbering them. The receiver sends messages back to the sender saying it received the messages; if the sender doesn’t get a response, it will resend the packets to ensure the recipient received them. Packets are also checked systematically for errors. TCP is extremely reliable, the packets that are sent with the TCP are tracked to ensure no data is lost or corrupted in transit. This is why file downloads don’t become corrupted even if the networks is interrupted. Of course, if the recipient is completely offline, the computer will give up and an error message will be seen informing the user that their computer cannot establish a connection with the other computer.

 

67

 

How does UDP Work?

UDP (User Datagram Protocol) is the same concept as a packet of information. The UDP protocol works similarly to a TCP, but without the error checking.

When you use the UDP protocol, the packets are sent only to the recipient, and the sender doesn’t wait for any response back from the recipient, and you may be left wondering if the recipient lost some packets, right? Well if you watch online movies, to lose a few frames wouldn’t be an issue as perhaps you will not see any difference. Imagine the UDP like a machine gun, it shoots bullets in a continuous stream without stopping.

Let’s look at the differences and the similarities:

 

TCP UDP
Acronym for Transmission Control Protocol. User Datagram Protocol or Universal Datagram Protocol.
Connection TCP is a connection-oriented protocol. UDP is a connectionless 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 suited for applications that require high reliability, and transmission time is relatively less critical. UDP is suitable for applications that need fast, efficient transmission, such as games. UDP’s stateless nature is also useful for servers that answer small queries from huge numbers of clients.
Use by other protocols HTTP, HTTPs, FTP, SMTP, Telnet. DNS, DHCP, TFTP, SNMP, RIP, VOIP.
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 error recovery is not attempted. It is a “best effort” protocol.
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 honoured upon receipt, meaning a read operation at the receiver socket will yield an entire message as it was originally sent.
Weight TCP is heavy-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 and error recovery. Erroneous packets are retransmitted from the source to the destination. UDP does error checking but simply discards erroneous packets. Error recovery is not attempted.
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.
Handshake SYN, SYN-ACK, ACK. No handshake (connectionless protocol).

 

 

Leave a Reply