1. Introduction

Let’s now take a closer look at the system architecture of SONiC.

2. Architecture overview

This diagram shows the SONiC architecture and how its components interact, from the hardware level up through the kernel and into user space.

At the bottom, we see the physical hardware of the switch running SONiC. This includes fans, power supplies and the LEDs that show the status of each port. Two other key elements of every network device are the pluggable modules and the switching ASIC.

Each hardware element has its own driver. The drivers run in kernel space and let the hardware communicate with applications in user space.

For example, the syncd container works with the ASIC driver in the kernel to control and monitor the switching ASIC. Other kernel drivers work with daemons in the PMON container. For instance, they make sure the switch doesn’t overheat by reading the temperature sensors and adjusting the fan speed.

One layer up is user space, where the actual SONiC subsystems live. At its heart is the Redis server, which holds the databases SONiC needs to run properly. All SONiC containers interact with the configuration and state databases in the database container. We’ll go through each container on this diagram and look at what it does in detail.

Another critical piece is the SWSS, or Switch State Service, container. It correlates events from different subsystems and triggers the resulting actions in other subsystems. For example, when an interface with an IP address comes up, the interface’s IP subnet must be added to the routing and forwarding tables.

Besides these containers, there are several application containers that implement the actual networking functions: routing protocols in the BGP container, link aggregation in the teamd container, and other protocols and functions in their own dedicated containers.

One container is not shown here: the management framework container. It is part of Enterprise SONiC by Broadcom, but not of the community edition or most other enterprise editions. We’ll talk about it later.

3. The database container

Now let’s see what each of these containers contributes to a switch running SONiC. We start with the base subsystems, which provide fundamental services.

The first is the database container, which runs the Redis databases. These databases are the single source of truth for the complete switch state. They store any information from one container that other containers need.

Normally, five main databases run in this container:

  • APPL_DB stores the state generated by the application containers, such as IP routes and their next hops, discovered neighbors and so on.
  • CONFIG_DB, as the name suggests, stores the switch configuration.
  • STATE_DB is probably the most sophisticated. It stores operational states that may be needed to resolve dependencies between subsystems, so these states matter to several subsystems at once. An example is the operational state of ports that are VLAN members or have IP addresses configured.
  • ASIC_DB is more or less a mirror of the ASIC state. It holds the information used to configure the ASIC, as well as operational information read from it.
  • COUNTERS_DB, again as the name suggests, holds all kinds of counters and statistics, for example for interface usage, packet drops and access list hits.

4. The SWSS container

The next base subsystem is the Switch State Service container, or SWSS. It handles communication and arbitration between the other containers.

It contains a set of processes whose names end in “syncd”. As is typical in SONiC, they listen for events in the system, such as changes to port states or interface configuration. They are publishers to the APPL_DB, which means they write information about these events to that database.

In contrast, the processes whose names end in “mgrd” update the Linux kernel about changes to port or interface state and configuration. They subscribe to the APPL_DB, the CONFIG_DB and the STATE_DB. This means they are notified about any change in these databases and then read the updated state.

Finally, there’s the orchagent process, short for orchestration agent. It takes the information from the APPL_DB and feeds it into the ASIC_DB, so that the ASIC can eventually be programmed to match the application-level state. So orchagent is a subscriber to the APPL_DB and a publisher to the ASIC_DB.

5. The syncd container

The last standard base subsystem is the syncd container.

It is simply the link between the ASIC_DB and the physical switching ASIC. It synchronizes state between the two in both directions. It programs the ASIC with new table information from the database, and it updates the database with new state information read from the ASIC.

It talks to the ASIC through the Switch Abstraction Interface, or SAI, which we’ve already heard about. The SAI implementation can both program and monitor the ASIC.

6. The management framework container

The SONiC management framework container is a special case, because it isn’t found in every SONiC edition.

You could also see it as a base subsystem, because it provides an interface to the switch configuration. It offers an API that gives access to the switch’s configuration resources and operational states.

It publishes configuration changes to the CONFIG_DB. To read configuration and operational states, it subscribes to the CONFIG_DB and the APPL_DB.

The management framework API can be accessed in several ways: through the local management framework CLI, a RESTCONF server or a gNMI server.

The management framework is not yet part of upstream SONiC, but it is implemented in Enterprise SONiC by Broadcom, the edition we use in this training. We’ll learn more about it in Module 3.

7. Application containers

The role of the application containers is easy to describe. Each one implements a specific networking function or protocol, and interacts with the base subsystems as needed.

Today, SONiC includes the following application containers:

  • BGP runs an instance of Free Range Routing, or FRR, which implements the complete routing stack. The name is mostly historical: routing protocols other than BGP also run in this FRR instance and this container. We’ll learn more about the routing stack in Module 5.
  • teamd runs the daemon of the same name and provides link aggregation, called port channels in SONiC. We’ll learn more about these in Module 3.
  • LLDP and SNMP run the protocols of the same name. LLDP, the Link Layer Discovery Protocol, discovers neighboring devices. SNMP, the Simple Network Management Protocol, is used to monitor the switch. We’ll learn more about both in Module 7.
  • DHCP relay runs an instance of ISC DHCP Relay. We’ll learn more about DHCP relay in Module 5.
  • PMON is again a special case. It handles platform monitoring, as mentioned earlier. It contains daemons that monitor the thermal sensors, power supplies, pluggable modules and so on, plus one that controls the switch fans. We’ll learn more about it in Module 7.

You can also add containers of your own, which makes SONiC unique. So it’s easy to extend SONiC’s functionality to fit your needs.