Giter VIP home page Giter VIP logo

cn-tu / reinforcement-learning-for-per-flow-buffer-sizing Goto Github PK

View Code? Open in Web Editor NEW
16.0 5.0 2.0 259.58 MB

Implementation of the paper "LFQ: Online Learning of Per-Flow Queuing Policies Using Deep Reinforcement Learning", Contact: Maximilian Bachl

Home Page: https://arxiv.org/abs/2007.02735

License: GNU General Public License v2.0

Python 63.31% Makefile 0.12% QMake 0.01% C++ 34.92% C 0.47% Shell 0.17% HTML 0.01% JavaScript 0.01% CSS 0.01% Gnuplot 0.01% MATLAB 0.05% Click 0.02% Perl 0.39% Batchfile 0.01% SWIG 0.01% TeX 0.50% Dockerfile 0.01%
reinforcement-learning aqm queuing congestion-control deep-learning

reinforcement-learning-for-per-flow-buffer-sizing's Introduction

reinforcement-learning-for-per-flow-buffer-sizing

Contact: Maximilian Bachl

This repository contains the code for the paper LFQ: Online Learning of Per-flow Queuing Policies using Deep Reinforcement Learning.

The code was run on Debian 10 (buster) on Linux kernel 4.19.0-9-amd64 with g++ 8.3.0.

Native installation (not recommended, Docker installation is easier)

Downloading libtorch

  • Download the C++ version of libtorch for CPUs. If you want to download a newer version, make sure that it is the Pre-cxx11 ABI version. Otherwise you'll have to change some flags in the build process.
  • Unpack it and move the contained directory libtorch to the root directory of this repository (the same directory in which there's the ns-allinone-3.30.1 directory)

Compiling

  • cd ns-allinone-3.30.1/ns-3.30.1/
  • ./waf clean
  • ./waf configure
  • ./waf build

Docker installation

Downloading libtorch (same as for the native installation)

  • Download the C++ version of libtorch for CPUs. If you want to download a newer version, make sure that it is the Pre-cxx11 ABI version. Otherwise you'll have to change some flags in the build process.
  • Unpack it and move the contained directory libtorch to the root directory of this repository (the same directory in which there's the ns-allinone-3.30.1 directory)

Using docker to run it

  • cd docker
  • docker build -f Dockerfile . -t rl_image
  • docker run -v $(realpath -s ..):/repo -w /repo/ns-allinone-3.30.1/ns-3.30.1/ --entrypoint bash rl_image run_all.sh
  • docker run -v $(realpath -s ..):/repo -w /repo/ns-allinone-3.30.1/ns-3.30.1/ --entrypoint bash -it rl_image
  • Now you're in the Docker image and all commands below for training or evaluating should work as usual.

Training an RL model

If the build finished successfully (this can take some time), you can train a model.

Assuming you're in the ns-3.30.1 directory, run

OMP_NUM_THREADS=1 LD_LIBRARY_PATH=../../libtorch/lib:$LD_LIBRARY_PATH ./waf -v --run "examples/traffic-control/rl"

To change parameters like the number of cpus to use for training, the tradeoff parameter alpha etc., change the variables on top of the file ns-allinone-3.30.1/ns-3.30.1/examples/traffic-control/rl.cc and recompile.

Evaluating

Evaluating an RL model

To evaluate a set of trained weights run

OMP_NUM_THREADS=1 LD_LIBRARY_PATH=../../libtorch/lib:$LD_LIBRARY_PATH ./waf -v --run "examples/traffic-control/rl <path_to_weights>"

Evaluating other AQM mechanisms

To evaluate, for example, FqCoDel, run

    OMP_NUM_THREADS=1 LD_LIBRARY_PATH=../../libtorch/lib:$LD_LIBRARY_PATH ./waf -v --run "examples/traffic-control/rl FqCoDelQueueDisc"

To run Fifo with a maximum queue size of 100, run

    OMP_NUM_THREADS=1 LD_LIBRARY_PATH=../../libtorch/lib:$LD_LIBRARY_PATH ./waf -v --run "examples/traffic-control/rl FifoQueueDisc 100"

Plotting

Plotting training runs

During training, various values are logged.

To plot them, run the following command:

./plot_metrics.py results/RLQueueDisc/logs/<name_of_the_file_to_be_plotted>

Plotting evaluation results

The following commands are supposed to be run after an AQM mechanism was evaluated.

To plot, for example, all queue traces produced by an evaluation of Fifo with queue size 1000, run the following command:

ls -d $PWD/results/FifoQueueDisc/queueTraces/1000/*.plotme | xargs ./plot_something.py

To plot the behavior of an AQM mechanism and get performance metrics, run, for example, the following command:

./plot_df.py results/RLQueueDisc/logs/*

Pre-trained weights

All weights that are used to generate the plots in the paper can be found in the directory reinforcement-learning-for-per-flow-buffer-sizing/ns-allinone-3.30.1/ns-3.30.1/results/RLQueueDisc/weights.

reinforcement-learning-for-per-flow-buffer-sizing's People

Contributors

muxamilian avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

reinforcement-learning-for-per-flow-buffer-sizing's Issues

Error in building the project

I download the libtorch from the link provided by the repo and unpack it under the root directory of the repo, as shown below. I am using a Ubuntu 20.04 with GCC 9.4.

.
├── libtorch
│   ├── bin
│   ├── build-hash
│   ├── build-version
│   ├── include
│   ├── lib
│   └── share
├── libtorch-shared-with-deps-1.5.1+cpu.zip
├── LICENSE
├── ns-allinone-3.30.1
│   ├── bake
│   ├── build.py
│   ├── constants.py
│   ├── netanim-3.108
│   ├── ns-3.30.1
│   ├── pybindgen-0.20.0
│   ├── README
│   └── util.py
├── paper
│   ├── beamercolorthemeTU.sty
│   ├── beamerfontthemeTU.sty
│   ├── beamerinnerthemeTU.sty
│   ├── beamerouterthemeTU.sty
│   ├── beamerthemeTU.sty
│   ├── figures
│   ├── IEEEtran.cls
│   ├── IEEEtranS.bst
│   ├── logos
│   ├── paper_short.tex
│   ├── paper.tex
│   ├── presentation_lcn.pdf
│   ├── presentation_lcn.tex
│   ├── presentation.tex
│   └── reference.bib
└── README.md

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.