3 # NEPI, a framework to manage network experiments
4 # Copyright (C) 2013 INRIA
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 # Author: Alina Quereilhac <alina.quereilhac@inria.fr>
21 from nepi.execution.ec import ExperimentController
23 from test_utils import skipIfAnyNotAlive
29 class UdpTunnelTestCase(unittest.TestCase):
31 self.host1 = "nepi2.pl.sophia.inria.fr"
32 self.host2 = "nepi5.pl.sophia.inria.fr"
33 self.user = "inria_nepi"
36 def t_tap_udp_tunnel(self, user, host1, host2):
38 ec = ExperimentController(exp_id = "test-tap-udp-tunnel")
40 node1 = ec.register_resource("PlanetlabNode")
41 ec.set(node1, "hostname", host1)
42 ec.set(node1, "username", user)
43 ec.set(node1, "cleanHome", True)
44 ec.set(node1, "cleanProcesses", True)
46 tap1 = ec.register_resource("PlanetlabTap")
47 ec.set(tap1, "ip4", "192.168.1.1")
48 ec.set(tap1, "pointopoint", "192.168.1.2")
49 ec.set(tap1, "prefix4", 24)
50 ec.register_connection(tap1, node1)
52 node2 = ec.register_resource("PlanetlabNode")
53 ec.set(node2, "hostname", host2)
54 ec.set(node2, "username", user)
55 ec.set(node2, "cleanHome", True)
56 ec.set(node2, "cleanProcesses", True)
58 tap2 = ec.register_resource("PlanetlabTap")
59 ec.set(tap2, "ip4", "192.168.1.2")
60 ec.set(tap2, "pointopoint", "192.168.1.1")
61 ec.set(tap2, "prefix4", 24)
62 ec.register_connection(tap2, node2)
64 udptun = ec.register_resource("UdpTunnel")
65 ec.register_connection(tap1, udptun)
66 ec.register_connection(tap2, udptun)
68 app = ec.register_resource("LinuxApplication")
69 cmd = "ping -c3 192.168.1.2"
70 ec.set(app, "command", cmd)
71 ec.register_connection(app, node1)
77 ping = ec.trace(app, 'stdout')
78 expected = """3 packets transmitted, 3 received, 0% packet loss"""
79 self.assertTrue(ping.find(expected) > -1)
81 if_name = ec.get(tap1, "deviceName")
82 self.assertTrue(if_name.startswith("tap"))
84 if_name = ec.get(tap2, "deviceName")
85 self.assertTrue(if_name.startswith("tap"))
90 def test_tap_udp_tunnel(self):
91 self.t_tap_udp_tunnel(self.user, self.host1, self.host2)
93 if __name__ == '__main__':