UDP User Datagram Protocol User Datagram Protocol UDP

  • Slides: 15
Download presentation
UDP User Datagram Protocol

UDP User Datagram Protocol

User Datagram Protocol (UDP) ¢ ¢ UDP is the protocol available to network programmers

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

Connectionless Service ¢ In connectionless service, a host just sends packets No connection needs to be established l No virtual circuit needs to be created l A connectionless socket can send messages to multiple recipients l

UDP Applications ¢ UDP can be used for: Instant messaging (e. g. ICQ) l

UDP Applications ¢ UDP can be used for: Instant messaging (e. g. ICQ) l Multicast messaging l ¢ UDP is best suited for applications which have: Sporadic messaging l Long periods of delay between messages l

8 bytes User Datagrams Bytes Name Description 2 Source Port The port used to

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

Ports ¢ Ports represent portals where information may be transmitted or received by a network -enabled machine l l l 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

Ports ¢ It is important to note (and often overlooked) that all datagrams contain 2 ports: l One for the source • The port that was used to send the message l 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

Ports ¢ Some ports were associated with specific network functions to make port numbers unnecessary in those domains: l l 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 M 1 Web 80 80 Web 90 25 SMTP ICQ 5190 Web 8080

Ports M 1 Web 80 80 Web 90 25 SMTP ICQ 5190 Web 8080 Tomcat 5190 ICQ Ext 10257 Ext 16403 M 2

User Datagrams UDP datagrams are encapsulated inside IP datagrams ¢ The normal IP headers

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

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 Layering Application User Datagram Protocol (UDP) Internet Protocol (IP) Network Interface Hardware

UDP Programming // in Java Datagram. Socket socket = new Datagram. Socket(16789); String msg

UDP Programming // in Java Datagram. Socket socket = new Datagram. Socket(16789); String msg = "hello"; String IP = "229. 201. 35. 83"; Inet. Address address = Inet. Address. get. By. Name(IP); Datagram. Packet output. Packet = new Datagram. Packet(msg. get. Bytes(), msg. length(), address, 12465); socket. send(output. Packet);

UDP Programming // in Java Datagram. Socket socket = new Datagram. Socket(16789); byte[] data

UDP Programming // in Java Datagram. Socket socket = new Datagram. Socket(16789); byte[] data = byte[256]; Datagram. Packet input. Packet = new Datagram. Packet(data, 256); socket. receive(input. Packet);

UDP Summary ¢ UDP is a transport-level protocol l l Which means that UDP

UDP Summary ¢ UDP is a transport-level protocol l l 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 l 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