X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=src%2Fnepi%2Fresources%2Fns3%2Fns3pipechanel.py;h=40b3ab59a7af0b9ea51a9eb32c124798ce53e8c4;hb=6285ca51026efb69642eea9dfc7c480e722d84a9;hp=c74b24d6cc2265c021d0cd27e63e6f06593d1314;hpb=5070e9681cddf7543189639d5fb4fcd76f7396e2;p=nepi.git diff --git a/src/nepi/resources/ns3/ns3pipechanel.py b/src/nepi/resources/ns3/ns3pipechanel.py index c74b24d6..40b3ab59 100644 --- a/src/nepi/resources/ns3/ns3pipechanel.py +++ b/src/nepi/resources/ns3/ns3pipechanel.py @@ -3,9 +3,8 @@ # Copyright (C) 2014 INRIA # # This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# it under the terms of the GNU General Public License version 2 as +# published by the Free Software Foundation; # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -41,7 +40,7 @@ class NS3BasePipeChannel(NS3Base): if not devices or len(devices) != 2: msg = "PipeChannel must be connected to exactly to two FdNetDevices" self.error(msg) - raise RuntimeError, msg + raise RuntimeError(msg) self._devices = devices @@ -58,14 +57,9 @@ class NS3BasePipeChannel(NS3Base): def _instantiate_object(self): """ The pipe channel does not really exists as an ns-3 object. - Do nothing, just validate that the simulator is in real time - mode, otherwise it is not going to work. + Do nothing. """ - mode = self.simulator.get("simulatorImplementationType") - if mode != "ns3::RealtimeSimulatorImpl": - msg = "The simulation must run in real time!!" - self.error(msg) - raise RuntimeError, msg + pass def _connect_object(self): dev1 = self.devices[0] @@ -73,17 +67,15 @@ class NS3BasePipeChannel(NS3Base): if dev1.uuid not in self.connected and dev2.uuid not in self.connected: (s0, s1) = socket.socketpair(socket.AF_UNIX, socket.SOCK_STREAM, 0) - self._send_fd(dev1, s0) - self._send_fd(dev2, s1) + + dev1.send_fd(s0) - def _send_fd(self, dev, fd): - import passfd - - address = self.simulation.invoke(dev.uuid, "recvFD") - sock = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM) - sock.connect(address) - passfd.sendfd(sock, fd, '0') + self._connected.add(dev1.uuid) + dev1._connected.add(self.uuid) + + dev2.send_fd(s1) + + self._connected.add(dev2.uuid) + dev2._connected.add(self.uuid) - self._connected.add(dev.uuid) - dev._connected.add(self.uuid)