The Internet makes two transport protocols available to applications, UDP and TCP. When you create a new network
application for the Internet, one of the first decisions that you must make is whether to use UDP or TCP. Each of these
protocols offers a different service model to the invoking applications.
TCP Services
The TCP service model includes a connection-oriented service and a reliable data transfer service. When an application
invokes TCP for its transport protocol, the application receives both of these services from TCP.
- Connection-oriented service: TCP has the client ans server exchange transport-layer control infornation with
each other before the application-level messages begin to flow. This so-called handshaking procedure alerts
the client and server, allowing them to prepare for an onslaught of packets. After the handshaking phase, a TCP
connection is said to exist between the sockets of the two processes. The connection is a full-duplex connection
in that the two processes sna send messages to each other over the connection at the same time.
- Reliable transport service: The communicating process can rely on TCP to deliver all data sent without error
and in the proper order. When one side of the applicaiton passes a stream of bytes into a socket, it can count on TCP
to deliver the same stream of bytes to the receiving socket, with no missing or duplicate bytes.
TCP also includes a congestion-control mechanism, a service for the general welfare of the Internet rather than for the
direct benefit of the communicating process. The TCP congestion-control mechanism throttles a sending process when the
network is congested between sender and receiver.
The throttling of the transmission rate can have a very harmful effect on real-time audio and video applications that
have a minimum required bandwidth constraint. Moreover, real-time applications are loss-tolerant and do not need a fully
reliable transport service. For these reasons, developers of real-time applications usually run their applications over
UDP rather than TCP.
UDP Services
UDP is a no-frills, lightweight transport protocol with a minimalist service model. UDP is connectionless, so there
is no handshaking before the two processes start to communicate. UDP provides an unreliable data transfer service--that
is, when a process sends a message into a UDP socket, UDP provides no guarantee that the message will ever reach
the receiving process.
|