How Does The Internet Work?

Welcome to Chapter 1, lesson 1 of a new series for novice web developers. This series is designed for individuals looking to transition into web development without the high costs associated with traditional courses that may add to your stress or worsen imposter syndrome. As someone who successfully transitioned from a nurse to a self-taught software developer, I'll provide you with firsthand guidance to help you advance from a novice to a proficient developer. Let's learn and work towards our goals together.

What we’re going to discuss is a prerequisite to software development that is often overlooked. Learning how the internet works is often skipped by novice web developers when starting their self-taught career. Its relevance may not be obvious in the short term but in the long run, it is essential to know what transpires under the hood when you start creating web applications. This lesson delves into the fundamentals of how the internet works, catering to novice web developers, and is crucial for establishing a strong foundational knowledge to build upon.

What Is The Internet?

The simple answer is that the Internet is the foundation that makes the Web possible. It is a network of computers that communicate with each other. To understand what a network is, let us build one from scratch.

Assume the internet does not exist, and you want to send a message from your computer to your friend’s computer. You could get an ethernet cable and connect directly to your friend’s computer. Now both of you can exchange messages directly.

A network of 2 computers connected via ethernet cable.
A network of 2 computers connected via ethernet cable.

Say a third friend wants to join this group. You’ll need 3 cables and two ports per computer.

A network of 3 computers connected via ethernet cable.
A network of 3 computers connected via ethernet cable.

Say subsequently other friends find this private group chat network interesting and want to join. There are ten of you now. You will need 45 cables and 9 ports per computer to directly connect each computer to every other one. There’s an obvious problem here. The cable and port connections would get pretty complicated the more we have people joining the network.

A network of 10 computers connected via ethernet cable.
A network of 10 computers connected via ethernet cable.

To solve this problem, we need a device called a router.

A router
A router

We will separate the group into two groups of 5 computers each. Each computer needs a cable to connect to the router. The connections will no longer be made directly with each computer. Messages must have a destination address before they are sent to the router which will read the address and forward the message to the intended computer. Now we have 2 groups that communicate internally with each other but not across the group.

2 networks of 5 computers each connected to a router
2 networks of 5 computers each connected to a router

Making communication possible across both groups will require one more ethernet cable to connect both routers. To send a message across the group, one router will forward it to the other.

Both networks communicating through their routers
Both networks communicating through their routers

A Network Of Networks

Let's say a third group of 5 computers finds our setup interesting and wants to join. In order to accommodate them, we need a fourth router to facilitate message forwarding across the 3 groups.

3 networks communicating through their routers
3 networks communicating through their routers

So far, what we've achieved is quite interesting. Now, let's push our imagination further. What if the whole world expresses interest in joining our network? How would we manage the necessary cables and routers for global connectivity? The complexity of such connections would be overwhelming. Fortunately, we don't have to tackle this on our own. We can leverage the existing telephone /.,ation between devices on the Internet. Some examples of ISPs include AT&T, T-Mobile, Afrihost, MTN, and Vodacom. When we connect to an ISP, the messages from our routers are transmitted to the ISP's routers through telephone lines and then forwarded to routers of other networks worldwide. This is essentially what comprises the internet – an interconnected network infrastructure.

Internet Service Providers (ISPs)
Internet Service Providers (ISPs)

How Are Computers Found On The Internet?

When you send a package from your house to another house through a courier, you need to specify the address of the destination. As we have already established, messages also need a destination computer address which routers use to forward the message to the right computer on the network.

How do computers get addresses? Every computer that connects to a router is assigned a special address called an “IP address”. IP stands for Internet Protocol. Unlike house addresses, an IP address consists of a series of 4 numbers separated by dots. For example 192.168.1.254.

IP address meme
IP addresses are the location addresses of computers on the internet.

Humans don’t necessarily want to memorize telephone numbers and addresses. We could, but that would not be the best use of our time. We use mobile apps to assign names to telephone numbers for easy reference later. Similarly, we don’t need to memorize the IP addresses of computers on the internet. We assign names to IP addresses called domain names. Like the phonebook of the internet, domain names such as google.com and their corresponding IP addresses are stored on special computers on the internet called Domain Name Servers (DNS). All computers have the IP addresses of domain name servers built-in by default. This means they can retrieve the corresponding IP address of any domain name. More on this later.

A data center.
Large computers (Domain Name Servers) at data centers store domain name - IP address records.
Photo by Brett Sayles: https://www.pexels.com/photo/server-racks-on-data-center-4508751/

The Internet Is Not The Web

I believe we now have ample knowledge to effectively differentiate between the internet and the web. The internet as we have established is a network infrastructure that enables communication between computers worldwide. The web is a service that runs on the internet. Here’s an analogy: if telephone wires, phone masts, transmitters, etc are the physical infrastructure that makes up telephone communication, then we can say good ol’ text messaging and phone calls are services that run on this infrastructure. Likewise, the web is a service that runs on the internet. Email is another type of service that runs on the Internet. We use special software called Web Browsers that run on our computer to communicate with other computers called Web Servers to access websites. This is the web.

Network Protocols And Packets

Now we understand how networks are set up and interconnected through routers and ISPs. But we do not yet know how exactly these messages are transmitted from one computer to another. Let’s say you open a messaging app on the web and send a message to a friend. The message will be converted from alphabetic text on your computer to electronic signals and transmitted through cables, routers, and ISPs over several networks to the destination computer. When the electronic signals get to your friend’s computer, they are converted back to alphabetic text which they can read. How this is accomplished exactly is through the use of what is referred to as a network protocol stack. A network protocol is an established set of rules that determine how messages (or data) are transmitted between different devices on the same network. These rules enable the devices to communicate with each other on the network. As humans, speaking a common language helps us to interact with each other globally regardless of the differences in our cultures and languages. Similarly, network protocols make it possible for devices to talk to each other regardless of the differences in their make or design. These predetermined sets of rules are built into every device’s software and hardware. The internet protocol stack operates through layers of network protocols that work in unison to enable the functionality of the web on the internet. This hierarchical structure ensures the smooth flow of data and communication across the network, allowing for the seamless operation of various Internet services and applications. Each layer plays a specific role in managing and transmitting data, thus contributing to the overall functionality of the Internet. We will cover the basic layers by tracing a message's path from one computer to another over the internet.

If a message is too long to be sent as one piece, it is split into smaller pieces called packets. This is important because if a large message is sent through the network, it would prevent anyone else from sending another message until the first one is fully transmitted. That’s not good. Packets allow messages to be sent in little pieces so that all messages can be transmitted simultaneously. When a message is sent:

  1. It begins at the Application Layer. The Application Layer is where specific network protocols for applications are located. The most well-known one is the Hypertext Transfer Protocol (HTTP), which enables the exchange of documents and media on the web. Other protocols at this layer include the Simple Mail Transfer Protocol (SMTP) for emails, File Transfer Protocol (FTP) for file transfer, and DNS for domain name resolution.
  2. When the message leaves the application layer, it goes through the Transport Layer. The transport layer breaks down the message into packets and assigns each packet a port number. A port number is an address for a specific application running on a computer. We use port numbers because different internet services, like the web, email, and FTP, all operate on a single computer. This means we need a way to make sure that messages are delivered to the correct service. To do this, each service listens for messages on a specific port number that is unique to that service.
  3. The packets then proceed to the Network or IP layer, where they are assigned their destination IP address.
  4. After receiving the IP address and port number, the packets are transmitted to the Hardware Layer. At this stage, the messages are converted from alphabetic text to electric signals and then transmitted through a series of routers and ISPs to reach the destination computer.
  5. When the packets arrive at the destination computer, they start at the bottom of the network stack and move upwards from the hardware layer through to the application layer.
  6. The electric signals are converted back into alphabetic text and re-assembled into their original form.
Protocol LayerDescription
Application Protocols LayerProtocols specific to applications. e.g. HTTP, FTP, SMTP, DNS
Transport LayerBreaks down messages into chunks called packets and assigns them a port number. e.g. Transmission Control Protocol (TCP), User Datagram Protocol (UDP)
Network LayerDirect packets to a specific computer using an IP address. e.g. Internet Protocol (IP)
Hardware LayerConverts packets into electric pulses, radio waves, or light pulses and vice versa.

Summary of network protocol layers and their functions.

Internet Protocol Stack meme
The internet protocol stack.

Clients And Servers

The Internet is made up of a network of computers that consist of clients and servers. Clients can be any device connected to the internet, such as PCs, smartphones, and IoT devices. The Web Browser as we mentioned briefly is a software that runs on client computers. Web browsers are used to request and display web pages from web servers.

Web servers on the other hand are computers on the internet that are dedicated to storing web pages. They serve these web pages to clients who request them to be displayed to a user.

What Happens When You Enter A URL Into A Web Browser?

A Uniform Resource Locator (URL), also known as a web address, is the address of a specific web page or file on the internet. It is what you type into the address bar of your browser. It could be a domain name or an IP address. Let’s examine the basics of what happens when you type a URL into the address bar of your web browser.

  1. When you enter a URL into your browser, it connects to the Domain Name Server (DNS) to get the corresponding IP address of the web server for that domain. For example, if you enter www.google.com, the IP address 142.251.35.164 is retrieved from the DNS, which is known as domain name resolution. This process converts domain names to IP addresses. If you enter the IP address of a website directly into the address bar, the browser recognizes it as an IP address and doesn't need to go through domain name resolution.
  2. The browser connects to the web server with the resolved IP address through an initial request and then sends an HTTP request via the internet protocol stack to the web server for the desired web page.
  3. The web server receives the request and checks if the requested page exists on its storage. The web server responds with the web page if it exists. However, if the server cannot find the requested page, it will respond with an HTTP 404 error message. 404 is an HTTP status code. In this case, it means ‘Page Not Found’. More on HTTP status codes later.
  4. The browser receives the requested page or the error message and the connection is closed.
  5. The browser reads the web page code and then requests other elements like images, video, or audio files.
  6. The browser will display the complete web page or an error message if the page is not found.

Conclusion And Key Takeaways

In this lesson, we took a beginner's approach to learning about the Internet. We started by discussing what networks are and established that the Internet is a massive infrastructure of networks. We then built a network from scratch. Next, we discussed how computers are located on the internet using IP addresses. After that, we looked at the web as one of the services running on the internet. We also discussed the rules governing communication between devices, known as network protocols, and examined HTTP, the web's protocol. Finally, we described clients and servers as computers on the internet and looked at what happens every time you enter a URL into the browser.

In the upcoming lesson, we will delve deeper into URLs and how resources are retrieved from the server. I hope you found the last lesson engaging. I am looking forward to the next one. Keep up the good work!

I love helping and mentoring individuals who are making a career transition into software development on my Discord.

Join Alfred Doh-Nani's Discord Server