summaryrefslogtreecommitdiff
path: root/ns3-simulations/nix/simulator/modules/platform.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/modules/platform.cc
parent9305e544d3c3b3ad49a47587616f2bde1dd8d323 (diff)
Update simulators
Diffstat (limited to 'ns3-simulations/nix/simulator/modules/platform.cc')
-rw-r--r--ns3-simulations/nix/simulator/modules/platform.cc33
1 files changed, 23 insertions, 10 deletions
diff --git a/ns3-simulations/nix/simulator/modules/platform.cc b/ns3-simulations/nix/simulator/modules/platform.cc
index 52f91b0..7cfc2b9 100644
--- a/ns3-simulations/nix/simulator/modules/platform.cc
+++ b/ns3-simulations/nix/simulator/modules/platform.cc
@@ -1,21 +1,32 @@
#include "modules.hpp"
+#include "ns3/pointer.h"
/**
* Create a sensors cell base on
* nbSensors Number of temperature sensors in the cell
* ap the Access Point (usually linked to the cloud)
*/
-Cell createCell(uint32_t nbSensors, Ptr<ns3::Node> ap){
+Cell createCell(uint32_t nbSensors, Ptr<ns3::Node> ap,int positionSeed){
// Create sensors
NodeContainer sensors;
sensors.Create(nbSensors);
- // Place nodes somehow, this is required by every wireless simulation
- for (uint32_t i = 0; i < nbSensors; i++)
- {
- sensors.Get (i)->AggregateObject (CreateObject<ConstantPositionMobilityModel> ());
- }
- ap->AggregateObject (CreateObject<ConstantPositionMobilityModel> ());
+
+ // Define sensors position/mobility
+ MobilityHelper mobility;
+ mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel"); // Sensors are fixed
+ Ptr<UniformRandomVariable> X = CreateObject<UniformRandomVariable> ();
+ X->SetAttribute ("Min", DoubleValue (0));
+ X->SetAttribute ("Max", DoubleValue (RECT_SIZE));
+ X->SetAttribute("Stream",IntegerValue(positionSeed));
+ Ptr<UniformRandomVariable> Y = CreateObject<UniformRandomVariable> ();
+ Y->SetAttribute ("Min", DoubleValue (0));
+ Y->SetAttribute ("Max", DoubleValue (RECT_SIZE));
+ Y->SetAttribute("Stream",IntegerValue(positionSeed+1));
+ mobility.SetPositionAllocator("ns3::RandomRectanglePositionAllocator",
+ "X",PointerValue(X),
+ "Y",PointerValue(Y));
+ mobility.Install(NodeContainer(ap,sensors));
// To apply XXWifiPhy and WifiMac on sensors
WifiHelper wifiHelper;
@@ -75,14 +86,16 @@ void setupScenario(Cell cell, CloudInfos cloudInfos, int sensorsPktSize, int sen
sensorsInt=ipv4.Assign(sensorsNetDev);
UdpEchoClientHelper echoClientHelper (InetSocketAddress (cloudInfos.second.first, cloudInfos.second.second));
- // echoClientHelper.SetAttribute ("MaxPackets", UintegerValue (10));
echoClientHelper.SetAttribute ("Interval", TimeValue (Seconds (sensorsSendInterval)));
echoClientHelper.SetAttribute ("PacketSize", UintegerValue (sensorsPktSize));
+ echoClientHelper.SetAttribute ("MaxPackets", UintegerValue (MAX_PACKET_BY_SENSOR));
ApplicationContainer pingApps;
// again using different start times to workaround Bug 388 and Bug 912
- echoClientHelper.SetAttribute ("StartTime", TimeValue (Seconds (1))); // Start at 1 (WIFI seems to not work when t<1)
- echoClientHelper.Install (sensors);
+ for(int i=0;i<sensors.GetN();i++){
+ echoClientHelper.SetAttribute ("StartTime", TimeValue (MilliSeconds (1+i)));
+ echoClientHelper.Install (sensors.Get(i));
+ }
}