Update simulators

This commit is contained in:
Loic Guegan 2019-05-16 14:32:18 +02:00
parent 9305e544d3
commit 026a84902c
505 changed files with 3375873 additions and 5912458 deletions

View file

@ -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));
}
}