if self.get("enableStack"):
uuid_stack_helper = self.simulation.create("InternetStackHelper")
self.simulation.invoke(uuid_stack_helper, "Install", self.uuid)
+
+ # Retrieve IPV4 object
+ ipv4_uuid = self.simulation.invoke(self.uuid, "retrieveObject",
+ "ns3::Ipv4L3Protocol")
+
+ # Add IPv4 RM to the node
+ ipv4 = self.ec.register_resource("ns3::Ipv4L3Protocol")
+ self.ec.register_connection(self.guid, ipv4)
+ ipv4rm = self.ec.get_resource(ipv4)
+ ipv4rm._uuid = ipv4_uuid
+ ipv4rm.set_started()
else:
### node.AggregateObject(PacketSocketFactory())
uuid_packet_socket_factory = self.simulation.create("PacketSocketFactory")
self._add_dce(dceapplications)
def _connect_object(self):
- ipv4 = self.ipv4
- if ipv4:
- self.simulation.invoke(self.uuid, "AggregateObject", ipv4.uuid)
- self._connected.add(ipv4.uuid)
- ipv4._connected.add(self.uuid)
-
- arp = self.arp
- if arp:
- self.simulation.invoke(self.uuid, "AggregateObject", arp.uuid)
- self._connected.add(arp.uuid)
- arp._connected.add(self.uuid)
+ if not self.get("enableStack"):
+ ipv4 = self.ipv4
+ if ipv4:
+ self.simulation.invoke(self.uuid, "AggregateObject", ipv4.uuid)
+ self._connected.add(ipv4.uuid)
+ ipv4._connected.add(self.uuid)
+
+ arp = self.arp
+ if arp:
+ self.simulation.invoke(self.uuid, "AggregateObject", arp.uuid)
+ self._connected.add(arp.uuid)
+ arp._connected.add(self.uuid)
mobility = self.mobility
if mobility:
result = self.is_finished
elif operation == "isAppRunning":
result = self._is_app_running(uuid)
- elif operation == "addStaticRoute":
- ### DEBUG
- self.debuger.dump_add_static_route(uuid, args)
- ########
-
- result = self._add_static_route(uuid, *args)
else:
newuuid = self.make_uuid()
self.debuger.dump_invoke(newuuid, uuid, operation, args, kwargs)
########
- if uuid.startswith(SINGLETON):
- obj = self._singleton(uuid)
+ if operation == "addStaticRoute":
+ result = self._add_static_route(uuid, *args)
+
+ elif operation == "retrieveObject":
+ result = self._retrieve_object(uuid, *args, **kwargs)
+
else:
- obj = self.get_object(uuid)
-
- method = getattr(obj, operation)
+ if uuid.startswith(SINGLETON):
+ obj = self._singleton(uuid)
+ else:
+ obj = self.get_object(uuid)
+
+ method = getattr(obj, operation)
- # arguments starting with 'uuid' identify ns-3 C++
- # objects and must be replaced by the actual object
- realargs = self.replace_args(args)
- realkwargs = self.replace_kwargs(kwargs)
+ # arguments starting with 'uuid' identify ns-3 C++
+ # objects and must be replaced by the actual object
+ realargs = self.replace_args(args)
+ realkwargs = self.replace_kwargs(kwargs)
- result = method(*realargs, **realkwargs)
+ result = method(*realargs, **realkwargs)
- # If the result is an object (not a base value),
- # then keep track of the object a return the object
- # reference (newuuid)
- if not (result is None or type(result) in [
- bool, float, long, str, int]):
- self._objects[newuuid] = result
- result = newuuid
+ # If the result is an object (not a base value),
+ # then keep track of the object a return the object
+ # reference (newuuid)
+ if not (result is None or type(result) in [
+ bool, float, long, str, int]):
+ self._objects[newuuid] = result
+ result = newuuid
### DEBUG
self.logger.debug("RET INVOKE %s%s = %s -> %s(%s, %s) " % (
return ifindex
return ifindex
+ def _retrieve_object(self, uuid, typeid, search = False):
+ obj = self.get_object(uuid)
+
+ type_id = self.ns3.TypeId()
+ tid = type_id.LookupByName(typeid)
+ nobj = obj.GetObject(tid)
+
+ newuuid = None
+ if search:
+ # search object
+ for ouuid, oobj in self._objects.iteritems():
+ if nobj == oobj:
+ newuuid = ouuid
+ break
+ else:
+ newuuid = self.make_uuid()
+ self._objects[newuuid] = nobj
+
+ return newuuid
+
+
+
command = "wrapper.shutdown()\n\n"
self.dump_to_script(command)
- def dump_add_static_route(self, uuid, args):
- if not self.enabled:
- return
-
- command = ("args = %(args)s\n"
- "wrapper._add_static_route(%(uuid)s, *args)\n\n"
- ) % dict({
- "uuid": self.format_value(uuid),
- "args": self.format_args(args),
- })
-
- self.dump_to_script(command)
-
def format_value(self, value):
if isinstance(value, str) and value.startswith("uuid"):
return value.replace("-", "")