Skip to content

added autonomous lab telco example #292

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "16b65cd9-dcb9-4b32-b7ac-ae152db55c00",
"metadata": {},
"source": [
"### Automate 5G Network Configurations with NVIDIA AI LLM Agents and Kinetica Accelerated Database"
]
},
{
"cell_type": "markdown",
"id": "b08157d5-eeea-463b-927b-10792da54d18",
"metadata": {},
"source": [
"This DLI introduces an Agentic Generative AI solution designed to address bandwidth allocation challenges in 5G networks. It is divided into two parts that guide you through setting up and managing a 5G network."
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "64f0e900-6e16-4054-b124-820a5dae11eb",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Cloning into 'autonomous_5g_slicing_lab'...\n",
"remote: Enumerating objects: 9025, done.\u001b[K\n",
"remote: Counting objects: 100% (9025/9025), done.\u001b[K\n",
"remote: Compressing objects: 100% (4230/4230), done.\u001b[K\n",
"remote: Total 9025 (delta 4692), reused 8969 (delta 4650), pack-reused 0 (from 0)\u001b[K\n",
"Receiving objects: 100% (9025/9025), 33.87 MiB | 55.32 MiB/s, done.\n",
"Resolving deltas: 100% (4692/4692), done.\n"
]
}
],
"source": [
"!git clone https://github.com/acanaveras/autonomous_5g_slicing_lab.git\n"
]
},
{
"cell_type": "markdown",
"id": "7eb5c629-44da-4d33-97d0-40717c65c6a6",
"metadata": {},
"source": [
"Insert your API Key in the next cell to get it stored for the application"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "fffa0783-c270-4ed6-9b4b-1f5040341f4f",
"metadata": {},
"outputs": [
{
"name": "stdin",
"output_type": "stream",
"text": [
"Enter your API Key: ········\n"
]
},
{
"ename": "FileNotFoundError",
"evalue": "[Errno 2] No such file or directory: '/autonomous_5g_slicing_lab/agentic-llm/config.yaml'",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mFileNotFoundError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[0;32mIn[2], line 25\u001b[0m\n\u001b[1;32m 22\u001b[0m config[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mAPI_KEY\u001b[39m\u001b[38;5;124m'\u001b[39m] \u001b[38;5;241m=\u001b[39m api_key\n\u001b[1;32m 24\u001b[0m \u001b[38;5;66;03m# Write the updated configuration back to the YAML file\u001b[39;00m\n\u001b[0;32m---> 25\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m \u001b[38;5;28;43mopen\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43myaml_path\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mw\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m)\u001b[49m \u001b[38;5;28;01mas\u001b[39;00m file:\n\u001b[1;32m 26\u001b[0m yaml\u001b[38;5;241m.\u001b[39msafe_dump(config, file)\n\u001b[1;32m 28\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m✅ API Key successfully saved to config.yaml\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n",
"File \u001b[0;32m/usr/local/lib/python3.10/dist-packages/IPython/core/interactiveshell.py:324\u001b[0m, in \u001b[0;36m_modified_open\u001b[0;34m(file, *args, **kwargs)\u001b[0m\n\u001b[1;32m 317\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m file \u001b[38;5;129;01min\u001b[39;00m {\u001b[38;5;241m0\u001b[39m, \u001b[38;5;241m1\u001b[39m, \u001b[38;5;241m2\u001b[39m}:\n\u001b[1;32m 318\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mValueError\u001b[39;00m(\n\u001b[1;32m 319\u001b[0m \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mIPython won\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mt let you open fd=\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mfile\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m by default \u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 320\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mas it is likely to crash IPython. If you know what you are doing, \u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 321\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124myou can use builtins\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m open.\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 322\u001b[0m )\n\u001b[0;32m--> 324\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mio_open\u001b[49m\u001b[43m(\u001b[49m\u001b[43mfile\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n",
"\u001b[0;31mFileNotFoundError\u001b[0m: [Errno 2] No such file or directory: '/autonomous_5g_slicing_lab/agentic-llm/config.yaml'"
]
}
],
"source": [
"import yaml\n",
"from getpass import getpass\n",
"from pathlib import Path\n",
"\n",
"# Prompt for API Key securely (input not shown)\n",
"api_key = getpass(\"Enter your API Key: \")\n",
"\n",
"# Define the path to the YAML file\n",
"yaml_path = Path(\"./autonomous_5g_slicing_lab/agentic-llm/config.yaml\")\n",
"\n",
"# Read existing YAML if it exists, otherwise start fresh\n",
"if yaml_path.exists():\n",
" with open(yaml_path, 'r') as file:\n",
" try:\n",
" config = yaml.safe_load(file) or {}\n",
" except yaml.YAMLError:\n",
" config = {}\n",
"else:\n",
" config = {}\n",
"\n",
"# Insert or update the API_KEY\n",
"config['API_KEY'] = api_key\n",
"\n",
"# Write the updated configuration back to the YAML file\n",
"with open(yaml_path, 'w') as file:\n",
" yaml.safe_dump(config, file)\n",
"\n",
"print(\"✅ API Key successfully saved to config.yaml\")\n"
]
},
{
"cell_type": "markdown",
"id": "a77a79b9-644e-4b4f-b781-ea6810a99980",
"metadata": {},
"source": [
"### Agentic LLMs for 5G Section\n",
"\n",
"Once you have the **5G Lab GitHub** repository cloned, you can proceed to the **Agentic LLMs** section. This part of the lab demonstrates how to deploy an agentic workflow to monitor network performance and dynamically adjust bandwidth allocation.\n",
"\n",
"- **Part A – Setup of 5G Lab environment** \n",
" Located at: `./autonomous5g_slicing_lab/llm-slicing-5g-lab/DLI_Lab_Setup.ipynb` \n",
" Provides instructions to set up a 5G Network Software Stack in your environemnt.\n",
"\n",
"- **Part B – 5G Network Agent Workflow** \n",
" Located at: `./autonomous5g_slicing_lab/agentic-llm/agentic_pipeline_DLI.ipynb` \n",
" Explains the agentic pipeline in **LangGraph** for managing 5G network slicing and bandwidth allocation.\n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.12"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
93 changes: 93 additions & 0 deletions community/autonomous_5g_slicing_lab/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# 5G Network Simulator Lab with Agentic Workflow

This repository contains Jupyter notebooks to set up and run an open-source 5G Network Simulator lab, coupled with an Agentic Generative AI solution for dynamic bandwidth allocation. The lab uses Open Air Interface (OAI) for the 5G Core and RAN, FlexRIC for slice management, and iPerf for traffic generation, with performance data logged in a Kinetica database. The agentic workflow, powered by a LangGraph agent, analyzes traffic data and optimizes bandwidth allocation.

## Overview

The repository is organized into two main tasks:
1. **Lab Setup**: Configures a 5G network simulation environment with a core network, gNodeB, two User Equipment (UE) simulators, and traffic generation tools.
2. **Agentic Workflow**: Runs a LangGraph-based UI to monitor network performance and adjust bandwidth allocation dynamically.

A shutdown notebook is also provided to reinitialize the lab if needed.

## Prerequisites

To run the lab, ensure you have:
- **Operating System**: Ubuntu (tested on 20.04 or later).
- **Hardware**: A machine with sufficient resources (e.g., 8GB RAM, multi-core CPU, optional GPU for Kinetica).
- **Software**:
- Docker and Docker Compose for the 5G Core Network.
- Python 3.10+ with Jupyter Notebook.
- iPerf3 (`sudo apt install -y iperf3`).
- Kinetica database access (credentials in `.env` file).
- **Dependencies**: Listed in `requirements.txt` in the respective directories.
- **Repository Contents**: Clone this repository and verify the presence of all files, including configuration files (`ran-conf/`), scripts (`build_ric_oai_ne.sh`, `multi_ue.sh`, `change_rc_slice.sh`), and Docker Compose files.

## Lab Setup

The lab setup configures a fully functional 5G network simulation environment. To set up the lab, run the Jupyter notebook located at `autonomous_5g_slicing_lab/llm-slicing-5g-lab/DLI_Lab_Setup.ipynb`. The notebook automates the following steps:

1. **Install Dependencies**: Installs iPerf3 and Python packages required for the lab, then restarts the Jupyter kernel to apply changes.
2. **Compile FlexRIC and gNodeB**: Builds the FlexRIC and gNodeB components using a provided script, preparing the RAN Intelligent Controller and base station software.
3. **Set Up 5G Core Network**: Launches the 5G Core Network functions for two network slices using Docker Compose, ensuring each slice has its own Session Management Function (SMF) and User Plane Function (UPF).
4. **Start FlexRIC**: Activates the FlexRIC to manage gNodeB parameters dynamically, logging output for troubleshooting.
5. **Start gNodeB**: Runs the OAI softmodem to simulate the gNodeB, connecting it to the core network and FlexRIC.
6. **Initialize Bandwidth Allocation**: Sets an initial 50/50 bandwidth split between the two slices, ensuring balanced resource allocation.
7. **Start User Equipment (UEs)**: Launches two UE simulators (UE1 and UE3), each connected to a separate slice, to interact with the gNodeB.
8. **Start iPerf Server**: Runs two iPerf3 servers on the external network to receive traffic from the UEs via the UPF.
9. **Generate Traffic and Log Data**: Runs iPerf clients on the UEs to generate UDP traffic at alternating speeds (30 Mbps and 120 Mbps), logging performance metrics (e.g., bitrate, packet loss) to a Kinetica database and local log files.

To execute these steps, open `autonomous_5g_slicing_lab/llm-slicing-5g-lab/DLI_Lab_Setup.ipynb` in Jupyter Notebook and run the cells sequentially. Monitor the logs in the `logs/` directory (e.g., `tail -f logs/UE1_iperfc.log`) for real-time feedback.

## Running the Agentic Workflow

Once the lab is set up, you can run the agentic workflow to monitor network performance and dynamically adjust bandwidth allocation. The workflow uses a LangGraph-based agent to analyze Kinetica database logs and optimize slice configurations.

To run the agentic workflow:
1. Open the Jupyter notebook at `autonomous_5g_slicing_lab/agentic-llm/agentic_pipeline-DLI.ipynb` in Jupyter Notebook.
2. Execute the cells to launch the LangGraph agent UI. The UI interacts with the 5G network simulator, retrieves performance data from the Kinetica database, and issues commands to FlexRIC to adjust bandwidth allocation based on traffic demands.

Ensure the lab setup (`DLI_Lab_Setup.ipynb`) is fully running before starting the agentic workflow, as it relies on the active 5G network simulation and traffic generation.

## Reinitializing the Lab

If you need to reset or reinitialize the lab (e.g., to clear logs, stop processes, or restart the environment), use the shutdown notebook:
- Open `autonomous_5g_slicing_lab/llm-slicing-5g-lab/DLI_Lab_Shutdown.ipynb` in Jupyter Notebook.
- Run the cells to gracefully stop all running processes (e.g., FlexRIC, gNodeB, UEs, iPerf servers) and clean up resources.

After running the shutdown notebook, you can restart the lab by re-running `DLI_Lab_Setup.ipynb`.

## Usage Notes

- **Execution Order**: Complete the lab setup before running the agentic workflow. The shutdown notebook can be used at any time to reset the environment.
- **Monitoring**: Check logs in `autonomous_5g_slicing_lab/llm-slicing-5g-lab/logs/` for debugging (e.g., `RIC.log`, `UE1.log`, `UE1_iperfc.log`).
- **Kinetica Access**: Use the credentials in `autonomous_5g_slicing_lab/llm-slicing-5g-lab/.env` (e.g., `KINETICA_USERNAME=nvidia_gtc_2025`, `KINETICA_PASSWORD=Kinetica123!`) to access the Kinetica database at `https://demo72.kinetica.com/gadmin/`.
- **Network Configuration**: The notebooks assume specific IP addresses (e.g., `12.1.1.2`, `192.168.70.135`). Modify these in the notebooks if your setup differs.
- **Environment**: The lab is designed for a controlled DLI environment. For personal machines, ensure all dependencies and the full repository directory are available.

## Repository Structure

- `autonomous_5g_slicing_lab/llm-slicing-5g-lab/`:
- `DLI_Lab_Setup.ipynb`: Notebook for setting up the 5G network simulator.
- `DLI_Lab_Shutdown.ipynb`: Notebook for reinitializing the lab.
- `requirements.txt`: Python dependencies for the lab.
- `build_ric_oai_ne.sh`: Script to compile FlexRIC and gNodeB.
- `docker-compose-oai-cn-slice1.yaml`, `docker-compose-oai-cn-slice2.yaml`: Docker Compose files for 5G Core Network slices.
- `ran-conf/`: Configuration files for gNodeB and UEs.
- `multi_ue.sh`: Script to start UE simulators.
- `change_rc_slice.sh`: Script to adjust bandwidth allocation.
- `.env`: Environment variables (e.g., Kinetica credentials).
- `logs/`: Directory for log files (created during execution).
- `autonomous_5g_slicing_lab/agentic-llm/`:
- `agentic_pipeline-DLI.ipynb`: Notebook for running the LangGraph agent UI.
- `requirements.txt`: Python dependencies for the agentic workflow.

## References

- [Open Air Interface 5G Core Network](https://openairinterface.org/oai-5g-core-network-project/)
- [OAI Softmodem RAN](https://github.com/simula/openairinterface5g/blob/dreibh/simulamet-testbed/doc/RUNMODEM.md)
- [iPerf Tool](https://iperf.fr/)
- [Kinetica Database](https://www.kinetica.com/)
- [LangGraph](https://github.com/langchain-ai/langgraph)

For issues or contributions, please open a GitHub issue or submit a pull request.
Loading