UDP - User Datagram Protocol ================================ .. 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 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 Feature : Connectionless Protocol ` * :ref:`UDP Feature : Low Latency ` * :ref:`UDP Feature : No Acknowledgment ` * :ref:`UDP Feature : No Flow Control ` * :ref:`UDP Feature : No Congestion Control ` * :ref:`UDP Feature : Checksum For Error Detection ` * :ref:`UDP Feature : Supports Multicast And Broadcast ` * :ref:`UDP Feature : Lightweight Header ` * :ref:`UDP Feature : Port Numbers ` * :ref:`UDP Feature : Stateless Commuincation ` * :ref:`UDP Header ` * :ref:`UDP Core Protocols ` * :ref:`UDP Socket Level Options ` * :ref:`UDP Linux Settings ` * :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/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/UDP_Packet.csv :widths: 10,20,30,40 :header-rows: 1 .. _UDP_step7: .. tab-set:: .. tab-item:: UDP Usecases .. csv-table:: :file: ./UDP/UDP_Use_Cases.csv :widths: 10,20,30 :header-rows: 1 .. _UDP_step8: .. tab-set:: .. tab-item:: UDP Basic Features .. csv-table:: :file: ./UDP/UDP_Features.csv :widths: 10,10,30 :header-rows: 1 .. _UDP_step9: .. tab-set:: .. tab-item:: UDP Feature : Connectionless Protocol **Connectionless Protocol - Testcases** .. csv-table:: :file: ./UDP/UDP_Feature1_Connectionless_protocol_Test_Cases.csv :widths: 10,10,30,20 :header-rows: 1 .. _UDP_step10: .. tab-set:: .. tab-item:: UDP Feature : Low Latency **Low Latency - Testcases** .. csv-table:: :file: ./UDP/UDP_Feature2_Low_Latency_Test_Cases.csv :widths: 10,10,30,20 :header-rows: 1 .. _UDP_step11: .. tab-set:: .. tab-item:: UDP Feature : No Acknowledgment **No Acknowledgment - Testcases** .. csv-table:: :file: ./UDP/UDP_Feature3_No_Acknowledgment_Test_Cases.csv :widths: 10,10,30,20 :header-rows: 1 .. _UDP_step12: .. tab-set:: .. tab-item:: UDP Feature : No Flow Control **No Flow Control - Testcases** .. csv-table:: :file: ./UDP/UDP_Feature4_No_flow_control_Test_Cases.csv :widths: 10,10,30,20 :header-rows: 1 .. _UDP_step13: .. tab-set:: .. tab-item:: UDP Feature : No Congestion Control **No Congestion Control - Testcases** .. csv-table:: :file: ./UDP/UDP_Feature5_No_congestion_control_Test_Cases.csv :widths: 10,10,30,20 :header-rows: 1 .. _UDP_step14: .. tab-set:: .. tab-item:: UDP Feature : Checksum For Error Detection **Checksum For Error Detection - Testcases** .. csv-table:: :file: ./UDP/UDP_Feature6_Checksum_for_error_detection_Test_Cases.csv :widths: 10,10,30,20 :header-rows: 1 .. _UDP_step15: .. tab-set:: .. tab-item:: UDP Feature : Supports Multicast And Broadcast **Supports Multicast And Broadcast - Testcases** .. csv-table:: :file: ./UDP/UDP_Feature7_Supports_multicast_and_Broadcast_Test_Cases.csv :widths: 10,10,30,20 :header-rows: 1 .. _UDP_step16: .. tab-set:: .. tab-item:: UDP Feature : Lightweight Header **Lightweight Header - Testcases** .. csv-table:: :file: ./UDP/UDP_Feature8_Lightweight_header_Test_Cases.csv :widths: 10,10,30,20 :header-rows: 1 .. _UDP_step17: .. tab-set:: .. tab-item:: UDP Feature : Port Numbers **Port Numbers - Testcases** .. csv-table:: :file: ./UDP/UDP_Feature9_Port_Numbers_Test_Cases.csv :widths: 10,10,30,20 :header-rows: 1 .. _UDP_step18: .. tab-set:: .. tab-item:: UDP Feature : Stateless Communication **Stateless Communication - Testcases** .. csv-table:: :file: ./UDP/UDP_Feature9_Port_Numbers_Test_Cases.csv :widths: 10,10,30,20 :header-rows: 1 .. _UDP_step19: .. tab-set:: .. tab-item:: UDP Header .. csv-table:: :file: ./UDP/UDP_Header.csv :widths: 10,10,10,30,40 :header-rows: 1 .. _UDP_step20: .. tab-set:: .. tab-item:: UDP Core Protocols .. csv-table:: :file: ./UDP/UDP_Core_Protocols.csv :widths: 10,10,10 :header-rows: 1 .. _UDP_step21: .. tab-set:: .. tab-item:: UDP Socket Level Options .. csv-table:: :file: ./UDP/UDP_Socket_Level_Options.csv :widths: 10,10,10,30 :header-rows: 1 .. _UDP_step22: .. tab-set:: .. tab-item:: UDP Linux Settings .. csv-table:: :file: ./UDP/UDP_Linux_Settings.csv :widths: 10,10,10,30 :header-rows: 1 .. _UDP_step23: .. tab-set:: .. tab-item:: Reference links * Reference links