2 # NEPI, a framework to manage network experiments
\r
3 # Copyright (C) 2013 INRIA
\r
5 # This program is free software: you can redistribute it and/or modify
\r
6 # it under the terms of the GNU General Public License version 2 as
\r
7 # published by the Free Software Foundation;
\r
9 # This program is distributed in the hope that it will be useful,
\r
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
12 # GNU General Public License for more details.
\r
14 # You should have received a copy of the GNU General Public License
\r
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
\r
17 # Author: Damien Saucez <damien.saucez@inria.fr>
\r
18 # Alina Quereilhac <alina.quereilhac@inria.fr>
\r
20 from experiment_interconnected import ExperimentInterconnected
\r
22 class ExperimentInterconnectedNs3Ns3(ExperimentInterconnected):
\r
23 def connect_with_udp_tunnel(self, xp_remote):
\r
24 # Connect the two experiments via a UDP tunnel direcly on the FD devices
\r
25 tunnel = self.ec.register_resource("planetlab::ns3::FdUdpTunnel")
\r
26 self.ec.register_connection(tunnel, self.fddev)
\r
27 self.ec.register_connection(tunnel, xp_remote.fddev)
\r
31 def interconnect(self, xp_remote):
\r
33 Interconnect two ns3 simulations via a UDP tunnel
\r
37 # topology must be setup
\r
38 if not self.topology_built:
\r
39 raise Exception("Topology not setup on ", self)
\r
40 if not xp_remote.topology_built:
\r
41 raise Exception("Topology not setup on ", xp_remote )
\r
43 # experiment cannot be interconnected to another experiment
\r
44 if self.interconnected:
\r
45 raise Exception("Experiment already interconnected on ", self)
\r
46 if xp_remote.interconnected:
\r
47 raise Exception("Experiment already interconnected on ", xp_remote)
\r
49 # IP for the AP of the two experiments
\r
51 ip = ["10.0.0.1", "10.0.0.2"]
\r
53 # add an FD device on both local and remote experiments
\r
54 self.add_fdnetdevice(ip[0], "30")
\r
55 xp_remote.add_fdnetdevice(ip[1], "30")
\r
57 # Connect the two experiments via a UDP tunnel direcly on the FD devices
\r
58 self.connect_with_udp_tunnel(xp_remote)
\r
60 # Add a route to the remote network on each experiment, via the FD device
\r
61 self.add_route(self.nsnodes[0], xp_remote.netblock, xp_remote.prefix, ip[1])
\r
62 xp_remote.add_route(xp_remote.nsnodes[0], self.netblock, self.prefix, ip[0])
\r
65 self.interconnected = True
\r