TCP and IP Fundamentals
informationnetworksundergraduatelecture
data/lecture/information/networks/computer-network-basics.lecture.n.md
1Introduction
This lecture distinguishes datagram forwarding by IP from byte-stream transport by TCP. After establishing the limits of the service that IP provides, it explains how TCP adds reliability through sequencing and retransmission.
2Network and Transport Layers
IP is a network-layer protocol. An IP address identifies a network-layer interface, and routers use a destination IP-address prefix to forward a datagram to its next hop. Routing constructs route information, whereas forwarding transfers each datagram according to that information.
TCP is a transport-layer protocol built on IP. It identifies communication endpoints by combining IP addresses with the port numbers introduced below and supports data transfer between applications.
3IP Best-Effort Forwarding
IP carries data received from an upper layer toward a destination as an IP datagram. IP provides a best-effort service. Network congestion, device failure, and other conditions can cause datagrams to be lost, arrive in a different order from the sending order, or arrive more than once. IP does not guarantee delivery, arrival order, or duplicate suppression.
4TCP Reliable Byte Streams
TCP provides an ordered byte stream between the two endpoints of a connection. TCP assigns sequence numbers to data and uses acknowledgments from the receiver to determine reception status. It retransmits data that has not been acknowledged and reorders data that arrives out of order, thereby delivering an ordered sequence of bytes to the application.
TCP supports full-duplex communication, so byte streams can be carried simultaneously in both directions. TCP does not, however, preserve the boundaries of individual messages sent by an application. An application protocol must represent its own lengths or delimiters.
5Port Numbers and TCP Connections
An IP address identifies a network-layer interface. In the context of a particular transport protocol such as TCP, a port number combines with an IP address to identify a communication endpoint. Conceptually, a TCP connection can be identified by the combination of source IP address, source port number, destination IP address, and destination port number.
A client generally uses a temporary port number, while a server waits for connections on a port number associated with the service that it provides. Port numbers allow multiple applications on a computer with the same IP address to communicate concurrently.
6Encapsulation and Communication Sequence
Application data is placed in a TCP segment, and the TCP segment is placed in the payload of an IP datagram. Adding lower-layer control information to upper-layer data in this manner is called encapsulation.
\text{application data}
\longrightarrow \text{TCP segment}
\longrightarrow \text{IP datagram}
For example, in HTTP/1.1 or HTTP/2 communication, TCP carries HTTP data as a byte stream, and IP forwards the TCP segments toward the destination as datagrams.
7Scope of Guarantees
TCP reliability concerns providing the receiver with the sender's bytes in order while the connection remains viable. It does not guarantee eventual delivery after a connection fails, nor does it guarantee that the receiving application has processed the data. TCP must not be interpreted as always delivering data.
8Key Points
- IP forwards datagrams on a best-effort basis and does not guarantee delivery or order.
- TCP builds an ordered, reliable, full-duplex byte stream on IP.
- An IP address identifies a network-layer interface, while a port number identifies an endpoint in the context of a transport protocol and an IP address.
- TCP's guarantees differ from a guarantee that an application has completed processing.
9Next Lecture
data/lecture/information/networks/dns-basics.lecture.n.md