# Traffic-Engineering App
This traffic-enginerring application will dynamically perform load-balancing among the output ports of any Equal-Cost Multi-Path (ECMP) group in the network.  In the ECMP scheme, flows are dispatched to the output ports of an ECMP group based on the hash function used by ECMP and the five-tuple infomation (i.e., the source and destination IP addresses, the source and destination port numbers, and the protocol type) in their packet headers. When the load dispatched to the output ports of many ECMP groups is imbalanced in the network, this application can significantly improve the  utilization of the network.  


Canonical URL: https://www.ndtwin.org/docs/tutorials-and-demo-videos/ndtwin-applications/trafficengineeringapp/

---


[![Watch the demo](https://img.youtube.com/vi/4SIjzu8RjyY/hqdefault.jpg)](https://www.youtube.com/watch?v=4SIjzu8RjyY)

| Component | Description | Format | Link |
| :--- | :--- | :--- | :--- |
| **Pre-configured Demo VM** | A fully set up virtual environment with all NDTwin components installed. Requires  VMware. | `.ova` | [Download](https://drive.google.com/file/d/1GKkT7UygMzFSda6zIpJio0vQh7jWsXU_/view?usp=sharing) |

This manual provides a step-by-step guide to deploying the **NDTwin Traffic Engineering App**.

---

## 1. Ryu SDN Controller

* **Path:** `~/NDTwin/Desktop`
* **Environment:** `ryu-env`
* **Note:** The controller must be started first to observe and manage the network links.

1. Navigate to the directory:

```bash
cd ~/NDTwin/Desktop

```

2. Activate the environment:

```bash
conda activate ryu-env

```

3. Execute the controller:

```bash
ryu-manager intelligent_router_static_topo.py --observe-link

```

---

## 2. Mininet Network Topology

* **Path:** `~/Desktop/Network-Traffic-Generator`
* **Environment:** `ntg_env`
* **Note:** Password for `sudo` is `ndtwin`. This step builds a network topology with 128 nodes.

1. Navigate to the directory:

```bash
cd ~/Desktop/Network-Traffic-Generator

```

2. Activate the environment:

```bash
conda activate ntg_env

```

3. Execute the topology script:

```bash
sudo $(which python) example_topology.py

```

---

## 3. NDTwin Kernel

* **Path:** `~/Desktop/NDTwin-Kernel/build`
* **Note:** Requires manual selection of deployment and AI features during startup.

1. Navigate to the build directory:

```bash
cd ~/Desktop/NDTwin-Kernel/build

```

2. Execute the kernel:

```bash
sudo ./bin/ndtwin_kernel --loglevel info

```

3. Select startup configurations:
* **Environment:** Enter `1` (Mininet / Simulated testbed).
* **OpenAI Token:** Enter `2` (Disable AI features).



---

## 4. Network Traffic Visualizer

* **Path:** `~/Desktop/Network-Traffic-Visualizer`
* **Note:** Provides a GUI to monitor the live network state and traffic flows.

1. Navigate to the directory:

```bash
cd ~/Desktop/Network-Traffic-Visualizer

```

2. Run the visualizer script:

```bash
./network_traffic_visualizer.sh

```

---

## 5. Traffic Engineering App

* **Path:** `~/Desktop/Traffic-Engineering-App`
* **Environment:** `te-env` (Python 3.12)
* **Note:** Uses `$(which python)` to force `sudo` to use the Conda environment's Python instead of the system Python.

1. Navigate to the directory:

```bash
cd ~/Desktop/Traffic-Engineering-App

```

2. Activate the environment:

```bash
conda activate te-env

```

3. Execute the application:

```bash
sudo $(which python) Traffic-Engineering-App.py

```

---

## 6. Traffic Generation and Load Balancing

* **Note:** This step simulates network load and applies the TE balancing logic.

1. In the **Network Traffic Generator** terminal, start the flows:

```bash
# Inside the NTG interface
flow --config
# Select the configuration file
config_template.json

```

2. In the **TE App** terminal, select the execution mode:
* **Select TE Mode:** Enter `2` (Execute periodically).
* **Execution Interval:** Enter `5` (Seconds).


3. **Verify Results:** * Monitor the Visualizer GUI to see the skewed traffic rebalance.
* Check the App logs for the message: `XX entries are added`.

