Merge remote-tracking branch 'git.irl/ilya'
diff --git a/apps/ccnx-hijacker.cc b/apps/ccnx-hijacker.cc
new file mode 100644
index 0000000..c0d74d7
--- /dev/null
+++ b/apps/ccnx-hijacker.cc
@@ -0,0 +1,117 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2011 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: Ilya Moiseenko <iliamo@cs.ucla.edu>
+ * Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#include "ccnx-hijacker.h"
+#include "ns3/log.h"
+#include "ns3/ccnx-interest-header.h"
+#include "ns3/ccnx-content-object-header.h"
+#include "ns3/string.h"
+#include "ns3/uinteger.h"
+#include "ns3/packet.h"
+
+#include "../model/ccnx-local-face.h"
+#include "ns3/ccnx-fib.h"
+
+#include <boost/ref.hpp>
+
+NS_LOG_COMPONENT_DEFINE ("CcnxHijacker");
+
+namespace ns3
+{
+
+NS_OBJECT_ENSURE_REGISTERED (CcnxHijacker);
+
+TypeId
+CcnxHijacker::GetTypeId (void)
+{
+ static TypeId tid = TypeId ("ns3::CcnxHijacker")
+ .SetParent<CcnxApp> ()
+ .AddConstructor<CcnxHijacker> ()
+ .AddAttribute ("Prefix","Prefix, which hijacker wants to attack",
+ StringValue ("/"),
+ MakeCcnxNameComponentsAccessor (&CcnxHijacker::m_prefix),
+ MakeCcnxNameComponentsChecker ())
+ .AddAttribute ("PayloadSize", "Virtual payload size for Content packets",
+ UintegerValue (1024),
+ MakeUintegerAccessor(&CcnxHijacker::m_virtualPayloadSize),
+ MakeUintegerChecker<uint32_t>())
+
+ .AddTraceSource ("TransmittedContentObjects", "TransmittedContentObjects",
+ MakeTraceSourceAccessor (&CcnxHijacker::m_transmittedContentObjects))
+ ;
+
+ return tid;
+}
+
+CcnxHijacker::CcnxHijacker ()
+{
+ // NS_LOG_FUNCTION_NOARGS ();
+}
+
+// inherited from Application base class.
+void
+CcnxHijacker::StartApplication ()
+{
+ NS_LOG_FUNCTION_NOARGS ();
+ NS_ASSERT (GetNode ()->GetObject<CcnxFib> () != 0);
+
+ CcnxApp::StartApplication ();
+
+ GetNode ()->GetObject<CcnxFib> ()->Add (m_prefix, m_face, 0);
+}
+
+void
+CcnxHijacker::StopApplication ()
+{
+ NS_LOG_FUNCTION_NOARGS ();
+ NS_ASSERT (GetNode ()->GetObject<CcnxFib> () != 0);
+
+ CcnxApp::StopApplication ();
+}
+
+
+void
+CcnxHijacker::OnInterest (const Ptr<const CcnxInterestHeader> &interest)
+{
+ CcnxApp::OnInterest (interest); // tracing inside
+
+ NS_LOG_FUNCTION (this << interest);
+
+ /*
+ if (!m_active) return;
+
+ static CcnxContentObjectTail tail;
+ Ptr<CcnxContentObjectHeader> header = Create<CcnxContentObjectHeader> ();
+ header->SetName (Create<CcnxNameComponents> (interest->GetName ()));
+
+ NS_LOG_INFO ("Respodning with ContentObject:\n" << boost::cref(*header));
+
+ Ptr<Packet> packet = Create<Packet> (m_virtualPayloadSize);
+
+ m_transmittedContentObjects (header, packet, this, m_face);
+
+ packet->AddHeader (*header);
+ packet->AddTrailer (tail);
+
+ m_protocolHandler (packet);*/
+}
+
+} // namespace ns3
diff --git a/apps/ccnx-hijacker.h b/apps/ccnx-hijacker.h
new file mode 100644
index 0000000..20adf46
--- /dev/null
+++ b/apps/ccnx-hijacker.h
@@ -0,0 +1,62 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2011 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: Ilya Moiseenko <iliamo@cs.ucla.edu>
+ * Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#ifndef CCNX_HIJACKER_H
+#define CCNX_HIJACKER_H
+
+#include "ccnx-app.h"
+
+#include "ns3/ptr.h"
+#include "ns3/ccnx-name-components.h"
+
+namespace ns3
+{
+
+class CcnxHijacker : public CcnxApp
+{
+public:
+ static TypeId
+ GetTypeId (void);
+
+ CcnxHijacker ();
+
+ // inherited from CcnxApp
+ void OnInterest (const Ptr<const CcnxInterestHeader> &interest);
+
+protected:
+ // inherited from Application base class.
+ virtual void
+ StartApplication (); // Called at time specified by Start
+
+ virtual void
+ StopApplication (); // Called at time specified by Stop
+
+private:
+ CcnxNameComponents m_prefix;
+ uint32_t m_virtualPayloadSize;
+
+ TracedCallback<Ptr<const CcnxContentObjectHeader>, Ptr<const Packet>,
+ Ptr<CcnxApp>, Ptr<CcnxFace> > m_transmittedContentObjects;
+};
+
+}
+
+#endif // CCNX_HIJACKER_H
diff --git a/examples/blackhole-sprint.cc b/examples/blackhole-sprint.cc
index 8b13789..f97be29 100644
--- a/examples/blackhole-sprint.cc
+++ b/examples/blackhole-sprint.cc
@@ -1 +1,309 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2011 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: Ilya Moiseenko <iliamo@cs.ucla.edu>
+ */
+
+
+#include "ns3/core-module.h"
+#include "ns3/network-module.h"
+#include "ns3/point-to-point-module.h"
+#include "ns3/NDNabstraction-module.h"
+#include "ns3/point-to-point-grid.h"
+#include "ns3/ipv4-global-routing-helper.h"
+#include "ns3/random-variable.h"
+#include <iostream>
+#include <sstream>
+#include <map>
+#include <list>
+#include <set>
+#include "ns3/rocketfuel-topology-reader.h"
+
+#include <boost/lexical_cast.hpp>
+#include <boost/foreach.hpp>
+
+using namespace ns3;
+using namespace std;
+using namespace boost;
+
+NS_LOG_COMPONENT_DEFINE ("BlackholeSprint");
+
+void PrintTime ()
+{
+ cout << "Progress: " << Simulator::Now ().ToDouble (Time::S) << "s" << endl;
+
+ Simulator::Schedule (Seconds (1.0), PrintTime);
+}
+
+
+class Experiment
+{
+public:
+ Experiment ()
+ : m_reader ("/sprint") { }
+
+ void
+ ConfigureTopology ()
+ {
+ Names::Clear ();
+
+ string weights ("./src/NDNabstraction/examples/sprint-pops.weights");
+ string latencies ("./src/NDNabstraction/examples/sprint-pops.latencies");
+ string positions ("./src/NDNabstraction/examples/sprint-pops.positions");
+
+ m_reader.SetFileName (positions);
+ m_reader.SetFileType (RocketfuelWeightsReader::POSITIONS);
+ m_reader.Read ();
+
+ m_reader.SetFileName (weights);
+ m_reader.SetFileType (RocketfuelWeightsReader::WEIGHTS);
+ m_reader.Read ();
+
+ m_reader.SetFileName (latencies);
+ m_reader.SetFileType (RocketfuelWeightsReader::LATENCIES);
+ m_reader.Read ();
+
+ m_reader.Commit ();
+ NS_ASSERT_MSG (m_reader.LinksSize () != 0, "Problems reading the topology file. Failing.");
+
+ NS_LOG_INFO("Nodes = " << m_reader.GetNodes ().GetN());
+ NS_LOG_INFO("Links = " << m_reader.LinksSize ());
+
+ // ------------------------------------------------------------
+ // -- Read topology data.
+ // --------------------------------------------
+
+ InternetStackHelper stack;
+ Ipv4GlobalRoutingHelper ipv4RoutingHelper ("ns3::Ipv4GlobalRoutingOrderedNexthops");
+ stack.SetRoutingHelper (ipv4RoutingHelper);
+ stack.Install (m_reader.GetNodes ());
+
+ m_reader.AssignIpv4Addresses (Ipv4Address ("10.0.0.0"));
+
+ // Install CCNx stack
+ NS_LOG_INFO ("Installing CCNx stack");
+ CcnxStackHelper ccnxHelper;
+ ccnxHelper.SetForwardingStrategy ("ns3::CcnxBestRouteStrategy");
+ ccnxHelper.EnableLimits (true, Seconds(0.1));
+ ccnxHelper.SetDefaultRoutes (false);
+ ccnxHelper.InstallAll ();
+
+ m_rand = UniformVariable (0, m_reader.GetNodes ().GetN());
+ m_linkRand = UniformVariable(0, m_reader.LinksSize());
+ }
+
+ void
+ ConfigureRouting ()
+ {
+ CcnxStackHelper ccnxHelper;
+ // // Populate FIB based on IPv4 global routing controller
+ ccnxHelper.InstallFakeGlobalRoutes ();
+ ccnxHelper.InstallRoutesToAll ();
+ }
+
+public:
+ void
+ Run (const Time &finishTime)
+ {
+ cout << "Run Simulation.\n";
+ Simulator::Stop (finishTime);
+ //Simulator::Schedule (Seconds (1.0), PrintTime);
+ Simulator::Run ();
+ Simulator::Destroy ();
+ cout << "Done.\n";
+ }
+
+ //We are creating 10 pairs of producer-hijacker and everybody else is a consumer
+ ApplicationContainer
+ AddApplications(uint32_t numOfPairs)
+ {
+ NS_LOG_INFO("Adding applications");
+ ApplicationContainer apps;
+
+ list<uint32_t > usedNodes;
+ list<uint32_t >::iterator listIterator;
+ list<uint32_t >::iterator listIterator2;
+
+ uint32_t producerNodeId;
+ uint32_t hijackerNodeId;
+
+ for(uint32_t pairCount = 0; pairCount < numOfPairs; pairCount++)
+ {
+ NS_LOG_INFO("pairCount = "<<pairCount);
+ while(true)
+ {
+ producerNodeId = m_rand.GetValue ();
+ hijackerNodeId = m_rand.GetValue ();
+
+ bool unique = true;
+ for(listIterator=usedNodes.begin(); listIterator != usedNodes.end(); ++listIterator)
+ {
+ if((*listIterator == producerNodeId) || (*listIterator == hijackerNodeId))
+ {
+ NS_LOG_INFO("NonUnique");
+ unique = false;
+ }
+ }
+
+ if(unique == true)
+ {
+ usedNodes.push_back(producerNodeId);
+ usedNodes.push_back(hijackerNodeId);
+ break;
+ }
+ }
+
+ NS_LOG_INFO("Producer #" << producerNodeId);
+ Ptr<Node> node1 = Names::Find<Node> ("/sprint", lexical_cast<string> (producerNodeId));
+ CcnxAppHelper producerHelper ("ns3::CcnxProducer");
+ producerHelper.SetPrefix ("/" + lexical_cast<string> (node1->GetId ()));
+
+ apps.Add(producerHelper.Install (node1));
+
+ NS_LOG_INFO("Hijacker # "<<hijackerNodeId);
+ Ptr<Node> node2 = Names::Find<Node> ("/sprint", lexical_cast<string> (hijackerNodeId));
+ CcnxAppHelper hijackerHelper ("ns3::CcnxHijacker");
+ hijackerHelper.SetPrefix ("/" + lexical_cast<string> (node1->GetId ()));
+
+ apps.Add(hijackerHelper.Install (node1));
+
+ /*NS_LOG_INFO("Consumers");
+ for(uint32_t j = 0; j<m_reader.GetNodes().GetN();j++)
+ {
+ //NS_LOG_INFO("j="<<j);
+ bool consumer = true;
+ for(listIterator=usedNodes.begin(); listIterator != usedNodes.end(); ++listIterator)
+ {
+ if(*listIterator == j)
+ {
+ consumer = false;
+ NS_LOG_INFO(j<<" CANNOT be CONSUMER");
+ break;
+ }
+ }
+
+ if(consumer == true)
+ {
+ Ptr<Node> node3 = Names::Find<Node> ("/sprint", lexical_cast<string> (j));
+
+ CcnxAppHelper consumerHelper ("ns3::CcnxConsumer");
+ consumerHelper.SetPrefix ("/" + lexical_cast<string> (node1->GetId ()));
+ consumerHelper.SetAttribute ("MeanRate", StringValue ("1Kbps"));
+ consumerHelper.SetAttribute ("Size", StringValue ("2"));
+
+ apps.Add(consumerHelper.Install (node3));
+ }
+ }*/
+ }
+
+ NS_LOG_INFO("Consumers");
+ for(listIterator=usedNodes.begin(); listIterator != usedNodes.end(); ++listIterator,++listIterator)
+ {
+ for(uint32_t j = 0; j<m_reader.GetNodes().GetN();j++)
+ {
+ //NS_LOG_INFO("j="<<j);
+ bool consumer = true;
+ for(listIterator2=usedNodes.begin(); listIterator2 != usedNodes.end(); ++listIterator2)
+ {
+ if(*listIterator2 == j)
+ {
+ consumer = false;
+ NS_LOG_INFO(j<<" CANNOT be a CONSUMER");
+ break;
+ }
+ }
+
+ if(consumer == true)
+ {
+ Ptr<Node> node3 = Names::Find<Node> ("/sprint", lexical_cast<string> (j));
+ Ptr<Node> node4 = Names::Find<Node> ("/sprint", lexical_cast<string> (*listIterator));
+
+ CcnxAppHelper consumerHelper ("ns3::CcnxConsumer");
+ NS_LOG_INFO("Node = " << *listIterator);
+ consumerHelper.SetPrefix ("/" + lexical_cast<string> (node4->GetId ()));
+ consumerHelper.SetAttribute ("MeanRate", StringValue ("1Kbps"));
+ consumerHelper.SetAttribute ("Size", StringValue ("2"));
+
+ apps.Add(consumerHelper.Install (node3));
+ }
+ }
+ }
+
+
+ return apps;
+ }
+
+ UniformVariable m_rand;
+ UniformVariable m_linkRand;
+
+private:
+ RocketfuelWeightsReader m_reader;
+};
+
+int
+main (int argc, char *argv[])
+{
+ cout << "Begin blackhole scenario\n";
+
+ Config::SetDefault ("ns3::PointToPointNetDevice::DataRate", StringValue ("2Mbps"));
+ Config::SetDefault ("ns3::DropTailQueue::MaxPackets", StringValue ("100"));
+
+ Time finishTime = Seconds (20.0);
+
+
+ CommandLine cmd;
+ cmd.AddValue ("finish", "Finish time", finishTime);
+ cmd.Parse (argc, argv);
+
+ Experiment experiment;
+
+ for (uint32_t i = 0; i < 80; i++)
+ {
+ Config::SetGlobal ("RngRun", IntegerValue (i));
+ cout << "seed = " << SeedManager::GetSeed () << ", run = " << SeedManager::GetRun () << endl;
+
+ Experiment experiment;
+ cout << "Run " << i << endl;
+
+ string prefix = "run-" + lexical_cast<string> (i) + "-";
+
+ experiment.ConfigureTopology ();
+ ApplicationContainer apps = experiment.AddApplications (10);
+ experiment.ConfigureRouting ();
+
+ /*ApplicationContainer apps = experiment.AddApplications ();
+
+ for (uint32_t i = 0; i < apps.GetN () / 2; i++)
+ {
+ cout << "From " << apps.Get (i*2)->GetNode ()->GetId ()
+ << " to " << apps.Get (i*2 + 1)->GetNode ()->GetId ();
+ cout << "\n";
+ }
+ */
+
+ //tracing
+ CcnxTraceHelper traceHelper;
+ traceHelper.EnableRateL3All (prefix + "rate-trace.log");
+ traceHelper.EnableSeqsAppAll ("ns3::CcnxConsumer", prefix + "consumers-seqs.log");
+
+ experiment.Run (finishTime);
+ }
+
+ cout << "Finish blackhole scenario\n";
+ return 0;
+}
diff --git a/examples/link-failure-abilene.cc b/examples/link-failure-abilene.cc
deleted file mode 100644
index f118b04..0000000
--- a/examples/link-failure-abilene.cc
+++ /dev/null
@@ -1,171 +0,0 @@
-/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2011 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: Ilya Moiseenko <iliamo@cs.ucla.edu>
- */
-
-
-
-#include "ns3/core-module.h"
-#include "ns3/network-module.h"
-#include "ns3/point-to-point-module.h"
-#include "ns3/NDNabstraction-module.h"
-#include "ns3/point-to-point-grid.h"
-#include "ns3/ipv4-global-routing-helper.h"
-#include "ns3/animation-interface.h"
-// #include "ns3/ccnx-l3-protocol.h"
-
-#include <iostream>
-#include <sstream>
-#include "ns3/annotated-topology-reader.h"
-#include "../utils/spring-mobility-helper.h"
-
-#include "ns3/config-store.h"
-
-using namespace ns3;
-using namespace std;
-
-NS_LOG_COMPONENT_DEFINE ("CcnxLinkFailureAbilene");
-
-
-int
-main (int argc, char *argv[])
-{
- // Packet::EnableChecking();
- // Packet::EnablePrinting();
- string input ("./src/NDNabstraction/examples/abilene-topology.txt");
-
- Time finishTime = Seconds (20.0);
- string animationFile;
- string strategy = "ns3::CcnxFloodingStrategy";
- CommandLine cmd;
- cmd.AddValue ("finish", "Finish time", finishTime);
- cmd.AddValue ("netanim", "NetAnim filename", animationFile);
- cmd.AddValue ("strategy", "CCNx forwarding strategy", strategy);
- cmd.Parse (argc, argv);
-
- ConfigStore config;
- config.ConfigureDefaults ();
-
- // ------------------------------------------------------------
- // -- Read topology data.
- // --------------------------------------------
-
- AnnotatedTopologyReader reader ("/abilene");
- reader.SetMobilityModel ("ns3::SpringMobilityModel");
- reader.SetFileName (input);
-
- NodeContainer nodes = reader.Read ();
-
- if (reader.LinksSize () == 0)
- {
- NS_LOG_ERROR ("Problems reading the topology file. Failing.");
- return -1;
- }
-
- SpringMobilityHelper::InstallSprings (reader.LinksBegin (), reader.LinksEnd ());
-
- // InternetStackHelper stack;
- Ipv4GlobalRoutingHelper ipv4RoutingHelper ("ns3::Ipv4GlobalRoutingOrderedNexthops");
- stack.SetRoutingHelper (ipv4RoutingHelper);
- stack.Install (nodes);
-
- // reader.AssignIpv4Addresses (Ipv4Address ("10.0.0.0"));
-
- NS_LOG_INFO("Nodes = " << nodes.GetN());
- NS_LOG_INFO("Links = " << reader.LinksSize ());
-
- // Install CCNx stack
- NS_LOG_INFO ("Installing CCNx stack");
- CcnxStackHelper ccnxHelper;
- ccnxHelper.SetForwardingStrategy (strategy);
- ccnxHelper.EnableLimits (false, Seconds(0.1));
- ccnxHelper.SetDefaultRoutes (true);
- ccnxHelper.InstallAll ();
-
- NS_LOG_INFO ("Installing Applications");
- CcnxConsumerHelper consumerHelper ("/5");
- ApplicationContainer consumers = consumerHelper.Install (Names::Find<Node> ("/abilene", "ATLAng"));
-
- // CcnxProducerHelper producerHelper ("/5",1024);
- // ApplicationContainer producers = producerHelper.Install (Names::Find<Node> ("/abilene", "IPLSng"));
-
- // // Populate FIB based on IPv4 global routing controller
- // ccnxHelper.InstallFakeGlobalRoutes ();
- // ccnxHelper.InstallRouteTo (Names::Find<Node> ("/abilene", "IPLSng"));
-
- // Simulator::Schedule (Seconds (1.0), PrintFIBs);
- // PrintFIBs ();
-
- // Simulator::Schedule (Seconds (10.0), PrintTime);
-
- Simulator::Stop (finishTime);
-
- AnimationInterface *anim = 0;
- if (animationFile != "")
- {
- anim = new AnimationInterface (animationFile);
- anim->SetMobilityPollInterval (Seconds (1));
- }
-
- // NS_LOG_INFO ("Configure Tracing.");
- /*AggregateTrace trace;
- Config::Connect ("/NodeList/*/ApplicationList/*/$ns3::CcnxConsumer/TransmittedInterests",
- MakeCallback (&AggregateTrace::TransmittedInterests, &trace));
-
- Config::Connect ("/NodeList/*/ApplicationList/*/$ns3::CcnxConsumer/ReceivedNacks",
- MakeCallback (&AggregateTrace::ReceivedNacks, &trace));
-
- Config::Connect ("/NodeList/*/ApplicationList/*/$ns3::CcnxProducer/ReceivedInterests",
- MakeCallback (&AggregateTrace::ReceivedInterests, &trace));
-
- Config::Connect ("/NodeList/*/ApplicationList/*/$ns3::CcnxProducer/TransmittedContentObjects",
- MakeCallback (&AggregateTrace::TransmittedData, &trace));
-
- Config::Connect ("/NodeList/*/ApplicationList/*/$ns3::CcnxConsumer/ReceivedContentObjects",
- MakeCallback (&AggregateTrace::ReceivedData, &trace));
- */
- // Config::Connect("/NodeList/*/ns3::CcnxL3Protocol/TransmittedInterestTrace",
- // MakeCallback (&OnTransmittedInterest));
- // Config::Connect ("/NodeList/*/ns3::CcnxL3Protocol/ReceivedInterestTrace",
- // MakeCallback (&OnReceivedInterest));
- // Config::Connect ("/NodeList/*/ns3::CcnxL3Protocol/DroppedInterestTrace",
- // MakeCallback (&OnDroppedInterest));
-
- // Config::Connect ("/NodeList/*/ns3::CcnxL3Protocol/ReceivedDataTrace",
- // MakeCallback (&OnReceivedData));
- // Config::Connect ("/NodeList/*/ns3::CcnxL3Protocol/TransmittedDataTrace",
- // MakeCallback (&OnTransmittedData));
- // Config::Connect ("/NodeList/*/ns3::CcnxL3Protocol/DroppedDataTrace",
- // MakeCallback (&OnDroppedData));
-
- config.ConfigureAttributes ();
-
- NS_LOG_INFO ("Run Simulation.");
- Simulator::Run ();
- Simulator::Destroy ();
- NS_LOG_INFO ("Done.");
-
- // NS_LOG_INFO("Total received interests = " << receivedInterests);
- // NS_LOG_INFO("Total transmitted interests = " << transmittedInterests);
- // NS_LOG_INFO("Total dropped interests = " << droppedInterests);
- // NS_LOG_INFO("Total received data = " << receivedData);
- // NS_LOG_INFO("Total transmitted data = " << transmittedData);
- // NS_LOG_INFO("Total dropped data = " << droppedData);
- NS_LOG_INFO (trace);
- return 0;
-}
diff --git a/examples/link-failure-sprint.cc b/examples/link-failure-sprint.cc
index dfbbf04..421f134 100644
--- a/examples/link-failure-sprint.cc
+++ b/examples/link-failure-sprint.cc
@@ -26,6 +26,8 @@
#include "ns3/point-to-point-grid.h"
#include "ns3/ipv4-global-routing-helper.h"
#include "ns3/random-variable.h"
+#include "ns3/ccnx-l3-protocol.h"
+#include "ns3/topology-reader.h"
#include <iostream>
#include <sstream>
@@ -54,35 +56,37 @@
class Experiment
{
public:
+ Experiment ()
+ : m_reader ("/sprint") { }
+
void
ConfigureTopology ()
{
+ Names::Clear ();
+
string weights ("./src/NDNabstraction/examples/sprint-pops.weights");
string latencies ("./src/NDNabstraction/examples/sprint-pops.latencies");
string positions ("./src/NDNabstraction/examples/sprint-pops.positions");
- string strategy ("ns3::CcnxBestRouteStrategy");
- // string strategy ("ns3::CcnxFloodingStrategy");
- RocketfuelWeightsReader reader ("/sprint");
- m_reader = reader;
-
- reader.SetFileName (positions);
- reader.SetFileType (RocketfuelWeightsReader::POSITIONS);
- reader.Read ();
-
- reader.SetFileName (weights);
- reader.SetFileType (RocketfuelWeightsReader::WEIGHTS);
- reader.Read ();
+ //RocketfuelWeightsReader reader ("/sprint");
- reader.SetFileName (latencies);
- reader.SetFileType (RocketfuelWeightsReader::LATENCIES);
- reader.Read ();
+ m_reader.SetFileName (positions);
+ m_reader.SetFileType (RocketfuelWeightsReader::POSITIONS);
+ m_reader.Read ();
+
+ m_reader.SetFileName (weights);
+ m_reader.SetFileType (RocketfuelWeightsReader::WEIGHTS);
+ m_reader.Read ();
+
+ m_reader.SetFileName (latencies);
+ m_reader.SetFileType (RocketfuelWeightsReader::LATENCIES);
+ m_reader.Read ();
- reader.Commit ();
- NS_ASSERT_MSG (reader.LinksSize () != 0, "Problems reading the topology file. Failing.");
+ m_reader.Commit ();
+ NS_ASSERT_MSG (m_reader.LinksSize () != 0, "Problems reading the topology file. Failing.");
- NS_LOG_INFO("Nodes = " << reader.GetNodes ().GetN());
- NS_LOG_INFO("Links = " << reader.LinksSize ());
+ NS_LOG_INFO("Nodes = " << m_reader.GetNodes ().GetN());
+ NS_LOG_INFO("Links = " << m_reader.LinksSize ());
// ------------------------------------------------------------
// -- Read topology data.
@@ -91,23 +95,29 @@
InternetStackHelper stack;
Ipv4GlobalRoutingHelper ipv4RoutingHelper ("ns3::Ipv4GlobalRoutingOrderedNexthops");
stack.SetRoutingHelper (ipv4RoutingHelper);
- stack.Install (reader.GetNodes ());
+ stack.Install (m_reader.GetNodes ());
- reader.AssignIpv4Addresses (Ipv4Address ("10.0.0.0"));
-
+ m_reader.AssignIpv4Addresses (Ipv4Address ("10.0.0.0"));
+
// Install CCNx stack
NS_LOG_INFO ("Installing CCNx stack");
CcnxStackHelper ccnxHelper;
- ccnxHelper.SetForwardingStrategy (strategy);
+ ccnxHelper.SetForwardingStrategy ("ns3::CcnxBestRouteStrategy");
ccnxHelper.EnableLimits (true, Seconds(0.1));
ccnxHelper.SetDefaultRoutes (false);
ccnxHelper.InstallAll ();
+
+ m_rand = UniformVariable (0, m_reader.GetNodes ().GetN());
+ //m_linkRand = UniformVariable(0, m_reader.LinksSize());
+ }
+ void
+ ConfigureRouting ()
+ {
+ CcnxStackHelper ccnxHelper;
// // Populate FIB based on IPv4 global routing controller
ccnxHelper.InstallFakeGlobalRoutes ();
ccnxHelper.InstallRoutesToAll ();
-
- m_rand = UniformVariable (0, reader.GetNodes ().GetN());
}
public:
@@ -122,131 +132,164 @@
cout << "Done.\n";
}
+ void
+ FailLinks(double threshold)
+ {
+ NS_LOG_INFO("Failing links");
+ m_linkRand = UniformVariable(0, 1.0);
+ double probability = 0.0;
+
+ BOOST_FOREACH (const TopologyReader::Link &link, m_reader.GetLinks())
+ {
+ probability = m_linkRand.GetValue();
+ NS_LOG_INFO ("Probability = " << probability);
+
+ if(probability <= threshold)
+ {
+ Ptr<Node> fromNode = link.GetFromNode ();
+ Ptr<Node> toNode = link.GetToNode ();
+ NS_LOG_INFO("From node id = " << fromNode->GetId());
+ NS_LOG_INFO("To node id = " << toNode->GetId());
+
+ Ptr<CcnxL3Protocol> fromCcnx = fromNode->GetObject<CcnxL3Protocol> ();
+ Ptr<CcnxL3Protocol> toCcnx = toNode->GetObject<CcnxL3Protocol> ();
+
+ Ptr<NetDevice> fromDevice = link.GetFromNetDevice ();
+ Ptr<NetDevice> toDevice = link.GetToNetDevice ();
+
+ Ptr<CcnxFace> fromFace = fromCcnx->GetFaceByNetDevice (fromDevice);
+ Ptr<CcnxFace> toFace = toCcnx->GetFaceByNetDevice (toDevice);
+
+ NS_LOG_INFO("From face id = " << fromFace->GetId());
+ NS_LOG_INFO("To face id = " << toFace->GetId());
+ fromFace->SetUp (false);
+ toFace->SetUp (false);
+
+ NS_LOG_INFO(fromFace->IsUp());
+ NS_LOG_INFO(toFace->IsUp());
+ }
+
+ }
+ /*
+ uint32_t nodeId = m_rand.GetValue ();
+ Ptr<Node> node = Names::Find<Node> ("/sprint", lexical_cast<string> (nodeId));
+
+ Ptr<CcnxL3Protocol> ccnx = node->GetObject<CcnxL3Protocol> ();
+ UniformVariable faceRandom = UniformVariable (0, ccnx->GetNFaces ());
+ uint32_t faceId = faceRandom.GetValue();
+ Ptr<CcnxFace> face = ccnx->GetFace (faceId);
+ face->SetUp(false);
+ */
+ }
+
//We are creating "everybody-to-everybody" usage pattern
ApplicationContainer
AddApplications()
{
+ NS_LOG_INFO("Adding applications");
+ NS_LOG_INFO("GetN = " << m_reader.GetNodes().GetN());
+
ApplicationContainer apps;
- for(int i =0; i<reader.GetNodes().GetN(); i++;)
+ for(uint32_t i = 0; i<m_reader.GetNodes().GetN(); i++)
{
- Ptr<Node> node1 = Names::Find<Node> ("/sprint", lexical_cast<string> (node1_num));
+ NS_LOG_INFO("i="<<i);
+ Ptr<Node> node1 = Names::Find<Node> ("/sprint", lexical_cast<string> (i));
+
CcnxAppHelper producerHelper ("ns3::CcnxProducer");
- producerHelper.SetPrefix ("/" + lexical_cast<string> (i));
+ producerHelper.SetPrefix ("/" + lexical_cast<string> (node1->GetId ()));
apps.Add(producerHelper.Install (node1));
-
- for(int j = 0; j<reader.GetNodes().GetN();j++)
+
+ for(uint32_t j = 0; j<m_reader.GetNodes().GetN();j++)
{
+ NS_LOG_INFO("j="<<j);
if(i==j)
continue;
- Ptr<Node> node2 = Names::Find<Node> ("/sprint", lexical_cast<string> (node2_num));
-
+ Ptr<Node> node2 = Names::Find<Node> ("/sprint", lexical_cast<string> (j));
+
CcnxAppHelper consumerHelper ("ns3::CcnxConsumer");
- consumerHelper.SetPrefix ("/" + lexical_cast<string> (i));
- consumerHelper.SetAttribute ("MeanRate", StringValue ("2Mbps"));
+ consumerHelper.SetPrefix ("/" + lexical_cast<string> (node1->GetId ()));
+ consumerHelper.SetAttribute ("MeanRate", StringValue ("1Kbps"));
consumerHelper.SetAttribute ("Size", StringValue ("2"));
apps.Add(consumerHelper.Install (node2));
}
}
- return apps;
- }
-
- ApplicationContainer
- AddRandomApplications (uint16_t numStreams)
- {
- map<uint32_t, set<uint32_t> > streams;
- ApplicationContainer apps;
- uint16_t createdStreams = 0;
- uint16_t guard = 0;
- while (createdStreams < numStreams && guard < (numeric_limits<uint16_t>::max ()-1))
- {
- guard ++;
-
- uint32_t node1_num = m_rand.GetValue ();
- uint32_t node2_num = m_rand.GetValue ();
-
- if (node1_num == node2_num)
- continue;
-
- if (streams[node1_num].count (node2_num) > 0) // don't create duplicate streams
- continue;
-
- streams[node1_num].insert (node2_num);
-
- Ptr<Node> node1 = Names::Find<Node> ("/sprint", lexical_cast<string> (node1_num));
- Ptr<Node> node2 = Names::Find<Node> ("/sprint", lexical_cast<string> (node2_num));
-
- CcnxAppHelper consumerHelper ("ns3::CcnxConsumer");
- consumerHelper.SetPrefix ("/" + lexical_cast<string> (node2->GetId ()));
- consumerHelper.SetAttribute ("MeanRate", StringValue ("2Mbps"));
- consumerHelper.SetAttribute ("Size", StringValue ("2"));
-
- CcnxAppHelper producerHelper ("ns3::CcnxProducer");
- producerHelper.SetPrefix ("/" + lexical_cast<string> (node2->GetId ()));
-
- apps.Add
- (consumerHelper.Install (node1));
-
- apps.Add
- (producerHelper.Install (node2));
-
- createdStreams ++;
- }
-
return apps;
}
-
UniformVariable m_rand;
-
-private:
+ UniformVariable m_linkRand;
RocketfuelWeightsReader m_reader;
};
int
main (int argc, char *argv[])
{
- cout << "Begin congestion-pop scenario\n";
+ cout << "Begin link failure scenario\n";
- Config::SetDefault ("ns3::PointToPointNetDevice::DataRate", StringValue ("1Mbps"));
- Config::SetDefault ("ns3::DropTailQueue::MaxPackets", StringValue ("20"));
+ Config::SetDefault ("ns3::PointToPointNetDevice::DataRate", StringValue ("10Mbps"));
+ Config::SetDefault ("ns3::DropTailQueue::MaxPackets", StringValue ("100"));
- Time finishTime = Seconds (20.0);
+ Time finishTime1 = Seconds (5.0);
+ Time finishTime2 = Seconds (20.0);
CommandLine cmd;
- cmd.AddValue ("finish", "Finish time", finishTime);
+ cmd.AddValue ("finish", "Finish time", finishTime1);
cmd.Parse (argc, argv);
Experiment experiment;
- for (uint32_t i = 0; i < 100; i++)
+ for (uint32_t i = 0; i < 80; i++)
{
+ Config::SetGlobal ("RngRun", IntegerValue (i));
+ cout << "seed = " << SeedManager::GetSeed () << ", run = " << SeedManager::GetRun () << endl;
+
+ Experiment experiment;
+ cout << "Run " << i << endl;
+
+ string prefix = "run-" + lexical_cast<string> (i) + "-";
+ //before link failure
experiment.ConfigureTopology ();
ApplicationContainer apps = experiment.AddApplications ();
+ experiment.ConfigureRouting ();
+ //tracing
+ //...
+ //experiment.Run (finishTime1);
+
+ //after link failure
+ experiment.FailLinks(0.1);
+
+ //tracing
+ CcnxTraceHelper traceHelper;
+ traceHelper.EnableRateL3All (prefix + "rate-trace.log");
+ traceHelper.EnableSeqsAppAll ("ns3::CcnxConsumer", prefix + "consumers-seqs.log");
+ //...
+ experiment.Run (finishTime2);
+/*
for (uint32_t i = 0; i < apps.GetN () / 2; i++)
{
cout << "From " << apps.Get (i*2)->GetNode ()->GetId ()
<< " to " << apps.Get (i*2 + 1)->GetNode ()->GetId ();
cout << "\n";
- }
+ }*/
- CcnxTraceHelper traceHelper;
+ //CcnxTraceHelper traceHelper;
// traceHelper.EnableAggregateAppAll ("ns3::CcnxConsumer");
// traceHelper.EnableAggregateAppAll ("ns3::CcnxProducer");
// traceHelper.EnableAggregateL3All ();
// traceHelper.SetL3TraceFile ("trace-l3.log");
// traceHelper.SetAppTraceFile ("trace-app.log");
// traceHelper.EnableRateL3All ("rate-trace.log");
- traceHelper.EnableSeqsAppAll ("ns3::CcnxConsumer", "consumers-seqs.log");
+ //traceHelper.EnableSeqsAppAll ("ns3::CcnxConsumer", "consumers-seqs.log");
- experiment.Run (finishTime);
+
}
- cout << "Finish congestion-pop scenario\n";
+ cout << "Finish link failure scenario\n";
return 0;
}
diff --git a/model/annotated-topology-reader.cc b/model/annotated-topology-reader.cc
index 194a90c..db8392d 100644
--- a/model/annotated-topology-reader.cc
+++ b/model/annotated-topology-reader.cc
@@ -112,6 +112,11 @@
return m_nodes;
}
+std::list<TopologyReader::Link>
+AnnotatedTopologyReader::GetLinks () const
+{
+ return m_linksList;
+}
NodeContainer
AnnotatedTopologyReader::Read (void)
diff --git a/model/annotated-topology-reader.h b/model/annotated-topology-reader.h
index b9268b8..eccbc29 100644
--- a/model/annotated-topology-reader.h
+++ b/model/annotated-topology-reader.h
@@ -63,6 +63,12 @@
GetNodes () const;
/**
+ * \brief Get links read by the reader
+ */
+ std::list<Link>
+ GetLinks () const;
+
+ /**
* \brief Assign IPv4 addresses to all links
*
* Note, IPv4 stack should be installed on all nodes prior this call
diff --git a/model/ccnx-pit.cc b/model/ccnx-pit.cc
index d9667cf..ca2c3f3 100644
--- a/model/ccnx-pit.cc
+++ b/model/ccnx-pit.cc
@@ -170,7 +170,7 @@
{
CcnxFibEntryContainer::type::iterator fibEntry = m_fib->LongestPrefixMatch (header);
NS_ASSERT_MSG (fibEntry != m_fib->m_fib.end (),
- "There should be at least default route set");
+ "There should be at least default route set" << " Prefix = "<<header.GetName() << "NodeID == " << m_fib->GetObject<Node>()->GetId() << "\n" << *m_fib);
entry = insert (end (),
CcnxPitEntry (Create<CcnxNameComponents> (header.GetName ()),
diff --git a/wscript b/wscript
index bbdda36..e33af19 100644
--- a/wscript
+++ b/wscript
@@ -109,7 +109,7 @@
#obj = bld.create_ns3_program('link-failure-sprint', ['NDNabstraction'])
#obj.source = 'examples/link-failure-sprint.cc'
- #obj = bld.create_ns3_program('blackhole-sprint', ['NDNabstraction'])
- #obj.source = 'examples/blackhole-sprint.cc'
+ obj = bld.create_ns3_program('blackhole-sprint', ['NDNabstraction'])
+ obj.source = 'examples/blackhole-sprint.cc'
bld.ns3_python_bindings()