Understanding Network Devices
How The Internet Reaches you
Imagine you open your laptop, type in google.com and press Enter. Within a fraction of a second, a web page appears right on your computer screen. What happened here? Electricity moved, light pulses from around the globe traveled through cables layed under the oceans. Your request was passed across continents like relay runners.
The internet does not float in the air, it reaches you through your internet service provider (ISP). Giants like Jio, Airtel run massive infrastructure like fibre optic cables, underground lines, switching centres and international gateways. The internet is like a gigantic Highway System and your ISP is the one who mentains the highway system reaching your bulding.
What Is a Modem?
Before your Wifi blinks and before you get an IP adress, you need to firt connect with your ISP, this is down by your Modem. The word Modem is short hand for Modulator-Demodulator. In simple terms, it is a translator. Your laptops, computer of phones speak digital language called Binary, it consists of 0s and 1s, But the cable outside your house or under the oceans carries signals in form of electrical signals or light pulses. The modem is responsible for converting these 0s and 1s to the required electrical or light pulses. It also converts what data comes back from those cables to 0s and 1s.
If your modem stopped working your entire internet connection would dissapear. Everything may still be working as required, but without the translator your network will be cut off from the internet highway.
Credits: GeeksForGeeks
What Is a Router?
Imagine you arrive at a music festival and Linkin Park is performing (my favourite band there!). The festval will have multiple stages, food stalls and gathering areas. Hundreds of Thousands of people will try to rush in try to get there where they want to go fast and first. Without someone amanging this movement things could get pretty ugly very quickly. You will have people bumping into each other, pushing and getting hurt, taking wrong turns or worse dont reach where they wanted to go.
In networking that management devices is called a Router. It is responsible for directing data flow so it reaches the right place at the right time. At the most basic level, a router connects multiple networks and makes intelligent decisions regarding what data should go where in order to efficieantly reach its destination.
Inside your home or office, devices like laptops, phones and printersall need to talk to each other adn also talk to the wider internet. Thr router mediates it all by doing three core jobs:
Assign Local IP Adresses: When a device joins your network, the router gives it a unique internal address. This is like handing out house numbers in a neighborhood so everyone knows where to send mail.
Decide Where Outgoing Traffic Goes: When your laptop requests a webpage, the router figures out where that request should go, it can go to another device on your local network or out toward the internet.
Forward Packets Between Your Internal Network And Internet: Once the router knows where data is supposed to go, it forwards that data in the right direction, like a traffic officer waving cars into correct lanes.
What Are Swicthes And Hubs?
Inside a local network, typically in your office or home, devices do not talk to the internet directly. They first talk to each other inside a Local Area Netwrok (LAN). The devies that make these internal connection possible are called Hubs and Switches. They may look similar, small devices with a bunch of LAN ports, but they behave differently.
The Hub is the simplest form of connection device. When a computer sendsdata into a hub, the hub copies that data and sends in to every connected device. It dows not check who the message is for. Its like shouting a message in a room full of poeple only when a single person needs it.
A switch however is more intelligent as it skeeps track of devices using something calles a MAC (Media Access Control). A MAC address is a unique hardware identifier assigned to every network interface card. When a device sends data, the swtich reads the destination MAC address and forwards the data only to the correct port. This results in faster and more efficient communication.
What Is A Firewall
Well if you are connected to the entire world via the internet, there can be both good and malicous data floating around. You need some security that determines what is allowed and what is not. This is done by a Firewall. A Firewall monitors and controls network traffic based on predefined rules like a security guard for a venue.
A firewall controls access using ports, which you can think of as numbered doors on a computer system. A web server typically listens on PORT 80 (HTTP) or 443 (HTTPS), while secure remote access often uses PORT 22 for SSH. A firewall ensures that only the necessary doors are open and that everything else remains blocked. This reduces the attacks by allowing only approved traffic on approveed PORTS.
Firewalls can be physical devices sitting in a home or office network, especially in enterprise setups where dedicated hardwares that inspect large volumes of traffic. But they can also be software based. On Linux machines, tools like iptables and ufw perform firewall duties.
For backend developers, understanding firewalls removes much of the issues attached to deployment. When an API is unreachable or SSH access fails, it is often due to some firewall doing exactly what it is meant to do. Knowing this makes debuggin easier.
What Are Load Balancers?
When we talk about production grade systems, one computer is incapable to handling all the queries a giant website like google gets. Now many computers work together to answer queries effieciently. This is where a Load Balancer becomes essesntial. Imagine yourself at a music festival (again because I recently went to one), there are multiple ticket booth to handle the crowd, what if there was just one? well it would take a lot of time for you to get your hands on a ticket. With multiple booths at place the crowd moves smoothly.
A load balancer is a physical device or in some cases a software that distributes incoming traffic across multiple backend servers running the same code. Instead of just one machine handling all the requests now it is divided into manageable parts. In a prodution environment where thousands or millions of users might be trying to acces your website, a single server can get overwhelmed very quickly. Load Balancing solves three main problems:
Better Performance: By spreading traffic around rather than crowding one server, response times stay fast.
Redundancy And Fault Tolerence: If one server fails, the load balancer detects it and routes traffic only to healthy servers, keeping the service running.
Horizontal Sacling: You can easily add more servers to handle traffic growth, traffic is just shared among a larger group.
A load balancer doesn't always just blindly sends requests around, it performs Health Checks for servers. Usually when writing ode for a backend server, the very first route that you will write will be a Health Check Route. This check if the server is ready to take requests.
It also often acts as a reverse proxy, this means client connect to the load balancer itself and send the request to the load balancer. It then forwards the traffic to the appropriate backend.
How All These Devices Work Together
In a typical home setup, the internet signal enters your house through a modem. It is then sent to the router which connects to a switch which uses the MAC address to determine to what device it needs to send the data to.
credit: GeeksForGeeks
Now scale this idea to big giants like netflx and google serving thousands and millions of users possibly every second. The pattern still remains the same but with more optimizations. Traffic enters through a firewall, behind it is the load balancer. Instead of sending every request to a single mahine, it distributes traffic to multiple machines to handle multiple requests efficiently. Deeper inside the network live the databse, this is a sensitive system and hence is hid deeper inside the network.
Understanding these devices changes how you debug, how to deploy, and how large scale systems are design.