Java Reference
In-Depth Information
is commonly used for discovery. For instance, when an ephemeral client such as a laptop
boots up, it will send a particular message to 255.255.255.255 to find the local DHCP
server. All nodes on the network receive the packet, but only the DHCP server responds.
In particular, it sends the laptop information about the local network configuration,
including the IP address that laptop should use for the remainder of its session and the
address of a DNS server it can use to resolve hostnames.
Ports
Addresses would be all you needed if each computer did no more than one thing at a
time. However, modern computers do many different things at once. Email needs to be
separated from FTP requests, which need to be separated from web traffic. This is ac‐
complished through ports . Each computer with an IP address has several thousand
logical ports (65,535 per transport layer protocol, to be precise). These are purely ab‐
stractions in the computer's memory and do not represent anything physical, like a USB
port. Each port is identified by a number between 1 and 65535. Each port can be allocated
to a particular service.
For example, HTTP, the underlying protocol of the Web, commonly uses port 80. We
say that a web server listens on port 80 for incoming connections. When data is sent to
a web server on a particular machine at a particular IP address, it is also sent to a par‐
ticular port (usually port 80) on that machine. The receiver checks each packet it sees
for the port and sends the data to any program that is listening to that port. This is how
different types of traffic are sorted out.
Port numbers between 1 and 1023 are reserved for well-known services like finger, FTP,
HTTP, and IMAP. On Unix systems, including Linux and Mac OS X, only programs
running as root can receive data from these ports, but all programs may send data to
them. On Windows, any program may use these ports without special privileges.
Table 1-1 shows the well-known ports for the protocols that are discussed in this topic.
These assignments are not absolutely guaranteed; in particular, web servers often run
on ports other than 80, either because multiple servers need to run on the same machine
or because the person who installed the server doesn't have the root privileges needed
to run it on port 80. On Unix systems, a fairly complete listing of assigned ports is stored
in the file /etc/services .
Table 1-1. Well-known port assignments
Protocol
Port
Protocol
Purpose
echo
7
TCP/UDP
Echo is a test protocol used to verify that two machines are able to connect by having one echo
back the other's input.
discard
9
TCP/UDP
Discard is a less useful test protocol in which all data received by the server is ignored.
daytime
13
TCP/UDP
Provides an ASCII representation of the current time on the server.
FTP data
20
TCP
FTP uses two well-known ports. This port is used to transfer files.
Search WWH ::




Custom Search