summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLoic Guegan <manzerberdes@gmx.com>2019-04-12 16:05:29 +0200
committerLoic Guegan <manzerberdes@gmx.com>2019-04-12 16:05:29 +0200
commit32ccf612d0ee2b167204f9b6191258ae890ccd7f (patch)
tree1cebbb50f3126f0bacaabb05cd5251beb3b1c156
parentcb10ad2490706fc87f19ef556f36aee679887ad6 (diff)
Add ECOFEN
-rw-r--r--ns3-simulator/Makefile21
-rw-r--r--ns3-simulator/main.cc17
-rw-r--r--ns3-simulator/modules/callbacks.cc2
-rw-r--r--ns3-simulator/modules/energy.cc21
-rw-r--r--ns3-simulator/modules/modules.hpp5
-rw-r--r--ns3-simulator/modules/platform.cc4
-rwxr-xr-xns3-simulator/simulatorbin271232 -> 272920 bytes
7 files changed, 53 insertions, 17 deletions
diff --git a/ns3-simulator/Makefile b/ns3-simulator/Makefile
index c2e1d35..d7bf341 100644
--- a/ns3-simulator/Makefile
+++ b/ns3-simulator/Makefile
@@ -1,20 +1,25 @@
+EXEC=simulator
+
+##### NS3 g++ Arguments
NS3_ARGS= -D NS3_LOG_ENABLE -L ${NS3_PATH}/build/lib -I ${NS3_PATH}/build/
NS3_ARGS+=$(addprefix -l, $(subst lib,,$(subst .so,,$(notdir $(wildcard ${NS3_PATH}/build/lib/*.so)))))
+##### Source Files
SRC=main.cc modules/platform.cc modules/energy.cc modules/callbacks.cc
-EXEC=simulator
-all: $(EXEC)
-$(EXEC): $(SRC)
- g++ $(NS3_ARGS) $(SRC) -o $@
+all: $(EXEC)
-run:
- @LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${NS3_PATH}/build/lib ./wifi-test
-export:
- @echo export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${NS3_PATH}/build/lib
+$(EXEC): $(SRC)
+ @echo -e "\e[32mDon't forget to define NS3_PATH env variable !\e[0m"
+ g++ $(NS3_ARGS) $(SRC) -o $@
+ @echo -e "\e[32mRun the following command before running $(EXEC):\e[0m"
+ @echo -e "\e[32mexport LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${NS3_PATH}/build/lib\e[0m"
clean:
- rm $(EXEC)
+
+
+.PHONY: clean
diff --git a/ns3-simulator/main.cc b/ns3-simulator/main.cc
index 0e21632..0e4e0f9 100644
--- a/ns3-simulator/main.cc
+++ b/ns3-simulator/main.cc
@@ -12,23 +12,28 @@ int main(int argc, char* argv[]){
uint32_t sensorsPktSize=150;
uint32_t sensorsNumber=2;
uint32_t nbHop=5;
+ uint32_t linksBandwidth=5;
+ uint32_t linksLatency=2;
CommandLine cmd;
- cmd.AddValue ("sensorsSendInterval", "Number of temperature measurement per second", sensorsFrequency);
- cmd.AddValue ("sensorsPktSize", "Sensor measurements packet size (bytes)", sensorsPktSize);
- cmd.AddValue ("sensorsNumber", "Number of sensors", sensorsNumber);
- cmd.AddValue ("nbHop", "Number of hop between AP and Cloud sensors", sensorsNumber);
+ cmd.AddValue ("sensorsSendInterval", "Number of sensors measurement per second", sensorsFrequency);
+ cmd.AddValue ("sensorsPktSize", "Sensors packet size (bytes)", sensorsPktSize);
+ cmd.AddValue ("sensorsNumber", "Number of sensors connected to AP", sensorsNumber);
+ cmd.AddValue ("nbHop", "Number of hop between AP and Cloud", sensorsNumber);
+ cmd.AddValue ("linksBandwidth", "Links bandwidth between AP and Cloud", linksBandwidth);
+ cmd.AddValue ("linksLatency", "Links latency between AP and Cloud", linksLatency);
cmd.Parse (argc, argv);
//LogComponentEnable("UdpEchoClientApplication", LOG_LEVEL_INFO);
//LogComponentEnable("PacketSink", LOG_LEVEL_INFO);
// ---------- Setup Simulations ----------
- CloudInfos cloud=createCloud(nbHop,5,2); // Create cloud P2P node chain o--o--o--o--o
+ CloudInfos cloud=createCloud(nbHop,linksBandwidth,linksLatency); // Create cloud P2P node chain o--o--o--o--o
+ setupCloudEnergy(cloud); // DO IT JUST AFTER createCloud !!!!! Otherwise you will be in trouble
Cell cell=createCell(sensorsNumber,cloud.first.Get(0)); // Use first cloud node as Access Point
setupScenario(cell,cloud,sensorsPktSize,sensorsFrequency); // Send data from Sensors to Cloud
setupCellEnergy(cell);
-
+
// Don't forget the following
Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
diff --git a/ns3-simulator/modules/callbacks.cc b/ns3-simulator/modules/callbacks.cc
index a552eb9..8016fbc 100644
--- a/ns3-simulator/modules/callbacks.cc
+++ b/ns3-simulator/modules/callbacks.cc
@@ -6,5 +6,5 @@ void PktReceived(std::string nodeName,Ptr< const Packet > packet, const Address
}
void EnergyUpdated(std::string nodeName,double oldValue, double newValue){
- NS_LOG_UNCOND("Node " << nodeName << " consumes " << newValue << "J");
+ NS_LOG_UNCOND("Node " << nodeName << " consumes " << newValue-oldValue << "J");
}
diff --git a/ns3-simulator/modules/energy.cc b/ns3-simulator/modules/energy.cc
index 9c91bf4..b37cbf0 100644
--- a/ns3-simulator/modules/energy.cc
+++ b/ns3-simulator/modules/energy.cc
@@ -46,6 +46,27 @@ void setupCellEnergy(Cell cell){
// 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 (0.0));
+ basicNodeEnergy.Set("OffConso", ns3::DoubleValue (0.0));
+ 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.Install(cloudNodes);
+ ns3::ConsumptionLogger conso;
+ conso.NodeConso(ns3::Seconds (1), ns3::Seconds(10), cloudNodes);
}
diff --git a/ns3-simulator/modules/modules.hpp b/ns3-simulator/modules/modules.hpp
index 9423866..0b84aa8 100644
--- a/ns3-simulator/modules/modules.hpp
+++ b/ns3-simulator/modules/modules.hpp
@@ -24,6 +24,7 @@
#include "ns3/energy-module.h"
#include "ns3/wifi-radio-energy-model-helper.h"
#include "ns3/point-to-point-helper.h"
+#include "ns3/ecofen-module.h"
// C++ library
#include <iostream> // Why not ?
@@ -62,6 +63,10 @@ void setupScenario(Cell cell, CloudInfos cloudInfos, int sensorsPktSize, int sen
* Configure WIFI energy module for cell
*/
void setupCellEnergy(Cell cell);
+/*
+ * Configure link/port energy using ecofen
+ */
+void setupCloudEnergy(CloudInfos cloudInfos);
// ---------- callbacks.cc ----------
diff --git a/ns3-simulator/modules/platform.cc b/ns3-simulator/modules/platform.cc
index 82c293d..52f91b0 100644
--- a/ns3-simulator/modules/platform.cc
+++ b/ns3-simulator/modules/platform.cc
@@ -11,7 +11,7 @@ Cell createCell(uint32_t nbSensors, Ptr<ns3::Node> ap){
sensors.Create(nbSensors);
// Place nodes somehow, this is required by every wireless simulation
- for (uint8_t i = 0; i < nbSensors; ++i)
+ for (uint32_t i = 0; i < nbSensors; i++)
{
sensors.Get (i)->AggregateObject (CreateObject<ConstantPositionMobilityModel> ());
}
@@ -106,7 +106,7 @@ CloudInfos createCloud(int nbHop, uint32_t bandwidth, uint32_t latency){
p2pDevices = pointToPoint.Install (curNodes);
Ipv4AddressHelper address;
- address.SetBase (("10.1."+std::to_string(i)+".0").c_str(), "255.255.255.0");
+ address.SetBase (("10."+std::to_string(i+1)+".0.0").c_str(), "255.255.0.0"); // Remember: 10.0.0.0 is used by WIFI
Ipv4InterfaceContainer p2pInterfaces;
p2pInterfaces = address.Assign (p2pDevices);
diff --git a/ns3-simulator/simulator b/ns3-simulator/simulator
index 0c7515e..81998b1 100755
--- a/ns3-simulator/simulator
+++ b/ns3-simulator/simulator
Binary files differ