SIMULATOR_UUID = "singleton::Simulator"
CONFIG_UUID = "singleton::Config"
GLOBAL_VALUE_UUID = "singleton::GlobalValue"
+IPV4_GLOBAL_ROUTING_HELPER_UUID = "singleton::Ipv4GlobalRoutingHelper"
-def load_ns3_module():
+def load_ns3_libraries():
import ctypes
import re
- bindings = os.environ.get("NS3BINDINGS")
libdir = os.environ.get("NS3LIBRARIES")
# Load the ns-3 modules shared libraries
# to prevent infinit loop
if initial_size == len(libs):
raise RuntimeError("Imposible to load shared libraries %s" % str(libs))
- initial_size = list(libs)
+ initial_size = len(libs)
+
+def load_ns3_module():
+ load_ns3_libraries()
# import the python bindings for the ns-3 modules
+ bindings = os.environ.get("NS3BINDINGS")
if bindings:
sys.path.append(bindings)
return uuid
def invoke(self, uuid, operation, *args, **kwargs):
+ if operation == "isRunning":
+ return self._is_running()
if operation == "isAppRunning":
return self._is_app_running(uuid)
if operation == "addStaticRoute":
result = method(*realargs, **realkwargs)
- if result is None or \
- isinstance(result, bool):
+ # If the result is not an object, no need to
+ # keep a reference. Directly return value.
+ if result is None or type(result) in [bool, float, long, str, int]:
return result
newuuid = self.make_uuid()
return realkwargs
+ def _is_running(self):
+ if self.ns3.Simulator.IsFinished():
+ return False
+
+ now = self.ns3.Simulator.Now()
+ if now.IsZero():
+ return False
+
+ return True
+
def _is_app_running(self, uuid):
now = self.ns3.Simulator.Now()
if now.IsZero():