initial import (Boeing r1752, NRL r878)
This commit is contained in:
commit
f8f46d28be
394 changed files with 99738 additions and 0 deletions
110
daemon/ns3/examples/ns3lte.py
Executable file
110
daemon/ns3/examples/ns3lte.py
Executable file
|
@ -0,0 +1,110 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
# Copyright (c)2011-2012 the Boeing Company.
|
||||
# See the LICENSE file included in this distribution.
|
||||
#
|
||||
# author: Jeff Ahrenholz <jeffrey.m.ahrenholz@boeing.com>
|
||||
#
|
||||
'''
|
||||
ns3lte.py - This script demonstrates using CORE with the ns-3 LTE model.
|
||||
*** Note that this script is not currently functional, see notes below. ***
|
||||
- issues connecting TapBridge with LteNetDevice
|
||||
|
||||
'''
|
||||
|
||||
import os, sys, time, optparse, datetime, math
|
||||
try:
|
||||
from core import pycore
|
||||
except ImportError:
|
||||
# hack for Fedora autoconf that uses the following pythondir:
|
||||
if "/usr/lib/python2.6/site-packages" in sys.path:
|
||||
sys.path.append("/usr/local/lib/python2.6/site-packages")
|
||||
if "/usr/lib64/python2.6/site-packages" in sys.path:
|
||||
sys.path.append("/usr/local/lib64/python2.6/site-packages")
|
||||
if "/usr/lib/python2.7/site-packages" in sys.path:
|
||||
sys.path.append("/usr/local/lib/python2.7/site-packages")
|
||||
if "/usr/lib64/python2.7/site-packages" in sys.path:
|
||||
sys.path.append("/usr/local/lib64/python2.7/site-packages")
|
||||
from core import pycore
|
||||
|
||||
from core.misc import ipaddr
|
||||
from corens3.obj import Ns3Session, Ns3LteNet
|
||||
import ns.core
|
||||
import ns.mobility
|
||||
|
||||
def ltesession(opt):
|
||||
''' Run a test LTE session.
|
||||
'''
|
||||
session = Ns3Session(persistent=True, duration=opt.duration)
|
||||
lte = session.addobj(cls=Ns3LteNet, name="wlan1")
|
||||
lte.setsubchannels(range(25), range(50, 100))
|
||||
if opt.verbose:
|
||||
ascii = ns.network.AsciiTraceHelper()
|
||||
stream = ascii.CreateFileStream('/tmp/ns3lte.tr')
|
||||
lte.lte.EnableAsciiAll(stream)
|
||||
#ns.core.LogComponentEnable("EnbNetDevice", ns.core.LOG_LEVEL_INFO)
|
||||
#ns.core.LogComponentEnable("UeNetDevice", ns.core.LOG_LEVEL_INFO)
|
||||
#lte.lte.EnableLogComponents()
|
||||
|
||||
prefix = ipaddr.IPv4Prefix("10.0.0.0/16")
|
||||
mobb = None
|
||||
nodes = []
|
||||
for i in xrange(1, opt.numnodes + 1):
|
||||
node = session.addnode(name = "n%d" % i)
|
||||
mob = ns.mobility.ConstantPositionMobilityModel()
|
||||
mob.SetPosition( ns.core.Vector3D(10.0 * i, 0.0, 0.0) )
|
||||
if i == 1:
|
||||
lte.setnodeb(node) # first node is nodeb
|
||||
mobb = mob
|
||||
node.newnetif(lte, ["%s/%s" % (prefix.addr(i), prefix.prefixlen)])
|
||||
nodes.append(node)
|
||||
if i == 1:
|
||||
(tmp, ns3dev) = lte.findns3dev(node)
|
||||
lte.lte.AddMobility(ns3dev.GetPhy(), mob)
|
||||
if i > 1:
|
||||
lte.linknodeb(node, nodes[0], mob, mobb)
|
||||
|
||||
session.thread = session.run(vis=opt.visualize)
|
||||
return session
|
||||
|
||||
def main():
|
||||
''' Main routine when running from command-line.
|
||||
'''
|
||||
usagestr = "usage: %prog [-h] [options] [args]"
|
||||
parser = optparse.OptionParser(usage = usagestr)
|
||||
parser.set_defaults(numnodes = 4, duration = 600, verbose = False, visualize=False)
|
||||
|
||||
parser.add_option("-d", "--duration", dest = "duration", type = int,
|
||||
help = "number of seconds to run the simulation")
|
||||
parser.add_option("-n", "--numnodes", dest = "numnodes", type = int,
|
||||
help = "number of nodes")
|
||||
parser.add_option("-z", "--visualize", dest = "visualize",
|
||||
action = "store_true", help = "enable visualizer")
|
||||
parser.add_option("-v", "--verbose", dest = "verbose",
|
||||
action = "store_true", help = "be more verbose")
|
||||
|
||||
def usage(msg = None, err = 0):
|
||||
sys.stdout.write("\n")
|
||||
if msg:
|
||||
sys.stdout.write(msg + "\n\n")
|
||||
parser.print_help()
|
||||
sys.exit(err)
|
||||
|
||||
(opt, args) = parser.parse_args()
|
||||
|
||||
if opt.numnodes < 2:
|
||||
usage("invalid numnodes: %s" % opt.numnodes)
|
||||
|
||||
for a in args:
|
||||
sys.stderr.write("ignoring command line argument: '%s'\n" % a)
|
||||
|
||||
return ltesession(opt)
|
||||
|
||||
def cleanup():
|
||||
print "shutting down session"
|
||||
session.shutdown()
|
||||
print "joining simulator thread (please kill it)"
|
||||
session.thread.join()
|
||||
|
||||
if __name__ == "__main__":
|
||||
session = main()
|
122
daemon/ns3/examples/ns3wifi.py
Executable file
122
daemon/ns3/examples/ns3wifi.py
Executable file
|
@ -0,0 +1,122 @@
|
|||
#!/usr/bin/python -i
|
||||
|
||||
# Copyright (c)2011-2013 the Boeing Company.
|
||||
# See the LICENSE file included in this distribution.
|
||||
#
|
||||
# author: Jeff Ahrenholz <jeffrey.m.ahrenholz@boeing.com>
|
||||
#
|
||||
'''
|
||||
ns3wifi.py - This script demonstrates using CORE with the ns-3 Wifi model.
|
||||
|
||||
How to run this:
|
||||
|
||||
pushd ~/ns-allinone-3.16/ns-3.16
|
||||
sudo ./waf shell
|
||||
popd
|
||||
python -i ns3wifi.py
|
||||
|
||||
To run with the CORE GUI:
|
||||
|
||||
pushd ~/ns-allinone-3.16/ns-3.16
|
||||
sudo ./waf shell
|
||||
core-daemon
|
||||
|
||||
# in another terminal
|
||||
core-daemon -e ./ns3wifi.py
|
||||
# in a third terminal
|
||||
core
|
||||
# now select the running session
|
||||
|
||||
'''
|
||||
|
||||
import os, sys, time, optparse, datetime, math
|
||||
try:
|
||||
from core import pycore
|
||||
except ImportError:
|
||||
# hack for Fedora autoconf that uses the following pythondir:
|
||||
if "/usr/lib/python2.6/site-packages" in sys.path:
|
||||
sys.path.append("/usr/local/lib/python2.6/site-packages")
|
||||
if "/usr/lib64/python2.6/site-packages" in sys.path:
|
||||
sys.path.append("/usr/local/lib64/python2.6/site-packages")
|
||||
if "/usr/lib/python2.7/site-packages" in sys.path:
|
||||
sys.path.append("/usr/local/lib/python2.7/site-packages")
|
||||
if "/usr/lib64/python2.7/site-packages" in sys.path:
|
||||
sys.path.append("/usr/local/lib64/python2.7/site-packages")
|
||||
from core import pycore
|
||||
|
||||
import ns.core
|
||||
from core.misc import ipaddr
|
||||
from corens3.obj import Ns3Session, Ns3WifiNet
|
||||
|
||||
def add_to_server(session):
|
||||
''' Add this session to the server's list if this script is executed from
|
||||
the core-daemon server.
|
||||
'''
|
||||
global server
|
||||
try:
|
||||
server.addsession(session)
|
||||
return True
|
||||
except NameError:
|
||||
return False
|
||||
|
||||
def wifisession(opt):
|
||||
''' Run a test wifi session.
|
||||
'''
|
||||
session = Ns3Session(persistent=True, duration=opt.duration)
|
||||
session.name = "ns3wifi"
|
||||
session.filename = session.name + ".py"
|
||||
session.node_count = str(opt.numnodes + 1)
|
||||
add_to_server(session)
|
||||
|
||||
wifi = session.addobj(cls=Ns3WifiNet, name="wlan1")
|
||||
wifi.setposition(30, 30, 0)
|
||||
wifi.phy.Set("RxGain", ns.core.DoubleValue(18.0))
|
||||
|
||||
prefix = ipaddr.IPv4Prefix("10.0.0.0/16")
|
||||
nodes = []
|
||||
for i in xrange(1, opt.numnodes + 1):
|
||||
node = session.addnode(name = "n%d" % i)
|
||||
node.newnetif(wifi, ["%s/%s" % (prefix.addr(i), prefix.prefixlen)])
|
||||
nodes.append(node)
|
||||
session.setupconstantmobility()
|
||||
wifi.usecorepositions()
|
||||
# PHY tracing
|
||||
#wifi.phy.EnableAsciiAll("ns3wifi")
|
||||
session.thread = session.run(vis=False)
|
||||
return session
|
||||
|
||||
def main():
|
||||
''' Main routine when running from command-line.
|
||||
'''
|
||||
usagestr = "usage: %prog [-h] [options] [args]"
|
||||
parser = optparse.OptionParser(usage = usagestr)
|
||||
parser.set_defaults(numnodes = 10, duration = 600, verbose = False)
|
||||
|
||||
parser.add_option("-d", "--duration", dest = "duration", type = int,
|
||||
help = "number of seconds to run the simulation")
|
||||
parser.add_option("-n", "--numnodes", dest = "numnodes", type = int,
|
||||
help = "number of nodes")
|
||||
parser.add_option("-v", "--verbose", dest = "verbose",
|
||||
action = "store_true", help = "be more verbose")
|
||||
|
||||
def usage(msg = None, err = 0):
|
||||
sys.stdout.write("\n")
|
||||
if msg:
|
||||
sys.stdout.write(msg + "\n\n")
|
||||
parser.print_help()
|
||||
sys.exit(err)
|
||||
|
||||
(opt, args) = parser.parse_args()
|
||||
|
||||
if opt.numnodes < 2:
|
||||
usage("invalid numnodes: %s" % opt.numnodes)
|
||||
|
||||
for a in args:
|
||||
sys.stderr.write("ignoring command line argument: '%s'\n" % a)
|
||||
|
||||
return wifisession(opt)
|
||||
|
||||
|
||||
if __name__ == "__main__" or __name__ == "__builtin__":
|
||||
session = main()
|
||||
print "\nsession =", session
|
131
daemon/ns3/examples/ns3wifirandomwalk.py
Executable file
131
daemon/ns3/examples/ns3wifirandomwalk.py
Executable file
|
@ -0,0 +1,131 @@
|
|||
#!/usr/bin/python -i
|
||||
|
||||
# Copyright (c)2011-2013 the Boeing Company.
|
||||
# See the LICENSE file included in this distribution.
|
||||
#
|
||||
# author: Jeff Ahrenholz <jeffrey.m.ahrenholz@boeing.com>
|
||||
#
|
||||
'''
|
||||
ns3wifirandomwalk.py - This script demonstrates using CORE with the ns-3 Wifi
|
||||
model and random walk mobility.
|
||||
Patterned after the ns-3 example 'main-random-walk.cc'.
|
||||
|
||||
How to run this:
|
||||
|
||||
pushd ~/ns-allinone-3.16/ns-3.16
|
||||
sudo ./waf shell
|
||||
popd
|
||||
python -i ns3wifirandomwalk.py
|
||||
|
||||
'''
|
||||
|
||||
import os, sys, time, optparse, datetime, math, threading
|
||||
try:
|
||||
from core import pycore
|
||||
except ImportError:
|
||||
# hack for Fedora autoconf that uses the following pythondir:
|
||||
if "/usr/lib/python2.6/site-packages" in sys.path:
|
||||
sys.path.append("/usr/local/lib/python2.6/site-packages")
|
||||
if "/usr/lib64/python2.6/site-packages" in sys.path:
|
||||
sys.path.append("/usr/local/lib64/python2.6/site-packages")
|
||||
if "/usr/lib/python2.7/site-packages" in sys.path:
|
||||
sys.path.append("/usr/local/lib/python2.7/site-packages")
|
||||
if "/usr/lib64/python2.7/site-packages" in sys.path:
|
||||
sys.path.append("/usr/local/lib64/python2.7/site-packages")
|
||||
from core import pycore
|
||||
|
||||
import ns.core
|
||||
import ns.network
|
||||
from core.api import coreapi
|
||||
from core.misc import ipaddr
|
||||
from corens3.obj import Ns3Session, Ns3WifiNet
|
||||
|
||||
|
||||
def add_to_server(session):
|
||||
''' Add this session to the server's list if this script is executed from
|
||||
the core-daemon server.
|
||||
'''
|
||||
global server
|
||||
try:
|
||||
server.addsession(session)
|
||||
return True
|
||||
except NameError:
|
||||
return False
|
||||
|
||||
def wifisession(opt):
|
||||
''' Run a random walk wifi session.
|
||||
'''
|
||||
session = Ns3Session(persistent=True, duration=opt.duration)
|
||||
session.name = "ns3wifirandomwalk"
|
||||
session.filename = session.name + ".py"
|
||||
session.node_count = str(opt.numnodes + 1)
|
||||
add_to_server(session)
|
||||
wifi = session.addobj(cls=Ns3WifiNet, name="wlan1", rate="OfdmRate12Mbps")
|
||||
wifi.setposition(30, 30, 0)
|
||||
# for improved connectivity
|
||||
wifi.phy.Set("RxGain", ns.core.DoubleValue(18.0))
|
||||
|
||||
prefix = ipaddr.IPv4Prefix("10.0.0.0/16")
|
||||
services_str = "zebra|OSPFv3MDR|vtysh|IPForward"
|
||||
nodes = []
|
||||
for i in xrange(1, opt.numnodes + 1):
|
||||
node = session.addnode(name = "n%d" % i)
|
||||
node.newnetif(wifi, ["%s/%s" % (prefix.addr(i), prefix.prefixlen)])
|
||||
nodes.append(node)
|
||||
session.services.addservicestonode(node, "router", services_str,
|
||||
opt.verbose)
|
||||
session.services.bootnodeservices(node)
|
||||
session.setuprandomwalkmobility(bounds=(1000.0, 750.0, 0))
|
||||
|
||||
# PHY tracing
|
||||
#wifi.phy.EnableAsciiAll("ns3wifirandomwalk")
|
||||
|
||||
# mobility tracing
|
||||
#session.setupmobilitytracing(wifi, "ns3wifirandomwalk.mob.tr",
|
||||
# nodes, verbose=True)
|
||||
session.startns3mobility(refresh_ms=150)
|
||||
|
||||
# start simulation
|
||||
# session.instantiate() ?
|
||||
session.thread = session.run(vis=opt.viz)
|
||||
return session
|
||||
|
||||
def main():
|
||||
''' Main routine when running from command-line.
|
||||
'''
|
||||
usagestr = "usage: %prog [-h] [options] [args]"
|
||||
parser = optparse.OptionParser(usage = usagestr)
|
||||
parser.set_defaults(numnodes = 5, duration = 600, verbose = False, viz = False)
|
||||
opt = { 'numnodes' : 5, 'duration': 600, 'verbose' :False, 'viz': False }
|
||||
|
||||
|
||||
parser.add_option("-d", "--duration", dest = "duration", type = int,
|
||||
help = "number of seconds to run the simulation")
|
||||
parser.add_option("-n", "--numnodes", dest = "numnodes", type = int,
|
||||
help = "number of nodes")
|
||||
parser.add_option("-v", "--verbose", dest = "verbose",
|
||||
action = "store_true", help = "be more verbose")
|
||||
parser.add_option("-V", "--visualize", dest = "viz",
|
||||
action = "store_true", help = "enable PyViz ns-3 visualizer")
|
||||
|
||||
def usage(msg = None, err = 0):
|
||||
sys.stdout.write("\n")
|
||||
if msg:
|
||||
sys.stdout.write(msg + "\n\n")
|
||||
parser.print_help()
|
||||
sys.exit(err)
|
||||
|
||||
(opt, args) = parser.parse_args()
|
||||
|
||||
if opt.numnodes < 2:
|
||||
usage("invalid numnodes: %s" % opt.numnodes)
|
||||
|
||||
for a in args:
|
||||
sys.stderr.write("ignoring command line argument: '%s'\n" % a)
|
||||
|
||||
return wifisession(opt)
|
||||
|
||||
|
||||
if __name__ == "__main__" or __name__ == "__builtin__":
|
||||
session = main()
|
||||
print "\nsession =", session
|
95
daemon/ns3/examples/ns3wimax.py
Executable file
95
daemon/ns3/examples/ns3wimax.py
Executable file
|
@ -0,0 +1,95 @@
|
|||
#!/usr/bin/python -i
|
||||
|
||||
# Copyright (c)2011-2012 the Boeing Company.
|
||||
# See the LICENSE file included in this distribution.
|
||||
#
|
||||
# author: Jeff Ahrenholz <jeffrey.m.ahrenholz@boeing.com>
|
||||
#
|
||||
'''
|
||||
ns3wimax.py - This script demonstrates using CORE with the ns-3 Wimax model.
|
||||
*** Note that this script is not currently functional, see notes below. ***
|
||||
Current issues:
|
||||
- large amount of base station chatter; huge trace files, 70% CPU usage
|
||||
- PCAP files unreadable
|
||||
- base station causes segfault if it sends packet; due to missing service flows
|
||||
(but AddFlow() is not available for bs devices)
|
||||
- no packets are sent between nodes - no connection?
|
||||
'''
|
||||
|
||||
import os, sys, time, optparse, datetime, math
|
||||
try:
|
||||
from core import pycore
|
||||
except ImportError:
|
||||
# hack for Fedora autoconf that uses the following pythondir:
|
||||
if "/usr/lib/python2.6/site-packages" in sys.path:
|
||||
sys.path.append("/usr/local/lib/python2.6/site-packages")
|
||||
if "/usr/lib64/python2.6/site-packages" in sys.path:
|
||||
sys.path.append("/usr/local/lib64/python2.6/site-packages")
|
||||
if "/usr/lib/python2.7/site-packages" in sys.path:
|
||||
sys.path.append("/usr/local/lib/python2.7/site-packages")
|
||||
if "/usr/lib64/python2.7/site-packages" in sys.path:
|
||||
sys.path.append("/usr/local/lib64/python2.7/site-packages")
|
||||
from core import pycore
|
||||
|
||||
from core.misc import ipaddr
|
||||
from corens3.obj import Ns3Session, Ns3WimaxNet
|
||||
|
||||
def wimaxsession(opt):
|
||||
''' Run a test wimax session.
|
||||
'''
|
||||
session = Ns3Session(persistent=True, duration=opt.duration)
|
||||
wimax = session.addobj(cls=Ns3WimaxNet, name="wlan1")
|
||||
#wimax.wimax.EnableLogComponents()
|
||||
|
||||
prefix = ipaddr.IPv4Prefix("10.0.0.0/16")
|
||||
# create one classifier for ICMP (protocol 1) traffic
|
||||
# src port low/high, dst port low/high, protocol, priority
|
||||
#classifier = (0, 65000, 0, 65000, 1, 1)
|
||||
classifier = (0, 65000, 0, 65000, 17, 1)
|
||||
nodes = []
|
||||
for i in xrange(1, opt.numnodes + 1):
|
||||
node = session.addnode(name = "n%d" % i)
|
||||
if i == 1:
|
||||
wimax.setbasestation(node)
|
||||
node.newnetif(wimax, ["%s/%s" % (prefix.addr(i), prefix.prefixlen)])
|
||||
if i > 2:
|
||||
wimax.addflow(nodes[-1], node, classifier, classifier)
|
||||
nodes.append(node)
|
||||
session.setupconstantmobility()
|
||||
session.thread = session.run(vis=False)
|
||||
return session
|
||||
|
||||
def main():
|
||||
''' Main routine when running from command-line.
|
||||
'''
|
||||
usagestr = "usage: %prog [-h] [options] [args]"
|
||||
parser = optparse.OptionParser(usage = usagestr)
|
||||
parser.set_defaults(numnodes = 3, duration = 600, verbose = False)
|
||||
|
||||
parser.add_option("-d", "--duration", dest = "duration", type = int,
|
||||
help = "number of seconds to run the simulation")
|
||||
parser.add_option("-n", "--numnodes", dest = "numnodes", type = int,
|
||||
help = "number of nodes")
|
||||
parser.add_option("-v", "--verbose", dest = "verbose",
|
||||
action = "store_true", help = "be more verbose")
|
||||
|
||||
def usage(msg = None, err = 0):
|
||||
sys.stdout.write("\n")
|
||||
if msg:
|
||||
sys.stdout.write(msg + "\n\n")
|
||||
parser.print_help()
|
||||
sys.exit(err)
|
||||
|
||||
(opt, args) = parser.parse_args()
|
||||
|
||||
if opt.numnodes < 2:
|
||||
usage("invalid numnodes: %s" % opt.numnodes)
|
||||
|
||||
for a in args:
|
||||
sys.stderr.write("ignoring command line argument: '%s'\n" % a)
|
||||
|
||||
return wimaxsession(opt)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
session = main()
|
Loading…
Add table
Add a link
Reference in a new issue