Difference between TCP and UDP

Our system is designed efficiently to ensure that we can transfer data from one system to another. Ever wondered how this process works?

Our network has a reference model that specifies standards for communications protocols and also the functionalities of each layer.

Protocols are a set of standard rules for communication from one system to another. They achieve this with the help of port numbers. Few of such protocols are TCP, IP, UDP, DHCP, FTP and so on. Here we are going to talk about protocols used in the transport layer.

Transport Layer is the second layer of the TCP/IP model which is an end-to-end layer used to deliver messages to a host. It is called an end-to-end layer because it provides a point-to-point connection.

The most standard protocols used in the transport layer to amplify its functionalities are TCP (Transmission Control Protocol), and  UDP (User Datagram Protocol).

Difference between TCP and UDP

TCP vs UDP

To give a constructed view of the differences between the TCP and UDP protocols, the table is provided below.

TCP UDP
It is a connection-oriented protocol where a connection needs to be established before any packet is transmitted. It is a connectionless protocol where no connection needs to be established before sending the data between the sender and receiver.
TCP has a 20-60 bytes variable header length. UDP has an 8 bytes fixed-length header followed by a payload.
TCP guarantees delivery of packets to the receiver even in cases of faults. Thus it is a reliable connection. Some packets of data may be lost on the way of transmission. Thus it is an unreliable transmission.
To ensure reliable transmission, an acknowledgement is required to confirm the packet is received by the receiver. UDP does not require acknowledgement of transfer of data.
TCP does ordering and sequencing to ensure that packets sent from a client will be delivered to the server in the same order they were sent. UDP does not guarantee ordered delivery of data.
TCP is a stateful protocol as both sides keep information on whether or not the data has been received. UDP is a stateless protocol i.e. no information about the previous transmission is kept by the server.
TCP provides security for data with the help of checksums and error handling. There is negligible security provided for the data transferred.
Retransmission of data packets is possible in case of loss or corruption of data Retransmission of data packets is not possible.
TCP is slower than UDP as it has many more functions than the latter. UDP is faster and more efficient as it focuses on sending the data and not the accuracy of the process.
TCP provides congestion control mechanisms to ensure that the network can carry the load of the traffic. UDP does not provide congestion control mechanisms.
TCP uses a flow control mechanism which checks if a sender is not overwhelming a receiver by sending too many packets at once. UDP does not provide flow control. They arrive in a continuous stream and are dropped in case of congestion.
TCP does not support broadcasting. UDP supports Broadcasting.
TCP is heavy-weight. UDP is lightweight
TCP uses timers to time-out the transmission if the acknowledgement of data packet isn’t received by the client. No timers used in this protocol.
TCP is suited for applications where reliability and accuracy are more important than time. UDP is suited for application where time and efficiency is more important than accuracy.
Examples:
  • World wide web
  • Email
  • File transfer protocol
Examples:
  • Online games
  • Streaming videos
  • Live broadcasts

What is TCP?

TCP or Transmission Control Protocol is specifically designed over an unreliable connection to give a reliable end-end byte stream. It was designed in a way so as it could dynamically adapt to properties of internetwork and be robust in the situations of any kinds of failures.

It is a connection-oriented and reliable protocol. Connection-oriented means a preplanned route is established before any transmission of data and is also torn down when the connection between the host is to be deleted. At the transport layer, it also means dependency between the packets to be transmitted.

It is reliable as it uses SR and GBN protocols and incorporates checksum for error detection. In case of loss or corruption of packets, retransmission is also possible in this protocol. To ensure that the packets were transmitted acknowledgements (cumulative or selective) are used.

TCP provides a process to process communication using socket addresses. It provides full-duplex communication and a stream delivery service ie. the sending/receiving process to deliver/obtain data is via data as a stream of bytes. TCP numbers each byte of data transferred in the connection which happens to be independent in each direction. The starts with an arbitrarily generated number. A sequence number is assigned to the first byte of data in that segment and an acknowledgement to the next byte the receiver expects to receive.

What is UDP?

UDP or User Datagram Protocol is the simplest transport layer protocol used. It is used for establishing communications with low latency and high bandwidth. UDP is an unreliable and connectionless protocol.

Connectionless means different paths for different datagrams, and here, for the transport layer, it could mean independence between the packets. It is unreliable in a way that it does not generate an acknowledgement from the receiver and the sender does not wait either, before sending the next packet. This protocol focuses on faster communication than on reliable or assured systems. It is used in systems generating high amounts of bandwidth, where a few missing or corrupted packets would go unnoticed but a fast stable connection is assured. UDP provides half-duplex communication. It does not guarantee the ordered delivery of data to the receiver. This protocol is stateless which means any previous information of communication is not kept by the client-server and each process can be understood in isolation.

Author

Shriya Upasani
MIT World Peace University

References

1. https://www.privateinternetaccess.com/blog/tcp-vs-udp-understanding-the-difference/
2. https://www.geeksforgeeks.org/transport-layer-responsibilities/
3. https://www.geeksforgeeks.org/differences-between-tcp-and-udp/
4. https://www.tutorialspoint.com/data_communication_computer_network/user_datagram_protocol.htm

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.