Virtual Laboratory: User Datagram Protocol (UDP)

ECE 422-Data Communication & Computer Networks: Connectionless Transport Layer Services

Networking Transport Layer Undergraduate

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)

0-15 bits
Source Port
(2 Bytes)
16-31 bits
Dest. Port
(2 Bytes)
32-47 bits
Length
(2 Bytes)
48-63 bits
Checksum
(2 Bytes)
Header (8 Bytes) + Payload (Variable)
  • 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?

DNS VoIP Online Gaming Video Streaming DHCP NTP

UDP is preferred when application data needs to arrive quickly (low latency) and can tolerate occasional loss of packets.

Laboratory Procedure

1

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.

2

Open the Simulation

Navigate to the "Simulation" tab. You will see a "Client" station and a "Server" station connected by a network link.

3

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.
4

Transmit (Success Scenario)

Click "Send Packet". Observe the packet animation traveling to the server. Note the "Logs" to see the packet being accepted.

5

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.

6

Documentation

Record your observations in your lab notebook. Specifically note the calculated length values for different payloads.

Datagram Builder

Header + Payload

0 bytes

Calculation Logic

Length: 8 (Header) + Payload Bytes.

Checksum: Simulated hash of header + pseudo-header (IP Src/Dest).

Network Visualization
CLIENT
192.168.1.5
SERVER
8.8.8.8:53
Ready to transmit...
> System initialized. UDP Socket ready on port 49152.

Report Writing Guidelines

A technical report should be clear, concise, and replicable. Follow this structure to document your findings from the UDP Protocol experiment.

1

Title Page

  • Experiment Title (e.g., "Study of UDP Protocol")
  • Course Name & Code
  • Student Name & Roll Number
  • Date of Experiment
2

Aim & Objectives

State the aim clearly: "To understand the structure of a UDP datagram and observe its connectionless nature."

3

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.
4

Experimental Work

Detail the procedure you followed in the simulation. Include screenshots of the simulation interface.

5

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
6

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.