Update simulator

This commit is contained in:
Loic Guegan 2019-04-12 16:45:24 +02:00
parent 32ccf612d0
commit ceabb2d95d
4 changed files with 33 additions and 23 deletions

View file

@ -2,9 +2,9 @@
#include "modules.hpp"
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){
NS_LOG_UNCOND("Node " << nodeName << " consumes " << newValue-oldValue << "J");
NS_LOG_UNCOND("Node " << nodeName << " consumes " << newValue-oldValue << "J" << " at time " << Simulator::Now ().GetSeconds () << "s");
}

View file

@ -7,16 +7,16 @@ void setupCellEnergy(Cell cell){
// Install energy source
BasicEnergySourceHelper edgeBasicSourceHelper;
edgeBasicSourceHelper.Set ("BasicEnergySourceInitialEnergyJ", DoubleValue (2.9009));
edgeBasicSourceHelper.Set ("BasicEnergySupplyVoltageV", DoubleValue (3.3));
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 (0.38));
radioEnergyHelper.Set ("RxCurrentA", DoubleValue (0.313));
radioEnergyHelper.Set ("IdleCurrentA", DoubleValue (0.273));
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);
@ -32,17 +32,11 @@ void setupCellEnergy(Cell cell){
i++;
}
// Ptr<BasicEnergySource> basicSourcePtr0 = DynamicCast<BasicEnergySource> (wifiEdgeNodesSources.Get (0));
// 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));
@ -53,17 +47,17 @@ void setupCloudEnergy(CloudInfos cloudInfos){
// Install basic energy
ns3::BasicNodeEnergyHelper basicNodeEnergy;
basicNodeEnergy.Set("OnConso", ns3::DoubleValue (0.0));
basicNodeEnergy.Set("OffConso", ns3::DoubleValue (0.0));
basicNodeEnergy.Set("OnConso", ns3::DoubleValue (ONCONSO));
basicNodeEnergy.Set("OffConso", ns3::DoubleValue (OFFCONSO));
basicNodeEnergy.Install (cloudNodes);
ns3::CompleteNetdeviceEnergyHelper completeNetdeviceEnergy;
completeNetdeviceEnergy.Set ("OffConso", ns3::DoubleValue (0));
completeNetdeviceEnergy.Set ("IdleConso", ns3::DoubleValue (0));
completeNetdeviceEnergy.Set ("RecvByteEnergy", ns3::DoubleValue (10));
completeNetdeviceEnergy.Set ("SentByteEnergy", ns3::DoubleValue (10));
completeNetdeviceEnergy.Set ("RecvPktEnergy", ns3::DoubleValue (10));
completeNetdeviceEnergy.Set ("SentPktEnergy", ns3::DoubleValue (10));
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;

View file

@ -31,6 +31,22 @@
#include <utility> // To use std::pair
#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;
// ---------- Data types ----------
@ -39,7 +55,7 @@ typedef std::pair<NetDeviceContainer,NetDeviceContainer> CellNetDevices; // Form
typedef std::pair<CellNodes,CellNetDevices> Cell;
typedef std::pair<Ipv4Address,int> EndPoint; // Format (IP,Port)
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 ----------
/**

Binary file not shown.