Adding SpringMobilityModel to adjust positions of nodes in large
topologies
Inspired by http://en.wikipedia.org/wiki/Force-based_algorithms_%28graph_drawing%29
diff --git a/examples/abilene-topology.cc b/examples/abilene-topology.cc
index 75a4b99..a96daf7 100644
--- a/examples/abilene-topology.cc
+++ b/examples/abilene-topology.cc
@@ -30,6 +30,7 @@
#include <iostream>
#include <sstream>
#include "ns3/annotated-topology-reader.h"
+#include "../utils/spring-mobility-helper.h"
using namespace ns3;
using namespace std;
@@ -80,6 +81,7 @@
// --------------------------------------------
AnnotatedTopologyReader reader ("/abilene");
+ reader.SetMobilityModel ("ns3::SpringMobilityModel");
reader.SetFileName (input);
NodeContainer nodes = reader.Read ();
@@ -90,6 +92,8 @@
return -1;
}
+ SpringMobilityHelper::InstallSprings (reader.LinksBegin (), reader.LinksEnd ());
+
// InternetStackHelper stack;
// Ipv4GlobalRoutingHelper ipv4RoutingHelper ("ns3::Ipv4GlobalRoutingOrderedNexthops");
// stack.SetRoutingHelper (ipv4RoutingHelper);
diff --git a/examples/abilene-topology.txt b/examples/abilene-topology.txt
index 5eb607d..4672859 100644
--- a/examples/abilene-topology.txt
+++ b/examples/abilene-topology.txt
@@ -1,7 +1,7 @@
router
#name city latitude longitude
ATLA-M5 Atlanta_GA 33.750000 -84.383300
-ATLAng Atlanta_GA 33.750000 -84.383300
+ATLAng Atlanta_GA 33.850000 -84.483300
CHINng Chicago_IL 41.833300 -87.616700
DNVRng Denver_CO 40.750000 -105.000000
HSTNng Houston_TX 29.770031 -95.517364
diff --git a/examples/sprint-topology.cc b/examples/sprint-topology.cc
index 5efffeb..3a53c35 100644
--- a/examples/sprint-topology.cc
+++ b/examples/sprint-topology.cc
@@ -31,43 +31,81 @@
#include "ns3/rocketfuel-topology-reader.h"
using namespace ns3;
+using namespace std;
NS_LOG_COMPONENT_DEFINE ("CcnxSprintTopology");
int
main (int argc, char *argv[])
{
- Packet::EnableChecking();
- Packet::EnablePrinting();
- std::string weights ("./src/NDNabstraction/examples/sprint.weights");
- std::string latencies ("./src/NDNabstraction/examples/sprint.latencies");
+ // Packet::EnableChecking();
+ // Packet::EnablePrinting();
+ string weights ("./src/NDNabstraction/examples/sprint.weights");
+ string latencies ("./src/NDNabstraction/examples/sprint.latencies");
- // ------------------------------------------------------------
- // -- Read topology data.
- // --------------------------------------------
-
- RocketfuelWeightsReader reader;
+ Time finishTime = Seconds (2.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.AddValue ("weights", "Weights file", weights);
+ cmd.AddValue ("latencies", "Latencies file", latencies);
+ cmd.Parse (argc, argv);
- reader.SetFileName (weights);
- reader.SetFileType (RocketfuelWeightsReader::WEIGHTS);
- NodeContainer nodes = reader.Read ();
-
- reader.SetFileName (latencies);
- reader.SetFileType (RocketfuelWeightsReader::LATENCIES);
- reader.Read ();
+ // ------------------------------------------------------------
+ // -- Read topology data.
+ // --------------------------------------------
- if (reader.LinksSize () == 0)
+ RocketfuelWeightsReader reader ("/sprint");
+ reader.SetBoundingBox (0, 0, 400, 250);
+
+ reader.SetFileName (weights);
+ reader.SetFileType (RocketfuelWeightsReader::WEIGHTS);
+ NodeContainer nodes = reader.Read ();
+
+ reader.SetFileName (latencies);
+ reader.SetFileType (RocketfuelWeightsReader::LATENCIES);
+ reader.Read ();
+
+ reader.Commit ();
+ if (reader.LinksSize () == 0)
{
- NS_LOG_ERROR ("Problems reading the topology file. Failing.");
- return -1;
+ NS_LOG_ERROR ("Problems reading the topology file. Failing.");
+ return -1;
}
- NS_LOG_INFO("Nodes = " << nodes.GetN());
- NS_LOG_INFO("Links = " << reader.LinksSize ());
+ NS_LOG_INFO("Nodes = " << nodes.GetN());
+ NS_LOG_INFO("Links = " << reader.LinksSize ());
- NS_LOG_INFO ("Run Simulation.");
- Simulator::Run ();
- Simulator::Destroy ();
- NS_LOG_INFO ("Done.");
- return 0;
+ InternetStackHelper stack;
+ Ipv4GlobalRoutingHelper ipv4RoutingHelper ("ns3::Ipv4GlobalRoutingOrderedNexthops");
+ stack.SetRoutingHelper (ipv4RoutingHelper);
+ stack.Install (nodes);
+
+ reader.AssignIpv4Addresses (Ipv4Address ("10.0.0.0"));
+
+ // 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 ();
+
+ // // Populate FIB based on IPv4 global routing controller
+ // ccnxHelper.InstallFakeGlobalRoutes ();
+ // ccnxHelper.InstallRouteTo (Names::Find<Node> ("/sprint", "San+Jose,+CA4062"));
+
+ // Simulator::Schedule (Seconds (1.0), PrintFIBs);
+ // PrintFIBs ();
+
+ Simulator::Stop (finishTime);
+
+ NS_LOG_INFO ("Run Simulation.");
+ Simulator::Run ();
+ Simulator::Destroy ();
+ NS_LOG_INFO ("Done.");
+ return 0;
}