Getting Started with SONiC
为什么要做SONiC
We know that there is a operating system running inside every switches, no matter if it is complicated or not. It is used for configuring and checking the status of the switch. Since the first switch came out in 1986, with various manufacturers have been doing related development, nowadays, we have a lot of different OSes. However, there are still some problems, for example:
- 生态封闭,不开源,主要是为了支持自家的硬件,无法很好的兼容其他厂商的设备
- 支持的场景很有限,难以使用同一套系统去支撑大规模的数据中心中复杂多变的场景
- 升级可能会导致网络中断,难以实现无缝升级,这对于云提供商来说有时候是致命的
- 设备功能升级缓慢,难以很好的支持快速的产品迭代
Therefore, Microsoft initiated an open-source project in 2016 - SONiC, so that we can solve the problems above by building universal network operating system (NOS). Moreover, Microsoft is widely using SONiC in Azure, which ensures SONiC can indeed support large scale cloud environments. This is also an advantage of SONiC.
主体架构
SONiC is an open-source network operating system (NOS) based on Debian and developed by Microsoft. It is designed with three core principles:
- 硬件和软件解耦:通过SAI(Switch Abstraction Interface)将硬件的操作抽象出来,从而使得SONiC能够支持多种硬件平台。这一层抽象层由SONiC定义,由各个厂商来实现。
- 使用docker容器将软件微服务化:SONiC上的主要功能都被拆分成了一个个的docker容器,和传统的网络操作系统不同,升级系统可以只对其中的某个容器进行升级,而不需要整体升级和重启,这样就可以很方便的进行升级和维护,支持快速的开发和迭代。
- 使用redis作为中心数据库对服务进行解耦:绝大部分服务的配置和状态最后都被存储到中心的redis数据库中,这样不仅使得所有的服务可以很轻松的进行协作(数据存储和pubsub),也可以让我们很方便的在上面开发工具,使用统一的方法对各个服务进行操作和查询,而不用担心状态丢失和协议兼容问题,最后还可以很方便的进行状态的备份和恢复。
这让SONiC拥有了非常开放的生态(Community,Workgroups,Devices),总体而言,SONiC的架构如下图所示:
(Source: SONiC Wiki - Architecture)
Of course, such design also has some disadvantages, such as: the disk usage will increase. However, nowadays storage space is usually not a big issue, and it can also be solved or eased by various ways.
发展方向
Although switches have been developed for many years, with the development of the cloud nowadays, the demands of network becomes higher and higher. No matter it's intuitive features, such as larger bandwidth and larger capacity, or the latest research, such as in-band computing, end-network fusion, etc., all result in higher requirements and challenges to the development of switches, as well as continuous innovations from manufacturers and research institutions. The same goes for SONiC. As time goes on, the number of feature request has not decreased at all.
关于SONiC的发展方向,我们可以在它的Roadmap中看到。如果大家对最新的动态感兴趣,也可以关注它的Workshop,比如,最近的OCP Global Summit 2022 - SONiC Workshop。这里就不展开了。
感谢
Huge thanks to the following friends for their help and contributions! Without you there would be no way to get this book done!
License
This book uses the CC BY-NC-SA 4.0 License Agreement.
参考资料
- SONiC Wiki - Architecture
- SONiC Wiki - Roadmap Planning
- SONiC Landing Page
- SONiC Workgroups
- SONiC Supported Devices and Platforms
- SONiC User Manual
- OCP Global Summit 2022 - SONiC Workshop