mirror of
https://gitlab.com/manzerbredes/paper-lowrate-iot.git
synced 2025-06-05 22:27:39 +00:00
Update simulator
This commit is contained in:
parent
32ccf612d0
commit
ceabb2d95d
4 changed files with 33 additions and 23 deletions
|
@ -2,9 +2,9 @@
|
||||||
#include "modules.hpp"
|
#include "modules.hpp"
|
||||||
|
|
||||||
void PktReceived(std::string nodeName,Ptr< const Packet > packet, const Address &address){
|
void PktReceived(std::string nodeName,Ptr< const Packet > packet, const Address &address){
|
||||||
NS_LOG_UNCOND("Node " << nodeName << " receive a packet");
|
NS_LOG_UNCOND("Node " << nodeName << " receive a packet" << " at time " << Simulator::Now ().GetSeconds () << "s");
|
||||||
}
|
}
|
||||||
|
|
||||||
void EnergyUpdated(std::string nodeName,double oldValue, double newValue){
|
void EnergyUpdated(std::string nodeName,double oldValue, double newValue){
|
||||||
NS_LOG_UNCOND("Node " << nodeName << " consumes " << newValue-oldValue << "J");
|
NS_LOG_UNCOND("Node " << nodeName << " consumes " << newValue-oldValue << "J" << " at time " << Simulator::Now ().GetSeconds () << "s");
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,16 +7,16 @@ void setupCellEnergy(Cell cell){
|
||||||
|
|
||||||
// Install energy source
|
// Install energy source
|
||||||
BasicEnergySourceHelper edgeBasicSourceHelper;
|
BasicEnergySourceHelper edgeBasicSourceHelper;
|
||||||
edgeBasicSourceHelper.Set ("BasicEnergySourceInitialEnergyJ", DoubleValue (2.9009));
|
edgeBasicSourceHelper.Set ("BasicEnergySourceInitialEnergyJ", DoubleValue (BASICENERGYSOURCEINITIALENERGYJ));
|
||||||
edgeBasicSourceHelper.Set ("BasicEnergySupplyVoltageV", DoubleValue (3.3));
|
edgeBasicSourceHelper.Set ("BasicEnergySupplyVoltageV", DoubleValue (BASICENERGYSUPPLYVOLTAGEV));
|
||||||
EnergySourceContainer apEdgeNodesSources = edgeBasicSourceHelper.Install (cell.first.first);
|
EnergySourceContainer apEdgeNodesSources = edgeBasicSourceHelper.Install (cell.first.first);
|
||||||
EnergySourceContainer wifiEdgeNodesSources = edgeBasicSourceHelper.Install (cell.first.second);
|
EnergySourceContainer wifiEdgeNodesSources = edgeBasicSourceHelper.Install (cell.first.second);
|
||||||
|
|
||||||
// Install device energy model
|
// Install device energy model
|
||||||
WifiRadioEnergyModelHelper radioEnergyHelper;
|
WifiRadioEnergyModelHelper radioEnergyHelper;
|
||||||
radioEnergyHelper.Set ("TxCurrentA", DoubleValue (0.38));
|
radioEnergyHelper.Set ("TxCurrentA", DoubleValue (TXCURRENTA));
|
||||||
radioEnergyHelper.Set ("RxCurrentA", DoubleValue (0.313));
|
radioEnergyHelper.Set ("RxCurrentA", DoubleValue (RXCURRENTA));
|
||||||
radioEnergyHelper.Set ("IdleCurrentA", DoubleValue (0.273));
|
radioEnergyHelper.Set ("IdleCurrentA", DoubleValue (IDLECURRENTA));
|
||||||
DeviceEnergyModelContainer edgeApDeviceModels = radioEnergyHelper.Install (cell.second.first, apEdgeNodesSources);
|
DeviceEnergyModelContainer edgeApDeviceModels = radioEnergyHelper.Install (cell.second.first, apEdgeNodesSources);
|
||||||
DeviceEnergyModelContainer edgeDeviceModels = radioEnergyHelper.Install (cell.second.second, wifiEdgeNodesSources);
|
DeviceEnergyModelContainer edgeDeviceModels = radioEnergyHelper.Install (cell.second.second, wifiEdgeNodesSources);
|
||||||
|
|
||||||
|
@ -32,17 +32,11 @@ void setupCellEnergy(Cell cell){
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ptr<BasicEnergySource> basicSourcePtr0 = DynamicCast<BasicEnergySource> (wifiEdgeNodesSources.Get (0));
|
||||||
|
|
||||||
|
|
||||||
// Ptr<BasicEnergySource> basicSourcePtr0 = DynamicCast<BasicEnergySource> (wifiEdgeNodesSources.Get (0));
|
|
||||||
|
|
||||||
// //basicSourcePtr0->TraceConnectWithoutContext ("RemainingEnergy", MakeCallback (&RemainingEnergy));
|
// //basicSourcePtr0->TraceConnectWithoutContext ("RemainingEnergy", MakeCallback (&RemainingEnergy));
|
||||||
// //device energy model
|
// //device energy model
|
||||||
|
|
||||||
// Ptr<DeviceEnergyModel> basicRadioModelPtr0 =
|
// Ptr<DeviceEnergyModel> basicRadioModelPtr0 =
|
||||||
// basicSourcePtr0->FindDeviceEnergyModels ("ns3::WifiRadioEnergyModel").Get (0);
|
// basicSourcePtr0->FindDeviceEnergyModels ("ns3::WifiRadioEnergyModel").Get (0);
|
||||||
|
|
||||||
// NS_ASSERT (basicRadioModelPtr0 != NULL);
|
// NS_ASSERT (basicRadioModelPtr0 != NULL);
|
||||||
// basicRadioModelPtr0->TraceConnectWithoutContext ("TotalEnergyConsumption", MakeCallback (&TotalEnergy));
|
// basicRadioModelPtr0->TraceConnectWithoutContext ("TotalEnergyConsumption", MakeCallback (&TotalEnergy));
|
||||||
|
|
||||||
|
@ -53,17 +47,17 @@ void setupCloudEnergy(CloudInfos cloudInfos){
|
||||||
|
|
||||||
// Install basic energy
|
// Install basic energy
|
||||||
ns3::BasicNodeEnergyHelper basicNodeEnergy;
|
ns3::BasicNodeEnergyHelper basicNodeEnergy;
|
||||||
basicNodeEnergy.Set("OnConso", ns3::DoubleValue (0.0));
|
basicNodeEnergy.Set("OnConso", ns3::DoubleValue (ONCONSO));
|
||||||
basicNodeEnergy.Set("OffConso", ns3::DoubleValue (0.0));
|
basicNodeEnergy.Set("OffConso", ns3::DoubleValue (OFFCONSO));
|
||||||
basicNodeEnergy.Install (cloudNodes);
|
basicNodeEnergy.Install (cloudNodes);
|
||||||
|
|
||||||
ns3::CompleteNetdeviceEnergyHelper completeNetdeviceEnergy;
|
ns3::CompleteNetdeviceEnergyHelper completeNetdeviceEnergy;
|
||||||
completeNetdeviceEnergy.Set ("OffConso", ns3::DoubleValue (0));
|
completeNetdeviceEnergy.Set ("OffConso", ns3::DoubleValue (OFFCONSO));
|
||||||
completeNetdeviceEnergy.Set ("IdleConso", ns3::DoubleValue (0));
|
completeNetdeviceEnergy.Set ("IdleConso", ns3::DoubleValue (IDLECONSO));
|
||||||
completeNetdeviceEnergy.Set ("RecvByteEnergy", ns3::DoubleValue (10));
|
completeNetdeviceEnergy.Set ("RecvByteEnergy", ns3::DoubleValue (RECVBYTEENERGY));
|
||||||
completeNetdeviceEnergy.Set ("SentByteEnergy", ns3::DoubleValue (10));
|
completeNetdeviceEnergy.Set ("SentByteEnergy", ns3::DoubleValue (SENTBYTEENERGY));
|
||||||
completeNetdeviceEnergy.Set ("RecvPktEnergy", ns3::DoubleValue (10));
|
completeNetdeviceEnergy.Set ("RecvPktEnergy", ns3::DoubleValue (RECVPKTENERGY));
|
||||||
completeNetdeviceEnergy.Set ("SentPktEnergy", ns3::DoubleValue (10));
|
completeNetdeviceEnergy.Set ("SentPktEnergy", ns3::DoubleValue (SENTPKTENERGY));
|
||||||
completeNetdeviceEnergy.Install(cloudNodes);
|
completeNetdeviceEnergy.Install(cloudNodes);
|
||||||
|
|
||||||
ns3::ConsumptionLogger conso;
|
ns3::ConsumptionLogger conso;
|
||||||
|
|
|
@ -31,6 +31,22 @@
|
||||||
#include <utility> // To use std::pair
|
#include <utility> // To use std::pair
|
||||||
#include <iomanip> // To use std::setw
|
#include <iomanip> // To use std::setw
|
||||||
|
|
||||||
|
// WIFI Energy Values
|
||||||
|
#define BASICENERGYSOURCEINITIALENERGYJ 1000
|
||||||
|
#define BASICENERGYSUPPLYVOLTAGEV 3.3
|
||||||
|
#define TXCURRENTA 0.38
|
||||||
|
#define RXCURRENTA 0.313
|
||||||
|
#define IDLECURRENTA 0.273
|
||||||
|
|
||||||
|
// Cloud Energy Values
|
||||||
|
#define ONCONSO 0
|
||||||
|
#define OFFCONSO 0
|
||||||
|
#define IDLECONSO 0
|
||||||
|
#define RECVBYTEENERGY 10
|
||||||
|
#define SENTBYTEENERGY 10
|
||||||
|
#define RECVPKTENERGY 10
|
||||||
|
#define SENTPKTENERGY 0
|
||||||
|
|
||||||
using namespace ns3;
|
using namespace ns3;
|
||||||
|
|
||||||
// ---------- Data types ----------
|
// ---------- Data types ----------
|
||||||
|
@ -39,7 +55,7 @@ typedef std::pair<NetDeviceContainer,NetDeviceContainer> CellNetDevices; // Form
|
||||||
typedef std::pair<CellNodes,CellNetDevices> Cell;
|
typedef std::pair<CellNodes,CellNetDevices> Cell;
|
||||||
typedef std::pair<Ipv4Address,int> EndPoint; // Format (IP,Port)
|
typedef std::pair<Ipv4Address,int> EndPoint; // Format (IP,Port)
|
||||||
typedef std::pair<NodeContainer,EndPoint> CloudInfos; // Format (CloudHops,CloudEndPoint), here data sent to CloudEndPoint
|
typedef std::pair<NodeContainer,EndPoint> CloudInfos; // Format (CloudHops,CloudEndPoint), here data sent to CloudEndPoint
|
||||||
// via CloudHops.Get(0) will flow throw all hops until the reaching the cloud
|
|
||||||
|
|
||||||
// ---------- platform.cc ----------
|
// ---------- platform.cc ----------
|
||||||
/**
|
/**
|
||||||
|
|
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue