Skip to content

Commit

Permalink
Merge pull request #11 from KathiraveluLab/dev
Browse files Browse the repository at this point in the history
Emulator Package Refactoring & Documentation
  • Loading branch information
pradeeban authored Sep 26, 2024
2 parents 673b278 + ed28f77 commit 0e9a769
Show file tree
Hide file tree
Showing 190 changed files with 12,100 additions and 181 deletions.
35 changes: 35 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Read the Docs configuration file for Sphinx projects
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Set the OS, Python version and other tools you might need
build:
os: ubuntu-22.04
tools:
python: "3.12"
# You can also specify other tool versions:
# nodejs: "20"
# rust: "1.70"
# golang: "1.20"

# Build documentation in the "docs/" directory with Sphinx
sphinx:
configuration: modules/emulator/docs/conf.py
# You can configure Sphinx to use a different builder, for instance use the dirhtml builder for simpler URLs
# builder: "dirhtml"
# Fail on all warnings to avoid broken references
# fail_on_warning: true

# Optionally build your docs in additional formats such as PDF and ePub
# formats:
# - pdf
# - epub

# Optional but recommended, declare the Python requirements required
# to build your documentation
# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
python:
install:
- requirements: modules/emulator/requirements.txt
44 changes: 30 additions & 14 deletions modules/emulator/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,25 @@
# Mininet Emulator
<div align="center">
<img src="images/AWANTA.png" alt="Project Header">
</div>

<div align="center">
<h1>AWANTA SDN Emulator</h1>
</div>

[//]: # (Need to add github actions - code coverage and build success badges)
<div align="center">

<a href="https://www.python.org/downloads/release/python-370/">![Python 3.7+](https://img.shields.io/badge/python-3.7+-blue.svg)</a>
<a href="https://github.com/KathiraveluLab/AWANTA/blob/dev/CODE_OF_CONDUCT.md">![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-v1.4%20adopted-ff69b4.svg)</a>
<a href="https://awanta-sdn-emulator.readthedocs.io/en/latest/?badge=latest">![Documentation Status](https://readthedocs.org/projects/awanta-sdn-emulator/badge/?version=latest)</a>
<a href="https://github.com/KathiraveluLab/AWANTA/discussions">![Discussion](https://img.shields.io/badge/Discuss-Ask%20Questions-blue])</a>

</div>

This project provides an emulator designed to simulate a small, fully connected mesh network with n nodes. The primary purpose of this emulator is to demonstrate and analyze network path changes under varying conditions.
Our emulator performs a trace-driven simulation, leveraging real-world latency data obtained from RIPE Atlas nodes. By injecting these latency traces during iperf tests conducted between the start and destination nodes, we can replicate realistic network conditions and observe the effects on performance.


This emulator is designed to emulate a small 3 node network to show path changes in the network. Here we perform a trace driven simulation by taking latency measurements from RIPE Atlas nodes and injecting the traces during an iperf test from start node to destination node.

## Getting Started

Expand Down Expand Up @@ -39,16 +58,21 @@ Download python 3.7+ binaries from here
https://www.python.org/downloads/
```


## Running the Mininet Emulator

To run with the given topology, please run this command.
```
$ sudo mn --custom modules/emulator/topology.py --topo network_topology
$ sudo python run_topology.py -topo <custom_topology_class>
```

Or run the topology file directly
### Custom Topology

For example, create a custom mininet topology class under network_manager/custom_topologies and register it under a name of your choice under network_manager/custom_topologies/__init__.py in the topology_map variable.

For an illustration a full_mesh_topology class has been created and is used by default when no topology is given in the command line interface.
```
$ sudo python3 modules/emulator/topology.py
$ sudo python3 -topo full_mesh_topology
```
Please do note that mininet requires sudo access, so when running these commands, don't forget to use sudo.

Expand All @@ -60,14 +84,6 @@ To start the ryu controller, install the ryu package from pip or build it from s
$ ryu-manager --observe-links modules/emulator/controller.py
```

## Topology Design

![Network Topology.png](images%2FNetwork%20Topology.png)



## Trace Driven Simulation Results

We utilize RIPE ATLAS trace results from the measurement module and integrate it with the SDN Framework. The SDN Framework dynamically switches the path based on these latency metrics. These experiments are yet to be done.
The controller has a configuration file ```controller.conf```, which contains the trace_manager to use and the routing strategy to use. These variables are passed through the .conf file because ryu controller does not allow command line arguments in the shell.


35 changes: 25 additions & 10 deletions modules/emulator/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,29 @@
from ryu.lib import hub
from ryu.topology import event

from network_manager import NetworkManager
from routing import Routing
from trace_manager import TraceManager
from constants import *
from src.routing.routing import Routing
from src.trace_manager.TraceManager import TraceManager
from src.network_manager.network_manager import NetworkManager
from src.trace_manager import trace_manager
from src.routing import routing

from ryu import cfg
from src.utils.constants import *


class Controller(app_manager.RyuApp):

def __init__(self, *args, **kwargs):
super(Controller, self).__init__(*args, **kwargs)
self.network_manager = NetworkManager()
self.trace_manager = TraceManager(TraceManagerConstants.PATH)
self.latency_data = self.trace_manager.process_files()
self.datapaths = {}
self.routing = Routing(self.network_manager, self.latency_data, self.datapaths)
self.network_manager = NetworkManager()
conf = cfg.CONF
conf.register_opts([
cfg.StrOpt('trace_manager', default="custom_latency_extractor", help=('Select the trace manager strategy')),
cfg.StrOpt('routing', default='latency_relaxing', help=('Select the routing strategy'))])

self.trace_manager: TraceManager = trace_manager[conf.trace_manager](TraceManagerConstants.PATH)
self.routing: Routing = routing[conf.routing](self.network_manager, self.datapaths)
self.monitor_thread = hub.spawn(self._monitor)

@set_ev_cls(ofp_event.EventOFPStateChange,
Expand Down Expand Up @@ -72,13 +80,20 @@ def add_flow(self, datapath, priority, match, actions, buffer_id=None):

def _monitor(self):
try:
self.trace_manager.process_files()
while True:
if len(self.datapaths) != 0:
self.routing.fetch_latency_results()
measurement_data = self.trace_manager.get_next_state()
if measurement_data is not None:
self.routing.fetch_latency_results(measurement_data)
else:
raise StopIteration
hub.sleep(ControllerConstants.FREQUENCY)
except StopIteration as e:
self.logger.error("Reached End of Measurement Data, Stopping Periodic Routing")
except Exception as e:
self.logger.error("Stopping Periodic Routing, Unexpected Error Occurred")
raise e
self.logger.error("Stopping periodic routing")

@set_ev_cls(event.EventSwitchEnter)
def handler_switch_enter(self, ev):
Expand Down
20 changes: 20 additions & 0 deletions modules/emulator/docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = .
BUILDDIR = _build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added modules/emulator/docs/_build/doctrees/src.doctree
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
4 changes: 4 additions & 0 deletions modules/emulator/docs/_build/html/.buildinfo
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Sphinx build info version 1
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
config: 70ebaf538ec82ce315eb054d37c9cb47
tags: 645f666f9bcd5a90fca523b33c5a78b7
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
114 changes: 114 additions & 0 deletions modules/emulator/docs/_build/html/_modules/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
<!DOCTYPE html>
<html class="writer-html5" lang="en" data-content_root="../">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Overview: module code &mdash; AWANTA SDN Emulator 0.0.1 documentation</title>
<link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=80d5e7a1" />
<link rel="stylesheet" type="text/css" href="../_static/css/theme.css?v=19f00094" />


<!--[if lt IE 9]>
<script src="../_static/js/html5shiv.min.js"></script>
<![endif]-->

<script src="../_static/jquery.js?v=5d32c60e"></script>
<script src="../_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="../_static/documentation_options.js?v=d45e8c67"></script>
<script src="../_static/doctools.js?v=9a2dae69"></script>
<script src="../_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="../_static/js/theme.js"></script>
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
</head>

<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" >



<a href="../index.html" class="icon icon-home">
AWANTA SDN Emulator
</a>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
<input type="text" name="q" placeholder="Search docs" aria-label="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
<ul>
<li class="toctree-l1"><a class="reference internal" href="../overview/overview.html">Overview</a></li>
<li class="toctree-l1"><a class="reference internal" href="../design.html">Modules</a></li>
<li class="toctree-l1"><a class="reference internal" href="../emulation/emulation.html">Running an Emulation</a></li>
</ul>

</div>
</div>
</nav>

<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="../index.html">AWANTA SDN Emulator</a>
</nav>

<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="Page navigation">
<ul class="wy-breadcrumbs">
<li><a href="../index.html" class="icon icon-home" aria-label="Home"></a></li>
<li class="breadcrumb-item active">Overview: module code</li>
<li class="wy-breadcrumbs-aside">
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">

<h1>All modules for which code is available</h1>
<ul><li><a href="src/exceptions/exceptions.html">src.exceptions.exceptions</a></li>
<li><a href="src/network_manager/custom_topologies/full_mesh_topology.html">src.network_manager.custom_topologies.full_mesh_topology</a></li>
<li><a href="src/network_manager/network_manager.html">src.network_manager.network_manager</a></li>
<li><a href="src/routing/latency_relaxing.html">src.routing.latency_relaxing</a></li>
<li><a href="src/routing/routing.html">src.routing.routing</a></li>
<li><a href="src/trace_manager/Measurement.html">src.trace_manager.Measurement</a></li>
<li><a href="src/trace_manager/NodeMeasurement.html">src.trace_manager.NodeMeasurement</a></li>
<li><a href="src/trace_manager/TraceManager.html">src.trace_manager.TraceManager</a></li>
<li><a href="src/trace_manager/custom_latency_extractor.html">src.trace_manager.custom_latency_extractor</a></li>
<li><a href="src/utils/constants.html">src.utils.constants</a></li>
<li><a href="src/utils/utils.html">src.utils.utils</a></li>
</ul>

</div>
</div>
<footer>

<hr/>

<div role="contentinfo">
<p>&#169; Copyright 2024, Sai Vamsi Alisetti.</p>
</div>

Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
<a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
provided by <a href="https://readthedocs.org">Read the Docs</a>.


</footer>
</div>
</div>
</section>
</div>
<script>
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>

</body>
</html>
Loading

0 comments on commit 0e9a769

Please sign in to comment.