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 Works: Study Notes

1. The internet and its protocols

The internet is a global network of networks. A request from a phone or computer may pass through many devices and networks before reaching a server, then travel back along a route that may be different. The system works because the devices follow shared rules called protocols. These rules let equipment made and operated by different organisations communicate reliably.

The most important foundational protocols are TCP/IP:

  • IP, the Internet Protocol, provides addressing and moves packets between networks.

  • TCP, the Transmission Control Protocol, provides a reliable, ordered flow of data between programs.

  • Other protocols handle particular tasks, such as translating names into addresses, securing web traffic, and assigning network settings.

The internet is not the same thing as the World Wide Web. The internet is the underlying network infrastructure; the Web is one service that runs on it, alongside email, online games, file transfers, and many others. A useful analogy is that the internet provides the roads, while the Web is one kind of traffic using them.

A brief history

  • In 1969, Charley Kline attempted to log in to a computer at the Stanford Research Institute from UCLA over ARPANET, an early network. He typed “L” and “O,” but the system crashed after he typed “G.” The first message sent over the network that became the internet was therefore “LO.” The login succeeded about an hour later.

  • As ARPANET grew, separate networks needed a way to communicate with one another. In 1974, Vint Cerf and Bob Kahn published a design for connecting networks, which became TCP/IP.

  • On January 1, 1983, ARPANET switched to TCP/IP in a coordinated change often called “flag day.” This is commonly considered a key milestone in the internet’s development.

  • In 1989, Tim Berners-Lee proposed the World Wide Web at CERN. The Web came after the internet and operates as a service on top of it.


2. Packets and packet switching

A message sent over the internet is divided into small units called packets. A packet carries data along with information needed to deliver it, such as source and destination addresses. Packets are often around 1,500 bytes, though their size varies.

This approach is called packet switching. It differs from the older circuit-switched telephone model:

  • In circuit switching, a dedicated connection is reserved between two endpoints for the entire call, even during pauses.

  • In packet switching, a message is divided into pieces that share network capacity with other users. Packets can travel by different routes and arrive in a different order from the one in which they were sent.

  • At the destination, the packets are assembled into the original data. Protocols such as TCP can identify missing or out-of-order pieces and arrange for them to be handled appropriately.

A useful analogy is mailing a book as numbered postcards. Each postcard carries a piece of the book and its page number. The postcards might take different routes and arrive out of order, but their numbers allow the recipient to reconstruct the book.

Packet switching makes efficient use of shared network links: many people can use the same cables or wireless channels at once. It also helps the network tolerate failures. If one route is damaged or unavailable, packets can be sent along another route.


3. Network layers and encapsulation

Networking involves many different jobs, so protocols are organised into layers. Each layer handles a particular task and relies on the layer below it. The TCP/IP model has four layers:

  • Application layer: The data or service a person uses, such as a web page, email, or chat message.

  • Transport layer: TCP or UDP moves data between programs on devices. TCP can provide reliability and ordering; UDP provides a simpler, lower-overhead service.

  • Internet layer: IP addresses packets and helps carry them across interconnected networks.

  • Link layer: Moves data across one local connection, such as Wi-Fi, Ethernet, or fibre.

The layers can be compared to preparing a gift for delivery. A message is put inside a package; the package receives a local address; additional routing information identifies the broader destination; and a vehicle physically carries it. Each stage adds information needed by the next stage.

When a layer adds its own information around the data it receives from the layer above, the process is called encapsulation. The information added by a layer is commonly called a header. At the destination, the receiving device processes the layers in reverse order, removing each layer’s information as it passes the data upward.

The OSI model is another way to describe networking. It divides related responsibilities into seven layers rather than four. It is widely used as a conceptual guide, and its layer numbers appear in everyday technical language. For example, a “layer seven” issue is an application-layer problem.


4. The link layer: moving bits locally

At the most basic level, network communication consists of bits. The physical medium determines how those bits are represented:

  • Copper cables carry electrical signals.

  • Fibre-optic cables carry pulses of light.

  • Wi-Fi and mobile networks use radio waves.

Ethernet is a common standard for local wired networks. A network card has a MAC address, a hardware address that is 48 bits long and usually written as six pairs of letters and numbers. On a local network, switches use MAC addresses to send frames to the intended device.

The link carrying a packet can change as it travels. One part of a journey may use Wi-Fi, another fibre, and another copper cable. The internet’s design does not require IP packets to use a single type of physical link.

Most data travelling between continents is carried by undersea fibre-optic cables laid along the ocean floor. Satellites carry a much smaller share of this traffic.

The link technology can be unusual and still carry IP. A 1990 April Fools’ document described “IP over Avian Carriers,” meaning packets carried by pigeons. In 2001, a Linux user group in Bergen, Norway, actually sent pings using pigeons. Four of nine pings returned, with delays of roughly 50 minutes to 1 hour and 45 minutes. The experiment was extremely slow and unreliable by modern standards, but it illustrated a key design principle: IP can operate over many different kinds of links.


5. IP addresses and subnetting

An IP address identifies a device or network interface for communication using IP. Like a postal address, it helps direct data to its destination.

IPv4

IPv4 uses 32-bit addresses. These are commonly written as four numbers separated by dots, with each number ranging from 0 to 255; for example, 142.250.183.14. The total address space contains 2322^{32}232 possible addresses, or about 4.3 billion.

That number once seemed ample, but the growth of phones, computers, televisions, cameras, and other connected devices led to a shortage. The central pool of new IPv4 addresses was exhausted in 2011.

Private addresses and NAT

One way to cope with the limited IPv4 address space is Network Address Translation (NAT). A home router can use one public address on the internet while assigning private addresses to devices inside the home. Private addresses, such as 192.168.1.5, can be reused in many different homes because they are not unique across the public internet.

The router keeps track of which internal device initiated a connection so that replies arriving at the public address can be directed to the correct device. This resembles an apartment building with one street address: a gatekeeper records which apartment made a request and routes the reply to the right apartment. Mobile providers may also use NAT on a large scale, allowing many phones to share a public address.

Networks, hosts, and CIDR

IP addresses are assigned in blocks. An address can be divided into:

  • A network part, which identifies the network.

  • A host part, which identifies a device or interface within that network.

A subnet mask or prefix length specifies where that division occurs. For example, the block 192.168.1.0/24 has a network prefix of 24 bits, leaving 8 bits for the remaining addresses. An 8-bit host field represents 256 possible values, though in the conventional IPv4 subnet described here, one address identifies the network and another is used for broadcast. That leaves 254 addresses for devices.

The prefix /24 is equivalent to the subnet mask 255.255.255.0. A shorter or longer prefix changes the block size:

  • A /16 block contains more than 65,000 addresses.

  • A /30 block contains four addresses.

This flexible method of specifying address blocks is called Classless Inter-Domain Routing (CIDR). It allows organisations to receive blocks sized more closely to their needs.

When a computer needs to send data, it checks whether the destination is within its own subnet. If it is, the computer can send the data directly on the local network. If not, it sends the packet to its default gateway, usually the router that connects the local network to other networks.

IPv6

IPv6 was developed to provide a vastly larger address space. Its addresses are 128 bits long and are written as groups of hexadecimal digits separated by colons. Consecutive groups of zeros can be shortened using a double colon.

IPv6 provides 21282^{128}2128 possible addresses—about 340 undecillion, or approximately 3 followed by 38 zeros. This is enough for an enormous number of unique public addresses, greatly reducing the need for NAT. IPv6 also uses a simplified packet header intended to make packet handling faster for routers.

IPv4 and IPv6 do not directly communicate as though they were the same protocol, so the internet currently operates both side by side. The transition is gradual, and a large and growing share of traffic uses IPv6.


6. Routers, routing, and the global internet

A router forwards packets between networks. Rather than knowing every detail of a packet’s entire journey, a router generally makes a local decision: which next connection, or next hop, should receive the packet?

Routers use routing tables, which contain destination address ranges and the next hops used to reach them. When several entries match a destination, the router chooses the most specific match, known as the longest prefix match. A default route provides a next step for destinations that do not match a more specific entry.

TTL and traceroute

An IP packet includes a counter called time to live (TTL). Each router reduces the counter as it forwards the packet. When the counter reaches zero, the packet is discarded and an error message is sent back. This prevents a packet caught in a routing loop from circulating forever.

The diagnostic tool traceroute uses TTL values to reveal the sequence of routers between a device and a destination. It sends packets with progressively larger TTL values. Each packet expires at a different hop, allowing the tool to identify the router at that point in the path. On Windows, the equivalent command is tracert. A route may include many hops, sometimes revealing the names or locations associated with routers.

Autonomous systems and BGP

The internet consists of tens of thousands of independently operated networks called autonomous systems. These may be run by internet providers, companies, universities, or other organisations.

The Border Gateway Protocol (BGP) is used to exchange routing information between autonomous systems. A network announces which address blocks can be reached through it. Neighbouring networks pass announcements along, helping other networks determine where to send traffic. In this sense, BGP resembles a system of route announcements shared among large networks.

Because networks depend on these announcements, an incorrect or misleading announcement can disrupt traffic:

  • In 2008, Pakistan Telecom announced a more specific route for YouTube addresses as part of an attempt to block YouTube inside Pakistan. The route announcement spread beyond the country, causing much of the world’s YouTube traffic to be directed toward Pakistan. YouTube became unreachable for many people for about two hours.

  • In 2021, a maintenance command disconnected Facebook’s backbone network. Facebook’s BGP routes were withdrawn, making Facebook, Instagram, and WhatsApp unreachable for about six hours.

A system called Resource Public Key Infrastructure (RPKI) allows networks to attach cryptographic information to route announcements. This helps other networks check whether a network is authorised to announce particular address blocks.


7. Ports and transport protocols

An IP address gets data to the correct device, but a device may run many programs at once. A port number identifies the program or service that should receive transport-layer data. Port numbers range from 0 to 65,535.

Some commonly used ports are:

  • Port 80: ordinary HTTP web traffic.

  • Port 443: HTTPS web traffic.

  • Port 22: SSH remote access.

  • Port 25: sending email using SMTP.

  • Port 53: DNS.

A client also uses a temporary port for its side of a conversation. The combination of network addresses and port information helps identify the communicating endpoints and applications.

UDP and TCP

The transport layer commonly uses UDP or TCP:

  • UDP, the User Datagram Protocol, sends data with little overhead. It does not itself guarantee delivery or put data back in order. It can be useful when speed and timeliness matter more than perfect delivery.

  • TCP, the Transmission Control Protocol, provides a reliable, ordered stream of data. It tracks what has been sent, confirms receipt, retransmits missing data, and ensures that the receiving program gets the data in order.

TCP is useful when every byte matters, as with many web pages, emails, and file downloads. UDP is often useful for video calls, online games, and live streams, where a late packet may be less valuable than a small, brief glitch.


8. TCP connections, reliability, and congestion control

The three-way handshake

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

  1. The client sends SYN, indicating that it wants to start a connection and providing an initial sequence number.

  2. The server replies with SYN-ACK, acknowledging the client’s message and providing its own initial sequence number.

  3. The client sends ACK, acknowledging the server’s message.

Once the handshake is complete, the endpoints can exchange data. The sequence numbers help TCP track the data, much like page numbers help a receiver reassemble numbered postcards.

Acknowledgements, retransmission, and orderly closure

The receiver sends acknowledgements to indicate which data has arrived. If an acknowledgement does not arrive within the expected time, the sender may assume that data was lost and retransmit it. TCP can identify duplicates, account for gaps, and deliver a complete, ordered stream to the application.

When a TCP conversation ends, each side can send a FIN message to indicate that it is finished. The other side acknowledges the close. This provides an orderly end to the connection.

Flow control

Flow control protects the receiving device from being overwhelmed. The receiver tells the sender how much data it can accept, using a value known as a window. A fast server can therefore adjust its sending rate to suit a slower phone or other receiver.

Congestion control

Congestion control protects the network from too much traffic. If many senders transmit aggressively at once, the result can be congestion and packet loss. Repeatedly resending lost packets without reducing the sending rate can make the congestion worse.

In 1986, an early internet connection between two laboratories in Berkeley suffered a dramatic slowdown: its speed fell from about 32 kilobits per second to 40 bits per second. Van Jacobson and colleagues developed congestion-control methods in response.

TCP typically starts cautiously, increasing its sending rate as conditions allow. When it detects signs of loss, it reduces the rate and then increases it again gradually. This balance allows connections to make use of available capacity while sharing network links. Modern TCP implementations use more advanced techniques, but they retain this basic principle of adjusting to network conditions.


9. DNS: translating names into addresses

People use names such as youtube.com, while IP communication uses numerical addresses. The Domain Name System (DNS) translates domain names into information such as IP addresses.

DNS is distributed rather than stored in one global phone book. It has a hierarchy that can be followed from right to left:

  • The root provides information about top-level domains.

  • Top-level domains include names such as .com and .in.

  • An organisation’s name servers provide information about its own domain.

A device typically asks a DNS resolver, often operated by its internet provider. If the resolver does not already have the answer cached, it can query the hierarchy: it asks a root server where to find the relevant top-level domain, then asks a top-level domain server where to find the domain’s name server, and finally asks that name server for the requested record.

There are 13 named root-server identities, labelled A through M. In practice, each identity is replicated across many locations worldwide, so the system has more than a thousand instances. This helps DNS queries reach a nearby server.

DNS answers are cached for a period of time. Caching reduces repeated queries and allows many lookups to be completed quickly. Incorrect or manipulated DNS information can send users to the wrong destination, which is why DNS security matters.

In 2016, the Mirai botnet, made from compromised home cameras and video recorders, flooded the DNS provider Dyn with traffic. Many people were temporarily unable to reach services such as Twitter, Netflix, Reddit, and GitHub, even though those services themselves were operating. Their names could not be reliably looked up.


10. DHCP and ARP on a local network

DHCP: receiving network settings

When a device joins a Wi-Fi or wired network, it usually receives its network settings automatically through Dynamic Host Configuration Protocol (DHCP). Its four-message exchange is often remembered as DORA:

  1. Discover: The device looks for a DHCP server.

  2. Offer: The server offers an address.

  3. Request: The device requests the offered address.

  4. Acknowledge: The server confirms the assignment.

DHCP can provide more than an IP address. It can also provide the subnet mask, default gateway, and DNS servers. The address is generally leased for a period of time, so the device may need to renew the lease.

ARP: finding a local MAC address

On an IPv4 local network, a device may know a router’s IP address but still need its MAC address to send a local frame to it. Address Resolution Protocol (ARP) helps connect the two. A device broadcasts a question asking which local device has a particular IP address; the device with that address replies with its MAC address.

ARP is a trusting local-network protocol. A malicious device on a shared network may falsely claim to be another device, such as the router. This is one reason shared public Wi-Fi networks require additional security measures.


11. HTTP and the Web

The Web uses HyperText Transfer Protocol (HTTP) to exchange requests and responses. A browser sends a request, such as asking for a page, and the server replies with a status code, headers, and content.

Common HTTP status codes include:

  • 200: The request succeeded.

  • 301: The resource has moved and the browser should look elsewhere.

  • 404: The requested resource was not found.

  • 500: The server encountered an error.

  • 418: “I’m a teapot,” a humorous status associated with a 1998 April Fools’ standard about controlling coffee pots over the internet.

As a broad rule, codes in the 400 range indicate a problem with the request or client, while codes in the 500 range indicate a server-side problem.

HTTP does not automatically remember previous requests. Websites use cookies, small pieces of information that a browser stores and sends back in later requests. Cookies can let a site remember that a user is logged in or that items remain in a shopping cart.

HTTP has developed over time:

  • HTTP/2 allows multiple resources to be transferred over a single connection at once.

  • HTTP/3 uses QUIC, a transport protocol built on UDP. It can make connections quicker to establish and can work better on unstable mobile networks.


12. HTTPS and TLS security

Plain HTTP is not encrypted. Someone able to observe traffic along the path, such as on an unsecured public network, may be able to read or alter it. HTTPS is HTTP protected by Transport Layer Security (TLS).

TLS provides three major guarantees:

  • Privacy: People in the middle of the connection should not be able to read the protected communication.

  • Integrity: Changes to protected data can be detected.

  • Authenticity: The client can check that it is communicating with the intended site rather than an impostor.

The client and server need to agree on cryptographic keys even though they have not met and may be communicating across a network that others can observe. TLS uses cryptographic methods to establish shared secrets securely. A paint-mixing analogy helps illustrate the idea: each side keeps a secret colour, mixes it with a public colour, and exchanges the mixtures. Each side can use its private colour to reach the same final mixture, while an observer who sees only the public exchanges cannot readily reproduce it. Real TLS uses mathematics rather than paint.

To help verify a server’s identity, the server presents a digital certificate. A trusted certificate authority signs the certificate. Browsers maintain information about authorities they trust and check the certificate’s signature and validity. Free certificate services such as Let’s Encrypt helped make HTTPS available to many more websites. Today, most web pages people visit are encrypted.


13. Other important network protocols

The internet supports many services beyond the Web:

  • SMTP sends email between mail servers.

  • IMAP lets users read and manage email from multiple devices while keeping the mailbox synchronised.

  • SSH provides a secure remote terminal for controlling computers and servers.

  • FTP was an older protocol for transferring files.

  • NTP synchronises clocks across networks, often to within milliseconds. Accurate time matters for tasks such as financial transactions and checking security certificates.

  • ICMP carries network error and testing messages.

  • Ping, a well-known ICMP-based diagnostic tool, sends an echo request and measures the time until an echo reply returns. Its name comes from the sound of sonar: send a signal and wait for an echo.

  • Wi-Fi and Bluetooth provide nearby wireless links.

  • Mobile networks provide the radio connection between a device and a mobile tower.

These technologies can vary while the IP packets above them remain part of the same internet architecture. IP is the common layer that allows different applications to work across different kinds of links. This arrangement is often represented as an hourglass: many technologies and applications narrow to a common waist at IP, then expand again into many kinds of network links.


14. Following a web request from start to finish

A single click can involve many protocols working together:

  1. Joining a network: DHCP gives the phone an IP address, subnet mask, default gateway, and DNS-server information.

  2. Finding the router locally: ARP discovers the router’s MAC address so the phone can send a local frame to it.

  3. Looking up the site: DNS translates the website name into an IP address. The answer may come from a cache or from a sequence of DNS servers.

  4. Establishing transport: The browser opens a TCP connection to the site’s HTTPS service, normally using port 443. TCP’s three-way handshake establishes the connection.

  5. Securing the connection: TLS checks the server’s certificate and establishes cryptographic keys.

  6. Sending the request: The browser sends an encrypted HTTP request, such as a request for a page.

  7. Crossing networks: Data is encapsulated in layers and sent through the home router. NAT may translate its private address. Routers forward packets hop by hop using their routing information, which depends in part on route information shared through BGP. The path may include undersea fibre cables.

  8. Returning the page: The server processes the request and sends the response back in packets.

  9. Reassembling and displaying: TCP arranges the received data in order, TLS decrypts it, and the browser uses the resulting content to draw the page.

These steps often complete in less than a second, even though the communication may involve many independent machines and networks.


15. Exploring and learning networking

Networking knowledge is useful in software development, cloud computing, cybersecurity, data systems, and AI. Understanding the layers helps diagnose problems by identifying which part of the communication is failing.

Useful tools include:

  • ipconfig on Windows to view IP address, subnet mask, and gateway information.

  • ping to test whether a device responds and to measure response time.

  • tracert to inspect the routers along a route.

  • nslookup to ask DNS for information directly.

  • Wireshark, a packet-analysis tool that can display traffic entering and leaving a computer. It can reveal DNS lookups, TCP handshakes, and TLS handshakes.

A practical learning sequence is to begin with layers and encapsulation, then study IP addressing and subnetting, routing, TCP and UDP, DNS, DHCP, and HTTP, and finally network security topics such as TLS and firewalls. Networking certifications such as CCNA follow a broadly similar progression.

The central idea is that internet communication is a coordinated exchange among many independent devices. Packets carry data, protocols define how devices handle it, and shared standards allow the pieces to work together across different networks and physical links.

Ask anything

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

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent