Bug 1675 - Throughput computation error in Wireless examples
authorJunling Bu <linlinjavaer@gmail.com>
Tue, 09 Jul 2013 21:13:38 +0200
changeset 9916 725d7c8811b8
parent 9915 d4c2228d3c30
child 9917 b61b15f922a2
Bug 1675 - Throughput computation error in Wireless examples
RELEASE_NOTES
examples/wireless/multirate.cc
examples/wireless/wifi-hidden-terminal.cc
--- a/RELEASE_NOTES	Tue Jul 09 19:21:07 2013 +0200
+++ b/RELEASE_NOTES	Tue Jul 09 21:13:38 2013 +0200
@@ -33,6 +33,7 @@
 - Bug 1678 - C++11 compliance problem with std::pair"
 - Bug 1683 - IPv6 autoconfigured don't use *infinite* lifetimes
 - Bug 1669 - ns-3 should support binding two and three (possibly more) arguments
+- Bug 1675 - Throughput computation error in Wireless examples
 - Bug 1688 - Routers should advertise themselves from the link-local address
 - Bug 1689 - IPv6 shouldn't add a default gateway without checking the Router lifetime
 - Bug 1697 - ICMPv6 Redirect trigger contains multiple bugs
--- a/examples/wireless/multirate.cc	Tue Jul 09 19:21:07 2013 +0200
+++ b/examples/wireless/multirate.cc	Tue Jul 09 21:13:38 2013 +0200
@@ -103,6 +103,7 @@
 
   double totalTime; 
   double expMean;
+  double samplingPeriod;
 
   uint32_t bytesTotal;
   uint32_t packetSize;
@@ -129,6 +130,7 @@
   m_output (name),
   totalTime (0.3),
   expMean (0.1), //flows being exponentially distributed
+  samplingPeriod(0.1),
   bytesTotal (0),
   packetSize (2000),
   gridSize (10), //10x10 grid  for a total of 100 nodes
@@ -172,12 +174,12 @@
 void
 Experiment::CheckThroughput ()
 {
-  double mbs = ((bytesTotal * 8.0) /1000000);
+  double mbs = ((bytesTotal * 8.0) /1000000 /samplingPeriod);
   bytesTotal = 0;
   m_output.Add ((Simulator::Now ()).GetSeconds (), mbs);
 
-  //check throughput every 1/10 of a second 
-  Simulator::Schedule (Seconds (0.1), &Experiment::CheckThroughput, this);
+  //check throughput every samplingPeriod second
+  Simulator::Schedule (Seconds (samplingPeriod), &Experiment::CheckThroughput, this);
 }
 
 /**
@@ -534,6 +536,17 @@
   CommandLine cmd;
   cmd.AddValue ("packetSize", "packet size", packetSize);
   cmd.AddValue ("totalTime", "simulation time", totalTime);
+  // according to totalTime, select an appropriate samplingPeriod automatically.
+  if (totalTime < 1.0)
+    {
+	  samplingPeriod = 0.1;
+    }
+  else
+    {
+	  samplingPeriod = 1.0;
+    }
+  // or user selects a samplingPeriod.
+  cmd.AddValue ("samplingPeriod", "sampling period", samplingPeriod);
   cmd.AddValue ("rtsThreshold", "rts threshold", rtsThreshold);
   cmd.AddValue ("rateManager", "type of rate", rateManager);
   cmd.AddValue ("outputFileName", "output filename", outputFileName);
--- a/examples/wireless/wifi-hidden-terminal.cc	Tue Jul 09 19:21:07 2013 +0200
+++ b/examples/wireless/wifi-hidden-terminal.cc	Tue Jul 09 21:13:38 2013 +0200
@@ -156,9 +156,10 @@
       if (i->first > 2)
         {
           Ipv4FlowClassifier::FiveTuple t = classifier->FindFlow (i->first);
-          std::cout << "Flow " << i->first - 2 << " (" << t.sourceAddress << " -> " << t.destinationAddress << ")\n";           std::cout << "  Tx Bytes:   " << i->second.txBytes << "\n";
+          std::cout << "Flow " << i->first - 2 << " (" << t.sourceAddress << " -> " << t.destinationAddress << ")\n";
+          std::cout << "  Tx Bytes:   " << i->second.txBytes << "\n";
           std::cout << "  Rx Bytes:   " << i->second.rxBytes << "\n";
-          std::cout << "  Throughput: " << i->second.rxBytes * 8.0 / 10.0 / 1024 / 1024  << " Mbps\n";
+          std::cout << "  Throughput: " << i->second.rxBytes * 8.0 / 10.0 / 1000 / 1000  << " Mbps\n";
         }
     }