mirror of
https://gitlab.com/manzerbredes/paper-lowrate-iot.git
synced 2025-05-01 17:37:45 +00:00
Add simulation scripts
This commit is contained in:
parent
39507e0bb5
commit
1da73fb609
18 changed files with 4043 additions and 2 deletions
66
ns3-simulations/ns3-simulator/modules/energy.cc
Normal file
66
ns3-simulations/ns3-simulator/modules/energy.cc
Normal file
|
@ -0,0 +1,66 @@
|
|||
|
||||
#include "modules.hpp"
|
||||
|
||||
void setupCellEnergy(Cell cell){
|
||||
NodeContainer nodes(cell.first.first,cell.first.second);
|
||||
NetDeviceContainer nodesNetDev(cell.second.first,cell.second.second);
|
||||
|
||||
// Install energy source
|
||||
BasicEnergySourceHelper edgeBasicSourceHelper;
|
||||
edgeBasicSourceHelper.Set ("BasicEnergySourceInitialEnergyJ", DoubleValue (BASICENERGYSOURCEINITIALENERGYJ));
|
||||
edgeBasicSourceHelper.Set ("BasicEnergySupplyVoltageV", DoubleValue (BASICENERGYSUPPLYVOLTAGEV));
|
||||
EnergySourceContainer apEdgeNodesSources = edgeBasicSourceHelper.Install (cell.first.first);
|
||||
EnergySourceContainer wifiEdgeNodesSources = edgeBasicSourceHelper.Install (cell.first.second);
|
||||
|
||||
// Install device energy model
|
||||
WifiRadioEnergyModelHelper radioEnergyHelper;
|
||||
radioEnergyHelper.Set ("TxCurrentA", DoubleValue (TXCURRENTA));
|
||||
radioEnergyHelper.Set ("RxCurrentA", DoubleValue (RXCURRENTA));
|
||||
radioEnergyHelper.Set ("IdleCurrentA", DoubleValue (IDLECURRENTA));
|
||||
DeviceEnergyModelContainer edgeApDeviceModels = radioEnergyHelper.Install (cell.second.first, apEdgeNodesSources);
|
||||
DeviceEnergyModelContainer edgeDeviceModels = radioEnergyHelper.Install (cell.second.second, wifiEdgeNodesSources);
|
||||
|
||||
|
||||
// Trace
|
||||
DeviceEnergyModelContainer energyModels(edgeApDeviceModels, edgeDeviceModels);
|
||||
DeviceEnergyModelContainer::Iterator it=energyModels.Begin();
|
||||
|
||||
int i=0;
|
||||
while(it!=energyModels.End()){
|
||||
(*it)->TraceConnect ("TotalEnergyConsumption", std::to_string(i),MakeCallback (&EnergyUpdated));
|
||||
it++;
|
||||
i++;
|
||||
}
|
||||
|
||||
// Ptr<BasicEnergySource> basicSourcePtr0 = DynamicCast<BasicEnergySource> (wifiEdgeNodesSources.Get (0));
|
||||
// //basicSourcePtr0->TraceConnectWithoutContext ("RemainingEnergy", MakeCallback (&RemainingEnergy));
|
||||
// //device energy model
|
||||
// Ptr<DeviceEnergyModel> basicRadioModelPtr0 =
|
||||
// basicSourcePtr0->FindDeviceEnergyModels ("ns3::WifiRadioEnergyModel").Get (0);
|
||||
// NS_ASSERT (basicRadioModelPtr0 != NULL);
|
||||
// basicRadioModelPtr0->TraceConnectWithoutContext ("TotalEnergyConsumption", MakeCallback (&TotalEnergy));
|
||||
|
||||
}
|
||||
|
||||
void setupCloudEnergy(CloudInfos cloudInfos){
|
||||
NodeContainer cloudNodes=cloudInfos.first;
|
||||
|
||||
// Install basic energy
|
||||
ns3::BasicNodeEnergyHelper basicNodeEnergy;
|
||||
basicNodeEnergy.Set("OnConso", ns3::DoubleValue (ONCONSO));
|
||||
basicNodeEnergy.Set("OffConso", ns3::DoubleValue (OFFCONSO));
|
||||
basicNodeEnergy.Install (cloudNodes);
|
||||
|
||||
ns3::CompleteNetdeviceEnergyHelper completeNetdeviceEnergy;
|
||||
completeNetdeviceEnergy.Set ("OffConso", ns3::DoubleValue (OFFCONSO));
|
||||
completeNetdeviceEnergy.Set ("IdleConso", ns3::DoubleValue (IDLECONSO));
|
||||
completeNetdeviceEnergy.Set ("RecvByteEnergy", ns3::DoubleValue (RECVBYTEENERGY));
|
||||
completeNetdeviceEnergy.Set ("SentByteEnergy", ns3::DoubleValue (SENTBYTEENERGY));
|
||||
completeNetdeviceEnergy.Set ("RecvPktEnergy", ns3::DoubleValue (RECVPKTENERGY));
|
||||
completeNetdeviceEnergy.Set ("SentPktEnergy", ns3::DoubleValue (SENTPKTENERGY));
|
||||
completeNetdeviceEnergy.Install(cloudNodes);
|
||||
|
||||
ns3::ConsumptionLogger conso;
|
||||
conso.NodeConso(ns3::Seconds (ECOFEN_LOG_EVERY), ns3::Seconds(ECOFEN_LOG_UNTIL), cloudNodes);
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue