1 / 31

User Datagram Protocol ( udp )

User Datagram Protocol ( udp ).  Prof. Crista Lopes. What is UDP ?. an unreliable transport protocol that can be used in the Internet. an alternative to the Transmission Control Protocol(TCP). UDP uses the Internet Protocol to get a data unit (datagram) from one computer to another.

alexism
Download Presentation

User Datagram Protocol ( udp )

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. User Datagram Protocol (udp)  Prof. Crista Lopes

  2. What is UDP? • an unreliable transport protocol that can be used in the Internet. • an alternative to the Transmission Control Protocol(TCP). • UDP uses the Internet Protocol to get a data unit (datagram) from one computer to another. • a connectionless transport layer protocol in the TCP/IP protocol stack.

  3. Position of UDP in the OSI model

  4. UDP(cont’d) • UDP does not provide: • flow or error control • connection management • guaranteed in-order packet delivery • UDP is almost a “null” transport layer. • UDP is often used for time-sensitive applications where missing data is preferred to late-arriving data.(i.e. Domain Name Server (DNS))

  5. Why UDP? • No connection needs to be set up. • Throughput may be higher because UDP packets are easier to process, especially at the source. • The user doesn’t care if the data is transmitted reliably. • Example:Real-time video and audio streaming protocols are designed to handle occasional lost packets, so only slight degradation in quality occurs, rather than large delays if lost packets were retransmitted. 

  6. TCP and UDP Functional Comparison

  7. IP addresses versus port numbers

  8. UDP header format

  9. UDP header format • Source port :This field identifies the sending port. • Destination port: This field identifies the destination port and is required. • Length :16-bit field that specifies the length in bytes of the entire datagram: header and data.  • Checksum: The 16-bit checksum field is used for error-checking of the header and data

  10. Checksum calculation • Checksum is the 16-bit one's complement of the one's complement sum of a pseudo header of information from the IP header, the UDP header, and the data, padded with zero octets at the end (if necessary) to make a multiple of two octets.

  11. IPv4 PSEUDO-HEADER

  12. Checksum calculation

  13. Encapsulation and decapsulation

  14. Notes • UDP packets are called user datagrams and have a fixed-size header of 8 bytes. • UDP length = IP length − IP header’s length • Port numbers obtained by Internet Assigned Numbers Authority (IANA):

  15. Some well-known ports used with UDP

  16. Domain Name System(DNS) • IP addresses are tough for humans to remember. • IP addresses are impossible to guess. • The domain name system is usually used to translate a host name into an IP address . • Domain names comprise a hierarchy so that names are unique, yet easy to remember.

  17. DNS and UDP • DNS primarily uses User Datagram Protocol (UDP) on port number 53 to serve requests. • Single UDP request from the client followed by a single UDP reply from the server. • In Domain Name System (DNS), queries must be fast and only consist of a single request followed by a single reply packet

  18. Domain Name • The domain name for a host is the sequence of labels that lead from the host (leaf node in the naming tree) to the top of the worldwide naming tree. • A domain is a subtree of the worldwide naming tree. • Top Level Domains : edu, gov, com, net, org • Countries each have a top level domain (2 letter domain name).

  19. Host name structure • Each host name is made up of a sequence of labels separated by periods. • Each label can be up to 63 characters • The total name can be at most 255 characters. • Examples: • whitehouse.gov • isr.ics.uci.edu

  20. DNS Organization • Distributed Database • The organization that owns a domain name is responsible for running a DNS server that can provide the mapping between hostnames within the domain to IP addresses. • some machine run by UCI is responsible for everything within the uci.edu domain.

  21. DNS Distributed Database • There is one primary server for a domain, and typically a number of secondary servers containing replicated databases. uci.eduDNS server uci.edu DNS DB uci.edu DNS DB rpi.edu DNS DB rpi.edu DNS DB Authoritative Replicas

  22. UDP or TCP • Both UDP and TCP are used in DNS: • Generally UDP is used to serve requests. • If the response data size exceeds 512 bytes, requestor resubmits request using TCP( i.e. zone transfers) .

  23. DNS Clients • A DNS client is called a resolver. • A call to gethostbyname()is handled by a resolver (typically part of the client). • Most Unix workstations have the file /etc/resolv.conf that contains the local domain and the addresses of DNS servers for that domain.

  24. /etc/resolv.conf domain ics.uci.edu 128.195.1.48

  25. edu com org jp ucsd The Root DNS Server • the official DNS root is administered by the Internet Corporation for Assigned Names and Numbers (ICANN).  • The root server needs to know the address of 1st (and many 2nd) level domain nameservers. uci ics eng

  26. DNS Servers • Servers handle requests for their domain directly. • If a server has no clue about where to find the address for a hostname, asks the root server. The root server will tell you what nameserver to contact. • A request may get forwarded a few times. • Servers cache external mappings(since root servers are bottleneck for trillions of queries placed every day)

  27. Address resolution mechanism 1-the root server address is often stored in a file of root hints, which are updated periodically by an administrator from a reliable source. 2-ask the root server to find the server authoritative for the top-level domain. 3-ask the obtained Top Level Domain DNS server for the second-level domain. 4-Repeating the previous step

  28. UDP Client and Server Example in Java • The server continuously receives datagram packets over a datagram socket. • Each datagram packet received by the server indicates a client request for a quotation. • When the server receives a datagram, it replies by sending a datagram packet that contains a one-line "quote of the moment" back to the client. • Two classes implement the server application: QuoteServer and QuoteServerThread. A single class implements the client application: QuoteClient.

  29. QuoteServer Class import java.io.*; public class QuoteServer { public static void main(String[] args) throws IOException { new QuoteServerThread().start(); } }

  30. The QuoteServerThreadClass public class QuoteServerThread extends Thread { ... super(name); socket = new DatagramSocket(4445); public void run() { while (moreQuotes) { try { byte[] buf = new byte[256]; // receive request DatagramPacket packet = new DatagramPacket(buf, buf.length); socket.receive(packet); // figure out response String dString = null; dString = getNextQuote(); … buf = dString.getBytes(); // send the response to the client at "address" and "port“ InetAddress address = packet.getAddress(); int port = packet.getPort(); packet = new DatagramPacket(buf, buf.length, address, port); socket.send(packet); }...}}

  31. The QuoteClient Class public class QuoteClient { public static void main(String[] args) throws IOException { if (args.length != 1) { System.out.println("Usage: java QuoteClient <hostname>"); return; } // get a datagram socket DatagramSocket socket = new DatagramSocket(); // send request byte[] buf = new byte[256]; InetAddress address = InetAddress.getByName(args[0]); DatagramPacket packet = new DatagramPacket(buf, buf.length, address, 4445); socket.send(packet); // get response packet = new DatagramPacket(buf, buf.length); socket.receive(packet); // display response String received = new String(packet.getData(), 0, packet.getLength()); System.out.println("Quote of the Moment: " + received); socket.close(); } }

More Related