The User Datagram Protocol (UDP) is a transport layer protocol that is
connection-less. This means that it does not establish a persistent connection before sending data. Unlike TCP, UDP is not reliable and does not guarantee the ordering of packets. This makes it a faster protocol than TCP, but it is also less robust.

Key Characteristics
- Connection-less: There is no handshake or connection setup before data is sent.
- Packet Boundary: UDP maintains packet boundaries, unlike the stream-based approach of TCP.
- Unreliable and Unordered: If an application needs to ensure packets arrive in a specific order or that all packets are received, it must handle these functions itself.
- Speed: Due to its simplicity and lack of overhead, UDP is faster than TCP.
- Broadcast Support: UDP can be used for broadcasting, which is not supported by TCP.
UDP Applications
According to the slides, UDP is used in applications where speed is more critical than reliability, such as:
- DNS Protocol
- Video/Audio Streaming
- Skype and Zoom
- Real-time applications
- VPN Tunnels (OpenVPN)
UDP Client Program:
#!/usr/bin/python3
import socket
IP = “10.0.0.2.7”
PORT = 9090
data = b’Hello, World!’
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.sendto(data, (IP, PORT))
UDP Server Program:
#!/usr/bin/python3
import socket
IP = “0.0.0.0”
PORT = 9090
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.bind((IP, PORT))
while True:
data, (ip, port) = sock.recvfrom(1024)
print(“Sender: {} and Port: {}”.format(ip, port))
print(“Received message: {}”.format(data))
Recent Comments