Introduction to Computer Networking


Networking


  • Computer Networks are like a phone system for computers
  • A computer places a “call” to exchange data with another computer
  • The communication is always just bytes
  • Worth knowing the basics, you are using the network constantly
  • When you wake up, how long passes before using a network?

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 http://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


  • Start with small scale
  • LAN – Local Area Network
  • One house, one floor of a building
  • Later, show scale up to world-wide internet
  • Two super popular LAN technologies
    • Ethernet, wired LAN
    • Wi-Fi, wireless LAN

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


  • Very popular wired LAN technology, 1974
  • Wires about as thick as a drinking straw
  • 100 meter max wire length
  • Wires often yellow or blue
  • RJ-45 plug, like a big phone plug
  • bandwidth speed – bits per second
  • Typical bandwidth numbers:
    • 100 megabits, 100 million bits per second, aka 100 mbps
    • 1 gigabit, 1 billion bits per second, aka 1 gbps, 1000 mbps
  • Letter “b” confusion – note “mbps” and “gbps” refer to bits not bytes
  • Networking speeds generally quoted in bits-per-second, as above

network-wi-fi-rj45

Ethernet RJ45 plug

network-wi-fi-router-back

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


  • e.g. send an image file between ethernet connected computers
  • This is the “one hop” LAN case (scale up to whole world later)
  • e.g. 50KB image.jpg
  • 50,000 bytes
  • How to send the image.jpg on the wire?
  • Use packets
  • Divide bytes of image.jpg into packets
  • Say each packet is 1500 bytes (varies)
  • Then image.jpg divides into about 32 packets
  • Network transmits one packet at a time

network-packets

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


  • Look at transmission of one 1500 byte packet
  • Each byte is 8 bits, e.g. 0 1 1 0 1 0 1 0
  • 1500 bytes * 8 bits-per-byte = 12000 bits total
  • Send each byte (slight simplification):
    • Go through all the bits, from left to right
    • For each 1, put 3 volts on the wire
    • For each 0, put 0 volts on the wire
  • To receive the packet:
    • Follow along the pattern of 3 volts / 0 volts coming down the wire
    • Assemble the 0’s and 1’s in groups of 8 to make each byte
  • Digital transmission – just 0’s and 1’s
  • Proceeds at around 2/3 the speed of light (varies)

network-signaling

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


  • Checksums detect transmission errors
  • Allow the receiver to detect that a packet was received correctly
  • Example checksum scheme:
    • Each byte is a number from 0-255
    • Sender adds up all packet’s bytes, say the sum is 157231
    • Take the last 2 digits, 31, as the “checksum” of the packet
    • Sender appends a checksum byte at the end of the packet
    • Receiver: add up the bytes received, check that the checksum matches
  • Checksum not matching indicates data corruption
  • Receiver asks the sender to re-send that packet
  • Very likely to detect errors
  • Not perfect – 2 errors could cancel out
  • Actual checksum schemes used are better than just the sum
  • Checksums are very widely used:
  • Ethernet, USB, Wi-Fi, … everything!
  • This is how your file transfers get every bit correct
  • Recall analog/digital theme: once the data is numbers, many useful algorithms are easy. Checksums are another example.

Packet checksum example:

network-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.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.