How does the Internet work – in simple terms

Introduction

Internet is the backbone of how we mostly communicate today with each other and across the world. One thing I can say from my own experience, from what I have noticed. Many engineers are working in the software engineering field but don’t have a clear understanding of how the internet works, at its most basic level. This may be because they might not have studied computer science in their colleges/schools and had degrees in different streams. It is completely fine. This blog post is my attempt to help them understand how the internet works, in simple words. 

So let’s start. 

I will be writing about the following things in this blog post:
– Switch and LAN
– Router
– Internet
– Data packet movement
– WAN
– ISP

Switch and LAN

Let’s consider that we have two computers (PC1 and PC2) in a local enclosed environment. We want to connect them so that some data can be transferred from PC1 to PC2 and vice versa. How can we enable that? We could have connected them with wires. But think of the situation if the number of computers is many. Then connecting every computer will become quite difficult. This is where “Switch” comes into the picture. A Switch is a device used in a common environment for the machines to talk to one another. The machines can be connected to this common switch via copper ethernet cables (CAT-5 or CAT-6) or Fiber Optic cables.

LAN (Local Area Network)

Here, the “common” environment can be any enclosed location like a residence, laboratory, office building, university, school etc. Note that, the computers cannot connect through the switch with any “wireless” technology (e.g. Bluetooth or Wi-Fi). To establish a connection between the computers using wireless technology, we have to use another device called “Access Point”. This set-up of using a switch or access point to create a network in a restricted area where computers can talk to one another is called a LAN (Local Area Network). There are ports present on both the switch and on the side/back of computers (desktop or laptop). These are called LAN Ports. For switches, if the number of ports is many, then the price will also be on the higher side. We need to connect cables to these LAN ports and through these ports communication takes place. The source computer (e.g. PC1) can send data as packets (or frames) to the switch/access point which will then understand the destination address of the packet, alert the destination computer (e.g. PC2) and finally send the packet to the destination computer. This is how data will be transferred from one computer to another computer in a LAN.

Router

If we have to connect these computers (PC1 and PC2) to any other computer outside the LAN, then having a switch or access point will not be enough. We need a special device called a “Router”. It is a device that can be connected to the LAN switch through a copper cable at one end and to another router in an ISP (Internet Service Provider) through a special Fiber optic cable at the other end. We don’t need a router if we want to connect computers only on LAN. Switch and Access point devices will be enough. A router does not have any role in connecting the devices on the same LAN.

Connection between LAN and Internet

Nowadays, we also have a special kind of combo device which can act as all three – a Switch, a Router and an Access Point. These devices are called Home Routers. For residences, mostly these devices are used. Since the Access Point feature is also present in them, they can utilise Wireless technology too. However, for a LAN where many computers are present, it requires separate Switch and Router devices for communication as Home Router will not be sufficient enough.

Internet

Whenever a home router/switch is connected to the router inside an ISP, it enters the world of the “Internet”. The formal definition of the Internet is “Network of networks”. It can be described as a structure or technical infrastructure that connects all the networks in the world so that anyone can communicate with any other person in the world. 

ISPs of Internet

Routers are present throughout the internet and distributed widely across the whole world. These routers are connected through Fiber optic cables. These Fiber optic cables are present even under the ocean making it possible for communication to happen between continents separated by oceans. Truly amazing!! Even startling is the fact that the communication happens between one computer to another, whatever the distance between them, in a matter of seconds. In the next section let’s discuss how this communication takes place. Different services are built on top of the Internet infrastructure – The Web and Email are a couple of them.

How do data packets move on the Internet?

As mentioned earlier, for communication to happen in LAN, data is sent as packets (or frames) from the source computer to the destination computer via a Switch. In case of transmission to the internet, the packet is first sent to the switch. The switch then sees the address and sends the packet to the nearby router. This router then understands the destination address and relays the packet to the relevant router on the internet decided by a table known as the “Routing Table”. This process is called “Forwarding”. Routers have special processors in-built in them. These processors create the “Routing Tables” by using special algorithms. These routing tables tell the routers which travel route should the packet choose to reach its destination. When the packet moves from one router to another, the latter ignores the previous router from where the packet came – this process is called “Router Filtering”. All the routers in the packet’s path want to send the packet to the destination in the fastest way possible. But during the creation of their routing tables, they consider the number of points to choose the shortest route and several other variables like packet density in a given path. This process of path selection depending on various factors is what is known as “Congestion Control”.

So what happens when someone interacts with the internet?

Take an example of a person who wants to view a video on YouTube. As soon as the person enters the YouTube URL or domain name (human-readable address) in its browser, the IP (Internet Protocol) address of the YouTube server is fetched from the DNS (Domain Name System). a request message is sent from the client (here, the browser) to the YouTube server. The server responds with the YouTube homepage. This is then displayed on the person’s browser. The “servers” are nothing but very powerful computers which host YouTube.  Since servers need to interact with lots of computers at the same time, they have to be powerful in terms of hardware compared to normal computers. From the person’s perspective, as soon as it clicks on a video in his browser, its computer generates another request message which is sent to the home router first (switch and then router in case they are on separate devices). The home router then sends the request message as packets of data to the YouTube server, over the internet. When YouTube sends back the relevant video for us to watch, it sends it piece by piece in different packets. This process is what is popularly known as “Streaming”. To avoid Single Point Failures, YouTube’s servers are distributed around the world and we communicate with the server that is most suitable for us. All these distributed servers are in sync and carry the same information.

WAN (Wide Area Network) and VPN (Virtual Private Network)

Earlier we talked about LANs in detail. What if a LAN wants to communicate with another LAN in a different part of the world in a way as if they both belong to the same restricted environment? A WAN (or Wide Area Network) does just that. WAN is a network consisting of a combination of different LANs. We need to enable/configure the LANs to communicate with one another and create a WAN. Communication over the whole internet and communication over the WAN is completely different. Remember that the internet, at its core, is a public network where anyone can intercept communication between two entities. Or the travelling packets can be seen and modified by anyone. If WAN is used with the VPN (Virtual Private Network) technology, this security issue can be removed. But we also need to know that no technology can provide 100% security assurance. VPN provides anonymity and encrypts the data before transferring the packets. Privacy and security are provided by VPN Tunnelling – a special feature of the VPN. The VPN Tunnelling is a network connection over the public network on the internet. The packets travel through many routers on the internet but security and anonymity are established by this tunnelling feature. This tunnelling happens between the router of one LAN to the router of the other LAN and hence the connection is sometimes also termed “Site-to-Site VPN”. To send the data through a VPN, the data packet is first encrypted and then enclosed (encapsulation) into another packet before it is sent. At the receiving end,  at first, the original packet is taken out of the VPN tunnel (decapsulation), decrypted and then sent to the destination computer. There is also something known as “Private WAN”. In that case, the ISPs provide a dedicated line (ISP WAN Network). These types of WANs can be very costly, especially over long distances.

Now, let’s discuss what ISPs are.

ISP (Internet Service Provider)

ISPs (or Internet Service Providers) are companies that enable us to connect to the internet in exchange for money. They are mainly responsible for the transmission of data packets from one location in the world to another location and maintain all the routers on the Internet. Each ISP is responsible for a specific internet router. In general, there are 3 categories of ISPs:

  1. Local ISP
  2. Regional ISP
  3. Global ISP

Local ISPs are responsible for communication over small areas and localities. Our residential connections are mostly integrated with this type of ISPs. The Regional ISPs are responsible for communication between different cities in the same country. Many Local ISPs connect to one Regional ISP. Then comes the Global ISPs, which are responsible for communication between the different countries. These are the big ones. Many regional ISPs connect back to these Global ISPs. 

Network of a country = Local ISPs + Regional ISPs

The offices of these ISPs are popularly known as POPs (Point-Of-Presence). These offices host routers, switches, servers and so on. A local ISP can have one or many POPs and individual home users/business LANs connected to them. Each router in a Regional ISP can make a choice, and the result of all these choices determines to which Global ISP the packet will be sent. As told earlier, packets can take a different route each time. Some Local ISPs can directly connect to Global ISPs without getting connected with a Regional ISP e.g. in some small companies.