UDP - University of Windsor

Download Report

Transcript UDP - University of Windsor

UDP
User Datagram Protocol
User Datagram Protocol (UDP)




UDP is the protocol available to network
programmers who wish to send datagrams
UDP datagrams are called user datagrams, since
they allow user-level creation & transmission of
datagrams
Other IP datagrams are used for implementation of
connection-based transport (TCP), error control
(ICMP), or inter-router communication (BGP, RIP,
OSPF)
UDP has a small, fixed-size (8 byte) header
Connectionless Service

In connectionless service, a host just
sends packets
No connection needs to be
established
 No virtual circuit needs to be created
 A connectionless socket can send
messages to multiple recipients

UDP Applications

UDP can be used for:
Instant messaging (e.g. ICQ)
 Multicast messaging


UDP is best suited for applications
which have:
Sporadic messaging
 Long periods of delay between
messages

8 bytes
User Datagrams
Bytes
Name
Description
2
Source Port The port used to send the message
2
Dest. Port
The port to be used to receive the message
2
Length
The length of the data in the message
2
Checksum
The checksum of the message data
?
Data
The data of the message
Ports

Ports represent portals where information
may be transmitted or received by a
network-enabled machine



One port may be used to send ICQ
messages to other ICQ users
Another port may be used to send requests
to mail servers (such as SMTP servers)
Without ports, messages from the SMTP
server or an ICQ user will be
indistinguishable
Ports

It is important to note (and often
overlooked) that all datagrams contain
2 ports:

One for the source
• The port that was used to send the
message

One for the destination
• The port that was used to receive the
message
Ports

Some ports were associated with specific
network functions to make port numbers
unnecessary in those domains:




25: SMTP (used for sending E-Mail)
80: HTTP (used for handling web requests)
90: SHTTP (used for handling secure web
requests)
Some others are listed on p.205 & p.244
• These reserved ports are both UDP and TCP
ports
Ports
M1
Web
80
80 Web
Web
90
25 SMTP
ICQ 5190
8080 Tomcat
5190 ICQ
Ext 10257
Ext 16403
M2
User Datagrams
UDP datagrams are encapsulated
inside IP datagrams
 The normal IP headers are present
 The data portion of the IP datagram
contains the UDP headers (port
numbers, etc.) and the message data

UDP Message
Encapsulation
UDP Header
IP Header
Frame Header
User Data
IP Data
Frame Data
Network Frame
UDP Layering
Application
User Datagram Protocol (UDP)
Internet Protocol (IP)
Network Interface
Hardware
UDP Programming
// in Java
DatagramSocket socket = new DatagramSocket(16789);
String msg = "hello";
String IP = "229.201.35.83";
InetAddress address = InetAddress.getByName(IP);
DatagramPacket outputPacket = new DatagramPacket(msg.getBytes(),
msg.length(), address, 12465);
socket.send(outputPacket);
UDP Programming
// in Java
DatagramSocket socket = new DatagramSocket(16789);
byte[] data = byte[256];
DatagramPacket inputPacket = new DatagramPacket(data, 256);
socket.receive(inputPacket);
UDP Summary

UDP is a transport-level protocol


Which means that UDP deals with message
delivery
UDP is a connectionless protocol built on top of IP,
which is already connectionless
• Therefore, UDP is essentially direct IP datagram
transmission

UDP does not provide a reliable service
• UDP uses ‘best effort’ delivery
• If messages do not arrive, the application layer (i.e. the
application itself) must determine if and when to retransmit
the message