summaryrefslogtreecommitdiff
path: root/ns3-simulations/nix/simulator/main.cc
diff options
context:
space:
mode:
authorLoic Guegan <manzerberdes@gmx.com>2019-05-16 14:32:18 +0200
committerLoic Guegan <manzerberdes@gmx.com>2019-05-16 14:32:18 +0200
commit026a84902cdc22f64b53aea3678d576bc29f479b (patch)
tree5b0cb6540533337c6c331f1333ac37979ad49ae4 /ns3-simulations/nix/simulator/main.cc
parent9305e544d3c3b3ad49a47587616f2bde1dd8d323 (diff)
Update simulators
Diffstat (limited to 'ns3-simulations/nix/simulator/main.cc')
-rw-r--r--ns3-simulations/nix/simulator/main.cc27
1 files changed, 24 insertions, 3 deletions
diff --git a/ns3-simulations/nix/simulator/main.cc b/ns3-simulations/nix/simulator/main.cc
index b7f043c..b625ecf 100644
--- a/ns3-simulations/nix/simulator/main.cc
+++ b/ns3-simulations/nix/simulator/main.cc
@@ -1,4 +1,7 @@
#include "modules/modules.hpp"
+#ifndef NS3_VERSION
+#define NS3_VERSION "unknown"
+#endif
NS_LOG_COMPONENT_DEFINE ("WIFISensorsSimulator");
@@ -14,6 +17,7 @@ int main(int argc, char* argv[]){
uint32_t nbHop=5;
uint32_t linksBandwidth=5;
uint32_t linksLatency=2;
+ uint32_t positionSeed=5;
CommandLine cmd;
cmd.AddValue ("sensorsSendInterval", "Number of sensors measurement per second", sensorsFrequency);
@@ -22,22 +26,28 @@ int main(int argc, char* argv[]){
cmd.AddValue ("nbHop", "Number of hop between AP and Cloud", nbHop);
cmd.AddValue ("linksBandwidth", "Links bandwidth between AP and Cloud", linksBandwidth);
cmd.AddValue ("linksLatency", "Links latency between AP and Cloud", linksLatency);
+ cmd.AddValue ("positionSeed", "RandomRectangle Sensors placement seed", positionSeed);
cmd.Parse (argc, argv);
+ // Check sensors frequency
+ if(sensorsFrequency<1){
+ NS_LOG_UNCOND("SensorsSendInterval too small: " << sensorsFrequency << " (it should be >1)." );
+ exit(1);
+ }
+
//LogComponentEnable("UdpEchoClientApplication", LOG_LEVEL_INFO);
//LogComponentEnable("PacketSink", LOG_LEVEL_INFO);
// ---------- Setup Simulations ----------
CloudInfos cloud=createCloud(nbHop,linksBandwidth,linksLatency); // Create cloud P2P node chain o--o--o--o--o
setupCloudEnergy(cloud); // DO IT JUST AFTER createCloud !!!!! Otherwise you will be in trouble
- Cell cell=createCell(sensorsNumber,cloud.first.Get(0)); // Use first cloud node as Access Point
+ Cell cell=createCell(sensorsNumber,cloud.first.Get(0),positionSeed); // Use first cloud node as Access Point
setupScenario(cell,cloud,sensorsPktSize,sensorsFrequency); // Send data from Sensors to Cloud
- setupCellEnergy(cell);
+ DeviceEnergyModelContainer wifi=setupCellEnergy(cell);
// Don't forget the following
Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
-
// Setup Logs
uint32_t nNode=ns3::NodeList::GetNNodes();
FlowMonitorHelper flowmon;
@@ -58,6 +68,17 @@ int main(int argc, char* argv[]){
NS_LOG_UNCOND("Flow " <<t.sourceAddress<< " -> "<< t.destinationAddress << " delay = " <<flow->second.delaySum.GetSeconds());
}
+
+ // Trace
+ DeviceEnergyModelContainer::Iterator it=wifi.Begin();
+ int i=0; // Note that node 0 is the AP
+ while(it!=wifi.End()){
+ NS_LOG_UNCOND ("Node " << i << " consumes " <<(*it)->GetTotalEnergyConsumption());
+ it++;
+ i--; // Edge device will have id < 0 and ap will have id 0
+ }
+
+
// Finish
Simulator::Destroy ();
return(0);