use print() - import print_function - should be fine for both py2 and py3
[nepi.git] / examples / dce / custom_local_p2p_ccn.py
index 3ba901a..243470f 100644 (file)
@@ -4,9 +4,8 @@
 #    Copyright (C) 2013 INRIA
 #
 #    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
-#    the Free Software Foundation, either version 3 of the License, or
-#    (at your option) any later version.
+#    it under the terms of the GNU General Public License version 2 as
+#    published by the Free Software Foundation;
 #
 #    This program is distributed in the hope that it will be useful,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,6 +17,8 @@
 #
 # Author: Alina Quereilhac <alina.quereilhac@inria.fr>
 
+from __future__ import print_function
+
 from nepi.execution.ec import ExperimentController 
 
 import os
@@ -56,11 +57,11 @@ def add_device(ec, node, ip,  prefix):
 
 ec = ExperimentController(exp_id = "dce-custom-ccn")
 
-node = ec.register_resource("LinuxNode")
+node = ec.register_resource("linux::Node")
 ec.set(node, "hostname", "localhost")
 ec.set(node, "cleanProcesses", True)
 
-simu = ec.register_resource("LinuxNS3Simulation")
+simu = ec.register_resource("linux::ns3::Simulation")
 ec.set(simu, "verbose", True)
 ec.register_connection(simu, node)
 
@@ -83,7 +84,7 @@ ec.register_connection(chan, dev2)
 
 # Add a LinuxCCNDceApplication to ns-3 node 1 to install custom ccnx sources
 # and run a CCNx daemon
-ccnd1 = ec.register_resource("ns3::LinuxCCNDceApplication")
+ccnd1 = ec.register_resource("linux::ns3::dce::CCNApplication")
 # NOTE THAT INSTALLATION MIGHT FAIL IF openjdk-6-jdk is not installed
 ec.set(ccnd1, "depends", "libpcap0.8-dev openjdk-6-jdk ant1.8 autoconf "
     "libssl-dev libexpat-dev libpcap-dev libecryptfs0 libxml2-utils auto"
@@ -110,7 +111,7 @@ repofile = os.path.join(
     "..", "..", "test", "resources", "linux", 
     "ns3", "ccn", "repoFile1")
 
-ccnr = ec.register_resource("ns3::LinuxCCNDceApplication")
+ccnr = ec.register_resource("linux::ns3::dce::CCNApplication")
 ec.set (ccnr, "binary", "ccnr")
 ec.set (ccnr, "environment", "CCNR_DIRECTORY=/REPO/")
 ec.set (ccnr, "files", "%s=/REPO/repoFile1" % repofile) 
@@ -123,7 +124,7 @@ ec.register_connection(ccnr, nsnode1)
 # daemon. Note that the CCNx sources and build instructions 
 # do not need to be specified again (NEPI will take the 
 # instructions from the first definition).
-ccnd2 = ec.register_resource("ns3::LinuxCCNDceApplication")
+ccnd2 = ec.register_resource("linux::ns3::dce::CCNApplication")
 ec.set (ccnd2, "binary", "ccnd")
 ec.set (ccnd2, "stackSize", 1<<20)
 ec.set (ccnd2, "environment", "CCND_CAP=50000; CCND_DEBUG=7")
@@ -133,7 +134,7 @@ ec.register_connection(ccnd2, nsnode2)
 
 # Add DCE application to configure peer CCN faces between
 # nodes
-ccndc1 = ec.register_resource("ns3::LinuxCCNDceApplication")
+ccndc1 = ec.register_resource("linux::ns3::dce::CCNApplication")
 ec.set (ccndc1, "binary", "ccndc")
 ec.set (ccndc1, "arguments", "-v;add;ccnx:/;udp;10.0.0.2")
 ec.set (ccndc1, "stackSize", 1<<20)
@@ -141,7 +142,7 @@ ec.set (ccndc1, "StartTime", "2s")
 ec.set (ccndc1, "StopTime", "120s")
 ec.register_connection(ccndc1, nsnode1)
 
-ccndc2 = ec.register_resource("ns3::LinuxCCNDceApplication")
+ccndc2 = ec.register_resource("linux::ns3::dce::CCNApplication")
 ec.set (ccndc2, "binary", "ccndc")
 ec.set (ccndc2, "arguments", "-v;add;ccnx:/;udp;10.0.0.1")
 ec.set (ccndc2, "stackSize", 1<<20)
@@ -150,7 +151,7 @@ ec.set (ccndc2, "StopTime", "120s")
 ec.register_connection(ccndc2, nsnode2)
 
 # Add a DCE application to perform a ccncat and retrieve content
-ccncat = ec.register_resource("ns3::LinuxCCNDceApplication")
+ccncat = ec.register_resource("linux::ns3::dce::CCNApplication")
 ec.set (ccncat, "binary", "ccncat")
 ec.set (ccncat, "arguments", "ccnx:/test/bunny.ts")
 ec.set (ccncat, "stdinFile", "")
@@ -165,7 +166,7 @@ ec.wait_finished([ccncat])
 
 stdout = ec.trace(ccncat, "stdout")
 # convert from bytes to MB
-print "%0.2f MBytes received" % (len(stdout) / 1024.0 / 1024.0 )
+print("%0.2f MBytes received" % (len(stdout) / 1024.0 / 1024.0 ))
 
 ec.shutdown()