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 # Authors : Julien Tribino <julien.tribino@inria.fr>
20 # Alina Quereilhac <alina.quereilhac@inria.fr>
33 # Switch1 ----- Switch2
39 from nepi.execution.ec import ExperimentController
44 ### Useful Method to Create RM ##
45 def add_node(ec, host, user):
46 node = ec.register_resource("PlanetlabNode")
47 ec.set(node, "hostname", host)
48 ec.set(node, "username", user)
49 ec.set(node, "cleanHome", True)
50 ec.set(node, "cleanProcesses", True)
53 def add_tap(ec, ip4, prefix4, pointopoint, node):
54 tap = ec.register_resource("PlanetlabTap")
55 ec.set(tap, "ip4", ip4)
56 ec.set(tap, "prefix4", prefix4)
57 ec.set(tap, "pointopoint", pointopoint)
58 ec.set(tap, "up", True)
59 ec.register_connection(tap, node)
62 def add_udptun(ec, tap1, tap2):
63 udptun = ec.register_resource("UdpTunnel")
64 ec.register_connection(tap1, udptun)
65 ec.register_connection(tap2, udptun)
68 def add_vroute(ec, network, tap):
69 vroute = ec.register_resource("PlanetlabVroute")
70 ec.set(vroute, "action", "add")
71 ec.set(vroute, "network", network)
72 ec.register_connection(vroute, tap)
75 def add_app(ec, command, node):
76 app = ec.register_resource("LinuxApplication")
77 ec.set(app, "command", command)
78 ec.register_connection(app, node)
81 ### Data that can be changed ###
84 hostname_switch1 = "planetlab2.virtues.fi"
85 hostname_switch2 = "planetlab2.upc.es"
86 hostname_switch3 = "planetlab2.cs.aueb.gr"
87 hostname_host1 = "planetlab2.ionio.gr"
88 hostname_host2 = "iraplab2.iralab.uni-karlsruhe.de"
89 hostname_host3 = "planetlab2.diku.dk"
92 ### Start Experiment ###
93 ec = ExperimentController(exp_id = "test-tap-tunnel")
95 ## Create The topology ##
96 host1 = add_node(ec, hostname_host1, user)
97 tap1 = add_tap(ec, "192.168.3.1", 24, "192.168.3.2", host1)
99 switch1 = add_node(ec, hostname_switch1, user)
100 tap2 = add_tap(ec, "192.168.3.2", 24, "192.168.3.1", switch1)
101 tap102 = add_tap(ec, "192.168.3.102", 29, "192.168.3.104", switch1)
102 tap152 = add_tap(ec, "192.168.3.152", 29, "192.168.3.156", switch1)
104 host2 = add_node(ec, hostname_host2, user)
105 tap13 = add_tap(ec, "192.168.3.13", 24, "192.168.3.14", host2)
107 switch2 = add_node(ec, hostname_switch2, user)
108 tap14 = add_tap(ec, "192.168.3.14", 24, "192.168.3.13", switch2)
109 tap104 = add_tap(ec, "192.168.3.104", 29, "192.168.3.102", switch2)
110 tap204 = add_tap(ec, "192.168.3.204", 29, "192.168.3.206", switch2)
112 host3 = add_node(ec, hostname_host3, user)
113 tap25 = add_tap(ec, "192.168.3.25", 24, "192.168.3.26", host3)
115 switch3 = add_node(ec, hostname_switch3, user)
116 tap26 = add_tap(ec, "192.168.3.26", 24, "192.168.3.25", switch3)
117 tap156 = add_tap(ec, "192.168.3.156", 29, "192.168.3.152", switch3)
118 tap206 = add_tap(ec, "192.168.3.206", 29, "192.168.3.204", switch3)
120 ## Create the UDP Tunnel ##
121 udptun1 = add_udptun(ec, tap1, tap2)
122 udptun2 = add_udptun(ec, tap13, tap14)
123 udptun3 = add_udptun(ec, tap25, tap26)
125 udptun4 = add_udptun(ec, tap102, tap104)
126 udptun5 = add_udptun(ec, tap152, tap156)
127 udptun6 = add_udptun(ec, tap204, tap206)
129 ## Create the PlanetLab Route ##
130 vroute1 = add_vroute(ec, "192.168.3.0", tap1)
131 vroute2 = add_vroute(ec, "192.168.3.0", tap13)
132 vroute3 = add_vroute(ec, "192.168.3.0", tap25)
134 vroute7 = add_vroute(ec, "192.168.3.8", tap102)
135 vroute8 = add_vroute(ec, "192.168.3.0", tap104)
136 vroute9 = add_vroute(ec, "192.168.3.24", tap152)
137 vroute10 = add_vroute(ec, "192.168.3.0", tap156)
138 vroute11 = add_vroute(ec, "192.168.3.24", tap204)
139 vroute12 = add_vroute(ec, "192.168.3.8", tap206)
141 ## Create all the Ping ##
143 app1 = add_app(ec, "ping -c8 192.168.3.13", host1)
144 app2 = add_app(ec, "ping -c8 192.168.3.25", host1)
145 app3 = add_app(ec, "ping -c8 192.168.3.104", host1)
146 app4 = add_app(ec, "ping -c8 192.168.3.156", host1)
147 app5 = add_app(ec, "ping -c8 192.168.3.2", host1)
149 app11 = add_app(ec, "ping -c8 192.168.3.1", host2)
150 app12 = add_app(ec, "ping -c8 192.168.3.25", host2)
151 app13 = add_app(ec, "ping -c8 192.168.3.102", host2)
152 app14 = add_app(ec, "ping -c8 192.168.3.206", host2)
153 app15 = add_app(ec, "ping -c8 192.168.3.14", host2)
155 app21 = add_app(ec, "ping -c8 192.168.3.1", host3)
156 app22 = add_app(ec, "ping -c8 192.168.3.13", host3)
157 app23 = add_app(ec, "ping -c8 192.168.3.152", host3)
158 app24 = add_app(ec, "ping -c8 192.168.3.204", host3)
159 app25 = add_app(ec, "ping -c8 192.168.3.26", host3)
163 ec.wait_finished([app1 ,app2, app3, app4, app5, app11 ,app12, app13, app14, app15, app21 ,app22, app23, app24, app25])
165 # Retreive ping results and save
167 ping1 = ec.trace(app1, 'stdout')
168 ping2 = ec.trace(app2, 'stdout')
169 ping3 = ec.trace(app3, 'stdout')
170 ping4 = ec.trace(app4, 'stdout')
171 ping5 = ec.trace(app5, 'stdout')
172 ping11 = ec.trace(app11, 'stdout')
173 ping12 = ec.trace(app12, 'stdout')
174 ping13 = ec.trace(app13, 'stdout')
175 ping14 = ec.trace(app14, 'stdout')
176 ping15 = ec.trace(app15, 'stdout')
177 ping21 = ec.trace(app21, 'stdout')
178 ping22 = ec.trace(app22, 'stdout')
179 ping23 = ec.trace(app23, 'stdout')
180 ping24 = ec.trace(app24, 'stdout')
181 ping25 = ec.trace(app25, 'stdout')
183 f = open("examples/openvswitch/ping_over_udpTapTunnel_performance_test.txt", 'w')
189 f.write("************ Ping From Host 1 : 192.168.3.1 ********************\n\n")
191 f.write("----------------------------------------\n\n")
193 f.write("----------------------------------------\n\n")
195 f.write("----------------------------------------\n\n")
197 f.write("----------------------------------------\n\n")
199 f.write("************ Ping From Host 2 : 192.168.3.13 ********************\n\n")
201 f.write("----------------------------------------\n\n")
203 f.write("----------------------------------------\n\n")
205 f.write("----------------------------------------\n\n")
207 f.write("----------------------------------------\n\n")
209 f.write("************ Ping From Host 3 : 192.168.3.25 ********************\n\n")
211 f.write("----------------------------------------\n\n")
213 f.write("----------------------------------------\n\n")
215 f.write("----------------------------------------\n\n")
217 f.write("----------------------------------------\n\n")
222 # Delete the overlay network