Difference Between TCP and UDP Protocols | Brief with Real-Time Examples

TCP vs UDP: Differences Between TCP & UDP Protocols

what is the difference between TCP and UDP

The Transport Layer is responsible for data transfer and ensures reliable and error-free delivery to the destination. The Transport Layer is the Host-to-Host layer in the Department of Defense OSI Model.

There are two categories of the Transport Layer:

Connection-Oriented Protocol (TCP)

This means that when data is transferred from source to destination, a connection is established before data is sent, based on agreed-upon parameters.

Connectionless Protocol (UDP)

This means that when data is transferred from source to destination, there is no need for agreed-upon parameters to establish the connection. The data is sent directly to the destination.

Connection-oriented protocols provide several important services:

Connections are established, maintained, and terminated between two devices.

Data is segmented into smaller chunks, and sequence numbers are assigned to verify its order upon arrival.

When data is sent to the destination, an acknowledgment is sent to confirm its delivery. If data is lost during transmission, it will be retransmitted.

Data transfer is regulated to ensure smooth transmission and prevent congestion.

Port Numbers and Sockets

TCP and UDP provide mechanisms for running data on the same host by differentiating port numbers. When a host receives a segment, the port number informs the transport layer which higher layer application should handle the packet. The port number range is from 0 to 65535 for both TCP and UDP.

Socket

An IP address and port number combination is called a socket, which differentiates hosts and services. For example, in 192.168.60.15:443, 192.168.60.15 is the IP address, and 443 is the port number. The range from 0-1023 is reserved for widely used services known as well-known ports.

Below is the table where you can see the port number, Protocol, and the Application

Port NumberTransport ProtocolsApplications
20,21TCPFTP
22TCPSSH
23TCPTelnet
25TCPSMTP
53UDP or TCPDNS
80TCPHTTP
110TCPPOP3
443TCPSSL
666TCPDoom

What is Network Topology? Types and Diagrams Explained

What is Transmission Control Protocol (TCP)

The Transmission Control Protocol (TCP) is a connection-oriented protocol responsible for reliable delivery from source to destination. In the early days, TCP and IP worked together to make its core function, but it was inflexible. Additionally, TCP works on the Transport Layer, and IP works on the Network Layer. This separation is in version 4 of TCP, defined in RFC 793.

Let’s take one example of the connection-oriented protocol.

TCP is a three-way handshake connection between two hosts.

  • Host A sent a SYN message to Host B to make the connection
  • Host B sent an ACK message to Host A, and SYN+ACK becomes a single message forwarded to Host A
  • Host A completes the three-way handshake by sending ACK to Host B SYN.

Real-Time Examples
Whatsapp, Instagram, Google Chat,iMessage, FTP, Telnet

The TCP Header

Total size of the TCP is 20 Bytes (160 bits) along with 12 fields

FieldLengthDescription
Source Port16-BitsSource TCP Port
Destination Port16-BitsDestination TCP Port
Sequence Number32-BitsSequence Number
ACK Number32-BitsAcknowledgement Number
Data Offset4-BitsShows the begin of TCP Segment
Reserved6-BitsAlways set to 0
Control Bits6-BitsURG,ACK,PSH,RST,SYN and FIN Flags
Window16-BitsUsed for flow control
Checksum16-BitsUsed for Error Checking
OptionsVariable 
PaddingVariableTo ensure the TCP Header end with 32-Bit

What is User Datagram Protocol (UDP)

ser Datagram Protocol is a connectionless protocol on the Transport Layer that is defined in RFC 768. Further, In UDP, there is no mechanism for a three-way handshake, no flow control, no acknowledgment, no sequence number. It is an unreliable protocol; it just forwards the packet and then takes no action on it.

Real-Time Examples
Online Games, Media Streaming, Voice over IP (VoIP)

The UDP Header

FieldLengthDescription
Source Port16-bitsSource UDP Port
Destination Port16-bitsDestination Port
Length16-bitsSize of the Header and data
Checksum16-bitsUsed for Error Checking

Key Difference Between TCP and UDP Protocol

TCPUDP
Also, Perform CRCConnectionless
Guarantee DeliveryNo Guarantee
Send AcknowledgmentNo ACK
Reliable but slowUnreliable but fast
Segment and sequenceNo segment and sequence
Resend dropped packetsNot resend
Provide Flow ControlNo
Perform CRC on dataAlso Perform CRC
Used Port NumberAlso Used Port Numbers

This Post Has One Comment

Leave a Reply