Adding a simple tutorial example
diff --git a/examples/ccnx-simple.cc b/examples/ccnx-simple.cc
new file mode 100644
index 0000000..1a2ae45
--- /dev/null
+++ b/examples/ccnx-simple.cc
@@ -0,0 +1,101 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2012 University of California, Los Angeles
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * 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
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#include "ns3/core-module.h"
+#include "ns3/network-module.h"
+#include "ns3/point-to-point-module.h"
+#include "ns3/NDNabstraction-module.h"
+
+using namespace ns3;
+
+/**
+ * This scenario simulates a very simple network topology:
+ *
+ *
+ * +----------+ 1Mbps +--------+ 1Mbps +----------+
+ * | consumer | <------------> | router | <------------> | producer |
+ * +----------+ 10ms +--------+ 10ms +----------+
+ *
+ *
+ * Consumer requests data from producer with frequency 10 interests per second
+ * (interests contain constantly increasing sequence number).
+ *
+ * For every received interest, producer replies with a data packet, containing
+ * 1024 bytes of virtual payload.
+ *
+ * Simulation time is 20 seconds, unless --finish parameter is specified
+ *
+ * To run scenario and see what is happening, use the following command:
+ *
+ * NS_LOG=CcnxSimple:CcnxConsumer ./waf --run=ccnx-simple
+ */
+
+NS_LOG_COMPONENT_DEFINE ("CcnxSimple");
+
+int
+main (int argc, char *argv[])
+{
+ Config::SetDefault ("ns3::PointToPointNetDevice::DataRate", StringValue ("1Mbps"));
+ Config::SetDefault ("ns3::PointToPointChannel::Delay", StringValue ("10ms"));
+ Config::SetDefault ("ns3::DropTailQueue::MaxPackets", StringValue ("20"));
+
+ Time finishTime = Seconds (20.0);
+
+ CommandLine cmd;
+ cmd.AddValue ("finish", "Finish time", finishTime);
+ cmd.Parse (argc, argv);
+
+ // Creating nodes
+ NodeContainer nodes;
+ nodes.Create (3);
+
+ // Connecting nodes using two links
+ PointToPointHelper p2p;
+ p2p.Install (nodes.Get (0), nodes.Get (1));
+ p2p.Install (nodes.Get (1), nodes.Get (2));
+
+ // Install CCNx stack on all nodes
+ NS_LOG_INFO ("Installing CCNx stack");
+ CcnxStackHelper ccnxHelper;
+ ccnxHelper.SetDefaultRoutes (true);
+ ccnxHelper.InstallAll ();
+
+ NS_LOG_INFO ("Installing CCNx applications");
+ CcnxAppHelper consumerHelper ("ns3::CcnxConsumerCbr");
+ // Consumer will request /prefix/0, /prefix/1, ...
+ consumerHelper.SetPrefix ("/prefix");
+ consumerHelper.SetAttribute ("Frequency", StringValue ("10")); // 10 interests a second
+ ApplicationContainer consumers = consumerHelper.Install (nodes.Get (0)); // first node
+
+ CcnxAppHelper producerHelper ("ns3::CcnxProducer");
+ // Producer will reply to all requests starting with /prefix
+ producerHelper.SetPrefix ("/prefix");
+ producerHelper.SetAttribute ("PayloadSize", StringValue("1024"));
+ ApplicationContainer producers = producerHelper.Install (nodes.Get (2)); // last node
+
+ Simulator::Stop (finishTime);
+
+ NS_LOG_INFO ("Run Simulation.");
+ Simulator::Run ();
+ Simulator::Destroy ();
+ NS_LOG_INFO ("Done!");
+
+ return 0;
+}
diff --git a/examples/wscript b/examples/wscript
new file mode 100644
index 0000000..def6b0a
--- /dev/null
+++ b/examples/wscript
@@ -0,0 +1,6 @@
+# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
+
+def build(bld):
+ obj = bld.create_ns3_program('ccnx-simple', ['NDNabstraction'])
+ obj.source = 'ccnx-simple.cc'
+
diff --git a/wscript b/wscript
index 2643c67..baf5c8e 100644
--- a/wscript
+++ b/wscript
@@ -30,7 +30,7 @@
def build(bld):
deps = ['core', 'network', 'point-to-point',
'topology-read','internet','applications',
- 'point-to-point-layout', 'netanim']
+ 'point-to-point-layout']
if bld.env['ENABLE_PYTHON_BINDINGS']:
deps.append ('visualizer')
@@ -89,45 +89,7 @@
tests.source = bld.path.ant_glob('test/*.cc');
- if True or bld.env['ENABLE_EXAMPLES']:
- obj = bld.create_ns3_program('ccnx-routing-simple', ['NDNabstraction'])
- obj.source = 'examples/ccnx-routing-simple.cc'
-
- obj = bld.create_ns3_program('ccnx-grid', ['NDNabstraction'])
- obj.source = 'examples/ccnx-grid.cc'
-
- obj = bld.create_ns3_program('annotated-topology', ['NDNabstraction'])
- obj.source = 'examples/annotated-topology-read-example.cc'
-
- obj = bld.create_ns3_program('ccnx-sprint-topology', ['NDNabstraction'])
- obj.source = 'examples/sprint-topology.cc'
-
- obj = bld.create_ns3_program('ccnx-abilene-topology', ['NDNabstraction'])
- obj.source = 'examples/abilene-topology.cc'
-
- obj = bld.create_ns3_program('ccnx-synthetic-topology', ['NDNabstraction'])
- obj.source = 'examples/synthetic-topology.cc'
-
- obj = bld.create_ns3_program('congestion-pop', ['NDNabstraction'])
- obj.source = 'examples/congestion-pop.cc'
-
- obj = bld.create_ns3_program('link-failure', ['NDNabstraction'])
- obj.source = 'examples/link-failure-sprint.cc'
-
- obj = bld.create_ns3_program('link-failure-base', ['NDNabstraction'])
- obj.source = 'examples/link-failure-base.cc'
-
- obj = bld.create_ns3_program('blackhole-sprint', ['NDNabstraction'])
- obj.source = 'examples/blackhole-sprint.cc'
-
- obj = bld.create_ns3_program('congestion-zoom', ['NDNabstraction'])
- obj.source = 'examples/congestion-zoom.cc'
-
- obj = bld.create_ns3_program('vanet-ccnx', ['NDNabstraction', 'highway-mobility'])
- obj.source = 'examples/vanet-ccnx.cc'
-
- obj = bld.create_ns3_program('car2car-wifi', ['internet', 'applications', 'visualizer', 'NDNabstraction'])
- obj.source = 'examples/car2car-wifi.cc'
-
+ if bld.env.ENABLE_EXAMPLES:
+ bld.add_subdirs('examples')
bld.ns3_python_bindings()