Menu

Networks

Protocols

Contents

  1. Protocols
  2. TCP/IP Stack
  3. Packet Switching
  4. Routing

Protocols are a set of rules for how computers communicate.

They stipulate:

  • How communication starts
  • How communication ends
  • How the sent data is organized
  • What to do when there’s an error
  • How to resend data if there’s an error

Without protocols computers could receive data but wouldn't know what to do with it. If all computers follow the protocols communication should work with few issues.

There are thousands of protocols which manage different types of digital communication between devices, however the commonly used ones are:

  • HTTP: Used by web browsers and web servers to manage website requests and sending web pages and connected resources in response to the requests.
  • HTTPS: This has the same purpose as HTTP but uses encryption to protect the contents of the request and any data sent in response.
  • POP: Is used for receiving mail from an mail server. It downloads all the messages on the server and then deletes them off the server. POP is an old protocol and was beneficial when server storage space was costly.
  • IMAP: Is used for receiving mail from a mail server. It synchronizes mail between multiple devices and the mail server. The devices and mail server contain copies of the same data.
  • SMTP: Used to send from a computer to the mail server or between mail servers.
  • FTP: Used for transferring files from a computer / client to a server. Sometimes files can be transferred between clients / computers.
  • IP: Responsible for how the packets move between networks (managed by routers). Uses IP addresses to identify the sender and destination.
  • TCP: Responsible for splitting data into packets, re-ordering packets when received and ensuring all packets are received.
  • Ethernet: Manages how data is physically transmitted down a cable.

Network communication is very complicated. To simplify things we break down different parts of the communication into four layers.

A single protocol must only work at a single layer and each one manages a different part of communication and thus groups similar protocols together.

We call the layered system the TCP/IP Stack.

The Layers

  • Layer 4 - Application: Called application because this is the level that user software works at. Protocols on this layer format the data to be sent correctly or unpackage the formatted data to be used when received
  • Layer 3 - Transport: Breaks down the formatted data into packets. Numbers the packets so they can be put back in order. Checks all packets are sent and received. Identifies how the computer should deal with the data using Ports (port numbers identify which kind of application the data should be used by)
  • Layer 2 - Internet: Manages making the connections between different Networks. Used by routers to pass data between networks.
  • Layer 1 - Link: Manages how the data is sent over cables or wireless signals

How the TCP/IP Stack works

Benefits of using Layers

  1. Protocols in each layer are self contained and don’t need to consider what other layers are doing. If someone was to create a new online game which passes data between different players, they only have to worry about working with one layer.
  2. Protocols can be changed within a layer without re-writing the layers above and beneath it. We can swap HTTP with HTTPS in the application layer without re-writing how data is sent down a cable or how the data is broken apart into packets.

Many of the files we send over a network are far too big to be sent in one go. Instead, we break them down into smaller manageable units called packets.

When receiving, for example a website, the website will be able up of thousands of individual packets

Each packet contains additional information to support the data being received and reassembled in the correct order.

  • Sequence number
  • Checksum
  • Type of packet
  • Addresses (sender & destination)

This data is stored in the header

Packet Switching

When sending packets over a network, or the internet, a series of steps take place. The below example using a webpage outlines the steps.

  1. You request a webpage
  2. The web server receives the request via the internet
  3. The webpage is broken down into smaller parts (packets)
  4. The packets are sent across the internet to your IP address. These packets may take different routes and arrive in a different order to that they were sent
  5. Your computer reassembles the packets into the website.
  6. If any packets are missing your computer requests the missing data.

Routing is how routers guide packets across the Internet. Every router keeps a routing table, a list of the networks it knows about and the best next router to send a packet to for each one.

When a packet reaches a router, the router reads the destination IP address in the packet header. It looks that address up in its routing table. The table gives the next router along a path to that destination. The router forwards the packet to that next router. The next router does the same, and so on, until the packet reaches the network where the destination device sits. A routing table might look like this:

Destination networkNext routerMetric
Network ARouter 22 hops
Network ARouter 55 hops
Network BRouter 11 hop

Choosing the best route

A routing table can hold more than one possible route to the same destination. Each route has a metric, a score such as the number of hops (routers crossed). A lower metric usually means a faster route. For example, a packet might be able to go through Router M (3 hops) or Router N (1 hop). The router picks Router N because it uses the fewest hops. But if Router N's link is busy with lots of video streaming, the router can choose Router M instead, even though it has more hops, because it is less congested. So the "best" route is often the fastest or least congested one, not just the shortest.

Sharing information

Routers do not work alone. They share information with other routers about which networks they can reach and how busy or reliable those links are. If a cable fails, this sharing lets routers update their tables and find a new path around the problem. This happens automatically and continuously, so the Internet keeps working even when parts of it go down.