Lost Password

TCP vs UDP: What’s the Difference

Besides being mentioned as one of the topics on the CCNA Exam, Transmission Control Protocol and User Datagram Protocol are two network protocols that share some similarities; but, also share a majority of differences when it comes to communication and how they connect to a number of services. For this article, we’ll look into the differences between TCP vs UDP and how TCP/UDP work in a network.

What is TCP?

tcp diagram

TCP or Transmission Control Protocol is a connection-oriented protocol that must communicate between 2 hosts to establish a connection before sending data to the destination host. When a connection has been established with the destination host, the data exchange between the source and destination hosts can begin to take place.

TCP provides a reliable communication structure within a network all because the destination host must acknowledge a TCP segment…without acknowledging a TCP segment would force the same segment to be sent again before proceeding with the next segment to be sent over.

Besides the benefit of providing reliable communication, TCP provides sequencing which plays a role in putting sequence numbers in the TCP header to allow destination hosts to put segments in the correct order when the segments arrive to the destination even if the segments arrive out of order.

The final benefit TCP has over vs UDP is that it provides flow control where the destination host can communicate with the source host in increasing or decreasing the rate data is sent. This is primarily done in the window size field in the TCP header.

The window size field allows more data to be sent before an acknowledgment is required and the window can be dynamic to adjust how large the window size will become which can allow higher bandwidth networks to expand and run more efficiently.

How TCP Establishes Connections?

tcp 3 way handshake diagram

Not mentioned in the brief introduction of Transmission Control Protocol above, TCP establishes and terminates a connection by way of the Acknowledge (ACK), Synchronize (SYN), and the Finish (FIN) flags found in the TCP header.

For establishing connections, TCP uses a ‘3-way Handshake‘ connection method where the source host will send a TCP segment to the destination host with the SYN flag set and set the flag bit to 1.

Second, the destination host would reply by sending a TCP segment back to the source host with a SYN-ACK flags set and set both flag bits to 1.

Finally, the source host will send a TCP segment with the ACK bit set to the destination host and will set this flag bit to 1 while establishing the connection to complete the 3-way cycle.

How TCP Terminates Connections?

tcp 4 way handshake diagram

When a TCP connection is finished say between a client PC (source) and an authentication server (destination), the source host would initiate a ‘4-way Handshake‘ communication to first send a TCP segment to the destination host with the FIN flag set.

For steps 2 and 3, the destination will respond with an ACK flag set to the source and then the destination host will send a FIN flag set behind the ACK flag set to the source.

Finally, the source host sends an ACK flag set in response to the destination’s FIN flag, and the connection would then be terminated or dropped until the source wishes to re-establish the connection to the authentication server to access an application or service again.

Common Uses of TCP

Since TCP must maintain reliable communication between hosts, TCP would be found in simple but reliable tasks such as file transfer functions (this would describe FTP ports 20 & 21) such as uploading a resume from your computer to a job search engine like Indeed or vice-versa with downloading an instructional manual in PDF form from a manufacturer’s support site.

In other productive cases, TCP plays a major role in e-mail communications (this can describe SMTP TCP ports 25 or 587 and IMAP TCP ports 143 or 993) as far as sending/forwarding and receiving email in multiple directions whether it’s communication between one sender/one recipient (one mail server) or one sender/many recipients (multiple mail servers).

Lastly, TCP is used when a client connects to a website like my website TornadoTwistar.com and to this blog post found on the destination web server which is hosted by Bluehost to allow the communication (this would describe HTTP TCP ports 80 and 443).

What is UDP?

udp diagram

Onto the opposite of what Transmission Control Protocol can do, UDP or User Datagram Protocol is much different vs TCP as it is a “connectionless” type of protocol that does not wait to establish a connection with a destination host before sending data. Simply put, the data is just sent to the destination with no delays.

Since UDP is considered a ‘best-effort’ protocol, it is not considered a reliable protocol on the communication side since no acknowledgments flags are sent out when the segments are sent which means there is no way of knowing if a segment will get to the destination host or not.

If a segment does become lost, UDP has no fail-safe mechanism of retrieving the lost segment to re-transmit again to keep the communication going between hosts.

Sequencing is also not available within UDP since there is no sequence number field in the UDP header which indicates that even if the segments do arrive out of order to the destination host then the segments will not be place back in order…simply put there is no mechanism UDP uses to take time to put the segments back in order.

Lastly, UDP does not use any data flow controls vs TCP since there is no window sizing field in the UDP header.

Common Uses of UDP

UDP itself is much different than TCP for it’s performance factor which means that data must move in “real-time” without any delays.

A common example of UDP in action is found in video and voice sessions (applications like Zoom and Microsoft Teams) in participating in a video conference hosted by a hiring manager for job interviews or private meetings. UDP ports for Microsoft Teams range from 3478-3481 & 50000-50059 and Zoom UDP ports are 3478-3479 & 8801-8802.

A more sophisticated example of UDP usage is within Simple Network Management Protocol (UDP ports 161 & 162) to use real-time monitoring and management of connected devices found on a local area network from a centralized computer and using information gathered from an agent on the connected device to understand the devices response on the network. This could be managing and controlling a home surveillance system to a MIMO router

Finally, UDP is common right at home in online gaming specifically in the role of real-time audio and video where player movement (firing a weapon, reloading, melee attacks, etc.) and updates in-game (host changes, team scores, scorestreaks, etc.) should be near instant without much latency.

Share This Post

Related Posts


    Leave a Reply

    Thanks for submitting your comment!
    Seraphinite AcceleratorOptimized by Seraphinite Accelerator
    Turns on site high speed to be attractive for people and search engines.