diff --git a/daemon/ns3/corens3/obj.py b/daemon/ns3/corens3/obj.py index c106aa9f..0d392a4b 100644 --- a/daemon/ns3/corens3/obj.py +++ b/daemon/ns3/corens3/obj.py @@ -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) diff --git a/daemon/ns3/examples/ns3lte.py b/daemon/ns3/examples/ns3lte.py index 58471a89..de9cef98 100755 --- a/daemon/ns3/examples/ns3lte.py +++ b/daemon/ns3/examples/ns3lte.py @@ -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: diff --git a/daemon/ns3/examples/ns3wifi.py b/daemon/ns3/examples/ns3wifi.py index bc29ca80..b5691677 100755 --- a/daemon/ns3/examples/ns3wifi.py +++ b/daemon/ns3/examples/ns3wifi.py @@ -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) diff --git a/daemon/ns3/examples/ns3wifirandomwalk.py b/daemon/ns3/examples/ns3wifirandomwalk.py index fc37cce4..18f473ad 100755 --- a/daemon/ns3/examples/ns3wifirandomwalk.py +++ b/daemon/ns3/examples/ns3wifirandomwalk.py @@ -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) diff --git a/daemon/ns3/examples/ns3wimax.py b/daemon/ns3/examples/ns3wimax.py index 01609398..d3d165a9 100755 --- a/daemon/ns3/examples/ns3wimax.py +++ b/daemon/ns3/examples/ns3wimax.py @@ -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() diff --git a/doc/scripting.rst b/doc/scripting.rst index 8879981c..f5620a1a 100644 --- a/doc/scripting.rst +++ b/doc/scripting.rst @@ -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")