Merge remote-tracking branch 'git.irl/Ilya'
diff --git a/examples/annotated-topology-read-example.cc b/examples/annotated-topology-read-example.cc
index 63e42c4..7aff4fe 100644
--- a/examples/annotated-topology-read-example.cc
+++ b/examples/annotated-topology-read-example.cc
@@ -30,18 +30,22 @@
#include "ns3/ipv4-list-routing-helper.h"
#include "ns3/annotated-topology-reader.h"
#include <list>
-//#include "ns3/visualizer-module.h"
+#include "ns3/visualizer-module.h"
+#include "ns3/ccnx.h"
+#include "ns3/ipv4-global-routing-helper.h"
+#include "ns3/NDNabstraction-module.h"
using namespace ns3;
using namespace std;
-NS_LOG_COMPONENT_DEFINE ("AnnotatedTopologyReadingExample");
+NS_LOG_COMPONENT_DEFINE ("AnnotatedTopologyExample");
int main (int argc, char *argv[])
{
GlobalValue::Bind ("SimulatorImplementationType", StringValue
("ns3::VisualSimulatorImpl"));
-
+ Packet::EnableChecking();
+ Packet::EnablePrinting();
string input ("/Users/iliamo/ns3-abstract-ndn/ns-3.11/src/NDNabstraction/examples/simpletopology.txt");
// Set up command line parameters used to control the experiment.
@@ -71,6 +75,16 @@
return -1;
}
+
+ for(uint32_t j=0; j<nodes.GetN(); j++)
+ {
+ uint32_t name = j+1;
+ std::stringstream ss;
+ ss<<name;
+ Names::Add (ss.str(), nodes.Get (j));
+ NS_LOG_INFO("Name = " << ss.str());
+ }
+
// ------------------------------------------------------------
// -- Create nodes and network stacks
// --------------------------------------------
@@ -79,15 +93,30 @@
//routing
- Ipv4StaticRoutingHelper staticRouting;
- Ipv4ListRoutingHelper listRH;
- listRH.Add (staticRouting, 0);
- stack.SetRoutingHelper (listRH); // has effect on the next Install ()
- stack.Install (nodes);
+ //Ipv4StaticRoutingHelper staticRouting;
+ //Ipv4ListRoutingHelper listRH;
+ //listRH.Add (staticRouting, 0);
+ //stack.SetRoutingHelper (listRH); // has effect on the next Install ()
+ //stack.Install (nodes);
+
+ Ipv4GlobalRoutingHelper ipv4RoutingHelper;
+ // Ptr<Ipv4RoutingHelper> ipv4RoutingHelper = stack.GetRoutingHelper ();
+ stack.SetRoutingHelper (ipv4RoutingHelper);
+ stack.Install(nodes);
NS_LOG_INFO ("creating ip4 addresses");
Ipv4AddressHelper address;
address.SetBase ("10.0.0.0", "255.255.255.252");
+
+ // // Create router nodes, initialize routing database and set up the routing
+ // // tables in the nodes.
+ Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
+
+ /*grid.AssignIpv4Addresses (
+ Ipv4AddressHelper("10.1.0.0", "255.255.255.0"),
+ Ipv4AddressHelper("10.2.0.0", "255.255.255.0")
+ );
+*/
int totlinks = reader->LinksSize ();
@@ -106,8 +135,39 @@
reader->ApplySettings(ndc,nc);
///*** settings applied
-
+ NS_LOG_INFO("installing ccnx stack");
+ CcnxStackHelper ccnx(Ccnx::NDN_FLOODING);
+ Ptr<CcnxFaceContainer> cf = ccnx.Install (nodes);
+ NS_LOG_INFO ("Installing Applications");
+ CcnxConsumerHelper helper ("/3");
+ ApplicationContainer app = helper.Install (nodes.Get(1));
+ app.Start (Seconds (1.0));
+ app.Stop (Seconds (1000.05));
+
+ /*CcnxConsumerHelper helper2 ("/4");
+ ApplicationContainer app2 = helper2.Install(c.Get(5));
+ app2.Start (Seconds (1.0));
+ app2.Stop (Seconds (1000.05));
+ */
+ CcnxProducerHelper helper3 ("/3",120);
+ ApplicationContainer app3 = helper3.Install(nodes.Get(6));
+ app3.Start(Seconds(0.0));
+ app3.Stop(Seconds(1500.0));
+ /*
+ CcnxProducerHelper helper4 ("/4",150);
+ ApplicationContainer app4 = helper4.Install(c.Get(0));
+ app4.Start(Seconds(0.0));
+ app4.Stop(Seconds(1500.0));
+ */
+
+ NS_LOG_INFO("Routes");
+ ccnx.AddRoute("1","/3",0,1);
+ ccnx.AddRoute("3","/3",1,1);
+ ccnx.AddRoute("3","/3",2,2);
+ /*ccnx.AddRoute("4","/3",1,1);
+ ccnx.AddRoute("5","/3",2,1);
+*/
// it creates little subnets, one for each couple of nodes.
NS_LOG_INFO ("creating ipv4 interfaces");
diff --git a/examples/ccnx-grid.cc b/examples/ccnx-grid.cc
index 0427ae2..70cd015 100644
--- a/examples/ccnx-grid.cc
+++ b/examples/ccnx-grid.cc
@@ -88,7 +88,7 @@
NS_LOG_INFO("Eventual name is " << ss.str());
}
}
- CcnxStackHelper ccnx(Ccnx::NDN_BESTROUTE);
+ CcnxStackHelper ccnx(Ccnx::NDN_FLOODING/*Ccnx::NDN_BESTROUTE*/);
Ptr<CcnxFaceContainer> cf = ccnx.Install (c);
NS_LOG_INFO ("Installing Applications");
@@ -147,7 +147,7 @@
NS_LOG_INFO ("Run Simulation.");
Simulator::Run ();
Simulator::Destroy ();
- NS_LOG_INFO ("Done.");
+ NS_LOG_INFO ("Done!");
return 0;
diff --git a/examples/syntactic-topology-ndnabstraction.cc b/examples/syntactic-topology-ndnabstraction.cc
index a1a92a1..61f5c49 100644
--- a/examples/syntactic-topology-ndnabstraction.cc
+++ b/examples/syntactic-topology-ndnabstraction.cc
@@ -1,17 +1,36 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; c-set-offset 'innamespace 0; -*- */
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
- * sync-topology-ndnabstraction.cpp
- * XcodeProject
+ * Copyright (c) 2011 University of California, Los Angeles
*
- * Created by Ilya on 7/18/11.
- * Copyright 2011 __MyCompanyName__. All rights reserved.
+ * 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: Ilya Moiseenko <iliamo@cs.ucla.edu>
*/
+
#include "ns3/core-module.h"
#include "ns3/network-module.h"
-#include "ns3/internet-module.h"
#include "ns3/point-to-point-module.h"
-#include "ns3/applications-module.h"
+#include "ns3/NDNabstraction-module.h"
+#include <ns3/point-to-point-grid.h>
+#include "ns3/ipv4-global-routing-helper.h"
+
+#include <iostream>
+#include <sstream>
+
+#include "ns3/visualizer-module.h"
+#include "ns3/ccnx.h"
+
using namespace ns3;
@@ -20,11 +39,17 @@
int
main (int argc, char *argv[])
{
+ GlobalValue::Bind ("SimulatorImplementationType", StringValue
+ ("ns3::VisualSimulatorImpl"));
+
// Set up some default values for the simulation. Use the
Config::SetDefault ("ns3::OnOffApplication::PacketSize", UintegerValue (210));
Config::SetDefault ("ns3::OnOffApplication::DataRate", StringValue ("448kb/s"));
+ Packet::EnableChecking();
+ Packet::EnablePrinting();
+
// Allow the user to override any of the defaults and the above
// DefaultValue::Bind ()s at run-time, via command-line arguments
CommandLine cmd;
@@ -34,25 +59,32 @@
NS_LOG_INFO ("Create nodes.");
NodeContainer c;
c.Create (7);
-
-
+ Names::Add ("1", c.Get (0));
+ Names::Add ("2", c.Get (1));
+ Names::Add ("3", c.Get (2));
+ Names::Add ("4", c.Get (3));
+ Names::Add ("5", c.Get (4));
+ Names::Add ("6", c.Get (5));
+ Names::Add ("7", c.Get (6));
+
+
NodeContainer n13 = NodeContainer (c.Get (0), c.Get (2));
- NodeContainer n23 = NodeContainer (c.Get (1), c.Get (3));
+ NodeContainer n23 = NodeContainer (c.Get (1), c.Get (2));
NodeContainer n35 = NodeContainer (c.Get (2), c.Get (4));
NodeContainer n34 = NodeContainer (c.Get (2), c.Get (3));
NodeContainer n45 = NodeContainer (c.Get (3), c.Get (4));
NodeContainer n56 = NodeContainer (c.Get (4), c.Get (5));
NodeContainer n57 = NodeContainer (c.Get (4), c.Get (6));
- Ipv4StaticRoutingHelper staticRouting;
+ //Ipv4StaticRoutingHelper staticRouting;
- Ipv4ListRoutingHelper list;
- list.Add (staticRouting, 1);
+ //Ipv4ListRoutingHelper list;
+ //list.Add (staticRouting, 1);
//Add static routing
- InternetStackHelper internet;
- internet.SetRoutingHelper (list); // has effect on the next Install ()
- internet.Install (c);
+ //InternetStackHelper internet;
+ //internet.SetRoutingHelper (list); // has effect on the next Install ()
+ //internet.Install (c);
// We create the channels first without any IP addressing information
NS_LOG_INFO ("Create channels.");
@@ -76,6 +108,15 @@
p2p.SetChannelAttribute ("Delay", StringValue ("50ms"));
NetDeviceContainer nd35 = p2p.Install (n35);
+ InternetStackHelper stack;
+ Ipv4GlobalRoutingHelper ipv4RoutingHelper;
+ // Ptr<Ipv4RoutingHelper> ipv4RoutingHelper = stack.GetRoutingHelper ();
+ stack.SetRoutingHelper (ipv4RoutingHelper);
+ stack.Install(c);
+ // // Create router nodes, initialize routing database and set up the routing
+ // // tables in the nodes.
+ Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
+
// Later, we add IP addresses.
NS_LOG_INFO ("Assign IP Addresses.");
Ipv4AddressHelper ipv4;
@@ -88,10 +129,59 @@
Ipv4InterfaceContainer i56 = ipv4.Assign (nd56);
Ipv4InterfaceContainer i57 = ipv4.Assign (nd57);
-
+
+
+
+ CcnxStackHelper ccnx(Ccnx::NDN_FLOODING/*Ccnx::NDN_BESTROUTE*/);
+ Ptr<CcnxFaceContainer> cf = ccnx.Install (c);
+
+ NS_LOG_INFO ("Installing Applications");
+ CcnxConsumerHelper helper ("/3");
+ ApplicationContainer app = helper.Install (c.Get(1));
+ app.Start (Seconds (1.0));
+ app.Stop (Seconds (1000.05));
+
+ /*CcnxConsumerHelper helper2 ("/4");
+ ApplicationContainer app2 = helper2.Install(c.Get(5));
+ app2.Start (Seconds (1.0));
+ app2.Stop (Seconds (1000.05));
+ */
+ CcnxProducerHelper helper3 ("/3",120);
+ ApplicationContainer app3 = helper3.Install(c.Get(6));
+ app3.Start(Seconds(0.0));
+ app3.Stop(Seconds(1500.0));
+ /*
+ CcnxProducerHelper helper4 ("/4",150);
+ ApplicationContainer app4 = helper4.Install(c.Get(0));
+ app4.Start(Seconds(0.0));
+ app4.Stop(Seconds(1500.0));
+ */
+
+ ccnx.AddRoute("1","/3",0,1);
+ ccnx.AddRoute("3","/3",2,1);
+ ccnx.AddRoute("3","/3",3,1);
+ ccnx.AddRoute("4","/3",1,1);
+ ccnx.AddRoute("5","/3",2,1);
+
+ /*ccnx.AddRoute ("1", "/3", 0, 1);
+ ccnx.AddRoute ("1", "/3", 1, 1);
+
+ ccnx.AddRoute ("2", "/3", 1, 1);
+
+ ccnx.AddRoute ("3", "/3", 1, 1);
+
+ ccnx.AddRoute ("4", "/3", 2, 1);
+
+ ccnx.AddRoute ("6", "/3", 2, 1);
+
+ ccnx.AddRoute ("7", "/3", 1, 1);
+
+ ccnx.AddRoute ("8", "/3", 1, 1);
+ */
+
// Create the OnOff application to send UDP datagrams of size
// 210 bytes at a rate of 448 Kb/s from n0 to n4
- NS_LOG_INFO ("Create Applications.");
+ /*NS_LOG_INFO ("Create Applications.");
uint16_t port = 9; // Discard port (RFC 863)
std::string sendsizeattr = "SendSize";
@@ -125,9 +215,9 @@
AsciiTraceHelper ascii;
p2p.EnableAsciiAll (ascii.CreateFileStream ("sync-topology-ndnabstraction.tr"));
- p2p.EnablePcapAll ("sync-topology-ndnabstraction");
+ p2p.EnablePcapAll ("sync-topology-ndnabstraction");*/
- Simulator::Stop (Seconds (20));
+ Simulator::Stop (Seconds (2000));
NS_LOG_INFO ("Run Simulation.");
Simulator::Run ();
diff --git a/helper/ccnx-stack-helper.cc b/helper/ccnx-stack-helper.cc
index 33951c5..e045dcd 100644
--- a/helper/ccnx-stack-helper.cc
+++ b/helper/ccnx-stack-helper.cc
@@ -201,12 +201,13 @@
node->AggregateObject (ccnx);
Ptr<CcnxPit> pit = ccnx->GetPit();
- NS_LOG_INFO("NODE #"<<node->GetNDevices());
+ NS_LOG_INFO("NODE->GetNDevices()="<<node->GetNDevices());
+
for (uint32_t index=0; index < node->GetNDevices (); index++)
{
- Ptr<PointToPointNetDevice> device = DynamicCast<PointToPointNetDevice>(node->GetDevice(index));
- if(device == 0)
- continue;
+ Ptr<PointToPointNetDevice> device = DynamicCast<PointToPointNetDevice>(node->GetDevice(index));
+ if(device == 0)
+ continue;
Ptr<CcnxNetDeviceFace> face = Create<CcnxNetDeviceFace> (node->GetDevice (index));
face->SetNode (node);
@@ -261,7 +262,7 @@
Ptr<Node> node = Names::Find<Node> (nodeName);
NS_ASSERT_MSG (node != 0, "Node [" << nodeName << "] does not exist");
-
+
Ptr<Ccnx> ccnx = node->GetObject<Ccnx> ();
NS_ASSERT_MSG (ccnx != 0, "Ccnx stack should be installed on the node");
@@ -288,7 +289,7 @@
fib->Add (prefixValue.Get (), face, metric);
}
*/
-
+
static void
CcnxL3ProtocolRxTxSink (Ptr<const Packet> p, Ptr<Ccnx> ccnx, uint32_t face)
{
diff --git a/model/ccnx-fib.cc b/model/ccnx-fib.cc
index 164b46b..f8c5956 100644
--- a/model/ccnx-fib.cc
+++ b/model/ccnx-fib.cc
@@ -27,6 +27,7 @@
#include "ns3/node.h"
#include "ns3/assert.h"
#include "ns3/names.h"
+#include "ns3/log.h"
#define NDN_RTO_ALPHA 0.125
#define NDN_RTO_BETA 0.25
@@ -95,7 +96,8 @@
}
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
-
+NS_LOG_COMPONENT_DEFINE ("CcnxFib");
+
using namespace __ccnx_private;
TypeId
@@ -147,16 +149,18 @@
void
CcnxFibEntry::AddOrUpdateRoutingMetric::operator () (CcnxFibEntry &entry)
{
+ NS_LOG_FUNCTION(this);
+ NS_ASSERT_MSG (m_face != NULL, "Trying to Add or Update NULL face");
+
CcnxFibFaceMetricByFace::type::iterator record = entry.m_faces.get<i_face> ().find (m_face);
if (record == entry.m_faces.get<i_face> ().end ())
{
entry.m_faces.insert (CcnxFibFaceMetric (m_face, m_metric));
}
else
- {
+ {
entry.m_faces.modify (record, ChangeMetric (m_metric));
}
-
// reordering random access index same way as by metric index
entry.m_faces.get<i_nth> ().rearrange (entry.m_faces.get<i_metric> ().begin ());
}
@@ -221,14 +225,17 @@
CcnxFib::Add (const CcnxNameComponents &prefix, Ptr<CcnxFace> face, int32_t metric)
{
// CcnxFibFaceMetric
+ NS_LOG_FUNCTION(this << prefix << face << metric);
CcnxFibEntryContainer::type::iterator entry = find (prefix);
if (entry == end ())
{
entry = insert (end (), CcnxFibEntry (prefix));
// insert new
}
- modify (entry, CcnxFibEntry::AddOrUpdateRoutingMetric (face, metric));
+ NS_ASSERT_MSG (face != NULL, "Trying to modify NULL face");
+ modify (entry, CcnxFibEntry::AddOrUpdateRoutingMetric (face, metric));
+
return entry;
}
diff --git a/model/ccnx-l3-protocol.cc b/model/ccnx-l3-protocol.cc
index d045339..87217bc 100644
--- a/model/ccnx-l3-protocol.cc
+++ b/model/ccnx-l3-protocol.cc
@@ -586,34 +586,33 @@
header->SetNack(false);
header->SetCongested(false);
- NS_ASSERT_MSG (m_forwardingStrategy != 0, "Need a forwarding protocol object to process packets");
+ NS_ASSERT_MSG (m_forwardingStrategy != 0, "Need a forwarding protocol object to process packets");
- m_pit->modify (pitEntry, CcnxPitEntry::AddIncoming(incomingFace));
+ m_pit->modify (pitEntry, CcnxPitEntry::AddIncoming(incomingFace));
- bool propagated = m_forwardingStrategy->
- PropagateInterest (pitEntry, fibEntry,incomingFace, header, packet,
- MakeCallback (&CcnxL3Protocol::SendInterest, this)
- );
+ bool propagated = m_forwardingStrategy->
+ PropagateInterest (pitEntry, fibEntry,incomingFace, header, packet,
+ MakeCallback (&CcnxL3Protocol::SendInterest, this)
+ );
- // If interest wasn't propagated further (probably, a limit is reached),
- // prune and delete PIT entry if there are no outstanding interests.
- // Stop processing otherwise.
- if( (!propagated) && (pitEntry->m_outgoing.size() == 0))
- {
- BOOST_FOREACH (const CcnxPitEntryIncomingFace face, pitEntry->m_incoming)
- {
+ // If interest wasn't propagated further (probably, a limit is reached),
+ // prune and delete PIT entry if there are no outstanding interests.
+ // Stop processing otherwise.
+ if( (!propagated) && (pitEntry->m_outgoing.size() == 0))
+ {
+ BOOST_FOREACH (const CcnxPitEntryIncomingFace face, pitEntry->m_incoming)
+ {
+ header->SetNack(true);
+ header->SetCongested(true);
+ NS_LOG_INFO("Sending CONGESTION packet");
+ SendInterest (face.m_face, header, packet->Copy());
-
- header->SetNack(true);
- header->SetCongested(true);
- SendInterest (face.m_face, header, packet->Copy());
-
- m_droppedInterestsTrace (header, DROP_CONGESTION,
+ m_droppedInterestsTrace (header, DROP_CONGESTION,
m_node->GetObject<Ccnx> (), incomingFace);
- }
+ }
m_pit->erase (pitEntry);
- }
+ }
/*}
else
{
diff --git a/model/ccnx-pit.cc b/model/ccnx-pit.cc
index 7c3681b..8fd21e0 100644
--- a/model/ccnx-pit.cc
+++ b/model/ccnx-pit.cc
@@ -137,13 +137,13 @@
{
NS_LOG_INFO ("Face has " << m_bucketsPerFace[face->GetId()] << " packets with max allowance " << maxBucketsPerFace[face->GetId()]);
- /*if((face->IsLocal() == false)
+ if((face->IsLocal() == false)
&& (m_bucketsPerFace[face->GetId()]+1.0 >= maxBucketsPerFace[face->GetId()] ))
{
return false;
- }*/
+ }
- //m_bucketsPerFace[face->GetId()] = m_bucketsPerFace[face->GetId()] + 1.0;
+ m_bucketsPerFace[face->GetId()] = m_bucketsPerFace[face->GetId()] + 1.0;
NS_LOG_INFO(this->size());
NS_LOG_INFO("before modify");
diff --git a/wscript b/wscript
index 41944aa..94a4269 100644
--- a/wscript
+++ b/wscript
@@ -29,7 +29,7 @@
def build(bld):
module = bld.create_ns3_module ('NDNabstraction', ['core', 'network', 'point-to-point',
- 'topology-read','internet','applications'])
+ 'topology-read','internet','applications','visualizer'])
module.uselib = 'BOOST BOOST_IOSTREAMS'
tests = bld.create_ns3_module_test_library('NDNabstraction')
@@ -66,6 +66,12 @@
obj = bld.create_ns3_program('ccnx-grid', ['NDNabstraction', 'point-to-point-layout'])
obj.source = 'examples/ccnx-grid.cc'
+ obj = bld.create_ns3_program('syntactic-topology', ['NDNabstraction', 'point-to-point-layout'])
+ obj.source = 'examples/syntactic-topology-ndnabstraction.cc'
+
+ obj = bld.create_ns3_program('annotated-topology', ['NDNabstraction', 'point-to-point-layout'])
+ obj.source = 'examples/annotated-topology-read-example.cc'
+
# for path in ["examples"]:
# anode = bld.path.find_dir (path)
# if not anode or not anode.is_child_of(bld.srcnode):