Modifying SpringMobilityModel to make all nodes readjust after even one
node changes its position (previously only this node was adjusting itself)
SpringMobilityModel now updates positions based on internal (static) timer
diff --git a/examples/sprint-topology.cc b/examples/sprint-topology.cc
index 3a53c35..b3baa7c 100644
--- a/examples/sprint-topology.cc
+++ b/examples/sprint-topology.cc
@@ -35,6 +35,13 @@
NS_LOG_COMPONENT_DEFINE ("CcnxSprintTopology");
+void PrintTime ()
+{
+ NS_LOG_INFO (Simulator::Now ());
+
+ Simulator::Schedule (Seconds (1.0), PrintTime);
+}
+
int
main (int argc, char *argv[])
{
@@ -42,16 +49,20 @@
// Packet::EnablePrinting();
string weights ("./src/NDNabstraction/examples/sprint.weights");
string latencies ("./src/NDNabstraction/examples/sprint.latencies");
+ string positions;
Time finishTime = Seconds (2.0);
string animationFile;
string strategy = "ns3::CcnxFloodingStrategy";
+ string save;
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.AddValue ("positions", "Positions files", positions);
+ cmd.AddValue ("save", "Save positions to a file", save);
cmd.Parse (argc, argv);
// ------------------------------------------------------------
@@ -61,9 +72,16 @@
RocketfuelWeightsReader reader ("/sprint");
reader.SetBoundingBox (0, 0, 400, 250);
+ if (!positions.empty())
+ {
+ reader.SetFileName (positions);
+ reader.SetFileType (RocketfuelWeightsReader::POSITIONS);
+ reader.Read ();
+ }
+
reader.SetFileName (weights);
reader.SetFileType (RocketfuelWeightsReader::WEIGHTS);
- NodeContainer nodes = reader.Read ();
+ reader.Read ();
reader.SetFileName (latencies);
reader.SetFileType (RocketfuelWeightsReader::LATENCIES);
@@ -76,13 +94,13 @@
return -1;
}
- NS_LOG_INFO("Nodes = " << nodes.GetN());
+ NS_LOG_INFO("Nodes = " << reader.GetNodes ().GetN());
NS_LOG_INFO("Links = " << reader.LinksSize ());
InternetStackHelper stack;
Ipv4GlobalRoutingHelper ipv4RoutingHelper ("ns3::Ipv4GlobalRoutingOrderedNexthops");
stack.SetRoutingHelper (ipv4RoutingHelper);
- stack.Install (nodes);
+ stack.Install (reader.GetNodes ());
reader.AssignIpv4Addresses (Ipv4Address ("10.0.0.0"));
@@ -98,14 +116,21 @@
// ccnxHelper.InstallFakeGlobalRoutes ();
// ccnxHelper.InstallRouteTo (Names::Find<Node> ("/sprint", "San+Jose,+CA4062"));
- // Simulator::Schedule (Seconds (1.0), PrintFIBs);
- // PrintFIBs ();
-
Simulator::Stop (finishTime);
+ Simulator::Schedule (Seconds (1.0), PrintTime);
+
+ // reader.SavePositions (save+".debug");
NS_LOG_INFO ("Run Simulation.");
Simulator::Run ();
Simulator::Destroy ();
NS_LOG_INFO ("Done.");
+
+ if (!save.empty ())
+ {
+ NS_LOG_INFO ("Saving positions.");
+ reader.SavePositions (save);
+ }
+
return 0;
}