4 Chapter 1: Introduction
■
instead of between hosts. Thus, applications that use UDP must be prepared to deal with
losses, reordering, and so on.
1.2 About Addresses
When you mail a letter, you provide the address of the recipient in a form that the postal
service can understand. Before you can talk to somebody on the phone, you must supply
their number to the telephone system. In a similar way, before a program can communicate
with another program, it must tell the network where to find the other program. In TCP/IP,
it takes two pieces of information to identify a particular program: an Internet address,
used by IP, and a port number, the additional address interpreted by the transport protocol
(TCP or UDP).
Internet addresses are 32-bit binary numbers.
1
In writing down Internet addresses
for human consumption (as opposed to using them inside applications), we typically show
them as a string of four decimal numbers separated by periods (e.g., 10.1.2.3); this is called
the dotted-quad notation. The four numbers in a dotted-quad string represent the contents
of the four bytes of the Internet address, thus each is a number between 0 and 255.
Technically, each Internet address refers to the connection between a host and an
underlying communication channel, such as a dial-up modem or Ethernet card. Because
each such network connection belongs to a single host, an Internet address identifies a
host as well as its connection to the network. However, because a host can have multi-
ple physical connections (interfaces) to the network, one host can have multiple Internet
addresses.
The port number in TCP or UDP is always interpreted relative to an Internet address.
Returning to our earlier analogies, a port number corresponds to a room number at a given
street address, say, that of a large building. The postal service uses the street address to
get the letter to a mailbox; whoever empties the mailbox is then responsible for getting
the letter to the proper room within the building. Or consider a company with an internal
telephone system: To speak to an individual in the company, you first dial the company’s
main number to connect to the internal telephone system, and then dial the extension
of the particular telephone of the individual you wish to speak with. In these analogies,
the Internet address is the street address or the company’s main number, whereas the
port corresponds to the room number or telephone extension. Port numbers are 16-bit
unsigned binary numbers, so each one is in the range of 1 to 65,535 (0 is reserved).
1
Throughout this book the term Internet address refers to the addresses used with the current version
of IP, which is version 4 [11]. Because it is expected that a 32-bit address space will be inadequate for
future needs, a new version of IP has been defined [5]; it provides the same service but has much bigger
Internet addresses (128 bits). IPv6, as the new version is known, has not been widely deployed; the
sockets API will require some changes to deal with its much larger addresses [6]. The .NET framework
does support IPv6 addresses, but they are not covered in this book.