OSI: THE communication model for Embedded Systems

When I started working on embedded systems, I would often find myself confused with the myriad of communication protocols available. It wasn’t until I stumbled across the OSI model and learned how it’s applied to embedded systems that I managed to connect every piece of the puzzle. With this quick guide, you will gain an understanding on why the OSI layering is so important, when it is used and what can you obtain from it’s application, including real world embedded examples. Let’s dive into it!


The OSI (Open Systems Interconnection) is a reference model for describing the functions of a communication system. While the OSI model is typically associated with computer networking, its principles can also be applied to embedded systems, although the traditional seven-layer OSI model can often be too complex. This is why I’ve come up with the simplified OSI model for embedded systems:

 

Simplified OSI model for embedded systems

1 - Physical layer: Deals with the physical transmission of data over a communication medium. In embedded systems, this layer involves the actual hardware components that facilitate communication, such as transceivers, connectors, and cables, including considerations like voltage levels, signaling, and physical interfaces.

2 - Data link layer: Ensures reliable and error-free data transfer between directly connected devices. This layer may involve protocols such as Ethernet, UART, SPI, I2C, or CAN bus, which handle the framing, error detection, and flow control of data packets.

In I2C communications, we have:

  1. Physical layer, represented by the twisted pair of wires.

  2. Data link layer, responsible for providing multi-node communication.

Keep in mind that the I2C protocol is also part of the physical layer, as it includes hardware setup and electrical characteristics, such as the bus (SCL for clock and SDA for data), pull-up resistors, and the devices themselves (open-drain config).

3 - Network layer: Provides logical addressing and routing of data packets across interconnected networks. This layer may include protocols like IP (Internet Protocol) or other network-specific protocols that handle addressing, routing, and fragmentation of data packets.

In LoRaWAN communications, we can find:

  1. Physical layer, represented by the radio modules, managing the LoRa modulation technique, frequency band, data rate, and power level.

  2. Data link layer, responsible for providing node-to-gateway and gateway-to-node communication.

  3. Network layer, responsible for routing the packets from the end-devices to the appropriate network server.

As it happened with I2C, LoRaWAN also includes information on how to set up the physical and data link layers, making it a multi-layer protocol.

4 - Transport Layer: The transport layer ensures the reliable delivery of data between endpoints. In embedded systems, this layer may involve protocols like TCP (Transmission Control Protocol) or UDP (User Datagram Protocol) for reliable or fast data transfer, respectively.

5 - Application: The goal of the embedded application layer is to provide a simplified and optimized interface for easy integration and efficient communication between embedded devices and other components of the networked environment. It involves protocols and interfaces that are lightweight, optimized for low power consumption, and designed to meet the specific requirements of the embedded application, like MQTT (Message Queuing Telemetry Transport) or CoAP (Constrained Application Protocol), which are designed for efficient data exchange and are well-suited for resource-constrained environments.

Our last example will involve using WiFi to send packets from one node to another over different networks

The breakdown for this protocol is as follows:

  1. Physical layer, represented by the radio modules, controls the radio frequency communication and modulation techniques.

  2. Data link layer, same as in LoRaWAN, it ensures reliable data transfer between nodes and handles errors.

  3. Network layer, responsible for packet forwarding within and to different networks

  4. Transport layer, provides a path to transfer data between end systems (node in network 1 to node in network 2) and is responsible for end-to-end error recovery and flow control.

  5. Embedded application layer, responsible for establishing, managing and terminating connections between applications (Session), data representation and encryption (Presentation), and interacting with the software applications (Application). It uses the transport layer to send messages over the network.

This is a complex protocol, involving every layer of the OSI model. For the Physical and Data link layers, you would need a WiFi capable SoC, such as an ESP8266, whereas the upper layers could be coded separately if neccesary.

By considering this model, you can develop more structured, modular, and scalable systems, facilitating communication between your embedded devices and other systems in a networked environment. Don’t forget that not all layers of the OSI model are applicable or implemented in every system, as they depend on the specific requirements, constraints, and communication capabilities of the system in question.

Even if there are other models in use today, such as TCP/IP (the base for internet itself), CISCO (for designing and setting up networks) or the hybrid model (combination of TCP/IP and OSI), the OSI model has proven itself the preferred solution for most embedded systems, so understanding it’s internal machinery will help you inmensely in your embedded systems journey.

Previous
Previous

Test-Driven Development: The bug killer

Next
Next

Don’t get lost in embedded systems: Practical roadmaps