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 def add_ns3_node(ec, simu):
24 node = ec.register_resource("ns3::Node")
25 ec.register_connection(node, simu)
27 ipv4 = ec.register_resource("ns3::Ipv4L3Protocol")
28 ec.register_connection(node, ipv4)
30 arp = ec.register_resource("ns3::ArpL3Protocol")
31 ec.register_connection(node, arp)
33 icmp = ec.register_resource("ns3::Icmpv4L4Protocol")
34 ec.register_connection(node, icmp)
36 udp = ec.register_resource("ns3::UdpL4Protocol")
37 ec.register_connection(node, udp)
39 tcp = ec.register_resource("ns3::TcpL4Protocol")
40 ec.register_connection(node, tcp)
44 def add_point2point_device(ec, node, ip, prefix):
45 dev = ec.register_resource("ns3::PointToPointNetDevice")
47 ec.set(dev, "prefix", prefix)
48 ec.register_connection(node, dev)
50 queue = ec.register_resource("ns3::DropTailQueue")
51 ec.register_connection(dev, queue)
55 ec = ExperimentController(exp_id = "dce-custom-ping")
57 node = ec.register_resource("LinuxNode")
58 ec.set(node, "hostname", "localhost")
59 ec.set(node, "cleanProcesses", True)
60 #ec.set(node, "cleanHome", True)
62 simu = ec.register_resource("LinuxNS3Simulation")
63 ec.set(simu, "verbose", True)
64 ec.set(simu, "nsLog", "DceApplication")
65 ec.set(simu, "enableDump", True)
66 ec.register_connection(simu, node)
68 nsnode1 = add_ns3_node(ec, simu)
69 p2p1 = add_point2point_device(ec, nsnode1, "10.0.0.1", "30")
70 ec.set(p2p1, "DataRate", "5Mbps")
72 nsnode2 = add_ns3_node(ec, simu)
73 p2p2 = add_point2point_device(ec, nsnode2, "10.0.0.2", "30")
74 ec.set(p2p2, "DataRate", "5Mbps")
77 chan = ec.register_resource("ns3::PointToPointChannel")
78 ec.set(chan, "Delay", "2ms")
80 ec.register_connection(chan, p2p1)
81 ec.register_connection(chan, p2p2)
83 ### create applications
84 ping = ec.register_resource("ns3::LinuxDceApplication")
85 ec.set (ping, "sources", "http://www.skbuff.net/iputils/iputils-s20101006.tar.bz2")
86 ec.set (ping, "build", "tar xvjf ${SRC}/iputils-s20101006.tar.bz2 && "
87 "cd iputils-s20101006/ && "
88 "sed -i 's/CFLAGS=/CFLAGS+=/g' Makefile && "
89 "make CFLAGS=-fPIC LDFLAGS='-pie -rdynamic' ping && "
90 "cp ping ${BIN_DCE} && cd - ")
91 ec.set (ping, "binary", "ping")
92 ec.set (ping, "stackSize", 1<<20)
93 ec.set (ping, "arguments", "-c 10;-s 1000;10.0.0.2")
94 ec.set (ping, "StartTime", "1s")
95 ec.set (ping, "StopTime", "20s")
96 ec.register_connection(ping, nsnode1)
100 ec.wait_finished([ping])
102 stdout = ec.trace(ping, "stdout")
106 print "PING OUTPUT", stdout