TCP/IP Lean: Web Servers for Embedded Systems, Second Edition

Chapter 5: User Datagram Protocol: UDP

Overview

While traveling up the TCP stack, you might have wondered when you'd get to the point of doing something useful. Pinging and routing are all very fine, but you can't use them to exchange meaningful data with another system. What is really needed is a simple protocol that sits on top of IP and allows you to launch data and receive replies on your network. That protocol already exists: it is user datagram protocol (UDP). In this chapter I'll look at how it works, and how you can send simple requests to a system.

Surprisingly, there isn't a standard general-purpose UDP utility to emulate, so I'll have to invent one. I'll be implementing a utility called Datagram, which can be used as a general-purpose UDP workhorse and a platform for further exploration of UDP-based protocols.

Ports and Sockets

What is this "meaningful" data that can be exchanged, and who defines the meaning? The answer is twofold. First are standard applications that run on most network servers and give a standard response to a UDP request, and second are user-defined applications, which may initiate or respond to communications in an entirely nonstandard way. So long as all of these applications encapsulate their data in UDP datagrams, there is no risk of confusion. Each UDP datagram is equipped with source and destination port numbers, which identify the source and destination applications for the data so that one application can't accidentally receive another's data.

Some port numbers are "well-known" (i.e., predefined). If...

UNLIMITED FREE
ACCESS
TO THE WORLD'S BEST IDEAS

SUBMIT
Already a GlobalSpec user? Log in.

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.

Customize Your GlobalSpec Experience

Category: Network Synchronization Products
Finish!
Privacy Policy

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.