How the Internet Works

By Steven Goodstein, DevOps Engineer

This post is exclusively referring to the TCP/IP model and an interpretation of it's layers. This is not a reference to the OSI model.

In 2016 I think we all take the internet for granted. We use the internet for hours a day. We are constantly sending emails, checking news, and connecting with others. Our devices are becoming more and more connected from our phones, laptops, and now even our watches and cars. To get to this place many engineering problems had to be solved.

So how exactly does the internet work? I’m going to discuss the basics and more specifically the TCP/IP model which is the most commonly used computer networking model in the world. At the core, the internet is just a giant wired network. If you think about the early days of phones it was essentially just wires connected to each other at long distances. An operator had to actually assist in making these connections. This is very similar to the internet in that the internet is really just wires going from place to place. There are long wires that span the oceans to provide worldwide internet. New technologies such as fiber optics have helped to improve the speed and efficiency of these connections but it’s important to note that it’s just one big network connected through cables. Today no one connects a wire to their computer though. What’s really going on is that we’re all wirelessly connected (using radio signals) to something that’s in close proximity to us, which actually is wired to this endless network.

To help understand how this all happens I’ll discuss the four layers of the TCP/IP network and how it helps get us all connected:

tcp-ip image

Link layer

The link layer is the bottom layer if you will. It is what our devices connect to locally and the first place we transmit data to. So for most of us our wireless network is this link layer, but ethernet is another example of the link layer. Since most of us use WiFi lets talk about that. The way it works is that we transmit data on WiFi to our routers via radio waves. Any device that has a radio built in is given a unique serial number to identify itself. This is called the MAC address and looks something like this a4:d1:8c:d3:ce:46. When we transmit this data we send it in what we call packets. This is broken up pieces of our data with an offset included. Since we are sending data in bits and pieces (as packets) this offset allows us to know how to reconfigure the whole message when it’s been brought back. One problem that might occur is when we have a bunch of people on Wifi we may actually send two messages at once to our routers. This can be confusing for our routers because data collisions occur. To get around this problem carrier sense multiple access with collision detection(CSMA/CD) was developed. What it does is that it first checks to make sure there is no data transmitting on the line. Then if so it transmits. This doesn't guarantee that there won't be simultaneous transmissions. If data does collide the originator of the message will send data back at a random interval. Since it is random it’s not likely to collide again. Seems like there should be a better way but this is actually very effective.

Internetwork layer

The internetwork layer is responsible for getting our data to it’s destination. To understand this you can think of the way we travel via public transportation. If you’re going on a trip you take your car or taxi to the airport. Then you take a plane in the right direction of where you want to go. Hardly ever is the destination airport precisely where you want to go. So from the airport you may have to then take a bus or a train. Then after the train ride maybe you will walk till your final destination. This is sort of how the internet works. Your router passes data along to the next router in the right direction. Then you are passed along again and again till you reach your destination. We call each of these hops. It’s the job of the routers to direct your data to the right place. Routers are able to ask their neighbors for routing information. In doing so Routers create a routing table. No single router knows how to take you to your complete destination. It only knows how to pass you in the right direction. Often your data transmitted in (packets) takes different routes to it’s destination. That’s okay because even if one piece gets there first the offset in the packets allows us to reconfigure that data perfectly. To help routers get data where they are going we need addresses, these are called IP addresses. Over WiFi our computers get it’s own address typically through DHCP. Our devices ask our local router for an IP and the router provides it. So you likely have a different IP every time you open and close your computer. Then when we send messages we are sending them to a specific IP address. We use textual names which are then converted into these numbers via the Domain Name System. With the domain/address you provided the routers pass your data from hop to hop until you reach your destination.

Transportation Layer

This layer is responsible for any mistakes made by the previous two layers. It compensates for packet loss, helps reassemble the packets, and helps account for slow connections. Whenever the sending computer (client) sends packets it receives a message back from the receiving computer that the data has been received. By keeping track of the time differences between sending and acknowledgment we are able to control how much data is sent at a time. If there’s a good connection more data will be sent and if bad less. This helps to not overwhelm the network. If there’s no acknowledgment for too long (the packet has possibly been lost) the receiving computer will send a message back to the sender notifying it of the last thing it received. When all the packets have been received the receiver is able to reconfigure the data based on offsets.

Application Layer

The final and top layer is the application layer. This is the layer at which applications like web browsers, mail program and video players exist. This is the layer closest to us that we interact with. By this point all the work has been done for sending data and making sure all data has been received. At the application layer we have protocols or sets of rules for how this data should be marked up for the receiver to understand and interpret it. A protocol that we are all familiar with is the HTTP protocol or increasingly more common the HTTPS protocol. If we make requests in the fashion that is expected we then receive data back in ways that our computers know how to interpret and display (browsers take care of all of this).

Conclusion

Between those four layers we have the internet. There is far more going on at each layer then mentioned but this is an overview of the basics. As you can see it takes a lot to create the internet and it is still growing. Two recent trends that prove the internet is still growing is the use of the HTTPS protocol and the use of IPv6 IP addresses. The growth will likely never end. Hopefully now you can appreciate just how much goes on when you press enter in your web browser.