- Internet & the Web
A Gentle Introduction to Computer Networking
How do you eat an elephant?
One steak at a time.
Computer networking can be a difficult and overwhelming topic. Consider the Internet - it's pretty amazing how many different kinds of components can interconnect reliably and communicate at such high speeds - mobile devices, game consoles, desktops, datacenters full of servers, and more. And that's not to mention the infrastructure that holds the whole thing together. How do you begin to comprehend something so vast as the Internet? One building block at a time.
Let's start with the first layer of the network: the physical layer.
Cutting the problem down to size
What does it take to communicate? We need some agreement on common ideas and goals.
It is no different with the physical layer of a network (see the sidenote on Network Building Blocks). There are volumes and volumes of documentation that describe the proper way to construct a cable to carry an Ethernet signal at a certain speed over a certain distance.
What is it that requires so much description? How many conductors in a cable, the precise dimensions of where each conductor fits into a connector or a receptacle, practical limitations on size or length - the list goes on.
While Ethernet is not the only physical media involved in distributing the Internet, it is common enough that you have probably already encountered it. It's the network cable from my cable modem to my home router. What's in your network?
Network Building Blocks
As soon as you begin any study of computer networks, you will encounter the concept of layers. By breaking up the problem, we get to take a step back from the overall complexity, and focus in on a particular subset of the problem.
- physical: digital information travels by some form of electromagnetic energy over some kind of physical medium. Electricity conducts through metal (typically copper); light passes through glass (fiber); and radio waves pass through all kinds of things. The physical layer of the network model focuses on describing the best way to pass digital signaling over a given medium.
- logical: to travel over a physical medium, digital information must be transformed from its binary pattern into a wave shape. The logical layer (a.k.a. data link layer) describes the methods for converting digital information into electrical or optical pulses. Layer 2 also defines a way to address individual participants on a local network.
- network: with a higher perspective, the third layer is concerned with interconnecting local- and wide-area segments. Global addressing and routing processes weave a variety of mismatched networks into a common scheme. Whether packet size or transfer rate differs across boundaries, the network layer brings them all together.
Stack it up
So what do you think goes on top of the physical layer? Or to ask another way, if the physical layer describes the medium, what do we describe in the next layer up? The shape of the wave. Layer 1 is what the wave travels on, and layer 2 is how to shape waves to represent information.
Since we're on a roll with Ethernet, let's keep on going. Ethernet is a specific example of an industry standard describing layers 1 and 2 - the wiring and the signaling - of a local area network (or LAN - multiple nodes on a common segment).
Generally speaking, the data link layer (or link layer, or logical in the sidebar to the right) determines what encoding techniques to use in transforming digital information to physical signal. (One example of this encoding is the sound you hear from a fax machine over a phone line.) Part of the encoding process involves chopping up the data into chunks, or packets.
The link layer describes the rules for how big or small the chunks can be (MTU - like saying how many ounces you can mail in a business class envelope). Just as with the postal service, there are rules for what an individual address looks like, how to address the packets, and where to put the data.
Your computer's network adapter (NIC) is an example of a link layer component. It communicates over an Ethernet cable to an Ethernet switch or another network adapter (maybe your cable modem or DSL router). In large environments, Ethernet switches bring together many hundreds if not thousands of individual network nodes (see photo, Ethernet Switch - layer 2).
Stack it higher!
With our choice of physical path, and our choice of how to make our packets pass across a local network, we can start to think big and interconnect local networks together. The Internet Protocol (IP) is about as famous as a layer 3 player could hope to be. The Internet communicates by passing packets between local and wide-area networks using the addressing and routing schemes as described by the IP protocol. It's like magic! Except now you get to see how some of the pieces fit together. Let's meet the man behind the curtain.
The first magic trick is encapsulation. This goes back to the concept of breaking apart the problem domains, so that we can solve each one in relative isolation. But how do you bring everything back together? If you have an IP packet (like an envelope that you've addressed according to the rules of IP), and you want it to cross an Ethernet segment - just shove the IP packet into an Ethernet packet and - BOOM! - there goes the dynamite. Once it crosses the Ethernet segment, the recipient opens the Ethernet packet and interprets the IP packet. From the IP perspective, there is no Ethernet - there are only other IP hosts. From the Ethernet perspective, there is no concept of IP, there are just Ethernet packets crossing the local segment.
The next trick is routing. Lucky for us, the math on this one is pretty straight-forward. The boundaries for subnets and local area networks usually line up, one for one. Either the packet's destination is on the local subnet, or it's not. If it's on the local subnet, use the local network (layer 2) to deliver the packet to the recipient. If it isn't on the local subnet, use the local network to deliver the packet to a default route that knows how to forward the packet one hop closer. Keep that chain of logic going, and eventually you arrive at your destination, or the packet exceeds its time to live.
However, routing quickly becomes a deep topic. On a small scale, a network only cares about a default route. But as you build up larger and larger networks, you find that you need a way to communicate routing information between your organization's routers. Major Internet providers interconnect with each other on an even larger scale. Their routers exchange routing information and must choose between many alternate paths. Although we won't worry about those details right now, check back for future articles on routing protocols.
The magic keeps going. There are many other problems faced by IP. Sometimes the local link speeds don't match up across a layer 3 hop. Sometimes the maximum packet size is different across local segments. IP has a trick for each of these problems and more, and still manages to interconnect all kinds of different networks. No single magic trick in IP is particularly exciting by itself, but as you see the big picture come together, you begin to grow an appreciation for the convergence of engineering that has built up the Internet we know today.
Bring it all together
With these things in mind, let's take a look at your home network. The physical layer is the Ethernet cable between your cable modem and your computer. Do you have WiFi? Do you share your Internet connection between multiple devices? Then you probably have a Linksys or D-Link or other small-scale switch-router, combining the functions of Ethernet switching (logical layer) and IP routing (network layer) into a single device.
Is it starting to make sense? Does the elephant still seem so big? We did a pretty good job of cutting this thing down to size. Any network begins with a physical path - layer 1. Information travels from node to node in wave form over that path - layer 2. Information routes according to a high-level addressing scheme - layer 3. Keep building on these basic blocks, and soon you'll have a network that spans the world and connects everyone together.