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 version 2 as
8 # published by the Free Software Foundation;
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 # Author: Alina Quereilhac <alina.quereilhac@inria.fr>
20 from nepi.execution.ec import ExperimentController
22 def add_ns3_node(ec, simu):
23 node = ec.register_resource("ns3::Node")
24 ec.register_connection(node, simu)
26 ipv4 = ec.register_resource("ns3::Ipv4L3Protocol")
27 ec.register_connection(node, ipv4)
29 arp = ec.register_resource("ns3::ArpL3Protocol")
30 ec.register_connection(node, arp)
32 icmp = ec.register_resource("ns3::Icmpv4L4Protocol")
33 ec.register_connection(node, icmp)
35 udp = ec.register_resource("ns3::UdpL4Protocol")
36 ec.register_connection(node, udp)
38 tcp = ec.register_resource("ns3::TcpL4Protocol")
39 ec.register_connection(node, tcp)
43 ec = ExperimentController(exp_id = "dce-local-ccnpeek")
45 node = ec.register_resource("linux::Node")
46 ec.set(node, "hostname", "localhost")
47 ec.set(node, "cleanProcesses", True)
49 simu = ec.register_resource("linux::ns3::Simulation")
50 ec.register_connection(simu, node)
52 nsnode = add_ns3_node(ec, simu)
54 ### create applications
55 ccnd = ec.register_resource("linux::ns3::dce::CCND")
56 ec.set (ccnd, "stackSize", 1<<20)
57 ec.set (ccnd, "StartTime", "1s")
58 ec.register_connection(ccnd, nsnode)
60 ccnpoke = ec.register_resource("linux::ns3::dce::CCNPoke")
61 ec.set (ccnpoke, "contentName", "ccnx:/chunk0")
62 ec.set (ccnpoke, "content", "DATA")
63 ec.set (ccnpoke, "stackSize", 1<<20)
64 ec.set (ccnpoke, "StartTime", "2s")
65 ec.register_connection(ccnpoke, nsnode)
67 ccnpeek = ec.register_resource("linux::ns3::dce::CCNPeek")
68 ec.set (ccnpeek, "contentName", "ccnx:/chunk0")
69 ec.set (ccnpeek, "stackSize", 1<<20)
70 ec.set (ccnpeek, "StartTime", "4s")
71 ec.set (ccnpeek, "StopTime", "20s")
72 ec.register_connection(ccnpeek, nsnode)
76 ec.wait_finished([ccnpeek])
78 stdout = ec.trace(ccnpeek, "stdout")
82 print "PEEK received", stdout