updates to set default nodes for ns3 examples

This commit is contained in:
Blake J. Harnden 2017-08-18 08:48:33 -07:00
parent 8155cdc617
commit 67501c9000
6 changed files with 21 additions and 10 deletions

View file

@ -360,11 +360,11 @@ class Ns3Session(Session):
A Session that starts an ns-3 simulation thread.
"""
def __init__(self, persistent=False, duration=600):
def __init__(self, session_id, persistent=False, duration=600):
self.duration = duration
self.nodes = ns.network.NodeContainer()
self.mobhelper = ns.mobility.MobilityHelper()
Session.__init__(self, persistent=persistent)
Session.__init__(self, session_id, persistent=persistent)
def run(self, vis=False):
"""
@ -478,7 +478,7 @@ class Ns3Session(Session):
continue
# from WayPointMobility.setnodeposition(node, x, y, z)
node.position.set(x, y, z)
node_data = node.data(flags=0)
node_data = node.data(0)
self.broadcast_node(node_data)
self.sdt.updatenode(node.objid, flags=0, x=x, y=y, z=z)
time.sleep(0.001 * refresh_ms)

View file

@ -12,6 +12,8 @@ import ns.mobility
from core import logger
from core.misc import ipaddress
from core.misc import nodemaps
from core.misc import nodeutils
from corens3.obj import Ns3LteNet
from corens3.obj import Ns3Session
@ -20,7 +22,8 @@ def ltesession(opt):
"""
Run a test LTE session.
"""
session = Ns3Session(persistent=True, duration=opt.duration)
nodeutils.set_node_map(nodemaps.NODES)
session = Ns3Session(1, persistent=True, duration=opt.duration)
lte = session.add_object(cls=Ns3LteNet, name="wlan1")
lte.setsubchannels(range(25), range(50, 100))
if opt.verbose:

View file

@ -17,7 +17,7 @@ To run with the CORE GUI:
# in another terminal
core-daemon -e ./ns3wifi.py
# in a third terminal
core
core-gui
# now select the running session
"""
@ -29,7 +29,8 @@ import ns.core
from core import logger
from core.misc import ipaddress
from core.misc import nodeutils
from core.misc import nodemaps
from corens3.obj import Ns3Session
from corens3.obj import Ns3WifiNet
@ -51,7 +52,8 @@ def wifisession(opt):
"""
Run a test wifi session.
"""
session = Ns3Session(persistent=True, duration=opt.duration)
nodeutils.set_node_map(nodemaps.NODES)
session = Ns3Session(1, persistent=True, duration=opt.duration)
session.name = "ns3wifi"
session.filename = session.name + ".py"
session.node_count = str(opt.numnodes + 1)

View file

@ -19,6 +19,8 @@ import ns.network
from core import logger
from core.misc import ipaddress
from core.misc import nodemaps
from core.misc import nodeutils
from corens3.obj import Ns3Session
from corens3.obj import Ns3WifiNet
@ -40,7 +42,8 @@ def wifisession(opt):
"""
Run a random walk wifi session.
"""
session = Ns3Session(persistent=True, duration=opt.duration)
nodeutils.set_node_map(nodemaps.NODES)
session = Ns3Session(1, persistent=True, duration=opt.duration)
session.name = "ns3wifirandomwalk"
session.filename = session.name + ".py"
session.node_count = str(opt.numnodes + 1)

View file

@ -14,6 +14,8 @@ import sys
from core import logger
from core.misc import ipaddress
from core.misc import nodemaps
from core.misc import nodeutils
from corens3.obj import Ns3Session
from corens3.obj import Ns3WimaxNet
@ -22,7 +24,8 @@ def wimaxsession(opt):
"""
Run a test wimax session.
"""
session = Ns3Session(persistent=True, duration=opt.duration)
nodeutils.set_node_map(nodemaps.NODES)
session = Ns3Session(1, persistent=True, duration=opt.duration)
wimax = session.add_object(cls=Ns3WimaxNet, name="wlan1")
# wimax.wimax.EnableLogComponents()

View file

@ -40,7 +40,7 @@ Here are the basic elements of a CORE Python script:
from core.session import Session
from core.netns import nodes
session = Session(persistent=True)
session = Session(1, persistent=True)
node1 = session.add_object(cls=nodes.CoreNode, name="n1")
node2 = session.add_object(cls=nodes.CoreNode, name="n2")
hub1 = session.add_object(cls=nodes.HubNode, name="hub1")