From 026a84902cdc22f64b53aea3678d576bc29f479b Mon Sep 17 00:00:00 2001 From: Loic Guegan Date: Thu, 16 May 2019 14:32:18 +0200 Subject: Update simulators --- ns3-simulations/nix/simulator/modules/platform.cc | 33 ++++++++++++++++------- 1 file changed, 23 insertions(+), 10 deletions(-) (limited to 'ns3-simulations/nix/simulator/modules/platform.cc') 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 ap){ +Cell createCell(uint32_t nbSensors, Ptr 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 ()); - } - ap->AggregateObject (CreateObject ()); + + // Define sensors position/mobility + MobilityHelper mobility; + mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel"); // Sensors are fixed + Ptr X = CreateObject (); + X->SetAttribute ("Min", DoubleValue (0)); + X->SetAttribute ("Max", DoubleValue (RECT_SIZE)); + X->SetAttribute("Stream",IntegerValue(positionSeed)); + Ptr Y = CreateObject (); + 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