46.1.2. Layer 4 Protocols: TCP, UDP, and ICMP
TCP, UDP, and ICMP all
"sit on top" of IP; that is, they
use IP to actually deliver the packets.
TCP's job is to provide ordered and guaranteed
delivery. Ordered delivery means that the application at the other
end of the TCP connection reads data in the same order as it was
sent. Guaranteed delivery means that TCP keeps track of which packets
arrived at the other end and resends packets that were dropped.
Together, these two characteristics provide a network communication
mechanism that acts very much like a Unix pipe from an
application's point of view; you simply write bytes
in one end and they come out the other. Many common network
applications sit on top of TCP and use these services, including
telnet, HTTP servers and web browsers, SSH (Section 46.6), and
email (Section 46.8).
UDP provides application access to the basic delivery mechanism of IP
and adds port addressing (see below). Some applications
don't need guaranteed delivery and want the lower
overhead of UDP, or want the low-level control of network error
recovery UDP can provide, or need to be able to do certain kinds of
broadcast. Services like DNS (Section 46.9) and DHCP
(Section 46.10) use UDP rather than TCP, as do many
Internet games.
Both TCP and UDP provide addressing of
their own above and beyond IP addresses; these addresses are called
ports . Generally,
simply getting a packet to a machine isn't quite
enough; if you want two programs to communicate, they need a
rendezvous point; there can be a lot of programs running on the
destination machine, and TCP and UDP need to know to which program
packets should be delivered. An IP address and a port provide the
means for two programs to hook up and start talking. Every
communication needs a port on each machine; one side
"listens" on a well-known port and
the other side "connects" to that
port, generating a random port of its own.
Ports are represented by an integer
number. Ports below 1024 are usually accessible only by programs
running as root and are thus mostly reserved for system services and
the like. /etc/services (Section 46.2) lists most of the well-known ports used by
the main system services.
Finally, ICMP provides diagnostic and traffic
control messages. ICMP is primarily used by applications such as
ping and traceroute (Section 46.4) to diagnose problems, check network status,
and the like. Routers can also use ICMP to control traffic.
-- DJPH