UDP - Dleifnesor/NET-215 GitHub Wiki

UDP and Ports

Overview

User Datagram Protocol (UDP) is a transport layer protocol in the OSI model that provides a connectionless communication method between devices. Unlike TCP (Transmission Control Protocol), UDP does not guarantee delivery, ordering, or error correction, making it faster and more efficient for applications that require low latency.


How UDP Works

  • UDP sends packets, called datagrams, without establishing a connection.
  • It does not retransmit lost packets, which reduces overhead.
  • It relies on the application layer to handle potential data loss or ordering issues.
  • UDP is commonly used for applications that require speed over reliability, such as VoIP, online gaming, video streaming, and DNS queries.

UDP vs TCP Comparison Table

Feature UDP (User Datagram Protocol) TCP (Transmission Control Protocol)
Connection Connectionless Connection-oriented (3-way handshake)
Reliability Unreliable (no error checking or retransmission) Reliable (error checking, retransmission)
Ordering No ordering guarantee Ensures packet order
Speed Faster due to low overhead Slower due to reliability mechanisms
Error Checking Yes (basic checksum) Yes (checksum, acknowledgments)
Data Flow Control No Yes (uses congestion control)
Use Cases Streaming, VoIP, DNS, gaming Web browsing, file transfer, emails

Common UDP Ports

Port Protocol Description
53 DNS Domain Name System queries
67, 68 DHCP Dynamic Host Configuration Protocol
69 TFTP Trivial File Transfer Protocol
123 NTP Network Time Protocol
161, 162 SNMP Simple Network Management Protocol
500 IKE IPsec Key Exchange
1701 L2TP Layer 2 Tunneling Protocol
4500 IPsec NAT-T IPsec over NAT

Advantages of UDP

  • Low latency: No connection setup, making it ideal for real-time applications.
  • Efficient: Less overhead compared to TCP.
  • Broadcast and Multicast support: Suitable for services that send data to multiple clients.

Disadvantages of UDP

  • No reliability: Packets may be lost without notice.
  • No congestion control: Can lead to packet loss during high traffic.
  • Not ideal for data integrity-critical applications.

When to Use UDP?

  • Online gaming (e.g., FPS games, real-time multiplayer)
  • Streaming services (e.g., YouTube, Netflix, Twitch)
  • VoIP (Voice over IP) (e.g., Skype, Zoom, Discord calls)
  • DNS resolution (quick domain name lookups)
  • Broadcast & Multicast applications

Conclusion

UDP is an essential protocol for fast, low-latency communication where speed is prioritized over reliability. While it lacks built-in error recovery, its efficiency makes it the preferred choice for streaming, gaming, and real-time communications.

For applications needing data integrity and reliability, TCP remains the preferred choice.


Related Topics