11
operation; you should see the new socket listed.17
4.1.7 What Makes a Connection Unique
Several socket programs might be running concurrently on the same machine. They may even all be accepting
messages from the same remote machine. So, when a message arrives, how can the OS tell which
program it should be routed to? The answer is that different socket programs are distinguished by their port
numbers. The ftpd service is on port 21, for instance. A communication between two machines must be
defined by five pieces of information:
• protocol (TCP, UDP, etc.)
• server IP address
• server socket port number
• client IP address
• client (ephemeral) socket port number
The server, for example, may be involved in several TCP transactions sent from the same machine, and thus
the server needs to have some way of distinguishing between them. And similarly, when the server sends
messages back to a client, the TCP system at the client's machine has to have some way of determining
which program the server's message is intended for.
Say for example, there are two users currently on machine X, one using ftp to port 21 at machine Y, and
another using telnet to port 23 at machine Z. But the programs being run by the two users will also have
ephemeral ports at their own machines, say 2592 and 5009, temporarily assigned to them by the TCP
system at machine X. The ftp program will inform the FTP server at machine Y about this 2592 number
when it first connects to Y, and when the server sends back to X it will use this number. The TCP system at
X will see this number, and route the message to the ftp program accordingly. Similar statements hold for
telnet, etc. And even if the two users had both been using ftp, their two different ephemeral port numbers
would distinguish them from each other.
4.2 Sample TCP/IP Application: NFS
As mentioned earlier, NFS allows machines to share files, in a manner transparent to the user. NFS uses the
UDP transport protocol.18
When I ran the df command on the ACS machine taco, the output included a line
rosarita:/usr/pkg 2077470 1556279 313444 83% /usr/pkg
17You may also some "UNIX" sockets, which don't involve networks.
18NFS actually uses Remote Procedure Call (RPC), which in turn uses UDP. RPC is just what the name implies: A program can
actually call a function-with parameters-which will execute on another machine. We have earlier referred to UDP's "unreliable"
nature, which means RPC must take its own reliability measures.
12
This says that the directory /usr/pkg on the machine rosarita has been mounted on taco, in a directory of
the same name, /usr/pkg (the name need not have been the same). This directory contains a number of
utilities, such as the GNU C compiler, gcc, in the file /usr/pkg/gnu/bin/gcc. Thus for instance the user can
Overview of Computer Networks
Start from the beginning
