UDP
UDP
Two Transport Protocols are available for Applications to use on the Internet:
1. UDP
2. TCP
TCP uses a technique called ____________. It means that
three messages are exchanged between the sender and the
receiver to establish the connection.
• three-way handshaking
USER DATAGRAM PROTOCOL
WHAT IS UDP?
USER DATAGRAM PROTOCOL
The User Datagram Protocol, is an unreliable and
connections with, process to process communication
model and is part of the Transport Layer Protocol in
the OSI model for providing internet services.
Features of User Datagram Protocol
UDP is part of the transport layer of the OSI
moder, is an unreliable and based on the best –effort
delivery options for the data.
Unreliable way to send data
- No confirmation of delivery
- UDP does not guarantee data delivery, meaning
packets can be lost without notification to the
sender.
- There is no guarantee that the messages or
packets sent would reach at all
- Unlike TCP, UDP does not send
acknowledgements to confirm receipt of data.
Streaming Music
HOW UDP PROTOCOL WORKS
❑ UDP is a connectionless protocol. Unlike the TCP which first requires a connection to be
established using the three-way SYN, SYN-ACK, and ACK handshake before packets can be
transmitted, UDP does not require the establishment of any connection between the sending
and receiving machines. Once the receiving machine makes a request to the sending
machine, the sending machine will continuously send datagrams over without establishing
any connection.
https://youtu.be/7brFDwM64aQ?si=CiWv2UcM2txML-AT
UDP HEADER FORMAT
Header format for User Datagram Protocol
❑ Total Length – this value is used to specify the length of the UDP
packet including the UDP header.
❑ Checksum – this is a 16-bit field and is used as an optional
attribute, It is left to the application to check the accuracy of the
transmitted data and applied to the entire UDP packet (datagram)
UDP header :
UDP header is an 8-bytes fixed and simple header. The first 8 Bytes contains all necessary header
information and the remaining part consist of data. UDP port number fields are each 16 bits long,
therefore the range for port numbers defined from 0 to 65535; port number 0 is reserved. Port
numbers help to distinguish different user requests or processes.
Example
Source Port is 2 Byte long field used to identify the port number of
the source. The source port number is the first four hexadecimal
digits i.e. 06 32 if we convert hexadecimal to decimal we get. 1586
28 – 8 = 20 bytes.
EXAMPLE:
1. The following is the contents of a UDP header in hexadecimal format.
CB84000D001C001C
a. What is the source port number?
b. What is the destination port number?
c. What is the total length of the user datagram?
d. What is the length of the data?
SOLUTION:
1. The source port number is the first four hexadecimal digits CB84, which means that the source
port number is 52,100. CB84 = (12 × 16³) + (11 × 16²) + (8 × 16¹) + (4 × 16⁰) = 52100
2. The destination port number is the second four hexadecimal digits 000D, which means that the
destination port number is 13. (000D )₁₆ = (0 × 16³) + (0 × 16²) + (0 × 16¹) + (13 × 16⁰) = 13
3. The third four hexadecimal digits 001C define the length of the whole UDP packet as 28 bytes.
001C = (0 × 16³) + (0 × 16²) + (1 × 16¹) + (12 × 16⁰) = 28
4. The length of the data is the length of the whole packet minus the length of the header, or 28 − 8
= 20 bytes
ACTIVITY:
Given a UDP header in hexadecimal format, answer the following:
1. 0632 DCBA 25EA A1A1
2. 0632 000D 001C E217
3. 0045 DF00 0058 FE20
4. CB84 000D 001C 001C
5. 0045 DF00 0058 0000
a. Source port number?
b. Destination port number?
c. Length of user datagram?
d. Length of the data?
UDP: ERROR DETECTION
Error detection function
Sender: Receiver:
❑treat segment contents as ❑compute checksum of
sequence of 16-bit integers received segment, including
❑checksum: addition (1’s the checksum in packet itself
complement sum) of
segment contents ❑check if the resulting
(computed) checksum is 0
❑sender puts checksum
value into UDP checksum oNO - error detected
field oYES - no error detected
Checksum Example
❑Note: when adding numbers, a carryout from the most significant bit needs
to be added to the result
wraparound 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1
sum 1 1 0 1 1 1 0 1 1 1 0 1 1 1 1 0 0
checksum 1 0 1 0 0 0 1 0 0 0 1 0 0 0 0 1 1
Receiver
1 1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0
1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
wraparound 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1
sum 1 1 0 1 1 1 0 1 1 1 0 1 1 1 1 0 0
checksum 1 0 1 0 0 0 1 0 0 0 1 0 0 0 0 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1
Complement1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1
ACTIVITY:
1. UDP uses 1’s complement for their checksums. Suppose you have the
following 8-bit bytes: 01010011, 01010100, 01110100. What is the 1’s
complement of the sum of these 8-bit bytes?