Template for ndnSIM simulations
This commit is contained in:
commit
5d89bf9684
10 files changed
+306
No files matched your search
@@ -0,0 +1,4 @@
|
|||||||
|
.waf*
|
||||||
|
.DS*
|
||||||
|
.lock*
|
||||||
|
build/
|
||||||
@@ -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/<scenario_name>
|
||||||
|
|
||||||
|
or using waf
|
||||||
|
|
||||||
|
./waf --run <scenario_name>
|
||||||
|
|
||||||
|
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/<scenario_name>
|
||||||
|
|
||||||
|
or
|
||||||
|
|
||||||
|
LD_LIBRARY_PATH=/usr/local/lib ./waf --run <scenario_name>
|
||||||
|
|
||||||
|
|
||||||
|
When running using ./waf, it is possible to run scenario with visualizer:
|
||||||
|
|
||||||
|
./waf --run <scenario_name> --vis
|
||||||
|
|
||||||
|
To run scenario using debugger, use the following command:
|
||||||
|
|
||||||
|
gdb --args ./build/<scenario_name>
|
||||||
|
|
||||||
|
Available simulations
|
||||||
|
=====================
|
||||||
|
|
||||||
|
*put here information how to run scenarios, and if available, brief description*
|
||||||
@@ -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.
|
||||||
|
|
||||||
@@ -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")
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
*.log
|
||||||
|
*.txt
|
||||||
@@ -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"
|
||||||
@@ -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.
|
||||||
|
|
||||||
@@ -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.
|
||||||
|
|
||||||
@@ -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)
|
||||||
Reference in new issue
Block a user