2 # NEPI, a framework to manage network experiments
3 # Copyright (C) 2013 INRIA
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License version 2 as
7 # published by the Free Software Foundation;
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17 # Author: Alina Quereilhac <alina.quereilhac@inria.fr>
19 from nepi.execution.attribute import Attribute, Flags, Types
20 from nepi.execution.resource import clsinit_copy, ResourceState
21 from nepi.resources.linux.ns3.fdudptunnel import LinuxNs3FdUdpTunnel
22 from nepi.util.sshfuncs import ProcStatus
23 from nepi.util.timefuncs import tnow, tdiffsec
31 class PlanetlabNs3FdUdpTunnel(LinuxNs3FdUdpTunnel):
32 _rtype = "planetlab::ns3::FdUdpTunnel"
33 _help = "Constructs a tunnel between two Ns-3 FdNetdevices " \
34 "located in remote PlanetLab nodes using a UDP connection "
35 _platform = "planetlab::ns3"
37 def get_endpoints(self):
38 """ Returns the list of RM that are endpoints to the tunnel
40 if not self._fd2 or not self._fd1:
41 from nepi.resources.ns3.ns3fdnetdevice import NS3BaseFdNetDevice
42 devices = self.get_connected(NS3BaseFdNetDevice.get_rtype())
43 if not devices or len(devices) != 2:
44 msg = "Tunnel must be connected to exactly two FdNetDevices"
46 raise RuntimeError(msg)
48 self._fd1 = devices[0]
49 self._fd2 = devices[1]
53 self._fd1.set("EncapsulationMode", "DixPi")
54 self._fd2.set("EncapsulationMode", "DixPi")
56 simu = self._fd1.simulation
57 from nepi.resources.linux.node import LinuxNode
58 nodes = simu.get_connected(LinuxNode.get_rtype())
59 self._fd1node = nodes[0]
61 simu = self._fd2.simulation
62 from nepi.resources.linux.node import LinuxNode
63 nodes = simu.get_connected(LinuxNode.get_rtype())
64 self._fd2node = nodes[0]
66 if self._fd1node.get("hostname") == \
67 self._fd2node.get("hostname"):
68 msg = "Tunnel requires endpoints on different hosts"
70 raise RuntimeError(msg)
72 return [self._fd1, self._fd2]