Introduction to Computer Networking

Here we look at the most basic features of networking and packets.

Networking

Computer networks are complicated in the details, but the basic ideas of how it all works are surprisingly simple, and that's what we're going to study.

The Internet is like a global phone system for computers: a computer can "call" another computer on the internet to get or send a little information. Suppose your laptop is connected to the internet, and you type "http://www.nytimes.com" into your browser -- what happens? Your computer contacts the computer "www.nytimes.com" -- placing a "call" in effect -- and sends a request for the main web page. The request is small, about 1KB (1 kilobyte). The www.nytimes.com machine sends back a large response which is the web page -- maybe 200KB -- and ends the call. Your browser gets back all this data and formats it for your screen so you can read the text, click links etc. We'll look at this fetch-web-page example a few different ways to see how the internet works.

LAN - Local Area Network

We'll start by looking at LAN (local area network) technology -- connecting 2-50 computers in a house or on one floor of a building.

Ethernet LAN - Bandwidth

ethernet rj45 plug
Ethernet RJ45 plug

router with ethernet cables plugged in
Ethernet cables plugged into the back of a Wi-Fi router (Linksys WRT54g)

Ethernet is an extremely common and influential wired LAN standard, so we'll start there. Ethernet cable lengths are typically limited to 100 meters, in keeping with its "local" orientation. A typical LAN application is networking the computers in one room or in one floor of a building. The most common form of ethernet wiring is 100base-T (100 megabit) with "RJ-45" connectors on the ends. An RJ-45 connector is about the size of your pinkie finger, like a wide phone wire plug.

Packets - Data From Here to There

packets transmitted on the wire

We'll start with the simplest case of two computer connected with an ethernet cable, and we want to send a 50KB jpeg image file from one computer to the other. This is the "one-hop" case .. networking between two computers separated only by an ethernet cable. Later we'll scale this up to the full Internet case of two computers on separate sides of the world. The first question is: how are the bytes of the image file on one computer sent to the other computer over the ethernet cable (or over Wi-Fi)?

For transmission, the 50KB of the image is divided into packets. The packet is the natural unit of transmission within networking. In this case, say each packet is about 1500 bytes (a typical packet size), then the bytes of the 50KB image could be divided into about 32 packets of around 1500 bytes each. It is not required that all the packets be the same size, just that every byte of the image is sent in one packet or another.

Ethernet - Sending One Packet

Ethernet provides a basic facility to transmit a packet between two computers connected by the ethernet cable. Say we have a packet of 1500 bytes of information we want to send. Each byte is 8 bits, so that's 12000 bits to send, where each bit is a 0 or 1. Here's an oversimplification that captures how it works: the ethernet cable contains two wires connecting the computers. The sending computer could read through the 12000 bits in order, and for each 1 bit, put 3 volts between the wires, and for each 0 bit, put 0 volts between the wires. The receiving computer can follow along, noting the 3v/0v pattern on the wires over time and so receive the 12000 bits. In reality the most recent ethernet contains 4 pairs of wires and supports sending information in both directions and with a more complex voltage scheme. However, this pattern of going through the bits and varying the voltage to "send" each bit is essentially how it all works.

Checksum vs. Errors

Packet checksum example:
add bytes of packet to get checksum

Each packet includes extra checksum bytes, so the receiver of the packet can detect if some of the bits in the packet got corrupted in transmission. A simple example checksum scheme would be: go through all the bytes, and add them all up. The checksum is the last 2 digits of the sum of all the bytes; send that checksum as an extra byte along with the rest of the packet data. The receiver can do the same computation -- adding up all the bytes -- to check that they get the same checksum. The actual checksum algorithm is more complex than just adding up the bytes, and is more capable of detecting errors. The checksum is probabilistic, not detecting 100% of errors; there is a microscopic chance that an error occurs but the checksum does not catch it.

The checksum allows the receiver to notice that a packet did not come through right, and get the sender to re-send that packet. Most packets get through fine, but re-sending a few packets happens all the time in your life. In this way, when you send a JPEG file from one place to another, it comes through correctly, down to every last bit.