1. Home
  2. Explore
  3. Computer Science
  4. How TCP/IP Powers the Internet

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

How TCP/IP Powers the Internet

How the Internet Moves a Message

A web page can appear on a phone in less than a second, even when the page is stored on a computer far away. The journey may cross cables, routers, and networks owned by many different organizations. No single machine directs the entire internet. Instead, devices cooperate by following shared rules called protocols.

The central pair of protocols is TCP/IP. IP helps move data toward the right computer; TCP can make sure that data arrives completely and in the right order. Together with many other protocols, they make it possible for different devices and networks to communicate.

From ARPANET to the Internet

The internet’s story began before the World Wide Web. On October 29, 1969, student Charley Kline tried to log in from a computer in Los Angeles to one at the Stanford Research Institute, about 500 kilometres away, using an early network called ARPANET. He typed “L,” then “O,” and then “G.” The system crashed after the “G,” so the first message sent over the network that developed into the internet was “lo.” The login succeeded about an hour later.

As ARPANET grew, other networks appeared, but they could not all communicate with one another. In 1974, Vint Cerf and Bob Kahn published a design for connecting separate networks into a “network of networks.” That design became TCP/IP. On January 1, 1983, ARPANET switched to TCP/IP in a coordinated change that engineers call flag day. Many people regard that change as the internet’s birthday.

The World Wide Web came later. Tim Berners-Lee proposed it at CERN in 1989 as a service that could run on the internet. The distinction is important: the internet is the underlying system of connected networks, while the web is one kind of service that uses it. Email, online games, and video calls also use the internet, but they are not all the web.

The internet is the network infrastructure; the web is one kind of traffic that travels across it.

Think About It: If the web is only one service on the internet, what are some other kinds of traffic the internet can carry?

Packets: Small Pieces That Share the Road

Older telephone networks often worked by reserving a dedicated circuit for a call. The connection remained reserved from one end to the other, even when the callers were silent. This resembles booking an entire road for one car.

The internet usually works differently. It breaks a message into smaller pieces called packets and sends them independently. A packet often contains around 1,500 bytes of data, along with information such as its destination. Packets from the same message can take different routes and arrive at different times or in a different order. The receiving system uses their information to put the message back together.

This method is called packet switching. A useful analogy is sending a book as numbered postcards. Each postcard carries part of the book, and its number helps the reader put the pages in order. Because the network does not reserve a complete path for one message, many people can share the same cables and links. If one route fails, packets may travel by another route instead. This ability to work around damage was an important goal of early network design.

Think About It: Why might it be more resilient to send packets along several available routes than to depend on one reserved route?

Layers: Dividing the Work

Moving a message across a network involves several different jobs. Layering organizes those jobs so that each layer has a defined responsibility and relies on the layer below it.

Sending a gift offers an analogy. A person places a letter inside a gift, places the gift in a box, adds the recipient’s address, and then hands it to a delivery service. Each step adds information or performs a different part of the delivery.

TCP/IP is commonly described using four layers:

  • Application layer: The information or service an application uses, such as a web page, email, or chat.
  • Transport layer: TCP or UDP helps deliver data to the appropriate program on a device. TCP can also provide complete, ordered delivery.
  • Internet layer: IP carries the addressing information used to move packets across networks.
  • Link layer: The link layer moves data across one local connection, such as Wi-Fi, Ethernet, or fibre.

As data moves down these layers, each layer adds its own control information, often called a header. This wrapping process is known as encapsulation. At the destination, the layers remove their headers in reverse order to uncover the original data. The process resembles Russian dolls, with one layer of information wrapped around another.

A different model, called the OSI model, divides networking into seven layers rather than four. It separates some responsibilities more finely. Engineers often use its layer numbers in everyday conversation: a “layer seven problem,” for example, refers to an application-layer problem.

The Link Layer: Moving Bits Nearby

Ultimately, network data becomes a stream of ones and zeros. The link carrying those bits can take different physical forms:

  • In copper cable, bits are represented by electrical pulses.
  • In fibre-optic cable, they are represented by flashes of light.
  • In Wi-Fi and mobile networks, they travel using radio waves.

Within homes and offices, Ethernet is a major link standard. Devices on a local network also have MAC addresses: hardware identifiers that are 48 bits long and usually written as six pairs of letters and numbers. A network switch uses MAC addresses to direct local frames to the appropriate device.

The internet is not limited to one kind of physical connection. Undersea fibre-optic cables carry nearly all data that travels between continents; satellites carry only a small share. What matters to IP is that the link can carry the bits, not whether those bits travel as electricity, light, or radio.

A striking demonstration of this flexibility came from the idea of IP over Avian Carriers: sending internet packets by pigeon. An April Fools’ document described the idea in 1990, and a Linux user group in Bergen, Norway, actually tried it in 2001. Nine pings were sent, one tied to each pigeon; four returned after roughly fifty minutes to an hour and three quarters. The method was slow and unreliable, but it illustrated a key design principle: IP packets can travel over very different kinds of links.

Think About It: What does the pigeon experiment suggest about the relationship between IP and the physical medium that carries data?

IP Addresses: Finding a Device

For a packet to reach a device, it needs an IP address. An IP address is like a postal address: it helps the network direct data toward the intended destination.

IPv4 and private addresses

The older, widely used format is IPv4. An IPv4 address contains 32 bits and is written as four numbers from 0 to 255, separated by dots. An example is 142.250.183.14. The 32-bit format provides about 4.3 billion possible addresses.

That supply once seemed vast, but the number of connected phones, computers, televisions, and cameras grew beyond it. The central pool of new IPv4 addresses ran out in 2011. One widely used way to manage the shortage is NAT, or network address translation.

With NAT, a home router has one public address for communication with the wider internet, while devices inside the home use private addresses, such as 192.168.1.5. These private addresses can be reused in many different homes. The router tracks which internal device made a request so that it can direct the reply back to the correct device. A mobile operator may perform NAT on a much larger scale, allowing thousands of phones to share one public address.

An apartment building provides a helpful analogy: the building has one street address, while a person at the entrance keeps track of which flat should receive each delivery.

Networks, hosts, and subnet masks

IP addresses are distributed in blocks. Within an address, one part identifies the network and another part identifies a device, or host, on that network. This resembles a postal address in which an area code identifies a region and a house number identifies a particular home within it.

A subnet mask or slash number indicates where the network part ends and the host part begins. For example, 192.168.1.0/24 means that the first 24 bits identify the network, leaving 8 bits for host addresses. The same subnet size can be written with the mask 255.255.255.0.

Eight bits can represent 256 possible values. In this example, one address identifies the network itself and another is used to broadcast to all devices on the network, leaving 254 addresses for devices.

Changing the slash number changes the block size. A /16 block contains more than 65,000 addresses, while a /30 block contains four. The flexible system that assigns these blocks is called CIDR, short for Classless Inter-Domain Routing. It allows organizations to receive blocks sized to their needs.

When a computer is ready to send a packet, it checks whether the destination is within its own subnet. If it is, the computer can send the packet directly on the local network. If not, it sends the packet to the default gateway—usually the local router—which provides a route toward other networks.

IPv6: A much larger address space

The newer format, IPv6, uses 128-bit addresses. They are written as eight groups of hexadecimal digits separated by colons. Long runs of zeros can be shortened using a double colon. The 128-bit address space contains about 340 undecillion addresses—a three followed by 38 zeros.

IPv6’s address supply is so large that every device can have its own public address without relying on NAT in the same way as IPv4. IPv6 also simplified the packet header to help routers process packets more quickly.

The transition is gradual because IPv4 and IPv6 cannot communicate directly with one another. For now, both operate side by side. A large and growing share of internet traffic, including traffic on many Indian mobile networks, already uses IPv6.

Think About It: Why does the distinction between a network part and a host part make it possible to route data efficiently?

Routers and Routes Across the Internet

A router moves packets from one network link to the next. It does not need to know every detail of a packet’s entire journey. Instead, it looks at the destination address and chooses the next direction. This is called hop-by-hop forwarding.

Routers keep routing tables: lists that associate address blocks with the next hop a packet should take. When several entries could match a destination, the router chooses the most specific match, called the longest prefix. A default route provides a next step for destinations that do not match a more specific entry.

TTL and traceroute

Packets also have a counter called time to live, or TTL. Each router reduces this value. When it reaches zero, the packet is discarded and the sender receives an error message. The counter prevents packets from circulating endlessly if a route loops.

The diagnostic tool traceroute makes use of this behavior. It sends packets with gradually increasing TTL values: first 1, then 2, then 3, and so on. Each router that discards a packet can reveal its identity. This lets a user inspect the sequence of network hops between a computer and a destination. On Windows, the related command is tracert.

Autonomous systems and BGP

The internet is made up of tens of thousands of independently run networks called autonomous systems. These may belong to different organizations. Within an organization, routers can share information about routes. Between autonomous systems, the main protocol is BGP, the Border Gateway Protocol.

BGP allows networks to announce which address blocks can be reached through them. Neighbouring networks pass those announcements along, spreading route information through the internet. The process is sometimes compared to gossip between large networks: each network tells others which destinations it can reach.

That trust can create problems. In February 2008, Pakistan Telecom was ordered to block YouTube within the country and announced a more specific route for YouTube’s addresses, intended to stay within Pakistan. The announcement leaked beyond the country, and much of the world began sending YouTube traffic toward Pakistan. Many people could not reach YouTube for about two hours.

In October 2021, a maintenance command at Facebook disconnected part of its backbone, and Facebook’s BGP routes were withdrawn. Facebook, Instagram, and WhatsApp became unreachable from the internet for about six hours. Reports also said that some staff members’ badges stopped opening doors.

Networks increasingly use RPKI—a system for signing route announcements—to help detect and reject false claims about which network can reach an address block.

Think About It: Why can a routing announcement from one network affect people trying to reach a service in many other parts of the world?

Ports and Transport: Getting Data to the Right Program

An IP address identifies a device, but a device may run many programs at once. Port numbers help direct incoming data to the right program. If an IP address is like the street address of a building, a port is like the flat number.

Port numbers range from 0 to 65,535. Some commonly used ports include:

  • Port 80 for ordinary web traffic
  • Port 443 for secure HTTPS traffic
  • Port 22 for SSH
  • Port 25 for sending email
  • Port 53 for DNS

A device also uses a temporary port for its side of a communication. This allows different conversations and programs to use the network at the same time.

The transport layer offers two contrasting approaches: UDP and TCP.

UDP: Fast, simple delivery

UDP is like sending a postcard. The sender sends data without waiting for confirmation that it arrived. UDP does not guarantee that all pieces will arrive or that they will arrive in order.

That simplicity can be useful for video calls, online games, and live streams. If a packet arrives too late to be useful, retransmitting it may be worse than accepting a brief glitch. A small interruption is often preferable to a frozen conversation.

TCP: Reliable, ordered delivery

TCP is more like registered post with tracking. It keeps track of the pieces sent, confirms their arrival, retransmits missing pieces, and gives the receiving application data in the right order. This is useful for web pages, email, and file downloads, where missing or rearranged data would cause problems.

Before TCP sends application data, the two sides establish a connection using a three-way handshake:

  1. The client sends SYN, indicating that it wants to communicate and giving an initial sequence number.
  2. The server replies with SYN-ACK, acknowledging the request and giving its own initial sequence number.
  3. The client sends ACK, confirming that it received the server’s response.

After the handshake, TCP numbers bytes with sequence numbers. The receiver sends acknowledgements to indicate how much data has arrived. If an acknowledgement does not arrive in time, the sender assumes data may have been lost and sends it again. Duplicate data can be discarded, while missing pieces are filled in. The application receives a complete, ordered stream.

When the conversation ends, each side sends FIN to say goodbye, and the other side acknowledges it. The handshake at the beginning and the orderly closing at the end help both devices keep track of the connection.

TCP’s Two Kinds of Control

TCP does more than deliver data reliably. It also controls sending rates in two ways.

Flow control protects the receiving device. The receiver tells the sender how much data it has room to accept, using a value called the window. A fast server should not overwhelm a slower phone.

Congestion control protects the network. If too much data is sent through a busy network, packets may be lost. Repeatedly sending more data in response can make the congestion worse.

This problem became especially visible during a congestion collapse in October 1986. Between two laboratories in Berkeley about 400 metres apart, the network’s speed fell from 32 kilobits per second to 40 bits per second—a thousandfold slowdown. Senders repeatedly retransmitted lost packets, causing more congestion and more losses. It was like a traffic jam in which every driver keeps pushing forward and honking.

Van Jacobson and colleagues helped address this problem. TCP now begins cautiously using slow start, increases its sending rate step by step, and backs off sharply when it detects loss. It then grows its rate again more gradually. The resulting rise-and-fall pattern is often described as a sawtooth. Modern methods have become more sophisticated, but the underlying idea remains: connections should increase their use of the network cautiously and respond to signs of congestion.

Think About It: Why does retransmitting data help with an isolated packet loss but risk making a congested network worse?

DNS: Turning Names into Addresses

People use names such as youtube.com; network routing uses IP addresses. DNS, the Domain Name System, translates names into addresses. It functions like a phone book, but no single book contains every name. Instead, DNS is organized as a hierarchy.

A DNS name is read from right to left through a tree of servers. The hierarchy includes the root, then top-level domains such as .com or .in, and then the servers responsible for individual organizations.

When a device needs an address, it asks a resolver, often operated by the internet provider. If the resolver already has a recent answer saved, it can return it immediately. Otherwise, it may ask a root server where to find the relevant top-level-domain server, ask that server where to find the organization’s name server, and then ask that name server for the final address.

There are 13 root-server identities, named A through M, but each is copied across many sites around the world. More than a thousand physical instances share those identities, helping a query reach a nearby server. DNS answers are often cached, or remembered, for a period of time, which is why many lookups take only milliseconds.

A wrong or malicious DNS answer can send users to the wrong destination, making DNS security important. In October 2016, a botnet called Mirai, built from hacked home cameras and video recorders, flooded the DNS company Dyn with junk traffic. Many people could not reach Twitter, Netflix, Reddit, and GitHub for hours, even though those services were still running. The problem was that users could not look up their addresses.

DHCP and ARP: Finding the Local Network

DHCP: Automatically getting network settings

When a device joins a Wi-Fi network, it usually does not need someone to type in its network settings. DHCP, the Dynamic Host Configuration Protocol, assigns them automatically.

Its four-message process is often remembered as DORA:

  1. Discover: The device asks whether a DHCP server is available.
  2. Offer: The router offers an address.
  3. Request: The device requests that address.
  4. Acknowledge: The router confirms the assignment.

The router also provides the subnet mask, default gateway, and DNS servers. The address is a lease, meaning it is temporary and must be renewed after a period of time.

ARP: Finding a local device’s MAC address

To send a frame to the router on a local network, a device needs the router’s MAC address. It may know the router’s IP address but not its MAC address. On a local network using IPv4, the device can use ARP, the Address Resolution Protocol, to find it.

The device sends a local broadcast asking which device has a particular IP address and requesting its MAC address. The device with that address replies. This resembles a teacher calling a roll number and waiting for the corresponding student to answer.

Because ARP relies on trusting these local replies, another device on a shared network can falsely claim to be the router. This is one reason public Wi-Fi needs encryption and other protections.

Think About It: How are DHCP and ARP different, even though both help a device communicate on a local network?

HTTP and the Web

At the application layer, the web commonly uses HTTP, the HyperText Transfer Protocol. HTTP follows a request-and-response pattern. A browser can send a request such as “GET this page,” and the server responds with a status code, headers, and the page content.

Status codes summarize what happened:

  • 200 means the request succeeded.
  • 301 means the resource has moved.
  • 404 means the requested resource was not found.
  • 500 means something went wrong on the server.

A 418 status code means “I’m a teapot.” It comes from a 1998 April Fools’ standard about controlling coffee pots over the internet. A teapot asked to brew coffee should refuse, and some real websites still use the code as a joke.

HTTP does not remember earlier requests by itself. Websites can use cookies—small pieces of information stored by the browser and sent back to the site—to help remember a login or the contents of a shopping cart.

HTTP has continued to develop. HTTP/2 can send many files over one connection at a time. HTTP/3 runs over QUIC, a newer protocol built on UDP. QUIC can make connections faster to start and work better on unstable mobile networks.

Think About It: Why might a website need cookies if HTTP does not remember earlier requests on its own?

HTTPS and TLS: Protecting the Conversation

Plain HTTP sends information in readable form. Someone able to observe traffic along the route—for example, on a café’s Wi-Fi—could potentially read or alter it. HTTPS protects HTTP by wrapping it in TLS, or Transport Layer Security.

TLS aims to provide three guarantees:

  • Privacy: People along the route should not be able to read the communication.
  • Integrity: Changes to the communication should be detectable.
  • Authenticity: The client should be able to check that it is communicating with the intended site.

A TLS connection must establish secret keys even though the client and server have not met and may be communicating over a path that others can observe. One analogy is mixing paint. Each side keeps a secret colour, combines it with a public colour, and exchanges the mixtures. Each can then combine the other side’s mixture with its own secret to reach the same final colour. An observer who sees only the public colour and exchanged mixtures cannot easily work out the secret. Real TLS uses mathematics rather than paint.

To check the server’s identity, the server presents a certificate—a digital identity card signed by a trusted certificate authority. A browser carries a list of trusted authorities and checks the certificate’s signature. Free certificate services such as Let’s Encrypt helped increase the adoption of HTTPS, and most web pages visited today are encrypted.

Other Protocols That Support the Internet

HTTP is prominent, but many other protocols perform essential jobs:

  • SMTP sends email between mail servers.
  • IMAP lets a person read email from different devices, helping an inbox stay consistent on a phone and a laptop.
  • SSH provides a secure remote terminal for controlling distant servers.
  • FTP was an older method for transferring files.
  • NTP keeps computer clocks synchronized, which matters for tasks such as bank transactions and checking security certificates.
  • ICMP carries network errors and test messages. The familiar ping tool sends an echo request and measures the time until an echo reply arrives. Its creator, Mike Muuss, named it after the sound of submarine sonar.
  • Wi-Fi and Bluetooth manage nearby radio links, while a mobile network manages the radio connection between a device and a tower.

These protocols use different methods, but IP provides a common way to carry packets across networks. An application can use IP, and IP can use many kinds of links—copper, fibre-optic cable, radio, or even an experimental pigeon carrier. Network engineers often draw this arrangement as an hourglass, with IP at the narrow middle: many applications sit above it, and many link technologies sit below it.

Think About It: How does having IP as a common layer help applications work across different kinds of network links?

Following One Web Request from Start to Finish

The separate ideas now fit together as a single journey:

  1. A device joins Wi-Fi. DHCP supplies an IP address, a subnet mask, a default gateway, and DNS servers.
  2. The device uses ARP to discover the router’s MAC address on the local network.
  3. The browser receives a website name. DNS finds the matching IP address, either from a cached answer or by asking through the DNS hierarchy.
  4. For a common HTTPS connection using TCP, the browser begins a TCP connection to port 443 with the three-way handshake.
  5. TLS establishes secret keys and checks the server’s certificate.
  6. The browser sends an encrypted HTTP request.
  7. The request is encapsulated in layers and sent through the home router. NAT may keep track of which private device made the request.
  8. Routers forward the packets hop by hop using routing information. BGP helps autonomous systems share route announcements. The route may cross an undersea cable.
  9. The server receives and unwraps the packets, processes the request, and sends the page back in packets.
  10. TCP reassembles the data in order, TLS decrypts it, and the browser draws the page.

HTTP/3 is an important variation: it uses QUIC over UDP rather than the common TCP-and-TLS sequence described above. In either case, the broader system still depends on protocols cooperating across layers.

Exploring and Learning More

Network knowledge is useful in software development, cloud computing, cybersecurity, data work, and AI. When a connection fails, understanding the layers helps identify where the problem may be.

Several tools reveal parts of the process:

  • ipconfig on Windows displays network information such as an address, mask, and gateway.
  • ping tests whether a machine responds and measures how long a reply takes.
  • tracert shows the hops packets encounter.
  • nslookup asks DNS about a name.
  • Wireshark displays packets entering and leaving a computer, making DNS lookups, TCP handshakes, and TLS handshakes visible.

A useful order for studying networking is to begin with layers and encapsulation, then practise IP addressing and subnetting, followed by routing, TCP and UDP, DNS, DHCP, and HTTP. Security concepts such as TLS and firewalls can then build on that foundation. Certifications such as CCNA follow roughly this progression.

Comprehensive Review

The internet works because many independent devices follow shared protocols. Packet switching breaks messages into pieces that can share network links and take alternate routes. Layers divide communication into manageable jobs: links carry bits, IP helps route packets, transport protocols connect data to programs, and application protocols provide services such as the web and email.

IP addresses identify destinations, while subnetting separates network locations from individual devices. Routers forward packets one hop at a time, and BGP shares routes among independently operated networks. Ports direct data to the right programs; TCP emphasizes reliable, ordered delivery, while UDP offers a simpler service suited to time-sensitive traffic. DNS translates human-readable names into IP addresses, DHCP supplies local network settings, and ARP helps find a local device’s MAC address.

HTTP carries web requests and responses. HTTPS protects those exchanges with TLS, which provides privacy, integrity, and a way to verify the server’s identity. From radio waves and fibre-optic cables to the application displayed in a browser, each part contributes to the same result: machines that may never have met exchange information by following common rules.

Ask anything

We've read this whole study set, so questions about it get the best answers.

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent