Java Glossary : UDP

CMP home Java glossary home Menu no menu Last updated 2004-06-28 by Roedy Green ©1996-2004 Canadian Mind Products

Java definitions: 0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

You are here : home : Java Glossary : U words : UDP.

UDP
User Datagram Protocol. This protocol is build on top of IP, and allows sending datagrams -- messages of arbitrary length (broken into packets). UDP makes no provision for checking that a message was received or retransmitting it. UDP is good when you have a short message coming in to the server with a short response. You avoid the overhead of setting up a TCP/IP connection and acking every little packet. If the server does not respond, you simply send your packet again. IPv6 has Jumbograms -- giant packets which will make UDP more attractive for high volume server applications. SNTP (Simple Network Time Protocol) is built on top of UDP.

You use the Java classes DatagramPacket and DatagramSocket.

How Does UDP Protocol Work

Have a look at the UDP packet header, which is tacked on after the usual IP header. UDP works almost exactly like IP protocol with the minor addition of destination ports.

IP Packet Header
Field Size in bits Purpose
source IP 32 Not in the UDP header, but rather in the basic IP header. Who sent the packet. When it finally arrives at its destination the receiver will know who it was from.
destination IP 32 Not in the UDP header, but rather in the basic IP header. Where the packet is going. On each leg of its journey the routing computer uses this to get the packet a little closer to its final destination.
checksum 16 This is computed as 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 as needed with zero bytes at the end to make a multiple of two bytes. If the checksum is set to zero, then checksuming is disabled. If the computed checksum is zero, then this field must be set to 0xFFFF.
source port 16 Similar to the function the source port in TCP/IP. It is a free port on the sender's machine where any responses should be sent.
destination port 16 Which program on the server this should be directed to.
message length 16 total size of UDP header plus data payload (but not the IP header) in 8-bit chunks (aka bytes or octets). The means the maximum size of a packet including data is 64K. This means the payload of data is at most 65,451 bytes. This could have easily been calculated from the length in the IP packet header, but for some reason they duplicated the information.

Everything is in big endian byte order. See details.

book_coverInternetworking with TCP/IP Vol.1: Principles, Protocols, and Architecture, 4th edition
0-13-018380-6
Douglas E. Comer
How IP, UDP and TCP/IP protocols work. How the domain name to IP translation DNS information in propagated.
amazon.com Barnes and Noble
amazon.ca chapters
amazon.co.uk amazon.de


CMP logo
CMP_home
home
Canadian Mind Products CSS
HTML Checked!
ICRA ratings logo
mindprod.com IP:[24.87.56.253]
Your IP:[80.134.30.163]
You are visitor number 3927.
Please send errors, omissions and suggestions
to improve this page to Roedy Green.
You can get a fresh copy of this page from: or possibly from your local J: drive mirror:
http://mindprod.com/jgloss/udp.html J:\mindprod\jgloss\udp.html