Navigating OSI Layers for Backend Engineers

Navigating OSI Layers for Backend Engineers

·

2 min read

Navigating the Open Systems Interconnection Model for Seamless Communication

Why do we need a communication model?

  • Agnostic applications

    • Without a standard model, your application must know the underlying network medium

    • Imagine if you have to author different version of your apps so that it works on wifi vs ethernet vs LTE vs fibre

  • Network Equipment Management

    • Without a standard model, upgrading network equipment becomes difficult
  • Decoupled Innovation

    • Innovations can be done in each layer separately without affecting the rest of the models

The OSI Layers (Sender)

  • 7 Layers each describe a specific networking component

  • Layer 7 - Application - HTTP/FTP/gRPC

    • Post request with JSON data to HTTPS server
  • Layer 6 - Presentation - Encoding, Serialization

    • Serialize JSON to flat byte strings
  • Layer 5 - Session - Connection establishment, TLS

    • Request to establish TCP connection/TLS
  • Layer 4 - Transport - UDP/TCP

    • Sends SYN request target port 443
  • Layer 3 - Network - IP

    • SYN is placed an IP packet(s) and adds the source/dest IPs
  • Layer 2 - Data link - Frames, Mac address Ethernet

    • Each packet goes into a single frame and adds the source/dest MAC addresses
  • Layer 1 - Physical - Electric signals, fibre or radio wave

    • Each frame becomes a string of bits which converted into either a radio signal(wifi), electric signal(ethernet) or light(fibre)

The OSI Layers (Receiver)

Layer 1 - Physical

    • Radio, electric or light is received and converted into digital bits
  • Layer 2 - Datalink

    • The bits from Layer 1 are assembled into frames
  • Layer 3 - Network

    • The frames from layer 2 are assembled into the IP packet
  • Layer 4 - Transport

    • The IP packets from layer 3 are assembled into the TCP segment

    • Deals with congestion control/ flow control/transmission in case of TCP

    • If Segment is SYN we don’t need to go further into more layers as we are still processing the connection request

  • Layer 5 - Session

    • The connection session is established or identified

    • We only arrive at the layer when necessary (a three-way handshake is done)

  • Layer 6 - Presentation

    • Deserialize flat byte strings back to JSON for the app to consume
  • Layer 7 - Application

    • The application understands the JSON POST request and your express JSON or Apache request receive event is triggered