UDP Basics ================================ .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **What is UDP?** UDP stands for User Datagram Protocol. It’s a communication protocol used for fast, connectionless data transmission between devices on a network. Unlike TCP, UDP does not guarantee delivery, order, or error checking — it simply sends packets and doesn’t wait for acknowledgments. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **Why is UDP useful?** UDP is useful when speed is more important than reliability. It’s ideal for applications where: * Occasional data loss is acceptable. * Real-time performance is critical. * Overhead from connection setup and error correction is undesirable. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **How it works?** * No connection setup – The sender just starts sending packets to the receiver. * Packets are sent – Each packet (called a datagram) is sent independently. * No acknowledgments – The sender doesn’t wait to see if the packet was received. * Receiver processes data – The receiver handles whatever packets it gets, in whatever order they arrive. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **Where is UDP used?** * Video streaming – Like live broadcasts where speed matters more than perfect quality. * Online gaming – Fast-paced games use UDP to reduce lag. * Voice over IP (VoIP) – Real-time voice communication prefers speed over reliability. * DNS lookups – DNS queries are small and fast, making UDP ideal. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **Why OSI Layer: Transport Layer (Layer 4)?** * It handles end-to-end communication between devices. * It provides port numbers to distinguish different services on the same device. * It enables multiplexing of data streams, even though it doesn’t manage reliability or ordering like TCP. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **What are the key features?** * Connectionless Protocol. * Unreliable Delivery. * No Ordering. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **How does a server know where to reply in UDP?** Each incoming UDP datagram includes: * Source IP address. * Source port number. The server uses these to send a reply. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **What is a datagram?** A datagram is a self-contained packet sent via UDP that includes both header and data. Each datagram is independent. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **Why is UDP used if it’s unreliable?** Because it's: * Fast and low-latency. * Requires less overhead. * Suitable for real-time or loss-tolerant applications. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **What are some applications that use UDP?** * DNS (Domain Name System). * VoIP (Voice over IP). * Video Streaming. * Online Gaming. * TFTP (Trivial File Transfer Protocol). * DHCP (Dynamic Host Configuration Protocol). * SNMP (Simple Network Management Protocol). * NTP (Network Time Protocol). .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **What is the working flow of UDP?** No Connection Needed: * UDP is connectionless — no handshake before sending data. * Sender just sends data directly. Data is Packed into Datagrams: * Each piece of data is packed into a UDP datagram. * Datagrams are independent (no sequence tracking). Datagram is Sent to Destination: * The sender sends the datagram to the receiver’s IP and port. * No guarantee of delivery. No Acknowledgment: * Receiver may or may not respond. * UDP does not expect or send ACKs. No Order or Reliability: * Packets may arrive out of order, or not at all. * It’s up to the application to handle errors, duplicates, or missing data. Receiver Gets Datagram: * If the datagram arrives, the receiver processes it immediately. * If it’s lost, UDP does nothing. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **Is UDP suitable for real-time applications?** Yes — UDP is ideal where speed matters more than reliability, like: * Online gaming. * Video conferencing. * Voice calls. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **Is UDP Windows specific?** * No, UDP is not Windows-specific. * UDP is supported across all major operating systems, including Windows, Linux, macOS, and others. * It is a widely-used transport protocol for applications that prioritize speed over reliability. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **Is UDP Linux specific?** * No, UDP is not Linux-specific. * UDP is available on all major operating systems, including Linux, Windows, macOS, and others. * It is used for time-sensitive applications that do not require guaranteed delivery. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **Which Transport Protocol is used by UDP?** * UDP (User Datagram Protocol) is itself a transport layer protocol. * It is connectionless, meaning it does not establish a connection before sending data, and it does not guarantee reliable delivery of packets. * UDP is ideal for applications requiring fast data transmission where occasional data loss is acceptable. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **Which Port is used by UDP?** * UDP does not have a fixed port by itself. * However, applications using UDP select specific port numbers for communication (e.g., DNS uses port 53, SNMP uses port 161). * Port numbers are defined by the application protocol being used over UDP. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **Is UDP using Client-server model?** * Yes, UDP can be used in a client-server model. * The client sends datagrams to the server, and the server responds. * Unlike TCP, there is no connection establishment, and the server does not send an acknowledgment of the received packets. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow Topics in this section, * :ref:`Learnings in this section ` * :ref:`Terminology ` * :ref:`Version Info ` * :ref:`UDP Version&RFC Details ` * :ref:`UDP Basic Setup on Ubuntu using IPv4 ` * :ref:`UDP Basic Setup on Ubuntu using IPv6 ` * :ref:`UDP Protocol Packet Details ` * :ref:`UDP Usecases ` * :ref:`UDP Basic Features ` * :ref:`UDP Core Protocols ` * :ref:`Reference links ` .. _UDP_step1: .. tab-set:: .. tab-item:: Learnings in this section * In this section, you are going to learn .. _UDP_step2: .. tab-set:: .. tab-item:: Terminology * Terminology .. _UDP_step3: .. tab-set:: .. tab-item:: Version Info * Version Info .. _UDP_step5: .. tab-set:: .. tab-item:: UDP Version&RFC Details .. csv-table:: :file: ./UDP_RFC.csv :widths: 10,10,10,30,40 :header-rows: 1 .. _UDP_step24: .. tab-set:: .. tab-item:: UDP Basic Setup on Ubuntu using IPv4 * setup .. _UDP_step25: .. tab-set:: .. tab-item:: UDP Basic Setup on Ubuntu using IPv6 * setup .. _UDP_step6: .. tab-set:: .. tab-item:: UDP Protocol Packet Details **UDP UDP Packet** .. csv-table:: :file: ./UDP_Packet.csv :widths: 10,20,30,40 :header-rows: 1 .. _UDP_step7: .. tab-set:: .. tab-item:: UDP Usecases .. csv-table:: :file: ./UDP_Use_Cases.csv :widths: 10,20,30 :header-rows: 1 .. _UDP_step8: .. tab-set:: .. tab-item:: UDP Basic Features .. csv-table:: :file: ./UDP_Features.csv :widths: 10,10,30 :header-rows: 1 .. _UDP_step20: .. tab-set:: .. tab-item:: UDP Core Protocols .. csv-table:: :file: ./UDP_Core_Protocols.csv :widths: 10,10,10 :header-rows: 1 .. _UDP_step23: .. tab-set:: .. tab-item:: Reference links * Reference links