Site Search

SONiC Workshop ~Ask a Generative AI about SONiC source code~

Introduction
This article is a summary of a talk given at the SONiC workshop held on May 16, 2025.
The purpose of this article is to promote understanding of the SONiC source code by using various generative AIs; it is not intended to provide detailed explanations of specific code or compare the performance of generative AIs.
Please note that the generation AI can also make mistakes (hallucination), so please be sure to check that the content is correct.

If you would like to receive the presentation materials, please download them below.

We asked the generative AI about the SONiC source code

Results of a chat-based question about the SONiC source code

First, let me share with you what I found out through chat about the SONiC source code.

ChatGPT4o by Open AI
"Where is the SONiC source code available?"
I asked, "

ChatGPT answers are published in the following GitHub repository:
He introduced me to "github.com", "sonic-net" and "SONiC".

Next, Google Gemini 2.0 Flash Deep Research
"Refer to the official SONiC GitHub repository and see a table of newly added features for all releases from 202305 to 202505."
I asked him to do so.

There seems to be no mistake in the main part, but please note that you need to check the details of the content.

Next, Claude 3.7 Sonnet from Anthoropic
"How to compile SONiC source code in 10 lines"
When I asked him to do so, he summarized it in 10 easy-to-understand lines.

  1. Install the necessary build tools (make, gcc/g++, pkg-config) and libraries (libwebpb, libfltk, libtiff, libpng, libjpeg)
  2. Download the SONiC source code from the repository (git clone)
  3. Change to the source code directory (cd sonic)
  4. Run the configure script to set up the environment (./configure)
  5. Build with the make command (make)
  6. Install it on your system with the make install command (sudo make install)
  7. If you have any problems with dependencies, run ./configure --help to see what options you need.
  8. To do a debug build, run CFLAGS="-g -O0"./configure
  9. To build only a specific component, run make[component]
  10. If you have problems after building, run make clean and then rebuild.

Reference: https://claude.ai/new


In this way, we asked about the SONiC source code through chat, and found that we were able to obtain useful information just by asking through chat.

Results of listening while referring to the SONiC source code

Next, I listened to it while referring to the SONiC source code.

As ChatGPT pointed out, there is a source code repository on GitHub at sonic-net.

Go to the Sonic-mgmt repository and click the Copilot button in the top right.
When I asked, "What is the overview of this repository?"
"There is software designed for managing and automating SONiC networks," he told me.

Go to tests, vlan, open test_vlan.py and
When I asked "Tell me how to use test_vlan.py"
He explained the configuration, functions, and actual usage.

Next, open a Pull Request for the sonic-mgmt repository.
When I asked "What is the summary of this Pull Request?"
"This PR adds/removes code related to docker-ptf for Python3."
He explained to me:

Microsoft's Visual Studio Code editor

Here is an example using Microsoft's Visual Studio Code editor.

You can clone a GitHub repository locally in VS Code and view it.

VS Code allows you to install various extensions, so
Add the GitHub Copilot Chat extension,
When I open a bgp-related file in Sonic-swss and ask for "File Summary"
"It's a script that sets the End of Initial Update marker during a BGP warm reboot," he explained.

A similar extension to GitHub Copilot Chat
Install Gemini Code Assist Chat and
I opened the Sonic-swss teamsyncd-related cpp file and listened to the "File Overview".
He then explained to me that it "synchronizes the LAG status, configuration database, and state database."

I asked the questions while referring to the SONiC source code on GitHub and VS Code, and they answered based on the source code I wanted to know about.

Results of importing and listening to the data in NotebookLM

NotebookLM is an AI research assistant provided by Google.

It loads PDFs, web pages, YouTube videos, etc., summarizes the contents of the document, and provides answers based on the document.
It generates overviews, FAQs, and guide notes based on the content of the documentation without asking any questions.
Even if you don't have the materials on hand, they will search for information online, summarize it in mind map format, and explain things to you through a podcast audio recording by two people, a man and a woman.

You can access NotebookLM to add sources.
You can upload PDFs, websites, YouTube videos, and texts. If you don't have any materials on hand,
If you enter "SONiC source code",
It automatically imports 10 SONiC source code related web pages and documents and creates overview notes, comprehension guides and mind maps in just a few minutes.

Also, if you click on the audio summary, in a few minutes you will hear a podcast audio commentary by a man and a woman, so you can understand with your ears as well as your eyes.

I tried importing SONiC source code-related information into NotebookLM and asking questions about it, and found that it summarizes the overview without the need for questions, so it can be used when you want to understand the whole picture.

Results of asking on DeepWiki

Next I asked on DeepWiki.
DeepWiki is a service provided by Cognition Labs that automatically analyzes and explains GitHub repositories.
It automatically analyzes the code base and generates diagrams to help you understand it visually, such as architectural diagrams and flowcharts, and you can also ask questions via chat.

It's very easy to use; just replace github in the GitHub URL with deepwiki.

For example, if you open the sonic-net / sonic-sairedis repository on github, it looks like this.

If you change github to deepwiki, you will find a detailed explanation of sonic-sairedis, including its overview and architecture.
In this example, the Japanese translation was done using the Chrome browser.

For example, if you ask "Please explain the relationship between SAI and REDIS" on the Deepwiki chat screen,
"We use REDIS as the communication mechanism for our SAI API implementation," he explained.

After asking about the SONiC repository on DeepWiki, I found that it is ideal for promoting understanding of the repository, as it provides easy-to-understand explanations of the source code in the repository.

SONiC configuration CLI command generation results

Finally, we will show you the results of generating a SONiC configuration CLI command.
I asked ChatGPT to generate a CLI script to add Ethernet1 and Ethernet2 to the untagged members of vlan10 using SONiC.
It generated a 3 line CLI command for me.

An error occurred at first, but when I ran it with sudo it ran without error and the VLAN configuration results were as expected.

Next, generate a CLI script to configure the following ACLs in ecSONiC:
Add sudo, Table name, Priority, and discard if IP received on Ethernet0 is a certain value.
When I asked for this, it generated a three-line CLI command.

When I tried to run it, an error occurred because the argument settings for the ACL rule setting command seemed to be incorrect.
The ACL table was created, but Ethernet 0 was not specified and all ports were specified.

When I tried running the correct CLI script, the ACL settings were as expected.

I tried generating a SONiC configuration CLI command using ChatGPT and was able to set up a simple VLAN, but an error occurred when trying to set up a more complicated ACL.
As the generating AI learns more SONiC CLI information in the future and becomes smarter, it will likely be able to handle more complex settings, but it looks like it will be a while before that happens.

Summary

・The use of generative AI is spreading in the world of coding
・SONiC source code can also be explained in an easy-to-understand manner using generated AI
・Read the source code to gain a deeper understanding of how SONiC works
・We are also working on generating configuration CLI scripts.

Make AI your ally and enjoy Happy SONiC Life!


Click here for list of materials

Document list

In addition to introducing products handled by Macnica,
We publish materials related to open networking, such as BGP cross network automatic construction files and network operation test evaluation reports.

Click here for details

Product Page Top

Aviz Networks

We are pioneers of SONiC, an open source network operating system, providing observability, configuration automation tools and support from a team of SONiC experts.

Edgecore Networks

We continue to be a pioneer in open networking by developing and selling products related to OpenNetworking/white Box switches.

IP Infusion

As a market leader among open networking providers, we provide reliable network solutions to over 600 customers, including carriers, service providers, and data centers.

Inquiry/Document request

In charge of Macnica Edgecore Networks

Weekdays: 9:00-17:00