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 ec = ExperimentController(exp_id = "dce-local-ccnpeek")
46 node = ec.register_resource("linux::Node")
47 ec.set(node, "hostname", "localhost")
48 ec.set(node, "cleanProcesses", True)
50 simu = ec.register_resource("linux::ns3::Simulation")
51 ec.register_connection(simu, node)
53 nsnode = add_ns3_node(ec, simu)
55 ### create applications
56 ccnd = ec.register_resource("linux::ns3::dce::CCND")
57 ec.set (ccnd, "stackSize", 1<<20)
58 ec.set (ccnd, "StartTime", "1s")
59 ec.register_connection(ccnd, nsnode)
61 ccnpoke = ec.register_resource("linux::ns3::dce::CCNPoke")
62 ec.set (ccnpoke, "contentName", "ccnx:/chunk0")
63 ec.set (ccnpoke, "content", "DATA")
64 ec.set (ccnpoke, "stackSize", 1<<20)
65 ec.set (ccnpoke, "StartTime", "2s")
66 ec.register_connection(ccnpoke, nsnode)
68 ccnpeek = ec.register_resource("linux::ns3::dce::CCNPeek")
69 ec.set (ccnpeek, "contentName", "ccnx:/chunk0")
70 ec.set (ccnpeek, "stackSize", 1<<20)
71 ec.set (ccnpeek, "StartTime", "4s")
72 ec.set (ccnpeek, "StopTime", "20s")
73 ec.register_connection(ccnpeek, nsnode)
77 ec.wait_finished([ccnpeek])
79 stdout = ec.trace(ccnpeek, "stdout")
83 print "PEEK received", stdout