2019-04-12 13:52:06 +02:00
|
|
|
|
|
|
|
#include "modules.hpp"
|
|
|
|
|
2019-04-12 14:48:47 +02:00
|
|
|
void setupCellEnergy(Cell cell){
|
2019-04-12 13:52:06 +02:00
|
|
|
NodeContainer nodes(cell.first.first,cell.first.second);
|
|
|
|
NetDeviceContainer nodesNetDev(cell.second.first,cell.second.second);
|
|
|
|
|
|
|
|
// Install energy source
|
|
|
|
BasicEnergySourceHelper edgeBasicSourceHelper;
|
2019-04-12 16:45:24 +02:00
|
|
|
edgeBasicSourceHelper.Set ("BasicEnergySourceInitialEnergyJ", DoubleValue (BASICENERGYSOURCEINITIALENERGYJ));
|
|
|
|
edgeBasicSourceHelper.Set ("BasicEnergySupplyVoltageV", DoubleValue (BASICENERGYSUPPLYVOLTAGEV));
|
2019-04-12 13:52:06 +02:00
|
|
|
EnergySourceContainer apEdgeNodesSources = edgeBasicSourceHelper.Install (cell.first.first);
|
|
|
|
EnergySourceContainer wifiEdgeNodesSources = edgeBasicSourceHelper.Install (cell.first.second);
|
|
|
|
|
|
|
|
// Install device energy model
|
|
|
|
WifiRadioEnergyModelHelper radioEnergyHelper;
|
2019-04-12 16:45:24 +02:00
|
|
|
radioEnergyHelper.Set ("TxCurrentA", DoubleValue (TXCURRENTA));
|
|
|
|
radioEnergyHelper.Set ("RxCurrentA", DoubleValue (RXCURRENTA));
|
|
|
|
radioEnergyHelper.Set ("IdleCurrentA", DoubleValue (IDLECURRENTA));
|
2019-04-12 13:52:06 +02:00
|
|
|
DeviceEnergyModelContainer edgeApDeviceModels = radioEnergyHelper.Install (cell.second.first, apEdgeNodesSources);
|
|
|
|
DeviceEnergyModelContainer edgeDeviceModels = radioEnergyHelper.Install (cell.second.second, wifiEdgeNodesSources);
|
|
|
|
|
|
|
|
|
|
|
|
// Trace
|
2019-04-25 09:00:11 +02:00
|
|
|
DeviceEnergyModelContainer::Iterator it=edgeDeviceModels.Begin();
|
|
|
|
int i=1; // Node 0 will be AP, other node will have negative id (cf following while)
|
|
|
|
// This is usefull in logs, in fact ECOFEN nodes will have positive ID and WIFI energy nodes negative id
|
|
|
|
// AP will have id 0 in ECOFEN and WIFI (in order to combine their energy value when parsing logs
|
|
|
|
while(it!=edgeDeviceModels.End()){
|
|
|
|
(*it)->TraceConnect ("TotalEnergyConsumption", std::to_string(0-i),MakeCallback (&EnergyUpdated));
|
2019-04-12 13:52:06 +02:00
|
|
|
it++;
|
|
|
|
i++;
|
|
|
|
}
|
2019-04-25 09:00:11 +02:00
|
|
|
// AP will have id 0
|
|
|
|
(*edgeApDeviceModels.Begin())->TraceConnect ("TotalEnergyConsumption", std::to_string(0),MakeCallback (&EnergyUpdated));
|
2019-04-12 13:52:06 +02:00
|
|
|
|
2019-04-12 16:45:24 +02:00
|
|
|
// Ptr<BasicEnergySource> basicSourcePtr0 = DynamicCast<BasicEnergySource> (wifiEdgeNodesSources.Get (0));
|
2019-04-12 13:52:06 +02:00
|
|
|
// //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));
|
|
|
|
|
2019-04-12 16:05:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void setupCloudEnergy(CloudInfos cloudInfos){
|
|
|
|
NodeContainer cloudNodes=cloudInfos.first;
|
|
|
|
|
|
|
|
// Install basic energy
|
|
|
|
ns3::BasicNodeEnergyHelper basicNodeEnergy;
|
2019-04-12 16:45:24 +02:00
|
|
|
basicNodeEnergy.Set("OnConso", ns3::DoubleValue (ONCONSO));
|
|
|
|
basicNodeEnergy.Set("OffConso", ns3::DoubleValue (OFFCONSO));
|
2019-04-12 16:05:29 +02:00
|
|
|
basicNodeEnergy.Install (cloudNodes);
|
|
|
|
|
|
|
|
ns3::CompleteNetdeviceEnergyHelper completeNetdeviceEnergy;
|
2019-04-12 16:45:24 +02:00
|
|
|
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));
|
2019-04-12 16:05:29 +02:00
|
|
|
completeNetdeviceEnergy.Install(cloudNodes);
|
2019-04-12 13:52:06 +02:00
|
|
|
|
2019-04-12 16:05:29 +02:00
|
|
|
ns3::ConsumptionLogger conso;
|
2019-04-29 09:00:49 +02:00
|
|
|
conso.NodeConso(ns3::Seconds (ECOFEN_LOG_EVERY), ns3::Seconds(SIM_TIME), cloudNodes);
|
2019-04-12 13:52:06 +02:00
|
|
|
}
|
|
|
|
|