Java Reference
In-Depth Information
operating system of a host. Applications access the services provided by UDP and TCP through
the sockets API. The arrow depicts the flow of data from the application, through the TCP and IP
implementations, through the network, and back up through the IP and TCP implementations
at the other end.
In TCP/IP, the bottom layer consists of the underlying communication channels—for
example, Ethernet or dial-up modem connections. Those channels are used by the network
layer , which deals with the problem of forwarding packets toward their destination (i.e., what
routers do). The single network layer protocol in the TCP/IP suite is the Internet Protocol; it
solves the problem of making the sequence of channels and routers between any two hosts
look like a single host-to-host channel.
The Internet Protocol provides a datagram service: every packet is handled and delivered
by the network independently, like letters or parcels sent via the postal system. To make this
work, each IP packet has to contain the address of its destination, just as every package that
you mail is addressed to somebody. (We'll say more about addresses shortly.) Although most
delivery companies guarantee delivery of a package, IP is only a best-effort protocol: it attempts
to deliver each packet, but it can (and occasionally does) lose, reorder, or duplicate packets in
transit through the network.
The layer above IP is called the transport layer. It offers a choice between two protocols:
TCP and UDP. Each builds on the service provided by IP, but they do so in different ways to
provide different kinds of transport, which are used by application protocols with different
needs. TCP and UDP have one function in common: addressing. Recall that IP delivers packets
to hosts; clearly, a finer granularity of addressing is needed to get a packet to a particular
application, perhaps one of many using the network on the same host. Both TCP and UDP
use addresses, called port numbers , to identify applications within hosts. They are called end-
to-end transport protocols because they carry data all the way from one program to another
(whereas IP only carries data from one host to another).
TCP is designed to detect and recover from the losses, duplications, and other errors
that may occur in the host-to-host channel provided by IP. TCP provides a reliable byte-stream
channel, so that applications do not have to deal with these problems. It is a connection-
oriented protocol: before using it to communicate, two programs must first establish a TCP
connection, which involves completing an exchange of handshake messages between the TCP
implementations on the two communicating computers. Using TCP is also similar in many ways
to file input/output (I/O). In fact, a file that is written by one program and read by another is a
reasonable model of communication over a TCP connection. UDP, on the other hand, does
not attempt to recover from errors experienced by IP; it simply extends the IP best-effort
datagram service so that it works between application programs 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 someone on the phone, you must supply their
number to the telephone system. In a similar way, before a program can communicate with
Search WWH ::




Custom Search