Learning path

Full curriculum

Full curriculum

Unit content

TCP and UDP

IP delivers packets between hosts, but applications also need a way to distinguish different communicating processes. Transport protocols add this application-to-application layer.

Two fundamental Internet transports are UDP and TCP.

Ports

A transport endpoint includes a port number. The IP address identifies a host interface; the port helps identify the application endpoint on that host.

UDP

UDP sends independent datagrams with very little added protocol machinery.

It does not guarantee that datagrams arrive, arrive only once or arrive in order. Applications use UDP when those guarantees are unnecessary or when they prefer to implement their own timing and reliability behavior.

TCP

TCP provides a connection-oriented, reliable, ordered byte stream between two endpoints.

If network packets are lost, TCP can retransmit data. It reorders received data as needed and controls how quickly data is sent in response to receiver capacity and network conditions.

Messages versus byte streams

UDP preserves individual datagram boundaries. TCP presents a continuous sequence of bytes: one send operation does not imply one corresponding receive operation.

Choosing a transport

TCP and UDP solve different problems. TCP supplies reliability and ordering as part of the transport protocol; UDP supplies a smaller datagram service and leaves more behavior to the application.