summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLoic Guegan <manzerberdes@gmx.com>2019-04-12 16:45:24 +0200
committerLoic Guegan <manzerberdes@gmx.com>2019-04-12 16:45:24 +0200
commitceabb2d95d3da8fd8ab2761e72430027f2645867 (patch)
tree49613e9d5d7cab4dc221f6e35d0a185b82d4af6a
parent32ccf612d0ee2b167204f9b6191258ae890ccd7f (diff)
Update simulator
-rw-r--r--ns3-simulator/modules/callbacks.cc4
-rw-r--r--ns3-simulator/modules/energy.cc34
-rw-r--r--ns3-simulator/modules/modules.hpp18
-rwxr-xr-xns3-simulator/simulatorbin272920 -> 277448 bytes
4 files changed, 33 insertions, 23 deletions
diff --git a/ns3-simulator/modules/callbacks.cc b/ns3-simulator/modules/callbacks.cc
index 8016fbc..ca04730 100644
--- a/ns3-simulator/modules/callbacks.cc
+++ b/ns3-simulator/modules/callbacks.cc
@@ -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");
}
diff --git a/ns3-simulator/modules/energy.cc b/ns3-simulator/modules/energy.cc
index b37cbf0..f1e4b83 100644
--- a/ns3-simulator/modules/energy.cc
+++ b/ns3-simulator/modules/energy.cc
@@ -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;
diff --git a/ns3-simulator/modules/modules.hpp b/ns3-simulator/modules/modules.hpp
index 0b84aa8..c43ce41 100644
--- a/ns3-simulator/modules/modules.hpp
+++ b/ns3-simulator/modules/modules.hpp
@@ -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 ----------
/**
diff --git a/ns3-simulator/simulator b/ns3-simulator/simulator
index 81998b1..8b740c7 100755
--- a/ns3-simulator/simulator
+++ b/ns3-simulator/simulator
Binary files differ