Skip to content

TCP and UDP Protocols

TCP (Transmission Control Protocol) and UDP (User Datagram Protocol) are the two primary transport layer protocols used in network communication. They operate at Layer 4 of the OSI model and determine how data is transmitted between devices.

TCP is a connection-oriented protocol that ensures reliable, ordered delivery of data. It establishes a connection before transmitting data and verifies that all packets arrive successfully.

  • Connection-oriented: Establishes connection via three-way handshake
  • Reliable delivery: Guaranteed data delivery with error checking
  • Ordered delivery: Packets arrive in the order sent
  • Flow control: Manages data transmission rate
  • Slower: Higher overhead due to reliability features
  • Acknowledgment: Receiver acknowledges receipt of data
PortServiceDescription
20FTP-DATAFile Transfer Protocol (data)
21FTPFile Transfer Protocol (control)
22SSHSecure Shell
23TelnetRemote login (unencrypted)
25SMTPSimple Mail Transfer Protocol
53DNSDomain Name System
80HTTPHyperText Transfer Protocol
110POP3Post Office Protocol 3
143IMAPInternet Message Access Protocol
443HTTPSHTTP Secure (SSL/TLS)
445SMBServer Message Block
3306MySQLMySQL Database
3389RDPRemote Desktop Protocol
5432PostgreSQLPostgreSQL Database
8080HTTP-ALTHTTP Alternative

UDP is a connectionless protocol that provides fast, unreliable delivery of data. It does not establish a connection or verify delivery, making it suitable for applications where speed is prioritized over accuracy.

  • Connectionless: No connection establishment required
  • Unreliable delivery: No guarantee packets arrive
  • Unordered delivery: Packets may arrive out of sequence
  • No flow control: Sends data at application’s pace
  • Faster: Lower overhead due to minimal features
  • No acknowledgment: Receiver does not confirm receipt
PortServiceDescription
53DNSDomain Name System queries
67DHCPDynamic Host Configuration Protocol (server)
68DHCPDynamic Host Configuration Protocol (client)
123NTPNetwork Time Protocol
161SNMPSimple Network Management Protocol
162SNMP-TRAPSNMP Traps
389LDAPLightweight Directory Access Protocol
500ISAKMPInternet Key Exchange (IPSec)
514SyslogSystem Logging Protocol
1900SSDPSimple Service Discovery Protocol
5353mDNSMulticast DNS
5355LLMNRLink-Local Multicast Name Resolution
FeatureTCPUDP
Connection TypeConnection-orientedConnectionless
ReliabilityReliableUnreliable
OrderingOrderedUnordered
SpeedSlowerFaster
Error CheckingYesYes (checksum only)
Flow ControlYesNo
Use CasesEmail, Web, FTP, SSHDNS, VoIP, Gaming, Streaming
Header Size20-60 bytes8 bytes

Use TCP when:

  • Data integrity is critical
  • You need ordered delivery
  • Connection management is important
  • Examples: Email, file transfers, web browsing

Use UDP when:

  • Speed is more important than reliability
  • Real-time communication is needed
  • Loss of some packets is acceptable
  • Examples: Video streaming, online gaming, VoIP