|
|
3.2.10. User Datagram Protocol
At the IP layer, a destination address identifies a host computer, no
further distinction is made regarding which user or which application
program will receive the datagram. User Datagram Protocol (UDP)
provides one of possible mechanisms allowing multiple application
programs executing on a given computer to send and receive datagrams
independently.
3.2.11. Identifying The Ultimate Destination
The operating systems in most computers support multiprogramming, which means they permit multiple application programs to execute simultaneously. We refer to each executing program as a process. It may seem natural to say that a process is the ultimate destination for a message. But there are several problems with such an approach.
Instead of thinking of a process as the ultimate destination, we will imagine that each machine contains a set of abstract destination points called protocol ports. Each protocol port is identified by a positive integer. The local operating system provides an interface mechanism that processes use to specify a port or access it.
Most operating systems provide synchronous access to ports. From a particular process point of view it means that the computation stops during a port access operation. For example, if a process attempts to extract data from a port before any data arrives, the operating system stops the process until data arrives. Once the data arrives, the operating system passes the data to the process and restarts it.
In general, ports are buffered, so data that arrives before a process is ready to accept it will not be lost.
To communicate with a foreign port, a sender needs to know both the
IP address of the destination machine and the protocol port number
of the destination within that machine.
3.2.12. The User Datagram Protocol
UDP belongs to TCP/IP protocol suite. It provides the primary mechanism that application programs use to send datagrams to other application programs. UDP provides protocol ports used to distinguish among multiple processes executing on a single machine. Each UDP message contains both a destination port number and a source port number, making it possible for the UDP software on the destination to deliver the message to the correct recipient to send a reply.
UDP uses the underlying Internet Protocol to transport a message from one machine to another, and provides the same unreliable, connectionless datagram delivery service as IP. It just adds the ability to distinguish among multiple destinations within a given host computer.
An application program that uses UDP accepts full responsibility for
handling the problem of reliability.
3.2.13. Format of UDP Messages
Each UDP message is called a user datagram. It consists of UDP header and UDP data area.
The header consists of four 16-bit fields that specify the port from
which the message was sent, the port to which the message is destined,
the message length (in octets), and a UDP checksum. The source port
is optional, if not used, it should be zero. The checksum is also
optional, if not used, it should be zero.
3.2.14. UDP Encapsulation and Protocol Layering
UDP is a protocol of the transport layer. Conceptually, application programs access UDP, which uses IP to send and receive datagrams.
Layering UDP above IP means that a complete UDP message, including
the UDP header and data, is encapsulated in an IP datagram as it
travels across an internet. The IP layer is responsible only for
transferring data between a pair of hosts on an internet, while UDP
layer is responsible only for differentiating among multiple sources
or destinations within one host.
3.2.15. Reserved and Available UDP Port Numbers
There are two fundamental approaches to port assignment.
The first approach uses central authority. Everyone agrees to allow a central authority to assign port numbers as needed and to publish the list of assignments. Then all software is built according to the list. This approach is sometimes called universal assignment and the port assignments specified by the authority are called well-known port assignments.
The second approach uses dynamic binding. Here ports are not globally known. Instead, whenever a program needs a port the network software assigns one. To learn about the current port assignment on another computer, it is necessary to send a request that asks a question like "How do I reach the file transfer service?". The target machine replies by giving the correct port number to use.
The TCP/IP designers adopted a hybrid approach that assigns a few port numbers a priori, but leaves most available for local sites or application programs. The assigned port numbers begin at low values and extend upward, leaving large integer values available for dynamic assignment.