1. Introduction

In the previous lesson, we learned that SONiC is an open source project. Naturally, it also builds on several other open source projects to create a reliable and scalable network operating system.

Let’s look at the most important projects that serve as building blocks for SONiC.

2. Overview

It’s worth stressing that SONiC wasn’t built from scratch. It relies on several well-known open source projects as a solid base.

The foundation for all of this is the Linux operating system. It provides a robust, scalable and versatile infrastructure for a SONiC system. Linux has been around for decades, is one of the most reliable operating systems you can build on, and it’s free.

SONiC is based on the Debian distribution, which is known for its stability, even among Linux distributions.

In the previous lesson, we also heard that SONiC has a modular, containerized architecture. This is implemented with Docker containers. Docker is the most popular container implementation and runs on top of the Linux kernel.

The Linux kernel and its ecosystem already offer a wealth of networking projects. SONiC can use them instead of reinventing the wheel.

SONiC also uses Redis databases as a single source of truth for the complete switch state.

One of SONiC’s most distinctive features is the abstraction of the switching ASIC, which makes it easy to port SONiC to new systems. This is done with the Switch Abstraction Interface, or SAI, which provides a uniform API to all ASIC functions.

Finally, SONiC adds a lot of functionality of its own, for example for system management and for specific features like MC-LAG, which we’ll cover in a later module. We’ll meet many of these throughout this training.

3. Linux and Debian

Let’s take a closer look at Linux as the base of SONiC, and at the qualities Linux is known for.

  • Reliable. Linux is a very reliable operating system, and SONiC builds on that.
  • Open. Linux is open, so it’s easy to use as a foundation.
  • Scalable. SONiC draws on Linux’s scalability to run very large networks.
  • Modular. This means the use of containers, but also that SONiC only needs the parts of Linux it actually requires, which keeps its footprint small.
  • Network-ready. Linux already includes many networking functions that SONiC can use, both in the kernel and in additional projects. We’ll come back to this shortly.

As mentioned, SONiC is built on the Debian distribution, which is known for its robustness. Debian may not always include the very latest features of the Linux kernel and its ecosystem. But for a reliable network operating system, we prefer stability over the newest features.

4. Containers and Docker

We’ve heard that SONiC uses containers to build a modular architecture. This approach has several benefits.

First, containers are isolated from each other, so one misbehaving container can’t affect the others. Still, containers can communicate with each other in a controlled way.

Second, each container brings its own packages and its own environment. So a container always behaves the same, no matter which system it runs on.

Compared with virtual machines, another way to isolate software, containers are much more lightweight. They share the kernel with the host system, so they don’t each need their own copy of the kernel. Together with much simpler communication between them, this makes containers far better suited to our purpose than VMs.

Finally, it’s very easy to extend SONiC by adding new containers. For example, we could add a container that runs a DHCP server, which isn’t part of standard SONiC. Enterprise SONiC even lets us control the resource usage of such containers, so we don’t have to trade stability for extensibility.

SONiC uses Docker to implement its containers. Docker is probably the most popular container implementation and has grown into a very robust and flexible product.

As we’ll see in the next lesson, almost every networking function, and several base functions, run in their own container.

5. Linux networking functions

As mentioned, Linux already comes with a lot of networking functionality that SONiC can use, both built into the kernel and as external projects.

It starts with the IPv4 and IPv6 protocol stack in the kernel. It handles interface addressing and also basic protocols such as ARP, Neighbor Discovery and Router Advertisements.

The kernel also supports Virtual Routing and Forwarding, or VRF, which lets us run separate routing tables in one system. This is a very important feature for overlay networks.

Which additional Linux packages does SONiC use?

  • FRR, or Free Range Routing, is probably the most important. It implements all the routing protocols that SONiC supports.
  • teamd is another key package. It controls link aggregation.
  • ISC DHCP Relay forwards DHCP requests across a Layer 3 network to a central DHCP server.

There are several other packages as well.

Using these packages means SONiC doesn’t need new implementations of mature protocols. It benefits from the reliability and experience of existing implementations. Because little new code had to be written for these protocols, SONiC is more stable.

Still, you may see some changes compared with the upstream versions of these packages. Some add functionality, others improve code quality even further. After all, no software is free of bugs.

6. Redis databases

Another important component in SONiC is the Redis database.

Redis is a fast in-memory data store that can serve both as a repository and as a cache. It also offers some degree of persistence. Redis is not a relational database. It follows a key-value model, where you get or set the value of an object using its key. It also supports different data types. To learn more about Redis, follow the link on the slide.

In SONiC, several Redis database instances together form a single source of truth for the switch state. This means that the entire switch configuration, all routing and forwarding tables, counters, and the states of ports, modules, fans and so on are stored in these databases.

The databases run in a separate database container, and most other containers access them. These containers act either as publishers, which write information about new states or events to a database, or as subscribers, which consume that information. Some processes are both publishers and subscribers.

7. Switch Abstraction Interface (SAI)

One of SONiC’s most distinctive concepts is that it hides the details of a particular switching ASIC behind a uniform programming interface. This makes SONiC independent of the underlying ASIC and makes it much easier to port SONiC to new ASICs.

This abstraction is provided by SAI, the Switch Abstraction Interface. SAI is a separate open source project governed by the Open Compute Project, or OCP. It’s a vendor-independent API that can control any switching ASIC for which a SAI implementation exists.

This way, SONiC doesn’t have to work directly with the ASIC vendor’s own SDK, which would otherwise require licensing and other agreements. Because SONiC relies on SAI, porting it to new ASICs is easier, which helps SONiC spread. And SONiC itself doesn’t need any ASIC-specific code.

One important point: SAI really only covers the switching ASIC. It doesn’t support other hardware found on typical switch platforms, such as LEDs, fans, thermal sensors, power supplies and pluggable modules. Access to these components is a platform-specific implementation that is part of SONiC itself.

You’ll find more about SAI on the OCP website, linked on the slide.