Purpose
Orient the transport layer within the stack and name its two service models before the per-protocol notes go into detail.
Core idea
The network layer moves packets between hosts. The transport layer builds on that to provide end-to-end connectivity between application processes across the network. In terms of encapsulation, application data rides in segments, segments ride in packets, and packets ride in frames.
flowchart LR A[Application data] --> S[Segment, transport layer] S --> P[Packet, network layer] P --> F[Frame, link layer] style S fill:#e3f2fd
The layer exposes two service models. Messages, also called datagrams, are discrete units of data delivered independently, and UDP provides them with no delivery guarantees. Bytestreams are continuous ordered streams of bytes, and TCP provides them with reliability, flow control, and congestion control layered on top of the network’s best-effort delivery.
Which one an application wants depends on whether it needs delivery guarantees more than it needs low overhead. TCP and UDP cover the two protocols.