1. Home
  2. Explore
  3. Computer Science
  4. How the Internet Works

Study methods

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

How the Internet Works

How the Internet Moves Information

The internet can seem almost magical: a phone connects wirelessly, a laptop opens a website, and a video travels across oceans in real time. Underneath, however, the internet is a system of connected devices that follow agreed-upon rules for identifying one another, packaging information, routing it, and reassembling it at its destination.

A useful way to understand the internet is to follow a request from a device at home to a distant server and then follow the response back.

Connecting a Home to the Internet

A typical home network begins with an internet service provider, or ISP. Companies such as Comcast, Verizon, and other providers connect homes, schools, and businesses to the larger internet.

The connection entering a home may use several different technologies:

  • A cable modem connects through a coaxial cable, the type of cable traditionally used for television and cable service.
  • A DSL modem uses telephone-line technology.
  • A FiOS or fiber-optic device uses optical fiber, in which information travels as pulses of light.
  • A provider may supply a device that combines several of these functions.

The modem or fiber device connects the home to the ISP. The ISP, in turn, connects to the broader collection of networks called the internet.

The home router

A single modem connection does not necessarily explain how many devices in a home connect simultaneously. A home may also contain a router. The router connects to the modem and distributes network access to devices such as:

  • Phones
  • Laptops
  • Desktop computers
  • Game consoles
  • Digital video recorders
  • Other wired or wireless devices

Many home routers provide Wi-Fi, allowing devices to communicate through radio waves rather than cables. They may also contain physical Ethernet ports for wired connections.

Increasingly, one device supplied by an ISP may combine the functions of:

  • A modem
  • A router
  • A Wi-Fi access point
  • A DHCP server
  • A DNS service
  • A firewall
  • An Ethernet switch

In other homes, these functions may be divided among several separate devices. The exact arrangement depends on the equipment and service provided.

Modems, routers, and switches

These devices perform different jobs, even when one physical box contains all of them.

A modem connects the home network to the technology used by the ISP. It translates between the communication system used inside the home and the system used by the provider.

A router directs packets toward their destinations. It decides which connection or “next hop” should receive a packet.

A switch connects multiple wired devices on the same local network. For example, a small switch may provide several additional Ethernet ports. It examines local traffic and sends it through the appropriate port rather than sending it everywhere.

A home router often includes a switch, which is why several wired devices can plug into its back.

IP Addresses: Numerical Identities

For devices to communicate, each device needs an address. An IP address, short for Internet Protocol address, identifies a device or network location.

The familiar form of an IPv4 address contains four numbers separated by periods, such as:

1.2.3.41.2.3.41.2.3.4

Each number can range from 000 through 255255255. Since each number has 256256256 possible values, an IPv4 address contains:

4×8=324 \times 8 = 324×8=32

bits. The number of possible 323232-bit addresses is:

2322^{32}232

This is roughly four billion possible addresses.

An IP address functions much like a postal address. A postal address tells a physical letter where to go; an IP address tells a digital packet which computer or network location should receive it.

A laptop, desktop computer, phone, game console, and internet server all need IP addresses when they participate in internet communication.

How a device receives an IP address

In the past, a technician might manually configure a computer with an IP address. Modern networks usually automate this process with DHCP, or Dynamic Host Configuration Protocol.

When a device connects to a network, it can effectively ask:

“I need an IP address. What address should I use?”

A DHCP server responds with an address and additional network information. The DHCP server may be operated by:

  • The ISP
  • A home router
  • A university
  • A business
  • Another organization managing the network

The public-facing connection from an ISP may receive one address, while the home router assigns separate local addresses to the devices inside the home.

Public and private addresses

Many devices inside homes, schools, and businesses use private IP addresses. Examples include addresses beginning with:

  • 10.10.10.
  • 192.168.192.168.192.168.
  • 172.16.172.16.172.16.

A device such as 10.0.1.3410.0.1.3410.0.1.34 is generally intended for use within a private network. It is not normally directly reachable from every computer on the public internet.

This arrangement works because most home devices are not intended to act as public servers. A phone or laptop usually initiates connections to services such as Gmail or a website. Even when another person sends an email, the message generally goes to an email provider’s server rather than directly to the recipient’s laptop. The recipient’s device later connects to the server to retrieve the message.

A router can therefore manage communication between many private devices inside a home and the wider internet.

Domain Names and DNS

People usually access websites by typing names such as Facebook.com, Gmail.com, or Google.com. Computers, however, communicate using IP addresses.

Remembering a name is much easier than remembering an arbitrary numerical address. The Domain Name System, or DNS, solves this problem by translating domain names into IP addresses.

A DNS server answers questions such as:

“What IP address corresponds to Google.com?”

The answer might be an address such as 5.6.7.85.6.7.85.6.7.8 in an illustrative example. The actual address can vary depending on location, time, and the way a company organizes its servers.

The DNS hierarchy

A local device commonly receives the address of one or more DNS servers through DHCP. Those DNS servers may be operated by the ISP or another organization.

If a DNS server does not already know the answer, it can ask another DNS server. The request may move through a hierarchy until a server provides the needed result. At the highest level are root servers, which help direct questions toward the servers responsible for particular top-level domains, such as:

  • .com
  • .edu
  • Other top-level domains

This creates a recursive or tiered lookup system. The computer does not need to know the numerical address in advance; it asks DNS to find it.

After receiving the IP address, the computer can place that address into the information used to send a packet.

DNS translates human-friendly domain names into the IP addresses that computers use to communicate.

Think About It: Why would a website still need an IP address even if people access it using a domain name?

Packets: Digital Envelopes

Computers communicate across the internet by sending packets. A packet is a small unit of digitally encoded information, represented ultimately as zeros and ones.

A helpful analogy is a physical letter:

  • The message is the data.
  • The envelope contains addressing information.
  • The postal system carries the envelope toward its destination.
  • The recipient opens and interprets the message.

Suppose a computer wants a server to return an image file called cat.jpeg. The request must include more than just the words “get me a cat.” It must be packaged with information identifying both the sender and the destination.

An illustrative packet might contain:

  • Source IP address: 1.2.3.41.2.3.41.2.3.4
  • Destination IP address: 5.6.7.85.6.7.85.6.7.8
  • A request for cat.jpeg

The source address tells the recipient where the packet came from. The destination address tells the network where the packet should go.

IP: Addressing and Fragmentation

IP, or Internet Protocol, is not merely a collection of addresses. It is a set of conventions that computers and network devices follow when exchanging packets.

Among IP’s responsibilities are:

  • Identifying the source and destination
  • Supporting packet delivery across networks
  • Providing information related to fragmentation
  • Defining how packets should be structured and interpreted

Fragmenting large data

A large file may not fit conveniently into one packet. Even if it could, placing one enormous packet onto the network could delay other users’ traffic. Instead, the data can be divided into smaller pieces called fragments.

For example, an image might be divided into four fragments. Each fragment can be placed into its own packet:

  • Packet 111 of 444
  • Packet 222 of 444
  • Packet 333 of 444
  • Packet 444 of 444

Each packet contains the source and destination addresses. The numbering also tells the receiving computer how many pieces exist and helps it determine which piece is missing.

Packets do not necessarily travel together. One fragment might follow one route while another fragment follows a different route. If all pieces eventually arrive, the receiving computer can reassemble them into the original image.

IP alone, however, does not guarantee that every packet will arrive or explain how missing packets should be recovered. That is where TCP becomes important.

TCP/IP: Reliable Communication

The term TCP/IP refers to the common combination of:

  • TCP, or Transmission Control Protocol
  • IP, or Internet Protocol

IP helps address and move packets. TCP adds mechanisms for making communication reliable.

TCP can use sequence numbers and acknowledgments to help ensure that:

  • Packets reach the intended destination
  • Packets are placed in the correct order
  • Missing packets are detected
  • Missing data can be retransmitted

Imagine that a computer receives packets 222, 333, and 444 of a four-packet response but does not receive packet 111. The computer can infer that the first packet is missing and request it again. The sender retransmits the missing packet, allowing the receiver to reconstruct the complete file.

Because the packets contain only encoded data, the receiving computer can stitch the pieces back together without the user needing to know that the file was split apart.

Ports: Identifying Services

An IP address identifies a computer or network location, but it may not identify the particular service that should receive the data.

A large company may operate many services at the same IP address:

  • A web server
  • An email server
  • A chat server
  • A video-conferencing server
  • Other applications

A port number identifies the intended service on that computer.

A packet might therefore contain information conceptually similar to:

  • Destination IP address: 5.6.7.85.6.7.85.6.7.8
  • Destination port: 808080

Port 808080 is traditionally associated with HTTP, or Hypertext Transfer Protocol, the protocol used by ordinary web servers.

Modern secure web connections generally use HTTPS, which commonly uses port 443443443. Email and file-transfer services use other port numbers. The port tells the receiving computer which application should handle the packet.

HTTP as a communication protocol

HTTP is a protocol, meaning a set of rules for communication. A browser and a web server follow these rules so that each knows what the other’s messages mean.

A browser sends an HTTP request. A web server interprets the request and sends an HTTP response. The response might contain an image, a web page, or other requested information.

Protocols are similar to social conventions. A handshake works because both participants understand the expected sequence. Likewise, a web browser and web server can communicate because both follow HTTP’s rules.

A protocol is an agreed-upon set of standards that allows communicating systems to understand what messages mean and how to respond.

TCP and UDP

Not every application needs the same kind of delivery.

TCP

TCP emphasizes reliable delivery. If a packet is lost, TCP can arrange for it to be sent again. This is useful when every part of the data matters, such as:

  • A web page
  • An image
  • An email
  • A file
  • A document

A missing piece of a file cannot simply be ignored, so retransmission is valuable.

UDP

UDP, or User Datagram Protocol, does not guarantee delivery in the same way. It can send data without requiring missing packets to be retransmitted.

This may seem less reliable, but it can be useful when speed and continuity matter more than perfect completeness.

Consider a live video conversation. If one small packet containing part of a person’s video or audio is lost, stopping the entire conversation to resend it may be more disruptive than simply continuing. The viewer may infer the missing information from context, or ask the speaker to repeat something.

UDP can therefore be useful for:

  • Live video conferencing
  • Real-time voice communication
  • Live sporting events
  • Other high-volume, time-sensitive applications

A recorded movie usually benefits from buffering and reliable delivery because missing a scene is undesirable. A live conversation may instead prioritize staying current, even if a few pieces of information are lost.

Think About It: Why might a live video call prefer speed over perfect delivery, while a downloaded document requires reliable delivery?

Routers and the Journey of a Packet

A laptop generally does not know the complete route to every computer in the world. Instead, it sends packets to a router, also called a gateway.

For example, a device might have:

  • IP address: 10.0.1.3410.0.1.3410.0.1.34
  • Router or gateway: 10.0.1.110.0.1.110.0.1.1

The router examines the packet’s destination and decides where to send it next.

Routing tables

Routers maintain routing information in memory. Conceptually, a routing table contains:

  1. An IP address or address prefix
  2. A direction or next hop for traffic matching that address

For example, a router may have one path for addresses beginning with one pattern and another path for addresses beginning with a different pattern. The router does not necessarily need to know the entire journey. It only needs to choose a suitable next step.

The packet may travel from one router to another, with every router making another forwarding decision. Each router is a hop in the journey.

If one router does not know the final destination, it forwards the packet to another router. With enough successive decisions, the packet moves closer to its destination.

The internet as a network of networks

The internet is not one single machine or one single cable. It is a network of networks.

Universities, internet service providers, technology companies, businesses, and other organizations operate their own networks. These networks connect their routers to one another using:

  • Physical cables
  • Fiber-optic connections
  • Radio links
  • Satellite connections
  • Undersea cables
  • Other communication technologies

Because many networks interconnect, information can move across cities, countries, and oceans.

Multiple paths and resilience

There are often several possible routes between two locations. This is an important design feature.

If one router or connection fails, traffic may be able to travel along a different path. The internet was designed with resilience in mind: communication should continue even when parts of the network become unavailable.

Different packets in the same response may therefore take different routes. The destination addresses remain the same, but the intermediate routers can differ.

Network traffic can also become congested. When routers are busy, they may:

  • Send packets along alternate routes
  • Delay packets
  • Drop packets when their capacity is overwhelmed

If TCP is being used, dropped packets can be detected and retransmitted. If UDP is being used, the application may simply continue without the missing data.

Measuring Routes with Traceroute

A tool called traceroute reveals the sequence of routers between one device and a destination.

When traceroute runs, it sends specially structured messages that cause routers along the path to identify themselves or respond. The tool reports:

  • The hop number
  • The router’s name or IP address
  • The time required to reach that hop

A traceroute to a nearby destination might pass through only a few routers. A traceroute across the United States or to another country might pass through many more.

The names of routers sometimes provide clues about their locations or organizations. Names may include:

  • Network or university names
  • ISP names
  • Geographic abbreviations
  • Airport codes
  • Terms such as “core,” “border,” or “gateway”

However, not every router responds to traceroute. A row of asterisks does not necessarily mean that the route has failed; it may mean that a router is configured not to answer that type of inquiry.

Understanding traceroute timing

Traceroute reports how long it takes to reach each listed router from the original computer. The measurements are not simply cumulative values that should all be added together.

A short delay may indicate a nearby router. A larger increase between two points may suggest a long physical distance or a slower connection. A major delay between a router in Seattle and one in Japan, for example, could reflect the time required for traffic to cross the Pacific Ocean.

The internet’s long-distance connections may use undersea cables, satellites, or other technologies. Even when the route crosses an ocean, the data can arrive in a fraction of a second.

A route from Cambridge, Massachusetts, to Berkeley, California, may involve many hops but still take roughly tens of milliseconds. A nearby website may be only a few milliseconds away, even if the organization associated with the website is physically close but hosts its servers elsewhere.

Content Delivery Networks

A website’s servers are not always located where the organization itself is located.

A university website may be hosted partly by a Content Delivery Network, or CDN. A CDN stores or serves website content from distributed servers, often placing content closer to users.

This can improve performance because the user’s packets do not always need to travel to the organization’s primary location. DNS can direct the user toward an appropriate server, while routers carry the traffic along the available network path.

Thus, a person may think of a website as belonging to one institution, while traceroute reveals that the actual web server is operated by another company in a different city.

Think About It: Why might a university use servers operated by a separate CDN instead of serving every webpage directly from its own campus?

The Physical Hardware Behind the Internet

The internet depends on physical equipment, even though users often experience it as software and invisible wireless communication.

Coaxial connectors

A cable modem commonly has a coaxial connector. Coaxial cables are relatively thick and typically have:

  • A cylindrical metal connector
  • A central pin
  • A threaded connection that may screw into the device

One end may connect to the modem, while the other connects to a wall outlet connected to the ISP’s cable network.

RJ11 telephone connectors

An RJ11 connector is the smaller connector traditionally associated with telephone lines. It can be used for telephone service provided through certain internet devices.

RJ45 Ethernet connectors

An RJ45 connector is wider and is commonly used with Ethernet cables. Ethernet cables provide wired network connections for devices such as:

  • Desktop computers
  • Game consoles
  • Routers
  • Switches
  • Other networked equipment

A cable modem or router may have several RJ45 ports for wired devices.

Fiber-optic cables

A fiber-optic cable carries information using light traveling through thin strands of optical material. Fiber can transmit information extremely quickly compared with signals carried through ordinary copper wires.

What is inside an Ethernet cable?

An Ethernet cable contains multiple individual wires enclosed within an outer protective sheath. The wires may be:

  • Solid-colored
  • Striped
  • Twisted together
  • Used for transmitting signals
  • Used for receiving signals
  • Used to reduce interference or provide insulation

For communication to work, the wiring arrangement at one end must correspond correctly to the arrangement at the other end. The cable itself is relatively simple; much of the complexity of the internet comes from the protocols, addressing systems, routers, and software layered on top of the physical wires.

IPv4 and IPv6

The familiar four-number address format is called IPv4, or Internet Protocol version 444. IPv4 uses 323232-bit addresses, allowing approximately four billion possible combinations.

The internet has been using addresses rapidly because many kinds of devices need them:

  • Phones
  • Computers
  • Servers
  • Network equipment
  • Internet of Things devices

Because the number of IPv4 addresses is limited, the internet is gradually adopting IPv6, or Internet Protocol version 666.

IPv6 uses 128128128-bit addresses rather than 323232-bit addresses. The number of possible addresses is therefore:

21282^{128}2128

This is vastly larger than 2322^{32}232 because the exponent determines how quickly the number of possibilities grows.

A computer’s network settings may show whether it is using IPv4, whether DHCP assigned the address, which router serves as its gateway, and which DNS servers it uses.

The Complete Journey of a Web Request

The major concepts can now be combined into one sequence.

  1. A device connects to a home router or another local network.
  2. DHCP provides the device with an IP address and network settings.
  3. The device requests the IP address associated with a domain name through DNS.
  4. DNS returns the numerical address of the destination server.
  5. The device creates a packet containing source and destination information.
  6. A port number identifies the service that should handle the request, such as HTTP on port 808080 or HTTPS on port 443443443.
  7. IP helps address the packet and move it through the network.
  8. Routers forward the packet from one hop to the next.
  9. The server receives the request and interprets it using the appropriate application protocol, such as HTTP.
  10. The server divides a large response into packets if necessary.
  11. The packets travel back through routers, possibly along different paths.
  12. TCP detects missing or incorrectly ordered data when reliable delivery is required.
  13. The receiving device reassembles the packets into the original image, webpage, file, or other response.

All of this can happen so quickly that the user experiences it as a single action: entering a website address and receiving a webpage.

Comprehensive Review

The internet works because several layers cooperate.

  • A home modem or fiber device connects a local network to an ISP.
  • A router connects multiple local devices and directs traffic toward other networks.
  • DHCP assigns IP addresses and related network settings automatically.
  • DNS translates domain names into IP addresses.
  • IP provides addressing and supports the movement and fragmentation of packets.
  • TCP provides sequencing, acknowledgments, and retransmission for reliable delivery.
  • UDP offers faster communication without guaranteeing that every packet arrives.
  • Port numbers identify the particular service that should receive a packet.
  • Routers use routing tables to forward packets toward their destinations.
  • Multiple routes provide flexibility and resilience when connections fail or become congested.
  • Traceroute reveals the hops and approximate timing along a route.
  • Physical media, including copper cables, coaxial cables, fiber-optic cables, radio waves, satellites, and undersea cables, carry the underlying signals.
  • IPv4 uses 323232-bit addresses, while IPv6 uses 128128128-bit addresses to provide a much larger address space.
  • Content delivery networks can place website servers in locations different from the organization that owns the website.

The internet is therefore best understood as a layered system: physical connections carry signals, protocols define how those signals are organized, addresses identify destinations, DNS helps humans use names, routers choose paths, and transport protocols determine how reliably information arrives.

Ask anything

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

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent