2 # NEPI, a framework to manage network experiments
3 # Copyright (C) 2014 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.resource import ResourceState, clsinit_copy
20 from nepi.resources.linux.ns3.tuntapfdlink import LinuxTunTapFdLink
29 class PlanetlabTunTapFdLink(LinuxTunTapFdLink):
30 """ Interconnects a TAP or TUN PlanetLab device to a FdNetDevice
32 _rtype = "planetlab::ns3::TunTapFdLink"
34 def __init__(self, ec, guid):
35 super(PlanetlabTunTapFdLink, self).__init__(ec, guid)
38 def fdnetdevice(self):
39 if not self._fdnetdevice:
40 from nepi.resources.ns3.ns3fdnetdevice import NS3BaseFdNetDevice
41 devices = self.get_connected(NS3BaseFdNetDevice.get_rtype())
42 if not devices or len(devices) != 1:
43 msg = "planetlab::ns3::TunTapFdLink must be connected to exactly one FdNetDevice"
45 raise RuntimeError, msg
47 self._fdnetdevice = devices[0]
50 self._fdnetdevice.set("EncapsulationMode", "DixPi")
52 simu = self._fdnetdevice.simulation
53 from nepi.resources.planetlab.node import PlanetlabNode
54 nodes = simu.get_connected(PlanetlabNode.get_rtype())
55 self._fd_node = nodes[0]
57 return self._fdnetdevice
62 from nepi.resources.planetlab.tap import PlanetlabTap
63 devices = self.get_connected(PlanetlabTap.get_rtype())
65 if not devices or len(devices) != 1:
66 msg = "planetlab::ns3::TunTapFdLink must be connected to exactly one PlanetlabTap"
68 raise RuntimeError, msg
70 self._tap = devices[0]
74 def upload_sources(self):
77 # vif-passfd python script
78 pl_vif_passfd = os.path.join(os.path.dirname(__file__),
82 "linux-tap-passfd.py")
84 scripts.append(pl_vif_passfd)
87 scripts = ";".join(scripts)
89 self.node.upload(scripts,
90 os.path.join(self.node.src_dir),