1. Introduction to UDP
The User Datagram Protocol (UDP) is one of the core members of the Internet Protocol (IP) suite. Unlike its counterpart TCP, UDP is a connectionless protocol. It does not establish a dedicated end-to-end connection before sending data.
Think of UDP as sending a postcard via regular mail. You write the address (Destination Port) and your return address (Source Port), drop it in the mailbox, and hope it arrives. There is no confirmation, no tracking number, and no guarantee of order. However, it is extremely fast and has very low latency overhead compared to sending a registered letter (TCP).
Key Characteristics:
- Connectionless: No handshaking (no 3-way handshake like TCP).
- Unreliable: No guarantee of delivery, ordering, or duplicate protection.
- Low Overhead: Header is only 8 bytes.
- Fast: Suitable for time-sensitive applications where speed is preferred over reliability.
2. UDP Datagram Structure
The UDP packet is called a Datagram. It consists of a header and a data payload.
UDP Header (8 Bytes Total)
- Source Port (16 bits): Identifies the sender's port.
- Destination Port (16 bits): Identifies the receiver's port.
- Length (16 bits): Specifies the length in bytes of the UDP header and UDP data. Minimum is 8 (header only).
- Checksum (16 bits): Used for error-checking of the header and data. Optional in IPv4, mandatory in IPv6.
Learning Objectives
- Understand the structure of a UDP datagram.
- Differentiate between TCP and UDP protocols.
- Analyze the concept of "unreliable" transport.
- Identify real-world applications of UDP.
- Calculate UDP length and simulate checksum logic.
Where is UDP used?
UDP is preferred when application data needs to arrive quickly (low latency) and can tolerate occasional loss of packets.
Laboratory Procedure
Study the Theory
Review the "Theory" section carefully. Understand the 8-byte UDP header format and the meaning of Source Port, Destination Port, Length, and Checksum.
Open the Simulation
Navigate to the "Simulation" tab. You will see a "Client" station and a "Server" station connected by a network link.
Construct a Datagram
- Enter a Source Port (e.g., 49152).
- Enter a Destination Port (e.g., 53 for DNS).
- Type a short message in the Payload field.
- Observe the automatic calculation of the Length field.
Transmit (Success Scenario)
Click "Send Packet". Observe the packet animation traveling to the server. Note the "Logs" to see the packet being accepted.
Simulate Network Failure
Click "Send with Error/Packet Loss". Observe how the packet may disappear or turn red. Note that UDP does not retry or notify the sender of the loss.
Documentation
Record your observations in your lab notebook. Specifically note the calculated length values for different payloads.
Datagram Builder
0 bytes
Calculation Logic
Length: 8 (Header) + Payload Bytes.
Checksum: Simulated hash of header + pseudo-header (IP Src/Dest).
192.168.1.5
8.8.8.8:53
Report Writing Guidelines
A technical report should be clear, concise, and replicable. Follow this structure to document your findings from the UDP Protocol experiment.
Title Page
- Experiment Title (e.g., "Study of UDP Protocol")
- Course Name & Code
- Student Name & Roll Number
- Date of Experiment
Aim & Objectives
State the aim clearly: "To understand the structure of a UDP datagram and observe its connectionless nature."
Theory
Explain the following concepts:
- What is UDP?
- UDP Header Format (draw the diagram).
- Comparison of UDP vs TCP (at least 5 points).
- Applications of UDP.
Experimental Work
Detail the procedure you followed in the simulation. Include screenshots of the simulation interface.
Observations & Calculations
Create a table with the following columns:
| S.No | Source Port | Dest Port | Payload (String) | Payload (Bytes) | Total Length | Status (Sent/Recv/Lost) |
|---|---|---|---|---|---|---|
| 1 | 49152 | 53 | DNS Query | 10 | 18 | Received |
| 2 | ... | ... | ... | ... | ... | Lost |
Conclusion & Precautions
- Conclusion: Summarize what you learned about UDP's unreliability and speed.
- Precautions: Mention checking port numbers carefully, ensuring payload size isn't excessively large for the simulation (though UDP supports up to 65,507 bytes), and observing the logs carefully.