Networks Training

  • About
  • My Books
  • SUGGESTED TRAINING
  • HOME
  • Cisco Networking
    • Cisco General
    • Cisco IOS
    • Cisco VPN
    • Cisco Wireless
  • Cisco ASA
    • Cisco ASA General
    • Cisco ASA Firewall Configuration
  • Certifications Training
    • CCNA Training
    • Cisco Certifications
    • I.T Training
  • General
    • General Networking
    • IP Telephony
    • Network Security
    • Product Reviews
    • Software
  • Cisco Routers
  • Cisco Switches
You are here: Home / General Networking / Differences Between TCP and UDP in IP Communication Networks

Differences Between TCP and UDP in IP Communication Networks

Written By Harris Andrea

TCP (Transmission Control Protocol) and UDP (User Datagram Protocol) are both Layer 4 transmission protocols in the OSI model. However, these two protocols are quite different. From a high level view you could say that TCP is reliable and UDP is unreliable. Why then would we use UDP?

comparison and differences between tcp and udp

Table of Contents

  • UDP Characteristics
  • TCP Characteristics
  • Quick Comparison Table
  • TCP 3-way handshake vs UDP Connectionless Communication
  • TCP Vs UDP Headers
    • TCP Header
    • UDP Header
  • Example of Protocols using TCP
  • Example of Protocols using UDP
  • Closing Remarks
    • Related Posts

UDP Characteristics

Due to UDP being able to tolerate loss, this provides for low latency. This is extremely useful for video streaming, live audio, and other applications requiring live data.

UDP is often referred to as a connectionless protocol. Unlike TCP, it does not require a session to be opened prior to, or during, the transmission of data.

This will often be called “best effort” transmission. Two network end-points that communicate via UDP start sending packets between them without first arranging any connection details.

TCP Characteristics

For things such as the transferring of files, downloading of webpages (internet browsing), sending/receiving email messages, connecting remotely to other machines etc, we use TCP.

This is because TCP establishes a connection before and during the transmission of data which prevents packet loss. The result of this may be a bit slower than UDP, but it also means all data will arrive at the destination reliably.

So why wouldn’t TCP work for video? Wouldn’t it be a good thing to have lossless video? The answer to this is that yes in theory that would be a good thing, but in reality it would not work very well.

TCP relies on a handshake process, windowing, and verification to effectively send its data without loss. The small delays this would cause are enough for video quality to suffer.

Quick Comparison Table

TCP UDP
Connection oriented Connectionless
Reliable Unreliable
Slower Faster
Higher header overhead Lower header overhead
Extensive error checking mechanisms Very basic error checking
Sequencing of data packets No sequencing of data packets
Re-transmission of lost packets No re-transmission
MORE READING:  What is Asymmetric Routing - Causes and Problems in Networks

TCP 3-way handshake vs UDP Connectionless Communication

TCP relies on a 3-way handshake to establish a connection with the destination before sending data.

This process consists of three basic steps:

  • First, the sender sends a SYN (Synchronize Sequence Number).
  • Next, the receiver replies to the SYN with a SYNACK. This includes an ACK signaling that the SYN was received and the SYN tells the sender which sequence number it expects to begin the transfer with.
  • Finally one last ACK is sent to the receiver letting it know the SYNACK was received properly. At this point a connection is established and data transfer may proceed.

Compare the three-way handshake process with that of UDP. There is no connection established with UDP. It can take different paths outbound vs. inbound. It can have small amounts of loss and the sender does not care whether the receiver gets all its information.

This is the very reason that there is less information in the header resulting in less bandwidth overhead and faster speeds.

TCP Vs UDP Headers

TCP Header

header of a TCP packet

UDP Header

UDP header

You may be wondering how one protocol can have more bandwidth overhead than the other. If the data being transmitted is the same amount then surely there wouldn’t be a difference right?

You would be wrong and the reason being is that the headers are different from each other with TCP having a much larger packet header as shown from the diagrams above.

TCP and UDP require that they encapsulate the data packets they are sending with their own headers as a way to tell the information how it is to be transmitted.

Both TCP and UDP have some commonalities in their packet headers. They both have source and destination ports as well as checksums to look at whether any data was lost in transmission.

MORE READING:  Routing Protocols Overview

What is more interesting are the differences. The only other thing UDP has is a “Length” field telling the recipient how much data is in the packet so it knows how long to wait for the information. TCP however, has many more fields.

TCP has fields for SYNs and ACKs which we have already discussed. It also has a section of the header reserved for control flags such as resetting the TCP connection when it realizes it is transmitting too fast.

Also included is the urgent pointer field which is usually ignored, but in combination with one of the control flags, it can be used to mark a message as requiring priority processing.

Perhaps most importantly is the windowing field. This field says how much data may be transferred before an ACK is required. Too small a data field leads to unnecessary slowness. Too large a field and there could be data loss.

Windowing allow the packets to grow in size until a limit is reached for loss. Perhaps you have noticed that downloads always begin slowly and seem to speed up after a while.

Example of Protocols using TCP

  • HTTP / HTTPs (ports 80, 443)
  • SSH (port 22)
  • FTP (port 21)
  • Telnet (port 23)
  • Email SMTP (port 25)
  • Remote Desktop Protocol – RDP (port 3389)

Example of Protocols using UDP

  • DNS (port 53)
  • Trivial File Transfer Protocol – TFTP (port 69)
  • Network Time Protocol – NTP (port 123)
  • Real Time Protocol (random UDP ports)

Closing Remarks

In conclusion, although TCP and UDP both ride over IP, they transmit very differently. TCP is slower, yet more reliable which is great for communication that cannot tolerate loss.

UDP on the other hand is much faster, has less bandwidth overhead, and can tolerate more loss. Due to this it is not a good solution for files that need to arrive intact. One is not better than the other, but they are definitely better at different things.

Related Posts

  • Comparison of Fiber Optic vs Copper Ethernet Cables in Networking
  • Understanding IP Prefix Lists in TCP/IP Networks (With Cisco Examples)
  • The Purpose of Routing Protocols in TCP/IP Networking
  • What is a Wildcard Mask – All About Wildcard Masks Used in Networking
  • Differences Between Routing, Forwarding, Switching in Networks

Filed Under: General Networking

Download Free Cisco Commands Cheat Sheets

Enter your Email below to Download our Free Cisco Commands Cheat Sheets for Routers, Switches and ASA Firewalls.

We use Elastic Email as our marketing automation service. By submitting this form, you agree that the information you provide will be transferred to Elastic Email for processing in accordance with their Terms of Use and Privacy Policy. Also, you allow me to send you informational and marketing emails from time-to-time.

About Harris Andrea

Harris Andrea is an Engineer with more than two decades of professional experience in the fields of TCP/IP Networks, Information Security and I.T. Over the years he has acquired several professional certifications such as CCNA, CCNP, CEH, ECSA etc.

He is a self-published author of two books ("Cisco ASA Firewall Fundamentals" and "Cisco VPN Configuration Guide") which are available at Amazon and on this website as well.

Leave a Reply

Your email address will not be published. Required fields are marked *

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

Search this site

About Networks Training

We Provide Technical Tutorials and Configuration Examples about TCP/IP Networks with focus on Cisco Products and Technologies. This blog entails my own thoughts and ideas, which may not represent the thoughts of Cisco Systems Inc. This blog is NOT affiliated or endorsed by Cisco Systems Inc. All product names, logos and artwork are copyrights/trademarks of their respective owners.

Amazon Disclosure

As an Amazon Associate I earn from qualifying purchases.
Amazon and the Amazon logo are trademarks of Amazon.com, Inc. or its affiliates.

Search

BLOGROLL

Tech21Century
Firewall.cx

Copyright © 2023 | Privacy Policy | Terms and Conditions | Hire Me | Contact | Amazon Disclaimer | Delivery Policy

79 shares