diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2b4333e --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +.waf* +.DS* +.lock* +build/ diff --git a/README.md b/README.md new file mode 100644 index 0000000..8cd11d8 --- /dev/null +++ b/README.md @@ -0,0 +1,78 @@ +Prerequisites +============= + +Custom version of NS-3 and specified version of ndnSIM needs to be installed. + +The code should also work with the latest version of ndnSIM, but it is not guaranteed. + + git clone git@github.com:cawka/ns-3-dev-ndnSIM.git -b ns-3.16-ndnSIM ns-3 + git clone git@github.com:NDN-Routing/ndnSIM.git -b v0.2.2 ns-3/src/ndnSIM + + cd ns-3 + ./waf configure + ./waf install + +For more information how to install NS-3 and ndnSIM, please refer to http://ndnsim.net website. + +Compiling +========= + +To configure in optimized mode without logging **(default)**: + + ./waf configure + +To configure in optimized mode with scenario logging enabled (logging in NS-3 and ndnSIM modules will still be disabled, +but you can see output from NS_LOG* calls from your scenarios and extensions): + + ./waf configure --logging + +To configure in debug mode with all logging enabled + + ./waf configure --debug + +If you have installed NS-3 in a non-standard location, you may need to set up ``PKG_CONFIG_PATH`` variable. +For example, if NS-3 is installed in /usr/local/, then the following command should be used to +configure scenario + + PKG_CONFIG_PATH=/usr/local/lib/pkgconfig ./waf configure + +or + + PKG_CONFIG_PATH=/usr/local/lib/pkgconfig ./waf configure --logging + +or + + PKG_CONFIG_PATH=/usr/local/lib/pkgconfig ./waf configure --debug + +Running +======= + +Normally, you can run scenarios either directly + + ./build/ + +or using waf + + ./waf --run + +If NS-3 is installed in a non-standard location, on some platforms (e.g., Linux) you need to specify ``LD_LIBRARY_PATH`` variable: + + LD_LIBRARY_PATH=/usr/local/lib ./build/ + +or + + LD_LIBRARY_PATH=/usr/local/lib ./waf --run + + +When running using ./waf, it is possible to run scenario with visualizer: + + ./waf --run --vis + +To run scenario using debugger, use the following command: + + gdb --args ./build/ + +Available simulations +===================== + +*put here information how to run scenarios, and if available, brief description* \ No newline at end of file diff --git a/extensions/README.md b/extensions/README.md new file mode 100644 index 0000000..a739f57 --- /dev/null +++ b/extensions/README.md @@ -0,0 +1,4 @@ +In this directory you can put any .cc file you want to be compiled and linked to your scenarios. + +This mainly useful for custom extension of ndnSIM and NS-3. + diff --git a/graphs/graph-style.R b/graphs/graph-style.R new file mode 100644 index 0000000..a79556d --- /dev/null +++ b/graphs/graph-style.R @@ -0,0 +1,51 @@ +library(grid) + +theme_custom <- function (base_size = 10, base_family = "serif") { + theme_grey(base_size = base_size, base_family = base_family) %+replace% + theme( + line = element_line(colour = "black", size = 0.5, linetype = 1, lineend = "butt"), + rect = element_rect(fill = "white", colour = "black", size = 0.5, linetype = 1), + text = element_text(family = base_family, face = "plain", colour = "black", size = base_size, hjust = 0.5, vjust = 0.5, angle = 0, lineheight = 0.9), + axis.text = element_text(size = rel(0.8), colour = "grey50"), + strip.text = element_text(size = rel(0.8)), + + axis.line = element_blank(), + axis.text.x = element_text(family = base_family, size = base_size * 0.7, lineheight = 0.8, vjust = 1.2), + axis.text.y = element_text(family = base_family, size = base_size * 0.7, lineheight = 0.8, hjust = 1.2), + axis.ticks = element_line(colour = "black", size=0.2), + axis.title.x = element_text(family = base_family, size = base_size, vjust = 0.5), + axis.title.y = element_text(family = base_family, size = base_size, angle = 90, vjust = 0.5), + axis.ticks.length = unit(0.15, "cm"), + axis.ticks.margin = unit(0.1, "cm"), + + legend.background = element_rect (fill=NA, colour=NA, size=0.1), + legend.margin = unit(0.2, "cm"), + legend.key = element_rect(fill = "grey95", colour = "white"), + legend.key.size = unit(1.2, "lines"), + legend.key.height = NULL, + legend.key.width = NULL, + legend.text = element_text(family = base_family, size = base_size * 0.8), + legend.text.align = NULL, + legend.title = element_text(family = base_family, size = base_size * 0.8, face = "bold", hjust = 1), + legend.title.align = NULL, + legend.position = "right", + legend.direction = NULL, + legend.justification = "center", + legend.box = NULL, + + panel.background = element_rect(fill = "white", colour = NA), + panel.border = element_rect(fill = NA, colour = "grey50"), + panel.grid.major = element_line(colour = "grey60", size = 0.1), + panel.grid.minor = element_line(colour = "grey70", size = 0.1, linetype="dotted"), + ## panel.margin = unit(c(0.1, 0.1, 0.1, 0.1), "lines"), + + strip.background = element_rect(fill = NA, colour = NA), + strip.text.x = element_text(family = base_family, size = base_size * 0.8), + strip.text.y = element_text(family = base_family, size = base_size * 0.8, angle = -90), + + plot.background = element_rect(colour = NA, fill = "white"), + plot.title = element_text(family = base_family, size = base_size), + plot.margin = unit(c(0, 0, 0, 0), "lines") + ) +} + diff --git a/results/.gitignore b/results/.gitignore new file mode 100644 index 0000000..3f735a4 --- /dev/null +++ b/results/.gitignore @@ -0,0 +1,2 @@ +*.log +*.txt diff --git a/run.py b/run.py new file mode 100755 index 0000000..9aa887a --- /dev/null +++ b/run.py @@ -0,0 +1,55 @@ +#!/usr/bin/env python +# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- + +from subprocess import call +from sys import argv +import os +import subprocess +import workerpool +import multiprocessing + +class SimulationJob (workerpool.Job): + "Job to simulate things" + def __init__ (self, cmdline): + self.cmdline = cmdline + def run (self): + print (" ".join (self.cmdline)) + subprocess.call (self.cmdline) + +pool = workerpool.WorkerPool(size = multiprocessing.cpu_count()) + +class Runner: + # def congestion_zoom (self): + # cmdline = ["./build/congestion-zoom-ndn"] + # job = SimulationJob (cmdline) + # pool.put (job) + + # cmdline = ["./build/congestion-zoom-tcp"] + # job = SimulationJob (cmdline) + # pool.put (job) + + # def congestion_pop (self): + # runs = range(1,101) + # for run in runs: + # cmdline = ["./build/congestion-pop-ndn", + # "--run=%d" % run + # ] + # job = SimulationJob (cmdline) + # pool.put (job) + + # cmdline = ["./build/congestion-pop-tcp", + # "--run=%d" % run + # ] + # job = SimulationJob (cmdline) + # pool.put (job) + +try: + runner = Runner () + # runner.congestion_zoom() + runner.congestion_pop() + +finally: + pool.shutdown () + pool.wait () + +print "\n\n >>> FINISHED <<< \n\n" diff --git a/scenarios/README.md b/scenarios/README.md new file mode 100644 index 0000000..56b267b --- /dev/null +++ b/scenarios/README.md @@ -0,0 +1,4 @@ +Each .cc file in this directory will be treated as a separate scenario +(i.e., each .cc should contain their own main function). Each scenario will +be linked together with all extensions, placed in ../extensions/ folder. + diff --git a/scenarios/disabled/README.md b/scenarios/disabled/README.md new file mode 100644 index 0000000..87a9a1d --- /dev/null +++ b/scenarios/disabled/README.md @@ -0,0 +1,2 @@ +If you do not want (temporarily) some scenario to be automatically compiled, place it in this folder and it will be ignored during build phase. + diff --git a/waf b/waf new file mode 100755 index 0000000..e0f1d07 Binary files /dev/null and b/waf differ diff --git a/wscript b/wscript new file mode 100644 index 0000000..066fb31 --- /dev/null +++ b/wscript @@ -0,0 +1,106 @@ +# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- + +VERSION='0.1' +APPNAME='template' + +from waflib import Build, Logs, Options, TaskGen +import subprocess + +def options(opt): + opt.add_option('--debug',action='store_true',default=False,dest='debug',help='''debugging mode''') + opt.add_option('--logging',action='store_true',default=True,dest='logging',help='''enable logging in simulation scripts''') + opt.add_option('--run', + help=('Run a locally built program; argument can be a program name,' + ' or a command starting with the program name.'), + type="string", default='', dest='run') + opt.add_option('--visualize', + help=('Modify --run arguments to enable the visualizer'), + action="store_true", default=False, dest='visualize') + opt.add_option('--mpi', + help=('Run in MPI mode'), + type="string", default="", dest="mpi") + opt.add_option('--time', + help=('Enable time for the executed command'), + action="store_true", default=False, dest='time') + + opt.load("compiler_c compiler_cxx boost ns3") + +def configure(conf): + conf.load("compiler_cxx boost ns3") + + conf.check_boost(lib='system iostreams') + boost_version = conf.env.BOOST_VERSION.split('_') + if int(boost_version[0]) < 1 or int(boost_version[1]) < 48: + Logs.error ("ndnSIM requires at least boost version 1.48") + Logs.error ("Please upgrade your distribution or install custom boost libraries (http://ndnsim.net/faq.html#boost-libraries)") + exit (1) + + try: + conf.check_ns3_modules("ndnSIM core network internet point-to-point topology-read applications mobility") + conf.check_ns3_modules("visualizer", mandatory = False) + except: + Logs.error ("NS-3 or one of the required NS-3 modules not found") + Logs.error ("NS-3 needs to be compiled and installed somewhere. You may need also to set PKG_CONFIG_PATH variable in order for configure find installed NS-3.") + Logs.error ("For example:") + Logs.error (" PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH ./waf configure") + conf.fatal ("") + + if conf.options.debug: + conf.define ('NS3_LOG_ENABLE', 1) + conf.define ('_DEBUG', 1) + conf.env.append_value('CXXFLAGS', ['-O0', '-g3']) + else: + conf.env.append_value('CXXFLAGS', ['-O3', '-g']) + + if conf.env["CXX"] == ["clang++"]: + conf.env.append_value('CXXFLAGS', ['-fcolor-diagnostics']) + + if conf.options.logging: + conf.define ('NS3_LOG_ENABLE', 1) + +def build (bld): + deps = 'BOOST BOOST_IOSTREAMS' + ' '.join (['ns3_'+dep for dep in ['core', 'network', 'internet', 'ndnSIM', 'topology-read', 'applications', 'mobility', 'visualizer']]).upper () + + common = bld.objects ( + target = "extensions", + features = ["cxx"], + source = bld.path.ant_glob(['extensions/**/*.cc']), + use = deps, + cxxflags = [bld.env.CXX11_CMD], + ) + + for scenario in bld.path.ant_glob (['scenarios/*.cc']): + name = str(scenario)[:-len(".cc")] + app = bld.program ( + target = name, + features = ['cxx'], + source = [scenario], + use = deps + " extensions", + includes = "extensions" + ) + +def shutdown (ctx): + if Options.options.run: + visualize=Options.options.visualize + mpi = Options.options.mpi + + if mpi and visualize: + Logs.error ("You cannot specify --mpi and --visualize options at the same time!!!") + return + + argv = Options.options.run.split (' '); + argv[0] = "build/%s" % argv[0] + + if visualize: + argv.append ("--SimulatorImplementationType=ns3::VisualSimulatorImpl") + + if mpi: + argv.append ("--SimulatorImplementationType=ns3::DistributedSimulatorImpl") + argv.append ("--mpi=1") + argv = ["openmpirun", "-np", mpi] + argv + Logs.error (argv) + + if Options.options.time: + argv = ["time"] + argv + + return subprocess.call (argv)