Computer Networking: a Primer – Part 2
In my last blog post, I gave a 10,000-foot view of computer networking. There remained some gaps in my understanding, though, particularly in regard to how connections work in the first place. As a user, the whole process seems so magical: you power on, enter a WiFi password, and ta-da! The world’s knowledge is now at your fingertips. But what is actually happening behind the scenes? How does your laptop know where to reach other computers? How is your individual laptop identifiable to other computers?
Your computer can be identified by its MAC address, a 48-bit unique identifier that is “burned-in” to the computer’s hardware (specifically, its network interface controller). This address can also be referred to as an ethernet address. The ethernet encompasses all technologies used to connect computers in a local network, like in your workplace. Your computer and your co-workers’ computers all connect to an ethernet switch (either physically by cable or through WiFi). Ethernet switches use a forwarding table to pass incoming “frames” (comparable to packets) to the correct computer. The switch populates its forwarding table by keeping track of the source MAC address in a frame’s header.
Getting an IP
To connect to the network, you first need to obtain an IP address for your computer. In the past, a sysadmin would assign an IP for each computer, but this is now handled by DHCP (Dynamic Host Configuration Protocol). When your computer connects to a network, it broadcasts out a message to the destination address
255.255.255.255. A DCHP server on the network hears that broadcast and responds by offering a configuration containing a IP address, subnet mask, and the length of time that your computer can have that configuration. Your computer then accepts the offer, and when your computer’s lease on that configuration is nearly up, it can request to keep the same configuration. In some cases having a changing IP address is a nuisance, so it is possible to pay extra for the luxury of a static IP.
When I am connected to the Tivix network, another user cannot send packets to my computer directly. Packets will go to the same Tivix IP address whether they are intended for me or for Sumit or Silin. That is because NATs (Network Address Translation devices) allow multiple computers to share the same public IP. The NAT makes it appear as if traffic from your computer is coming from its external interface, so your actual IP is hidden and harder to access. NATs also offer the benefit of using up fewer IPv4 addresses, which are in short supply. Of course, NATs make networking tricky, and services like Skype and peer-to-peer sharing applications must use workarounds to allow private IPs to communicate directly with one another.
Getting to Your Destination
Now you are connected to the network, but your computer needs more information before you can actually visit a website. DNS (Domain Name System) acts as the “phone book of the internet.” When you first type an address, like tivix.com, into a browser, your browser will not know where to go until “tivix.com” is mapped to an IP address,
220.127.116.11. Your computer sends a request to a DNS resolver server asking for help. If that DNS server also doesn’t have any entry cached for tivix.com, it will try querying other DNS servers (first a root server, followed by a server specific to .com addresses) until it gets the mapping it needs.
Finally, your computer is ready to send out packets. Routing is the process of getting a packet from point A to point B. In theory, there are different ways to get a packet across a network. We could “flood” the routers by delivering the packet to every system on the network, but that is inefficient. We could give the packet itself the directions to its destination, but that means the end host needs to know the network topology. So instead, routers use forwarding tables. Routers build a spanning tree of the network, in which all routers are connected without any loops. Routing algorithms calculate the best routes, taking into account factors like the number of hops between routers, the time delay, and the cost to use a link. In practice, routers aren’t working with a single spanning tree representing the entire internet — instead, the internet is subdivided into smaller entities called autonomous systems. An autonomous system, for example AT&T or Qwest, can choose which routing protocol to use internally. When AT&T needs to send packets to another autonomous system, like Qwest, it is required to use Border Gateway Protocol (BGP-4), which provides a standardized method of routing.
There you have it: the Internet demystified. Well… sort of. Each of the above topics are better suited for large tomes than for a blog post. For other newbies wanting to learn more, I highly recommend Stanford Online‘s course.