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 as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 # Author: Alina Quereilhac <alina.quereilhac@inria.fr>
20 from nepi.execution.attribute import Attribute, Flags, Types
21 from nepi.execution.resource import clsinit_copy, ResourceState
22 from nepi.resources.linux.ns3.fdudptunnel import LinuxNs3FdUdpTunnel
23 from nepi.util.sshfuncs import ProcStatus
24 from nepi.util.timefuncs import tnow, tdiffsec
32 class PlanetlabNs3FdUdpTunnel(LinuxNs3FdUdpTunnel):
33 _rtype = "planetlab::ns3::FdUdpTunnel"
34 _help = "Constructs a tunnel between two Ns-3 FdNetdevices " \
35 "located in remote PlanetLab nodes using a UDP connection "
36 _platform = "planetlab::ns3"
38 def get_endpoints(self):
39 """ Returns the list of RM that are endpoints to the tunnel
41 if not self._fd2 or not self._fd1:
42 from nepi.resources.ns3.ns3fdnetdevice import NS3BaseFdNetDevice
43 devices = self.get_connected(NS3BaseFdNetDevice.get_rtype())
44 if not devices or len(devices) != 2:
45 msg = "Tunnel must be connected to exactly two FdNetDevices"
47 raise RuntimeError, msg
49 self._fd1 = devices[0]
50 self._fd2 = devices[1]
54 self._fd1.set("EncapsulationMode", "DixPi")
55 self._fd2.set("EncapsulationMode", "DixPi")
57 simu = self._fd1.simulation
58 from nepi.resources.linux.node import LinuxNode
59 nodes = simu.get_connected(LinuxNode.get_rtype())
60 self._fd1node = nodes[0]
62 simu = self._fd2.simulation
63 from nepi.resources.linux.node import LinuxNode
64 nodes = simu.get_connected(LinuxNode.get_rtype())
65 self._fd2node = nodes[0]
67 if self._fd1node.get("hostname") == \
68 self._fd2node.get("hostname"):
69 msg = "Tunnel requires endpoints on different hosts"
71 raise RuntimeError, msg
73 return [self._fd1, self._fd2]