Protocols & Layers

Contents
  1. Protocols
  2. TCP/IP Stack

1. Protocols

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.

2. TCP/IP Stack

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.