# sonic-net/sonic-swss architecture

> Architecture diagram of the GitHub repository sonic-net/sonic-swss, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sonic-net/sonic-swss
- Repository: https://github.com/sonic-net/sonic-swss

## Overview

SONiC SWSS is the switch-state service: it connects network-control and configuration inputs to switch state and hardware through database-backed daemons. The principal path is route information from FPM/BGP into route tables, then orchestration into SAI. Other branches synchronize link, neighbor, FDB, and team state, manage switch features, and collect/report counters. The README describes SWSS’s database-interface role; edges for unsampled daemons are limited to that documented role and their tree-supported responsibilities.

Main entry points: [`orchagent/orchdaemon.cpp`](https://github.com/sonic-net/sonic-swss/blob/master/orchagent/orchdaemon.cpp) (Orchestration daemon), [`crates/countersyncd/src/actor/ipfix.rs`](https://github.com/sonic-net/sonic-swss/blob/master/crates/countersyncd/src/actor/ipfix.rs) (IPFIX processing), [`tlm_teamd/main.cpp`](https://github.com/sonic-net/sonic-swss/blob/master/tlm_teamd/main.cpp) (Team interface daemon), [`crates/countersyncd/src/main.rs`](https://github.com/sonic-net/sonic-swss/blob/master/crates/countersyncd/src/main.rs) (Counter sync service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_sync["State synchronization"]
  node_fpm["FPM route sync<br/>[routesync.cpp]"]
  node_neighbor["Neighbor sync<br/>[neighsync.cpp]"]
  node_fdb["FDB sync<br/>[fdbsync.cpp]"]
  node_port["Port link sync<br/>[linksync.cpp]"]
end

subgraph group_orch["Switch orchestration"]
  node_orchmain["Orchestration entry<br/>[main.cpp]"]
  node_orchdaemon["Orchestration daemon<br/>[orchdaemon.cpp]"]
  node_l3["Routes and neighbors<br/>[routeorch.cpp]"]
  node_portsorch["Ports and interfaces<br/>[portsorch.cpp]"]
  node_fdborch["Forwarding database<br/>[fdborch.cpp]"]
  node_p4["P4 object managers<br/>[p4orch.cpp]"]
end

subgraph group_config["Feature configuration"]
  node_cfgmgr["Feature config managers"]
end

subgraph group_telemetry["Counters and telemetry"]
  node_counterd["Counter sync service<br/>[main.rs]"]
  node_ipfix["IPFIX processing<br/>[ipfix.rs]"]
  node_counterdb["Counter database writer<br/>[counter_db.rs]"]
  node_stats["Stats reporter<br/>[stats_reporter.rs]"]
  node_flex["Flex counter manager"]
end

subgraph group_team["Team interfaces"]
  node_teamd["Team interface daemon<br/>[main.cpp]"]
  node_teamctl["Team control manager<br/>[teamdctl_mgr.cpp]"]
  node_teamvalues["Team values store<br/>[values_store.cpp]"]
end

node_bgp(("BGP control plane"))
node_appdb[("Application database")]
node_configdb[("Configuration database")]
node_sai["SAI switch hardware"]
node_netlink["Kernel netlink"]
node_state_db[("State database")]

node_bgp -->|"sends routes"| node_fpm
node_fpm -->|"publishes routes"| node_appdb
node_neighbor -->|"publishes state"| node_appdb
node_fdb -->|"publishes state"| node_appdb
node_port -->|"publishes links"| node_appdb
node_orchmain -->|"starts"| node_orchdaemon
node_orchdaemon -->|"consumes state"| node_appdb
node_orchdaemon -->|"reads configuration"| node_configdb
node_orchdaemon -->|"dispatches work"| node_l3
node_orchdaemon -->|"dispatches work"| node_portsorch
node_orchdaemon -->|"dispatches work"| node_fdborch
node_orchdaemon -->|"dispatches work"| node_p4
node_l3 -->|"programs routes"| node_sai
node_portsorch -->|"programs ports"| node_sai
node_fdborch -->|"programs forwarding"| node_sai
node_p4 -->|"programs objects"| node_sai
node_cfgmgr -->|"handles configuration"| node_configdb
node_counterd -->|"subscribes"| node_netlink
node_counterd -->|"starts actor"| node_ipfix
node_netlink -->|"delivers records"| node_ipfix
node_ipfix -->|"forwards statistics"| node_counterdb
node_counterdb -->|"writes counters"| node_appdb
node_ipfix -->|"forwards statistics"| node_stats
node_flex -->|"configures counters"| node_appdb
node_teamd -->|"subscribes to LAG"| node_state_db
node_teamd -->|"updates interfaces"| node_teamctl
node_teamd -->|"stores dumps"| node_teamvalues
node_teamvalues -->|"updates values"| node_state_db

click node_fpm "https://github.com/sonic-net/sonic-swss/blob/master/fpmsyncd/routesync.cpp"
click node_neighbor "https://github.com/sonic-net/sonic-swss/blob/master/neighsyncd/neighsync.cpp"
click node_fdb "https://github.com/sonic-net/sonic-swss/blob/master/fdbsyncd/fdbsync.cpp"
click node_port "https://github.com/sonic-net/sonic-swss/blob/master/portsyncd/linksync.cpp"
click node_orchmain "https://github.com/sonic-net/sonic-swss/blob/master/orchagent/main.cpp"
click node_orchdaemon "https://github.com/sonic-net/sonic-swss/blob/master/orchagent/orchdaemon.cpp"
click node_l3 "https://github.com/sonic-net/sonic-swss/blob/master/orchagent/routeorch.cpp"
click node_portsorch "https://github.com/sonic-net/sonic-swss/blob/master/orchagent/portsorch.cpp"
click node_fdborch "https://github.com/sonic-net/sonic-swss/blob/master/orchagent/fdborch.cpp"
click node_p4 "https://github.com/sonic-net/sonic-swss/blob/master/orchagent/p4orch/p4orch.cpp"
click node_cfgmgr "https://github.com/sonic-net/sonic-swss/tree/master/cfgmgr"
click node_counterd "https://github.com/sonic-net/sonic-swss/blob/master/crates/countersyncd/src/main.rs"
click node_ipfix "https://github.com/sonic-net/sonic-swss/blob/master/crates/countersyncd/src/actor/ipfix.rs"
click node_counterdb "https://github.com/sonic-net/sonic-swss/blob/master/crates/countersyncd/src/actor/counter_db.rs"
click node_stats "https://github.com/sonic-net/sonic-swss/blob/master/crates/countersyncd/src/actor/stats_reporter.rs"
click node_flex "https://github.com/sonic-net/sonic-swss/blob/master/orchagent/flex_counter/flex_counter_manager.cpp"
click node_teamd "https://github.com/sonic-net/sonic-swss/blob/master/tlm_teamd/main.cpp"
click node_teamctl "https://github.com/sonic-net/sonic-swss/blob/master/tlm_teamd/teamdctl_mgr.cpp"
click node_teamvalues "https://github.com/sonic-net/sonic-swss/blob/master/tlm_teamd/values_store.cpp"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_fpm,node_neighbor,node_fdb,node_port toneBlue
class node_orchmain,node_orchdaemon,node_l3,node_portsorch,node_fdborch,node_p4,node_appdb,node_configdb,node_state_db toneAmber
class node_cfgmgr toneMint
class node_counterd,node_ipfix,node_counterdb,node_stats,node_flex toneRose
class node_teamd,node_teamctl,node_teamvalues,node_bgp,node_sai,node_netlink toneIndigo
```

## Components

### State synchronization

- [FPM route sync](https://github.com/sonic-net/sonic-swss/blob/master/fpmsyncd/routesync.cpp): `fpmsyncd/routesync.cpp`
- [Neighbor sync](https://github.com/sonic-net/sonic-swss/blob/master/neighsyncd/neighsync.cpp): `neighsyncd/neighsync.cpp`
- [FDB sync](https://github.com/sonic-net/sonic-swss/blob/master/fdbsyncd/fdbsync.cpp): `fdbsyncd/fdbsync.cpp`
- [Port link sync](https://github.com/sonic-net/sonic-swss/blob/master/portsyncd/linksync.cpp): `portsyncd/linksync.cpp`

### Switch orchestration

- [Orchestration entry](https://github.com/sonic-net/sonic-swss/blob/master/orchagent/main.cpp): `orchagent/main.cpp`
- [Orchestration daemon](https://github.com/sonic-net/sonic-swss/blob/master/orchagent/orchdaemon.cpp): `orchagent/orchdaemon.cpp`
- [Routes and neighbors](https://github.com/sonic-net/sonic-swss/blob/master/orchagent/routeorch.cpp): `orchagent/routeorch.cpp`
- [Ports and interfaces](https://github.com/sonic-net/sonic-swss/blob/master/orchagent/portsorch.cpp): `orchagent/portsorch.cpp`
- [Forwarding database](https://github.com/sonic-net/sonic-swss/blob/master/orchagent/fdborch.cpp): `orchagent/fdborch.cpp`
- [P4 object managers](https://github.com/sonic-net/sonic-swss/blob/master/orchagent/p4orch/p4orch.cpp): `orchagent/p4orch/p4orch.cpp`

### Feature configuration

- [Feature config managers](https://github.com/sonic-net/sonic-swss/tree/master/cfgmgr): `cfgmgr`

### Counters and telemetry

- [Counter sync service](https://github.com/sonic-net/sonic-swss/blob/master/crates/countersyncd/src/main.rs): `crates/countersyncd/src/main.rs`
- [IPFIX processing](https://github.com/sonic-net/sonic-swss/blob/master/crates/countersyncd/src/actor/ipfix.rs): `crates/countersyncd/src/actor/ipfix.rs`
- [Counter database writer](https://github.com/sonic-net/sonic-swss/blob/master/crates/countersyncd/src/actor/counter_db.rs): `crates/countersyncd/src/actor/counter_db.rs`
- [Stats reporter](https://github.com/sonic-net/sonic-swss/blob/master/crates/countersyncd/src/actor/stats_reporter.rs): `crates/countersyncd/src/actor/stats_reporter.rs`
- [Flex counter manager](https://github.com/sonic-net/sonic-swss/blob/master/orchagent/flex_counter/flex_counter_manager.cpp): `orchagent/flex_counter/flex_counter_manager.cpp`

### Team interfaces

- [Team interface daemon](https://github.com/sonic-net/sonic-swss/blob/master/tlm_teamd/main.cpp): `tlm_teamd/main.cpp`
- [Team control manager](https://github.com/sonic-net/sonic-swss/blob/master/tlm_teamd/teamdctl_mgr.cpp): `tlm_teamd/teamdctl_mgr.cpp`
- [Team values store](https://github.com/sonic-net/sonic-swss/blob/master/tlm_teamd/values_store.cpp): `tlm_teamd/values_store.cpp`

### Other components

- **BGP control plane**
- **Application database**
- **Configuration database**
- **SAI switch hardware**
- **Kernel netlink**
- **State database**

## Connections

- BGP control plane → FPM route sync: sends routes
- FPM route sync → Application database: publishes routes
- Neighbor sync → Application database: publishes state
- FDB sync → Application database: publishes state
- Port link sync → Application database: publishes links
- Orchestration entry → Orchestration daemon: starts
- Orchestration daemon → Application database: consumes state
- Orchestration daemon → Configuration database: reads configuration
- Orchestration daemon → Routes and neighbors: dispatches work
- Orchestration daemon → Ports and interfaces: dispatches work
- Orchestration daemon → Forwarding database: dispatches work
- Orchestration daemon → P4 object managers: dispatches work
- Routes and neighbors → SAI switch hardware: programs routes
- Ports and interfaces → SAI switch hardware: programs ports
- Forwarding database → SAI switch hardware: programs forwarding
- P4 object managers → SAI switch hardware: programs objects
- Feature config managers → Configuration database: handles configuration
- Counter sync service → Kernel netlink: subscribes
- Counter sync service → IPFIX processing: starts actor
- Kernel netlink → IPFIX processing: delivers records
- IPFIX processing → Counter database writer: forwards statistics
- Counter database writer → Application database: writes counters
- IPFIX processing → Stats reporter: forwards statistics
- Flex counter manager → Application database: configures counters
- Team interface daemon → State database: subscribes to LAG
- Team interface daemon → Team control manager: updates interfaces
- Team interface daemon → Team values store: stores dumps
- Team values store → State database: updates values
