The Internet and the Beauty of Encapsulation
Tags: launchschool, theinternet
Published: 2022-04-10 03:01:36

---
title: The Internet and the Beauty of Encapsulation
published: true
description: An overview of how and why network protocols work together
tags: LaunchSchool, TheInternet
cover_image: https://upload.wikimedia.org/wikipedia/commons/6/67/87-94_Grumman_LLV.jpg
---

## Or how I learned trust the other person to do their job.

Networking (and by extension, the internet) has a beautiful quality possessed by civilization itself - division and specialization of labor.

Consider for a moment - what would happen if all the auto mechanics suddenly vanished from the earth?  The reality that none of us know how our car works with sufficient detail to recreate it would set in rather rapidly.  Some say this is a _sad_ reality.  Nay!  It is a _happy_ one!  The tremendous wealth that human civilization has as a part of its foundation a division and specialization of labor that frees any one person from having to know everything.  So to with network communication.

(I actually like working on my car - ours is a special age where rather than _must_ we _can_)

## The Physical Layer

The point is most clear with the physical means by which we transmit information.  Most of our network communication involves transmitting bits (i.e. 1s or 0s) - any physical medium that can be in one of two states will allow us to accomplish this.  And over the years we have developed several different way to communicate this - electrical signals on wire, electromagnetic waves and even flashes of light.  

Each of these mediums was developed to address issue the others were incapable of meeting.  Just a few examples from my own experience running IT at a small school
  - Copper wires work great at transmitting electrical signals, especially when you can add them during construction of a building
  - Fiber optics (using light to transmit bits) is made primarily of glass and plastic and so won't be affected by nearby lightning strikes (I've had to replace switches due to this actually!).  Also distance and bandwidth improvement over copper.
  - But everyone looked at me strange when I tried to plug a Cat6 ethernet cable into my phone.  Wifi lets us brake free of the wires, man!

...I'm also wondering at this moment if anyone has built an automatic smoke-signal system that integrates with the internet.  Knowing humanities creative capacity and penchant for the ridiculous, I'm putting my money on yes.  I also wonder under what conditions a router might decide that our smoke signal link is the best route. And here is the key point - **the rest of the network protocols would be totally agnostic to this type of network link** - it might take a while to load, but you could watch a YouTube video delivered over a smoke signal link.

## Ethernet

Moving up to the next layer of network protocols we see the benefit of the layers being agnostic to one another.  When I pull the security camera footage of our building up on my phone the information flows over all three medium types I mentioned above!  Imagine if my phone app had to tailor its request differently depending on the type of medium - the complexity added by any update to the system would cause updates to cease.

Or, to return to the car, imagine if driving an electric car was totally different from driving a car with an combustion engine.  A massive barrier to adoption would be thrown up, and there would be no discernable benefit (save vendor lock-in).  

Rather, each layer can rely upon the layers below to do what they promise, no matter how they do it.  Just as we can rely upon the brake to stop us, no matter how it does.  Ethernet can bundle up the transmitted bits into an abstraction that works no matter the physical medium.

## The Internet Layer

For the sake of example we can move up yet another layer.  Ethernet relies on unique addresses (MAC addresses) for each host on the local network - and though IPv6 might allow this for all devices on the internet, the amount of information the routers would have to store would be quite prohibitive.  Enter the Internet Protocol - a way for information to pass between networks.

Again, we see that passing information between networks works best if the protocol is agnostic to the structure of those networks (as Ethernet is agnostic to the physical medium that is actually transmitting the bits).  'Give me the packet' says IP 'and tell me where it should go - I don't care about the rest'.  

Perhaps for our car we now discuss the roads.  Be you truck, car, minivan, bus, front-loader, ebike, fishing-trolley-outfitted-with-wheels, you take to the roads to reach your destination.  


## Though we could, let us go no further

I will end the story there, though we have only just begun.  We could talk about network resiliency, reliability built on top of unreliability and security built on top of insecurity we will not.  I will also not discuss highway rules, traffic lights and taxis.  But you get the idea.

Let us instead marvel at the the brilliance of division and specialization of labor.