link failure and blackhole scenarios seem to work
diff --git a/examples/link-failure-abilene.cc b/examples/link-failure-abilene.cc
index f118b04..4a94585 100644
--- a/examples/link-failure-abilene.cc
+++ b/examples/link-failure-abilene.cc
@@ -18,154 +18,185 @@
* 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 "ns3/random-variable.h"
#include <iostream>
#include <sstream>
-#include "ns3/annotated-topology-reader.h"
-#include "../utils/spring-mobility-helper.h"
+#include <map>
+#include <list>
+#include <set>
+#include "ns3/rocketfuel-topology-reader.h"
-#include "ns3/config-store.h"
+#include <boost/lexical_cast.hpp>
+#include <boost/foreach.hpp>
using namespace ns3;
using namespace std;
+using namespace boost;
-NS_LOG_COMPONENT_DEFINE ("CcnxLinkFailureAbilene");
+NS_LOG_COMPONENT_DEFINE ("LinkFailureSprint");
+void PrintTime ()
+{
+ cout << "Progress: " << Simulator::Now ().ToDouble (Time::S) << "s" << endl;
+
+ Simulator::Schedule (Seconds (1.0), PrintTime);
+}
+
+
+class Experiment
+{
+public:
+ Experiment ()
+ : m_reader ("/abilene", 2.0) { }
+
+ void
+ ConfigureTopology ()
+ {
+ string input ("./src/NDNabstraction/examples/abilene-topology.txt");
+ string strategy ("ns3::CcnxBestRouteStrategy");
+ // string strategy ("ns3::CcnxFloodingStrategy");
+
+
+ m_reader.SetFileName (input);
+
+ NodeContainer nodes = m_reader.Read ();
+
+ if (m_reader.LinksSize () == 0)
+ {
+ NS_LOG_ERROR ("Problems reading the topology file. Failing.");
+ return;
+ }
+
+ 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 (strategy);
+ ccnxHelper.EnableLimits (true, Seconds(0.1));
+ ccnxHelper.SetDefaultRoutes (false);
+ ccnxHelper.InstallAll ();
+
+ // // Populate FIB based on IPv4 global routing controller
+ ccnxHelper.InstallFakeGlobalRoutes ();
+ ccnxHelper.InstallRoutesToAll ();
+
+ m_rand = UniformVariable (0, m_reader.GetNodes ().GetN());
+ m_linkRand = UniformVariable(0, m_reader.LinksSize());
+ }
+
+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 "everybody-to-everybody" usage pattern
+ ApplicationContainer
+ AddApplications()
+ {
+ ApplicationContainer apps;
+ for(uint32_t i =0; i<m_reader.GetNodes().GetN(); i++)
+ {
+ Ptr<Node> node1 = Names::Find<Node> ("/abilene", lexical_cast<string> (i));
+ CcnxAppHelper producerHelper ("ns3::CcnxProducer");
+ producerHelper.SetPrefix ("/" + lexical_cast<string> (i));
+
+ apps.Add(producerHelper.Install (node1));
+
+ for(uint32_t j = 0; j<m_reader.GetNodes().GetN();j++)
+ {
+ if(i==j)
+ continue;
+
+ Ptr<Node> node2 = Names::Find<Node> ("/abilene", lexical_cast<string> (j));
+
+ CcnxAppHelper consumerHelper ("ns3::CcnxConsumer");
+ consumerHelper.SetPrefix ("/" + lexical_cast<string> (i));
+ consumerHelper.SetAttribute ("MeanRate", StringValue ("1Mbps"));
+ consumerHelper.SetAttribute ("Size", StringValue ("2"));
+
+ apps.Add(consumerHelper.Install (node2));
+ }
+ }
+ return apps;
+ }
+
+ UniformVariable m_rand;
+ UniformVariable m_linkRand;
+
+private:
+ AnnotatedTopologyReader m_reader;
+};
int
main (int argc, char *argv[])
{
- // Packet::EnableChecking();
- // Packet::EnablePrinting();
- string input ("./src/NDNabstraction/examples/abilene-topology.txt");
+ cout << "Begin link failure scenario\n";
+
+ Config::SetDefault ("ns3::PointToPointNetDevice::DataRate", StringValue ("2Mbps"));
+ Config::SetDefault ("ns3::DropTailQueue::MaxPackets", StringValue ("100"));
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)
+
+ Experiment experiment;
+
+ for (uint32_t i = 0; i < 100; i++)
{
- NS_LOG_ERROR ("Problems reading the topology file. Failing.");
- return -1;
+
+ experiment.ConfigureTopology ();
+ 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";
+ }
+
+ 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");
+
+ experiment.Run (finishTime);
}
- 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);
+ cout << "Finish link failure scenario\n";
return 0;
}