Upgrading wscript and run.py

This commit is contained in:
Alexander Afanasyev committed 2013-02-18 19:33:23 -08:00
1 parent 5d89bf9684
commit 5c66f9b5f8
2 files changed
+76 -27

No files matched your search

+74 -27
View File
@@ -7,6 +7,44 @@ import os
import subprocess import subprocess
import workerpool import workerpool
import multiprocessing import multiprocessing
import argparse
######################################################################
######################################################################
######################################################################
parser = argparse.ArgumentParser(description='Simulation runner')
parser.add_argument('scenarios', metavar='scenario', type=str, nargs='*',
help='Scenario to run')
parser.add_argument('-l', '--list', dest="list", action='store_true', default=False,
help='Get list of available scenarios')
parser.add_argument('-s', '--simulate', dest="simulate", action='store_true', default=False,
help='Run simulation and postprocessing (false by default)')
parser.add_argument('-g', '--no-graph', dest="graph", action='store_false', default=True,
help='Do not build a graph for the scenario (builds a graph by default)')
args = parser.parse_args()
if not args.list and len(args.scenarios)==0:
print "ERROR: at least one scenario need to be specified"
parser.print_help()
exit (1)
if args.list:
print "Available scenarios: "
else:
if args.simulate:
print "Simulating the following scenarios: " + ",".join (args.scenarios)
if args.graph:
print "Building graphs for the following scenarios: " + ",".join (args.scenarios)
######################################################################
######################################################################
######################################################################
class SimulationJob (workerpool.Job): class SimulationJob (workerpool.Job):
"Job to simulate things" "Job to simulate things"
@@ -18,38 +56,47 @@ class SimulationJob (workerpool.Job):
pool = workerpool.WorkerPool(size = multiprocessing.cpu_count()) pool = workerpool.WorkerPool(size = multiprocessing.cpu_count())
class Runner: class Processor:
# def congestion_zoom (self): def run (self):
# cmdline = ["./build/congestion-zoom-ndn"] if args.list:
# job = SimulationJob (cmdline) print " " + self.name
# pool.put (job) return
# cmdline = ["./build/congestion-zoom-tcp"] if "all" not in args.scenarios and self.name not in args.scenarios:
# job = SimulationJob (cmdline) return
# pool.put (job)
# def congestion_pop (self): if args.list:
# runs = range(1,101) pass
# for run in runs: else:
# cmdline = ["./build/congestion-pop-ndn", if args.simulate:
# "--run=%d" % run self.simulate ()
# ] pool.join ()
# job = SimulationJob (cmdline) self.postprocess ()
# pool.put (job) if args.graph:
self.graph ()
# cmdline = ["./build/congestion-pop-tcp", def graph (self):
# "--run=%d" % run subprocess.call ("./graphs/%s.R" % self.name, shell=True)
# ]
# job = SimulationJob (cmdline) class Scenario (Processor):
# pool.put (job) def __init__ (self, name):
self.name = name
# other initialization, if any
def simulate (self):
cmdline = ["./build/SCENARIO_TO_RUN"]
job = SimulationJob (cmdline)
pool.put (job)
def postprocess (self):
# any postprocessing, if any
pass
try: try:
runner = Runner () # Simulation, processing, and graph building
# runner.congestion_zoom() fig = Scenario (name="NAME_TO_CONFIGURE")
runner.congestion_pop() fig.run ()
finally: finally:
pool.join ()
pool.shutdown () pool.shutdown ()
pool.wait ()
print "\n\n >>> FINISHED <<< \n\n"
+2
View File
@@ -47,6 +47,7 @@ def configure(conf):
if conf.options.debug: if conf.options.debug:
conf.define ('NS3_LOG_ENABLE', 1) conf.define ('NS3_LOG_ENABLE', 1)
conf.define ('NS3_ASSERT_ENABLE', 1)
conf.define ('_DEBUG', 1) conf.define ('_DEBUG', 1)
conf.env.append_value('CXXFLAGS', ['-O0', '-g3']) conf.env.append_value('CXXFLAGS', ['-O0', '-g3'])
else: else:
@@ -57,6 +58,7 @@ def configure(conf):
if conf.options.logging: if conf.options.logging:
conf.define ('NS3_LOG_ENABLE', 1) conf.define ('NS3_LOG_ENABLE', 1)
conf.define ('NS3_ASSERT_ENABLE', 1)
def build (bld): def build (bld):
deps = 'BOOST BOOST_IOSTREAMS' + ' '.join (['ns3_'+dep for dep in ['core', 'network', 'internet', 'ndnSIM', 'topology-read', 'applications', 'mobility', 'visualizer']]).upper () deps = 'BOOST BOOST_IOSTREAMS' + ' '.join (['ns3_'+dep for dep in ['core', 'network', 'internet', 'ndnSIM', 'topology-read', 'applications', 'mobility', 'visualizer']]).upper ()