0% found this document useful (0 votes)
12 views39 pages

UDP

The document provides an overview of the User Datagram Protocol (UDP), highlighting its characteristics as an unreliable, connectionless transport protocol that allows for faster data transmission without the need for connection establishment. It details the UDP header format, checksum for error detection, and compares UDP with TCP, emphasizing UDP's lightweight nature and its suitability for applications like multimedia streaming and online gaming. Examples and activities are included to illustrate how UDP functions and how to interpret UDP headers.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views39 pages

UDP

The document provides an overview of the User Datagram Protocol (UDP), highlighting its characteristics as an unreliable, connectionless transport protocol that allows for faster data transmission without the need for connection establishment. It details the UDP header format, checksum for error detection, and compares UDP with TCP, emphasizing UDP's lightweight nature and its suitability for applications like multimedia streaming and online gaming. Examples and activities are included to illustrate how UDP functions and how to interpret UDP headers.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 39

REVIEW

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.

Sends data more faster than TCP


- UDP is faster because there is no error-checking for packets.
Features of User Datagram Protocol
Connectionless Transmission
UDP protocol does not establish a virtual path for data
transmission, so each data datagram, uses a different path to
reach the destination side.

Not connection oriented


- UDP does not establish a connection before sending data, making it
faster but less reliable.
UDP EXAMPLES

Playing Online Games


Zoom/Teams

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

The UDP datagram, is composed of two parts, UDP


Header of size 8 bytes and the data that is encapsulated is
attached to the header.

UDP packets, called user


datagrams, have a fixed-size
header of 8 bytes made up of four
fields, each of 2 bytes (16 bits).

The 16 bits can define a total length of 0 to 65,535 bytes.


However, the total length needs to be less because a UDP
user datagram is stored in an IP datagram with the total
length of 65,535 bytes.
❑ Source Port Number – it a 16 bit value, required to identify
the port transmitting data.
❑ Destination Port Number – used to identify the port
number, that will be receiving the data.

❑ 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

Given a DUMP of a UDP header in hexadecimal format 06 32 00


0D 00 1C E2 17. Find the following:-

1. Source port number?


2. Destination port number?
3. Length of user datagram?
4. Length of the data?
Example

Given a DUMP of a UDP header in hexadecimal format 06 32 00


0D 00 1C E2 17. Find the following:-

1. Source port number?

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

(0632)₁₆ = (0 × 16³) + (6 × 16²) + (3 × 16¹) + (2 × 16⁰) = 1586


Example

Given a DUMP of a UDP header in hexadecimal format 06 32 00


0D 00 1C E2 17. Find the following:-

2. Destination port number?


It is a 2 Byte long field, used to identify the port of the destined
packet. The destination port number is the second four hexadecimal
digits 00 0D if we convert hexadecimal to decimal we get
13

(000D )₁₆ = (0 × 16³) + (0 × 16²) + (0 × 16¹) + (13 × 16⁰) = 13


Example

Given a DUMP of a UDP header in hexadecimal format 06 32 00


0D 00 1C E2 17. Find the following:-

3. Length of user datagram?


Length is the length of UDP including the header and the data. It is a 16-
bits field. The third four hexadecimal digits 00 1C if we convert
hexadecimal to decimal we get 16 define the length of the whole UDP
packet as
28

(001C )₁₆ = (0 × 16³) + (0 × 16²) + (1 × 16¹) + (12 × 16⁰) = 28


Example

Given a DUMP of a UDP header in hexadecimal format 06 32 00


0D 00 1C E2 17. Find the following:-

4. Length of the data?


It is 8 bytes as it is fixed. The length of the data is the length of the whole
packet — the length of the header

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

❑Function must be easy to compute


❑Function must capture the likely changes to the packet
❑If the packet was corrupted through these likely changes, the
function value must change
❑Function must be easy to verify

❑UDP uses a function called a checksum


❑Very common idea: used in multiple parts of networks and
computer systems
UDP checksum
Goal: detect “errors” (e.g., flipped bits) in transmitted segment

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

❑Example: add two 16-bit integers


Sender1 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
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?

2. How does the receiver detect errors?


HOW DOES UDP WORK?
• The UDP protocol works by immediately firing data at the receiver who made a
data transmission request, until the transmission is complete or terminated.
Sometimes called a “fire-and-forget” protocol, UDP fires data at a recipient in no
particular sequence, without confirming delivery or checking if packets arrived
as intended.
• While TCP establishes a formal connection via its “handshake” agreement before
sending data. UDP doesn’t have time for that. It speeds up data transfer by
sending packets without making any agreement with a receiver. Then, it’s up to
the recipient to make sense of the data.
TCP VS UDP COMPARISON
https://youtu.be/MG6vZqDpYNs?si=pX_cryhawv-87syJ
Why would anyone use UDP?
UDP is light weight protocol:

• No delay for connection establishment


o UDP just blasts away without any formal preliminaries
o …..which avoids introducing any unnecessary delays
• No connection state
o No allocation of buffers, parameters, sequence, etc.
o ……making it easier to handle many active clients at once
• Small packet header overhead
o UDP header is only eight-bytes long
https://youtu.be/HMKC3RSUuJg?si=2fKERrv-bquMpAFg
POPULAR APPLICATIONS THAT USE UDP
❑Multimedia streaming
- Retransmitting lost/corrupted packets is not worthwhile
- By the time the packet is retransmitted, it’s too late
- E.g., telephone calls, video conferencing, gaming
❑Simple query protocols like Domain Name System
- Overhead of connection establishment is overkill
- Easier to have application retransmit if needed

You might also like