mirror of
https://gitlab.com/manzerbredes/paper-lowrate-iot.git
synced 2025-04-19 04:09:43 +00:00
Start some simulation tests
This commit is contained in:
parent
1399886f4d
commit
a6e70544bb
37 changed files with 53416 additions and 5509 deletions
1
ns3-simulations/.#simulate.org
Symbolic link
1
ns3-simulations/.#simulate.org
Symbolic link
|
@ -0,0 +1 @@
|
|||
loic@lguegan.7447:1555309869
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -1,6 +0,0 @@
|
|||
node,energy
|
||||
0,1.00026
|
||||
1,2.00021
|
||||
2,2.00021
|
||||
3,2
|
||||
4,1
|
|
|
@ -1 +0,0 @@
|
|||
node,energy
|
|
|
@ -1,5 +0,0 @@
|
|||
0,1.00026
|
||||
1,2.00021
|
||||
2,2.00021
|
||||
3,2
|
||||
4,1
|
|
|
@ -1 +0,0 @@
|
|||
node,energy
|
|
|
@ -1 +0,0 @@
|
|||
node,energy
|
|
2558
ns3-simulations/logs/ns-3_1SSI_10SPS_0SN_2NH_10LB_10LL.org
Normal file
2558
ns3-simulations/logs/ns-3_1SSI_10SPS_0SN_2NH_10LB_10LL.org
Normal file
File diff suppressed because it is too large
Load diff
2558
ns3-simulations/logs/ns-3_1SSI_10SPS_10SN_2NH_10LB_10LL.org
Normal file
2558
ns3-simulations/logs/ns-3_1SSI_10SPS_10SN_2NH_10LB_10LL.org
Normal file
File diff suppressed because it is too large
Load diff
2558
ns3-simulations/logs/ns-3_1SSI_10SPS_11SN_2NH_10LB_10LL.org
Normal file
2558
ns3-simulations/logs/ns-3_1SSI_10SPS_11SN_2NH_10LB_10LL.org
Normal file
File diff suppressed because it is too large
Load diff
2558
ns3-simulations/logs/ns-3_1SSI_10SPS_12SN_2NH_10LB_10LL.org
Normal file
2558
ns3-simulations/logs/ns-3_1SSI_10SPS_12SN_2NH_10LB_10LL.org
Normal file
File diff suppressed because it is too large
Load diff
2558
ns3-simulations/logs/ns-3_1SSI_10SPS_13SN_2NH_10LB_10LL.org
Normal file
2558
ns3-simulations/logs/ns-3_1SSI_10SPS_13SN_2NH_10LB_10LL.org
Normal file
File diff suppressed because it is too large
Load diff
2558
ns3-simulations/logs/ns-3_1SSI_10SPS_14SN_2NH_10LB_10LL.org
Normal file
2558
ns3-simulations/logs/ns-3_1SSI_10SPS_14SN_2NH_10LB_10LL.org
Normal file
File diff suppressed because it is too large
Load diff
2558
ns3-simulations/logs/ns-3_1SSI_10SPS_15SN_2NH_10LB_10LL.org
Normal file
2558
ns3-simulations/logs/ns-3_1SSI_10SPS_15SN_2NH_10LB_10LL.org
Normal file
File diff suppressed because it is too large
Load diff
2558
ns3-simulations/logs/ns-3_1SSI_10SPS_16SN_2NH_10LB_10LL.org
Normal file
2558
ns3-simulations/logs/ns-3_1SSI_10SPS_16SN_2NH_10LB_10LL.org
Normal file
File diff suppressed because it is too large
Load diff
2558
ns3-simulations/logs/ns-3_1SSI_10SPS_17SN_2NH_10LB_10LL.org
Normal file
2558
ns3-simulations/logs/ns-3_1SSI_10SPS_17SN_2NH_10LB_10LL.org
Normal file
File diff suppressed because it is too large
Load diff
2558
ns3-simulations/logs/ns-3_1SSI_10SPS_18SN_2NH_10LB_10LL.org
Normal file
2558
ns3-simulations/logs/ns-3_1SSI_10SPS_18SN_2NH_10LB_10LL.org
Normal file
File diff suppressed because it is too large
Load diff
2558
ns3-simulations/logs/ns-3_1SSI_10SPS_19SN_2NH_10LB_10LL.org
Normal file
2558
ns3-simulations/logs/ns-3_1SSI_10SPS_19SN_2NH_10LB_10LL.org
Normal file
File diff suppressed because it is too large
Load diff
2558
ns3-simulations/logs/ns-3_1SSI_10SPS_1SN_2NH_10LB_10LL.org
Normal file
2558
ns3-simulations/logs/ns-3_1SSI_10SPS_1SN_2NH_10LB_10LL.org
Normal file
File diff suppressed because it is too large
Load diff
2558
ns3-simulations/logs/ns-3_1SSI_10SPS_20SN_2NH_10LB_10LL.org
Normal file
2558
ns3-simulations/logs/ns-3_1SSI_10SPS_20SN_2NH_10LB_10LL.org
Normal file
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
2558
ns3-simulations/logs/ns-3_1SSI_10SPS_3SN_2NH_10LB_10LL.org
Normal file
2558
ns3-simulations/logs/ns-3_1SSI_10SPS_3SN_2NH_10LB_10LL.org
Normal file
File diff suppressed because it is too large
Load diff
2558
ns3-simulations/logs/ns-3_1SSI_10SPS_4SN_2NH_10LB_10LL.org
Normal file
2558
ns3-simulations/logs/ns-3_1SSI_10SPS_4SN_2NH_10LB_10LL.org
Normal file
File diff suppressed because it is too large
Load diff
2558
ns3-simulations/logs/ns-3_1SSI_10SPS_5SN_2NH_10LB_10LL.org
Normal file
2558
ns3-simulations/logs/ns-3_1SSI_10SPS_5SN_2NH_10LB_10LL.org
Normal file
File diff suppressed because it is too large
Load diff
2558
ns3-simulations/logs/ns-3_1SSI_10SPS_6SN_2NH_10LB_10LL.org
Normal file
2558
ns3-simulations/logs/ns-3_1SSI_10SPS_6SN_2NH_10LB_10LL.org
Normal file
File diff suppressed because it is too large
Load diff
2558
ns3-simulations/logs/ns-3_1SSI_10SPS_7SN_2NH_10LB_10LL.org
Normal file
2558
ns3-simulations/logs/ns-3_1SSI_10SPS_7SN_2NH_10LB_10LL.org
Normal file
File diff suppressed because it is too large
Load diff
2558
ns3-simulations/logs/ns-3_1SSI_10SPS_8SN_2NH_10LB_10LL.org
Normal file
2558
ns3-simulations/logs/ns-3_1SSI_10SPS_8SN_2NH_10LB_10LL.org
Normal file
File diff suppressed because it is too large
Load diff
2558
ns3-simulations/logs/ns-3_1SSI_10SPS_9SN_2NH_10LB_10LL.org
Normal file
2558
ns3-simulations/logs/ns-3_1SSI_10SPS_9SN_2NH_10LB_10LL.org
Normal file
File diff suppressed because it is too large
Load diff
|
@ -4,6 +4,7 @@ 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)))))
|
||||
NS3_VERSION=$(shell cat ${NS3_PATH}/VERSION)
|
||||
|
||||
##### Source Files
|
||||
SRC=main.cc modules/platform.cc modules/energy.cc modules/callbacks.cc
|
||||
|
@ -11,10 +12,9 @@ SRC=main.cc modules/platform.cc modules/energy.cc modules/callbacks.cc
|
|||
|
||||
all: $(EXEC)
|
||||
|
||||
|
||||
$(EXEC): $(SRC)
|
||||
@echo -e "\e[32mDon't forget to define NS3_PATH env variable !\e[0m"
|
||||
g++ $(NS3_ARGS) $(SRC) -o $@
|
||||
g++ -D NS3_VERSION=${NS3_VERSION} $(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"
|
||||
|
||||
|
|
|
@ -37,12 +37,28 @@ int main(int argc, char* argv[]){
|
|||
// Don't forget the following
|
||||
Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
|
||||
|
||||
// Run Simulations
|
||||
uint32_t nNode=ns3::NodeList::GetNNodes();
|
||||
NS_LOG_UNCOND("Starting simulation with "<< nNode << " nodes");
|
||||
Simulator::Stop (Seconds (20));
|
||||
Simulator::Run ();
|
||||
Simulator::Destroy ();
|
||||
|
||||
// Setup Logs
|
||||
uint32_t nNode=ns3::NodeList::GetNNodes();
|
||||
FlowMonitorHelper flowmon;
|
||||
Ptr<FlowMonitor> monitor = flowmon.InstallAll();
|
||||
Ptr<Ipv4FlowClassifier> classifier = DynamicCast<Ipv4FlowClassifier> (flowmon.GetClassifier ());
|
||||
|
||||
// Run Simulations
|
||||
Simulator::Stop (Seconds (30));
|
||||
Simulator::Run ();
|
||||
|
||||
// Print logs
|
||||
NS_LOG_UNCOND("NS-3 Version " << NS3_VERSION);
|
||||
NS_LOG_UNCOND("Simulation used "<< nNode << " nodes");
|
||||
std::map<FlowId, FlowMonitor::FlowStats> stats = monitor->GetFlowStats ();
|
||||
for (std::map< FlowId, FlowMonitor::FlowStats>::iterator flow=stats.begin(); flow!=stats.end(); flow++)
|
||||
{
|
||||
Ipv4FlowClassifier::FiveTuple t = classifier->FindFlow(flow->first);
|
||||
NS_LOG_UNCOND("Flow " <<t.sourceAddress<< " -> "<< t.destinationAddress << " delay = " <<flow->second.delaySum.GetSeconds());
|
||||
}
|
||||
|
||||
// Finish
|
||||
Simulator::Destroy ();
|
||||
return(0);
|
||||
}
|
||||
|
|
|
@ -6,5 +6,11 @@ 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-oldValue << "J" << " at time " << Simulator::Now ().GetSeconds () << "s");
|
||||
double currentTime=Simulator::Now ().GetSeconds ();
|
||||
double energyConsumes=newValue-oldValue;
|
||||
NS_LOG_UNCOND("Node " << nodeName << " consumes " << energyConsumes << "J" << " at time " << currentTime << "s");
|
||||
|
||||
NS_LOG_UNCOND("Node " << nodeName << " newVal " << newValue << "J" << " at time " << currentTime << "s");
|
||||
NS_LOG_UNCOND("Node " << nodeName << " oldValue " << oldValue << "J" << " at time " << currentTime << "s");
|
||||
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "ns3/point-to-point-helper.h"
|
||||
#include "ns3/ecofen-module.h"
|
||||
#include "ns3/node-list.h"
|
||||
#include "ns3/flow-monitor-module.h"
|
||||
|
||||
// C++ library
|
||||
#include <iostream> // Why not ?
|
||||
|
@ -33,11 +34,11 @@
|
|||
#include <iomanip> // To use std::setw
|
||||
|
||||
// ECOFEN
|
||||
#define ECOFEN_LOG_UNTIL 1
|
||||
#define ECOFEN_LOG_UNTIL 100
|
||||
#define ECOFEN_LOG_EVERY 0.1
|
||||
|
||||
// WIFI Energy Values
|
||||
#define BASICENERGYSOURCEINITIALENERGYJ 1000
|
||||
#define BASICENERGYSOURCEINITIALENERGYJ 2.9009
|
||||
#define BASICENERGYSUPPLYVOLTAGEV 3.3
|
||||
#define TXCURRENTA 0.38
|
||||
#define RXCURRENTA 0.313
|
||||
|
|
Binary file not shown.
20
ns3-simulations/parseDelay.awk
Executable file
20
ns3-simulations/parseDelay.awk
Executable file
|
@ -0,0 +1,20 @@
|
|||
#!/bin/awk -f
|
||||
|
||||
BEGIN {
|
||||
delaySum=0
|
||||
delayCount=0
|
||||
}
|
||||
|
||||
/delay =/ {
|
||||
gsub("ns","",$7)
|
||||
gsub("+","",$7)
|
||||
delaySum+=$7
|
||||
delayCount+=1
|
||||
}
|
||||
|
||||
END {
|
||||
if(delayCount>0)
|
||||
print(delaySum/delayCount)
|
||||
else
|
||||
print(0)
|
||||
}
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
BEGIN {
|
||||
durationECOFEN=0
|
||||
sum=0
|
||||
}
|
||||
|
||||
# For ECOFEN energy model
|
||||
|
@ -20,11 +21,11 @@ BEGIN {
|
|||
# For WIFI ns-3 energy model
|
||||
/Node -?[0-9]+ consumes/ {
|
||||
gsub("J","",$4) # Remove trailling Joule symbol
|
||||
if (!($2 in energy)){
|
||||
if (!($2 in energyWIFI)){
|
||||
energyWIFI[$2]=$4
|
||||
}
|
||||
else {
|
||||
energyWIFI[$2]=$4+energyWIFI[$2]
|
||||
energyWIFI[$2]+=$4
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,23 +1,26 @@
|
|||
|
||||
|
||||
|
||||
|
||||
* Run simulations
|
||||
** Experiments
|
||||
*** Number of sensors
|
||||
#+BEGIN_SRC bash :noweb yes :results output
|
||||
<<singleRun>>
|
||||
for sensorsNumber in $(seq 0 20)
|
||||
do
|
||||
run
|
||||
done
|
||||
|
||||
#+END_SRC
|
||||
|
||||
#+RESULTS:
|
||||
|
||||
** Single Run
|
||||
#+BEGIN_SRC bash :noweb yes :results output
|
||||
<<singleRun>>
|
||||
run
|
||||
#+END_SRC
|
||||
|
||||
#+RESULTS:
|
||||
|
||||
|
||||
#+NAME: singleRun
|
||||
#+BEGIN_SRC bash :noweb yes
|
||||
simulator="ns3-simulator/simulator"
|
||||
parseEnergyScript="./parseEnergy.awk"
|
||||
parseDelayScript="./parseDelay.awk"
|
||||
logFolder="logs/"
|
||||
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${NS3_PATH}/build/lib
|
||||
run () {
|
||||
|
@ -33,12 +36,16 @@
|
|||
|
||||
# Compute some metrics
|
||||
energyLog=$(echo "$log" | $parseEnergyScript)
|
||||
avgDelay=$(echo "$log" | $parseDelayScript)
|
||||
totalEnergy=$(echo "$energyLog"| awk 'BEGIN{power=0;FS=","}NR!=1{power+=$2}END{print(power)}')
|
||||
nbPacketCloud=$(echo "$log"|grep -c "CloudSwitch receive")
|
||||
nbNodes=$(echo "$log"|awk '/Starting simul/{print($4)}')
|
||||
nbNodes=$(echo "$log"|awk '/Simulation used/{print($3)}')
|
||||
ns3Version=$(echo "$log"|awk '/NS-3 Version/{print($3)}')
|
||||
|
||||
# Save logs
|
||||
echo -e "#+TITLE: $(date) ns-3 simulation\n" > $logFile
|
||||
echo -e "#+TITLE: $(date) ns-3 (version ${ns3Version}) simulation\n" > $logFile
|
||||
echo "* Environment Variables" >> $logFile
|
||||
env >> $logFile
|
||||
echo "* Full Command" >> $logFile
|
||||
echo "$simCMD" >> $logFile
|
||||
echo "* Output" >> $logFile
|
||||
|
@ -46,7 +53,7 @@
|
|||
echo "* Energy CSV (negative nodeId = WIFI, 0 = AP (Wireless+Wired), positive nodeId = ECOFEN" >> $logFile
|
||||
echo "$energyLog" >> $logFile
|
||||
echo "* Metrics" >> $logFile
|
||||
echo " sensorsSendInterval:${sensorsSendInterval} sensorsPktSize:${sensorsPktSize} sensorsNumber:${sensorsNumber} nbHop:${nbHop} linksBandwidth:${linksBandwidth} linksLatency:${linksLatency} totalEnergy:$totalEnergy nbPacketCloud:$nbPacketCloud nbNodes:$nbNodes" >> $logFile
|
||||
echo "-METRICSLINE- sensorsSendInterval:${sensorsSendInterval} sensorsPktSize:${sensorsPktSize} sensorsNumber:${sensorsNumber} nbHop:${nbHop} linksBandwidth:${linksBandwidth} linksLatency:${linksLatency} totalEnergy:$totalEnergy nbPacketCloud:$nbPacketCloud nbNodes:$nbNodes avgDelay:${avgDelay} ns3Version:${ns3Version}" >> $logFile
|
||||
|
||||
}
|
||||
#+END_SRC
|
||||
|
@ -57,3 +64,30 @@
|
|||
: Processing logs/logs/log.txt.csv
|
||||
: Processing logs/logs/log.txt-energy.csv
|
||||
|
||||
* Logs Analysis
|
||||
** Log -> CSV
|
||||
#+NAME: logToCSV
|
||||
#+BEGIN_SRC bash :results none
|
||||
csvOutput="logs/data.csv"
|
||||
|
||||
# First save csv header line
|
||||
aLog=$(find logs/ -type f -name "*.org"|head -n 1)
|
||||
metrics=$(cat $aLog|grep "\-METRICSLINE\-"|sed "s/-METRICSLINE-//g")
|
||||
echo $metrics | awk '{for(i=1;i<=NF;i++){split($i,elem,":");printf(elem[1]);if(i<NF)printf(",");else{print("")}}}' > $csvOutput
|
||||
|
||||
# Second save all values
|
||||
for logFile in $(find logs/ -type f -name "*.org")
|
||||
do
|
||||
metrics=$(cat $logFile|grep "\-METRICSLINE\-"|sed "s/-METRICSLINE-//g")
|
||||
echo $metrics | awk '{for(i=1;i<=NF;i++){split($i,elem,":");printf(elem[2]);if(i<NF)printf(",");else{print("")}}}' >> $csvOutput
|
||||
done
|
||||
#+END_SRC
|
||||
** R Scripts
|
||||
*** Load Data
|
||||
#+BEGIN_SRC R
|
||||
print("lkj")
|
||||
#+END_SRC
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue