Internet protocols: IP, TCP, and the layers
Internet communication is organised into layers, each solving one part of the problem. IP gets packets to the right machine; TCP makes delivery reliable.
Layered design
Networking is split into layers so each can change independently. The TCP/IP model has four: the link layer moves data across one physical network; the internet layer moves packets between networks; the transport layer delivers data between programs; and the application layer holds protocols such as HTTP and email. The seven-layer OSI model is a more detailed teaching reference.
IP addresses
The Internet Protocol (IP) gives every connected device an address. IPv4 addresses are 32 bits, written as four numbers such as 192.168.1.10, allowing about 4.3 billion addresses, which proved too few. IPv6 uses 128-bit addresses, written in hexadecimal such as 2001:db8::1, giving a practically unlimited supply. Adoption of IPv6 has grown steadily alongside IPv4.
Routing
Routers read each packet's destination IP address and forward it toward the destination using routing tables. Between large networks, the Border Gateway Protocol (BGP) shares information about which networks can be reached through which paths. A packet may pass through a dozen or more routers; the traceroute tool shows the hops.
TCP: reliable delivery
IP alone does not guarantee delivery: packets can be lost, duplicated, or arrive out of order. The Transmission Control Protocol (TCP) fixes this. It sets up a connection with a three-way handshake (SYN, SYN-ACK, ACK), numbers the data, has the receiver acknowledge what arrives, retransmits lost data, and reorders it. TCP also slows down when the network is congested.
UDP: fast and simple
The User Datagram Protocol (UDP) sends packets with no connection setup, acknowledgements, or retransmission. It is faster and lighter but unreliable. It suits uses where speed matters more than perfection, such as live video calls, online games, and DNS lookups, where an old, late packet is useless anyway.
Ports
A single computer runs many networked programs, so transport protocols use port numbers to deliver data to the right one. Web servers commonly listen on port 80 for HTTP and 443 for HTTPS. An IP address plus a port identifies a specific program on a specific machine, like a building address plus a flat number.
NAT and private addresses
Because IPv4 addresses ran short, homes typically use private addresses, such as those starting 192.168, inside the LAN. The home router uses network address translation (NAT) to share one public IP address among all devices, rewriting addresses as packets leave and return. NAT stretched IPv4's life but complicates some direct connections.
Worked example
When you load a web page, your browser asks the operating system to open a TCP connection to the server's IP address on port 443. The three-way handshake takes about one round trip; if latency to the server is 40 milliseconds, that alone costs about 40 milliseconds before any page data flows. Secure connection setup adds more round trips, which is why reducing round trips speeds up the web.
Key takeaways
The TCP/IP model has link, internet, transport, and application layers; OSI has seven. IPv4 has 32-bit addresses (about 4.3 billion); IPv6 has 128-bit addresses. Routers forward packets using routing tables; BGP connects large networks. TCP provides reliable, ordered delivery with handshakes, acknowledgements, and retransmission; UDP is fast but unreliable. Ports identify programs; HTTPS commonly uses 443. NAT shares one public IPv4 address among many devices.
Flashcard
Link, internet, transport, application layers
Check your understanding
Why would a live video call typically use UDP rather than TCP?
