mirror of
https://gitlab.com/manzerbredes/paper-lowrate-iot.git
synced 2025-04-08 14:29:07 +00:00
Clean repo, update paper
This commit is contained in:
parent
4045a41e02
commit
5a77b67d6b
965 changed files with 678 additions and 15644411 deletions
|
@ -21,6 +21,21 @@
|
|||
\providecommand{\BIBdecl}{\relax}
|
||||
\BIBdecl
|
||||
|
||||
\bibitem{halperin_demystifying_nodate}
|
||||
D.~Halperin, B.~Greenstein, A.~Sheth, and D.~Wetherall,
|
||||
``\BIBforeignlanguage{en}{Demystifying 802.11n {Power} {Consumption}},''
|
||||
p.~5.
|
||||
|
||||
\bibitem{li_end--end_2018}
|
||||
\BIBentryALTinterwordspacing
|
||||
Y.~Li, A.-C. Orgerie, I.~Rodero, B.~L. Amersho, M.~Parashar, and J.-M. Menaud,
|
||||
``\BIBforeignlanguage{en}{End-to-end energy models for {Edge} {Cloud}-based
|
||||
{IoT} platforms: {Application} to data stream analysis in {IoT}},''
|
||||
\emph{\BIBforeignlanguage{en}{Future Generation Computer Systems}}, vol.~87,
|
||||
pp. 667--678, Oct. 2018. [Online]. Available:
|
||||
\url{https://linkinghub.elsevier.com/retrieve/pii/S0167739X17314309}
|
||||
\BIBentrySTDinterwordspacing
|
||||
|
||||
\bibitem{orgerie_ecofen:_2011}
|
||||
A.~C. Orgerie, L.~Lefèvre, I.~Guérin-Lassous, and D.~M.~L. Pacheco,
|
||||
``{ECOFEN}: {An} {End}-to-end energy {Cost} {mOdel} and simulator {For}
|
||||
|
@ -28,4 +43,10 @@ A.~C. Orgerie, L.~Lefèvre, I.~Guérin-Lassous, and D.~M.~L. Pacheco,
|
|||
{IEEE} {International} {Symposium} on a {World} of {Wireless}, {Mobile} and
|
||||
{Multimedia} {Networks}}, Jun. 2011, pp. 1--6.
|
||||
|
||||
\bibitem{cornea_studying_2014-1}
|
||||
B.~F. Cornea, A.~C. Orgerie, and L.~Lefèvre, ``Studying the energy consumption
|
||||
of data transfers in {Clouds}: the {Ecofen} approach,'' in \emph{2014 {IEEE}
|
||||
3rd {International} {Conference} on {Cloud} {Networking} ({CloudNet})}, Oct.
|
||||
2014, pp. 143--148.
|
||||
|
||||
\end{thebibliography}
|
||||
|
|
538
2019-Mascots.org
538
2019-Mascots.org
|
@ -2,9 +2,11 @@
|
|||
|
||||
#+EXPORT_EXCLUDE_TAGS: noexport
|
||||
#+STARTUP: hideblocks
|
||||
#+PROPERTY: header-args :eval no
|
||||
#+OPTIONS: H:5 author:nil email:nil creator:nil timestamp:nil skip:nil toc:nil ^:nil
|
||||
#+LATEX_CLASS: IEEEtran
|
||||
#+LATEX_HEADER: \usepackage{hyperref}
|
||||
#+LATEX_HEADER: \usepackage{booktabs}
|
||||
#+LATEX_HEADER: \IEEEoverridecommandlockouts
|
||||
#+LATEX_HEADER: \author{\IEEEauthorblockN{1\textsuperscript{st} Anne-Cécile Orgerie}
|
||||
#+LATEX_HEADER: \IEEEauthorblockA{\textit{Univ Rennes, Inria, CNRS, IRISA, Rennes, France} \\
|
||||
|
@ -35,6 +37,7 @@ component, formatting, style, styling, insert
|
|||
* Use-Case [1 col]
|
||||
** Application Characteristic
|
||||
|
||||
#+BEGIN_COMMENT
|
||||
The IoT part is composed of an Access Point (AP), connected to several sensors using WIFI. In the
|
||||
system, the IoT part is considered as the part where the system data are created. In fact, the
|
||||
data life cycle start when the sensors records their respective local temperature at a frequency
|
||||
|
@ -44,67 +47,72 @@ component, formatting, style, styling, insert
|
|||
|
||||
The network part is considered as the medium that link the IoT part to the cloud. It is composed
|
||||
of several network switches and router and it is considered to be a wired network.
|
||||
|
||||
|
||||
#+END_COMMENT
|
||||
|
||||
|
||||
** Cloud Infrastructure
|
||||
|
||||
* System Model [2 col]
|
||||
|
||||
The system model is divided in two parts. First, the IoT and the Network part are models through
|
||||
simulations. Then, the Cloud part is model using real servers connected to watt-meters. In this way,
|
||||
it is possible to evaluate the end-to-end energy consumption of the system.
|
||||
|
||||
** IoT Part
|
||||
In the first place, the IoT part is composed of several sensors connected to an AP which forms a
|
||||
cell. It is model using the ns-3 network simulator. Thus, we setup between 5 and 20 sensors
|
||||
connected to the AP using WIFI 5GHz 802.11n. The node are placed randomly in a square of 30
|
||||
meters around the AP which correspond to a typical real use case. All the nodes of the cell are
|
||||
setup with the default WIFI energy model provided by ns-3. The different energy values used by
|
||||
the energy model come from the literature and are provided on Table \ref{tab:wifi-energy}. Note
|
||||
that we suppose that the energy source of the cell nodes are unlimited and thus every nodes can
|
||||
communicate for all the simulation duration.
|
||||
cell. It is model using the ns-3 network simulator. Thus, we setup between 5 and 15 sensors
|
||||
connected to the AP using WIFI 5GHz 802.11n. The node are placed randomly in a rectangle of 400m2
|
||||
around the AP which correspond to a typical real use case. All the nodes of the cell are setup
|
||||
with the default WIFI energy model provided by ns-3. The different energy values used by the
|
||||
energy model are provided on Table \ref{tab:wifi-energy}. These energy were extracted from
|
||||
previous work\cite{halperin_demystifying_nodate,li_end--end_2018} on 802.11n. Note that we
|
||||
suppose that the energy source of the cell nodes are unlimited and thus every nodes can
|
||||
communicate until the end of all the simulations.
|
||||
|
||||
As a scenario, sensors send to the AP packets of 192 bits that include: \textbf{1)} A 128 bits
|
||||
sensors id \textbf{2)} A 32 bits integer representing the temperature \textbf{3)} An integer
|
||||
timestamp representing the temperature sensing time. The data are transmitted immediately at each
|
||||
sensing interval $I$ varied from 1s to 60s. Finally, the AP is in charge to relay data to the
|
||||
sensing interval $I$ varied from 1s to 60s. Finally, the AP is in charge of relaying data to the
|
||||
cloud using the network part.
|
||||
|
||||
|
||||
#+BEGIN_EXPORT latex
|
||||
\begin{table}[]
|
||||
\centering
|
||||
\caption{Wifi Energy Settings}
|
||||
\label{tab:wifi-energy}
|
||||
\begin{tabular}{|l|l|l|}
|
||||
\hline
|
||||
& Value & Reference(s) \\ \hline
|
||||
Supply Voltage & 3.3V & TODO \\ \hline
|
||||
Tx & 0.38A & TODO \\ \hline
|
||||
Rx & 0.313A & TODO \\ \hline
|
||||
Idle & 0.273A & TODO \\ \hline
|
||||
\end{tabular}
|
||||
\end{table}
|
||||
\centering
|
||||
\caption{Wifi Energy Values}
|
||||
\label{tab:wifi-energy}
|
||||
\begin{tabular}{@{}lr@{}}
|
||||
Parameter & Value \\ \midrule
|
||||
Supply Voltage & 3.3V \\
|
||||
Tx & 0.38A \\
|
||||
Rx & 0.313A \\
|
||||
Idle & 0.273A \\ \bottomrule
|
||||
\end{tabular}
|
||||
\end{table}
|
||||
#+END_EXPORT
|
||||
|
||||
|
||||
** Network Part
|
||||
The network part represents the network starting from the AP to the Cloud excluding the server.
|
||||
It is also model into ns-3. We consider the server to be 9 hops aways from the AP with a typical
|
||||
round-trip latency of 100ms from the AP to the server. ECOFEN \cite{orgerie_ecofen:_2011} is used
|
||||
to model the energy consumption of the network part. ECOFEN is a ns-3 network energy module for
|
||||
ns-3 dedicated to wired network energy estimation. The different energy values used in the
|
||||
network part are from the literature and shown in Table \ref{tab:net-energy}.
|
||||
round-trip latency of 100ms from the AP to the server. Each node from the AP to the Cloud is
|
||||
assume to be network switches with static and dynamic network energy consumption. ECOFEN
|
||||
\cite{orgerie_ecofen:_2011} is used to model the energy consumption of the network part. ECOFEN
|
||||
is a ns-3 network energy module for ns-3 dedicated to wired network energy estimation. It is
|
||||
based on an energy-per-bit model including static consumption by assuming a linear relation
|
||||
between the amount of data sent to the network interface and the power consumption. The different
|
||||
energy values used to instanciate the ECOFEN energy model for the network part are shown in Table
|
||||
\ref{tab:net-energy} and come from previous work \cite{cornea_studying_2014-1}.
|
||||
|
||||
#+BEGIN_EXPORT latex
|
||||
\begin{table}[]
|
||||
\centering
|
||||
\caption{Network Part Energy Settings}
|
||||
\label{tab:net-energy}
|
||||
\begin{tabular}{|l|l|l|}
|
||||
\hline
|
||||
& Value & Reference(s) \\ \hline
|
||||
Idle & 1J & TODO \\ \hline
|
||||
Bytes (Tx/Rx) & 3.4nJ & TODO \\ \hline
|
||||
Pkt (Tx/Rx) & 192.0nJ & TODO \\ \hline
|
||||
\begin{tabular}{@{}lr@{}}
|
||||
Parameter & Value \\ \midrule
|
||||
Idle & 1J \\
|
||||
Bytes (Tx/Rx) & 3.4nJ \\
|
||||
Pkt (Tx/Rx) & 192.0nJ \\ \bottomrule
|
||||
\end{tabular}
|
||||
\end{table}
|
||||
#+END_EXPORT
|
||||
|
@ -113,8 +121,16 @@ component, formatting, style, styling, insert
|
|||
Finally, to measure the energy consumption of the server, we used real server from the
|
||||
large-scale test-beds Grid5000 (G5K). In fact, G5K has a cluster called Nova composed of several
|
||||
nodes which are connected to watt-meters. In this way, we can benefit from real energy
|
||||
measurements. The server is configured to use KVM for virtualization. Virtual Machines (VM)
|
||||
measurements. The server used in the experiment is composed of Intel Xeon E5-2620 processor with
|
||||
64 GB of RAM and 600GB of disk space on a Linux based distribution. This server is configured to
|
||||
use KVM as virtualization mechanism. We deploy a classical Linux x86_64 disctribution on the
|
||||
Virtual Machines (VM) along with a MySQL database. We different amount of allocated memory for
|
||||
the VM namely 1024MB/2048MB/4096MB to highlight its effects on the server energy consumption.
|
||||
|
||||
The sensors requests are simulated using another server. This server is in charge to send hundred
|
||||
of requests to the VM in order to fill the database. Consequently, it is easy to vary the
|
||||
different requests characteristics namely: \textbf{1)} The number request, to virtually
|
||||
add/remove sensors \textbf{2)} The requests frequency.
|
||||
|
||||
* Evaluation [3 col]
|
||||
** IoT/Network Consumption
|
||||
|
@ -129,9 +145,463 @@ component, formatting, style, styling, insert
|
|||
\bibliographystyle{IEEEtran}
|
||||
\bibliography{references}
|
||||
|
||||
|
||||
* Data Provenance :noexport:
|
||||
|
||||
** Data Analysis
|
||||
*** NS3
|
||||
To Generate all the plots, please execute the following line:
|
||||
#+NAME: runAnalysis
|
||||
#+CALL: plotToPDF(plots=genAllPlots(data=NS3-logToCSV()))
|
||||
|
||||
#+RESULTS: runAnalysis
|
||||
|
||||
**** R Scripts
|
||||
***** Generate all plots script
|
||||
Available variables:
|
||||
|---------------------|
|
||||
| Name |
|
||||
|---------------------|
|
||||
| sensorsSendInterval |
|
||||
| sensorsPktSize |
|
||||
| sensorsNumber |
|
||||
| nbHop |
|
||||
| linksBandwidth |
|
||||
| linksLatency |
|
||||
| totalEnergy |
|
||||
| nbPacketCloud |
|
||||
| nbNodes |
|
||||
| avgDelay |
|
||||
| simKey |
|
||||
|---------------------|
|
||||
|
||||
#+NAME: genAllPlots
|
||||
#+BEGIN_SRC R :noweb yes :results output
|
||||
<<NS3-RUtils>>
|
||||
data=read_csv("logs/ns3/last/data.csv")
|
||||
# easyPlotGroup("linksLatency","totalEnergy", "LATENCY","sensorsNumber")
|
||||
# easyPlotGroup("linksBandwidth","totalEnergy", "BW","sensorsNumber")
|
||||
easyPlot("sensorsNumber","totalEnergy", "NBSENSORS")
|
||||
easyPlotGroup("positionSeed", "totalEnergy","SENSORSPOS","sensorsNumber")
|
||||
easyPlotGroup("positionSeed", "avgDelay","SENSORSPOS","sensorsNumber")
|
||||
easyPlotGroup("sensorsSendInterval","sensorsEnergy","SENDINTERVAL","sensorsNumber")
|
||||
easyPlotGroup("sensorsSendInterval","networkEnergy","SENDINTERVAL","sensorsNumber")
|
||||
|
||||
#+END_SRC
|
||||
|
||||
#+RESULTS: genAllPlots
|
||||
|
||||
***** R Utils
|
||||
RUtils is intended to load logs (data.csv) and providing
|
||||
simple plot function for them.
|
||||
|
||||
#+NAME: NS3-RUtils
|
||||
#+BEGIN_SRC R :eval never
|
||||
library("tidyverse")
|
||||
|
||||
# Fell free to update the following
|
||||
labels=c(nbNodes="Number of nodes",sensorsNumber="Number of sensors",totalEnergy="Total Energy (J)",
|
||||
nbHop="Number of hop (AP to Cloud)", linksBandwidth="Links Bandwidth (Mbps)", avgDelay="Average Application Delay (s)",
|
||||
linksLatency="Links Latency (ms)", sensorsSendInterval="Sensors Send Interval (s)", positionSeed="Position Seed",
|
||||
sensorsEnergy="Sensors Wifi Energy Consumption (J)", networkEnergy="Network Energy Consumption (J)")
|
||||
|
||||
# Get label according to varName
|
||||
getLabel=function(varName){
|
||||
if(is.na(labels[varName])){
|
||||
return(varName)
|
||||
}
|
||||
return(labels[varName])
|
||||
}
|
||||
|
||||
easyPlot=function(X,Y,KEY){
|
||||
curData=data%>%filter(simKey==KEY)
|
||||
stopifnot(NROW(curData)>0)
|
||||
ggplot(curData,aes_string(x=X,y=Y))+geom_point()+geom_line()+xlab(getLabel(X))+ylab(getLabel(Y))
|
||||
ggsave(paste0("plots/",KEY,"-",X,"_",Y,".png"))
|
||||
}
|
||||
|
||||
easyPlotGroup=function(X,Y,KEY,GRP){
|
||||
curData=data%>%filter(simKey==KEY) %>% mutate(!!GRP:=as.character(UQ(rlang::sym(GRP)))) # %>%mutate(sensorsNumber=as.character(sensorsNumber))
|
||||
stopifnot(NROW(curData)>0)
|
||||
ggplot(curData,aes_string(x=X,y=Y,color=GRP,group=GRP))+geom_point()+geom_line()+xlab(getLabel(X))+ylab(getLabel(Y)) + labs(color = getLabel(GRP))
|
||||
ggsave(paste0("plots/",KEY,"-",X,"_",Y,".png"))
|
||||
}
|
||||
#+END_SRC
|
||||
|
||||
**** Plots -> PDF
|
||||
Merge all plots in plots/ folder into a pdf file.
|
||||
#+NAME: plotToPDF
|
||||
#+BEGIN_SRC bash :results output :noweb yes
|
||||
orgFile="plots/plots.org"
|
||||
<<singleRun>> # To get all default arguments
|
||||
|
||||
# Write helper function
|
||||
function write {
|
||||
echo "$1" >> $orgFile
|
||||
}
|
||||
|
||||
echo "#+TITLE: Analysis" > $orgFile
|
||||
write "#+LATEX_HEADER: \usepackage{fullpage}"
|
||||
write "#+OPTIONS: toc:nil"
|
||||
# Default arguments
|
||||
write '\begin{center}'
|
||||
write '\begin{tabular}{lr}'
|
||||
write 'Parameters & Values\\'
|
||||
write '\hline'
|
||||
write "sensorsPktSize & ${sensorsPktSize} bytes\\\\"
|
||||
write "sensorsSendInterval & ${sensorsSendInterval}s\\\\"
|
||||
write "sensorsNumber & ${sensorsNumber}\\\\"
|
||||
write "nbHop & ${nbHop}\\\\"
|
||||
write "linksBandwidth & ${linksBandwidth}Mbps\\\\"
|
||||
write "linksLatency & ${linksLatency}ms\\\\"
|
||||
write '\end{tabular}'
|
||||
write '\newline'
|
||||
write '\end{center}'
|
||||
|
||||
for plot in $(find plots/ -type f -name "*.png")
|
||||
do
|
||||
write "\includegraphics[width=0.5\linewidth]{$(basename ${plot})}"
|
||||
done
|
||||
|
||||
# Export to pdf
|
||||
emacs $orgFile --batch -f org-latex-export-to-pdf --kill
|
||||
#+END_SRC
|
||||
|
||||
#+RESULTS:
|
||||
|
||||
**** Log -> CSV
|
||||
logToCSV extract usefull data from logs and put them into logs/data.csv.
|
||||
|
||||
#+NAME: NS3-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
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
**** Custom Plots
|
||||
|
||||
#+NAME: ssiNet
|
||||
#+BEGIN_SRC R :noweb yes :results graphics :file plots/sensorsSendInterval-net.png
|
||||
<<NS3-RUtils>>
|
||||
# Load Data
|
||||
data=read_csv("logs/ns3/last/data.csv")
|
||||
|
||||
data%>%filter(simKey=="SENDINTERVAL",sensorsNumber==20) %>% ggplot(aes(x=sensorsSendInterval,y=networkEnergy))+xlab(getLabel("sensorsSendInterval"))+ylab(getLabel("networkEnergy"))+
|
||||
geom_line()+labs(title="For 20 sensors")
|
||||
ggsave("plots/sensorsSendInterval-net.png",dpi=80)
|
||||
#+END_SRC
|
||||
|
||||
|
||||
#+NAME: ssiWifi
|
||||
#+BEGIN_SRC R :noweb yes :results graphics :file plots/sensorsSendInterval-wifi.png
|
||||
<<NS3-RUtils>>
|
||||
data=read_csv("logs/ns3/last/data.csv")
|
||||
data%>%filter(simKey=="SENDINTERVAL",sensorsNumber==20) %>% ggplot(aes(x=sensorsSendInterval,y=sensorsEnergy))+xlab(getLabel("sensorsSendInterval"))+ylab(getLabel("sensorsEnergy"))+
|
||||
geom_line() + geom_line()+labs(title="For 20 sensors")
|
||||
ggsave("plots/sensorsSendInterval-wifi.png",dpi=80)
|
||||
#+END_SRC
|
||||
|
||||
|
||||
#+BEGIN_SRC R :results graphics :noweb yes :file plot-final.png :session *R*
|
||||
<<NS3-RUtils>>
|
||||
simTime=1800
|
||||
|
||||
# Network
|
||||
data=read_csv("logs/ns3/last/data.csv")
|
||||
data=data%>%filter(simKey=="NBSENSORS")
|
||||
dataC5=data%>%filter(sensorsNumber==5)%>% mutate(energy=networkEnergy/simTime) %>%select(energy,sensorsNumber)
|
||||
dataC10=data%>%filter(sensorsNumber==10)%>%mutate(energy=networkEnergy/simTime) %>%select(energy,sensorsNumber)
|
||||
dataNet=rbind(dataC5,dataC10)%>%mutate(type="Network")
|
||||
|
||||
# Network
|
||||
dataS5=data%>%filter(sensorsNumber==5)%>% mutate(energy=sensorsEnergy/simTime) %>%select(energy,sensorsNumber)
|
||||
dataS10=data%>%filter(sensorsNumber==10)%>%mutate(energy=sensorsEnergy/simTime) %>%select(energy,sensorsNumber)
|
||||
dataS=rbind(dataS5,dataS10)%>%mutate(type="Sensors")
|
||||
|
||||
data=rbind(dataNet,dataS)%>%mutate(sensorsNumber=as.character(sensorsNumber))
|
||||
|
||||
ggplot(data)+geom_bar(aes(x=sensorsNumber,y=energy,fill=type),stat="identity")+xlab("Sensors Number")+ylab("Power Consumption (W)")+guides(fill=guide_legend(title="Part"))
|
||||
ggsave("plot-final.png",dpi=80)
|
||||
|
||||
#+END_SRC
|
||||
|
||||
|
||||
*** Cloud
|
||||
**** R Scripts
|
||||
***** Plots script
|
||||
#+BEGIN_SRC R :results output :noweb yes :file second-final/plot.png
|
||||
<<RUtils>>
|
||||
dataOrig=loadData("./second-final/data.csv")
|
||||
|
||||
data=dataOrig%>%filter(simKey=="nbSensors")%>%filter(state=="sim",nbSensors==100)
|
||||
dataIDLE=dataOrig%>%filter(simKey=="nbSensors")%>%filter(state!="sim",nbSensors==100)
|
||||
data=data%>%mutate(meanEnergy=mean(energy))
|
||||
dataIDLE=dataIDLE%>%mutate(meanEnergy=mean(energy))
|
||||
data=rbind(data,dataIDLE)
|
||||
ggplot(data,aes(x=time,y=energy))+geom_point(position="jitter")+xlab(getLabel("time"))+expand_limits(y=0)+facet_wrap(~state)+geom_hline(aes(color=state,yintercept=mean(meanEnergy)))
|
||||
ggsave("./second-final/plot.png",dpi=180)
|
||||
#+END_SRC
|
||||
|
||||
#+RESULTS:
|
||||
#+begin_example
|
||||
# A tibble: 3,050 x 8
|
||||
ts energy simKey vmSize nbSensors time state meanEnergy
|
||||
<dbl> <dbl> <chr> <dbl> <dbl> <dbl> <chr> <dbl>
|
||||
1 1558429001. 90.2 nbSensors 2048 100 0 IDLE 90.8
|
||||
2 1558429001. 89 nbSensors 2048 100 0.0199 IDLE 90.8
|
||||
3 1558429001. 89 nbSensors 2048 100 0.0399 IDLE 90.8
|
||||
4 1558429001. 90.8 nbSensors 2048 100 0.0599 IDLE 90.8
|
||||
5 1558429001. 91 nbSensors 2048 100 0.0799 IDLE 90.8
|
||||
6 1558429001. 90.5 nbSensors 2048 100 0.1000 IDLE 90.8
|
||||
7 1558429001. 89.9 nbSensors 2048 100 0.120 IDLE 90.8
|
||||
8 1558429001. 88.6 nbSensors 2048 100 0.140 IDLE 90.8
|
||||
9 1558429001. 88.6 nbSensors 2048 100 0.160 IDLE 90.8
|
||||
10 1558429001. 90.5 nbSensors 2048 100 0.180 IDLE 90.8
|
||||
# … with 3,040 more rows
|
||||
#+end_example
|
||||
|
||||
|
||||
|
||||
****** Custom Plots
|
||||
|
||||
#+NAME: ssiNet
|
||||
#+BEGIN_SRC R :noweb yes :results graphics :file plots/sensorsSendInterval-net.png
|
||||
<<RUtils>>
|
||||
|
||||
data%>%filter(simKey=="SENDINTERVAL",sensorsNumber==20) %>% ggplot(aes(x=sensorsSendInterval,y=networkEnergy))+xlab(getLabel("sensorsSendInterval"))+ylab(getLabel("networkEnergy"))+
|
||||
geom_line()+labs(title="For 20 sensors")
|
||||
ggsave("plots/sensorsSendInterval-net.png",dpi=80)
|
||||
#+END_SRC
|
||||
|
||||
#+RESULTS:
|
||||
[[file:plots/sensorsSendInterval-net.png]]
|
||||
|
||||
|
||||
#+NAME: ssiWifi
|
||||
#+BEGIN_SRC R :noweb yes :results graphics :file plots/sensorsSendInterval-wifi.png
|
||||
<<RUtils>>
|
||||
data%>%filter(simKey=="SENDINTERVAL",sensorsNumber==20) %>% ggplot(aes(x=sensorsSendInterval,y=sensorsEnergy))+xlab(getLabel("sensorsSendInterval"))+ylab(getLabel("sensorsEnergy"))+
|
||||
geom_line() + geom_line()+labs(title="For 20 sensors")
|
||||
ggsave("plots/sensorsSendInterval-wifi.png",dpi=80)
|
||||
#+END_SRC
|
||||
|
||||
#+RESULTS: ssiWifi
|
||||
[[file:plots/sensorsSendInterval-wifi.png]]
|
||||
|
||||
#+RESULTS:
|
||||
[[file:plots/sensorsSendInterval.png]]
|
||||
|
||||
|
||||
***** R Utils
|
||||
RUtils is intended to load logs (data.csv) and providing
|
||||
simple plot function for them.
|
||||
|
||||
#+NAME: G5K-RUtils
|
||||
#+BEGIN_SRC R :eval never
|
||||
library("tidyverse")
|
||||
|
||||
# Fell free to update the following
|
||||
labels=c(time="Time (s)")
|
||||
|
||||
loadData=function(path){
|
||||
data=read_csv(path)
|
||||
}
|
||||
|
||||
# Get label according to varName
|
||||
getLabel=function(varName){
|
||||
if(is.na(labels[varName])){
|
||||
return(varName)
|
||||
}
|
||||
return(labels[varName])
|
||||
}
|
||||
#+END_SRC
|
||||
|
||||
**** Plots -> PDF
|
||||
Merge all plots in plots/ folder into a pdf file.
|
||||
#+NAME: plotToPDF
|
||||
#+BEGIN_SRC bash :results output :noweb yes
|
||||
orgFile="plots/plots.org"
|
||||
<<singleRun>> # To get all default arguments
|
||||
|
||||
# Write helper function
|
||||
function write {
|
||||
echo "$1" >> $orgFile
|
||||
}
|
||||
|
||||
echo "#+TITLE: Analysis" > $orgFile
|
||||
write "#+LATEX_HEADER: \usepackage{fullpage}"
|
||||
write "#+OPTIONS: toc:nil"
|
||||
# Default arguments
|
||||
write '\begin{center}'
|
||||
write '\begin{tabular}{lr}'
|
||||
write 'Parameters & Values\\'
|
||||
write '\hline'
|
||||
write "sensorsPktSize & ${sensorsPktSize} bytes\\\\"
|
||||
write "sensorsSendInterval & ${sensorsSendInterval}s\\\\"
|
||||
write "sensorsNumber & ${sensorsNumber}\\\\"
|
||||
write "nbHop & ${nbHop}\\\\"
|
||||
write "linksBandwidth & ${linksBandwidth}Mbps\\\\"
|
||||
write "linksLatency & ${linksLatency}ms\\\\"
|
||||
write '\end{tabular}'
|
||||
write '\newline'
|
||||
write '\end{center}'
|
||||
|
||||
for plot in $(find plots/ -type f -name "*.png")
|
||||
do
|
||||
write "\includegraphics[width=0.5\linewidth]{$(basename ${plot})}"
|
||||
done
|
||||
|
||||
# Export to pdf
|
||||
emacs $orgFile --batch -f org-latex-export-to-pdf --kill
|
||||
#+END_SRC
|
||||
|
||||
**** CSVs -> CSV
|
||||
Merge all energy file into one (and add additional fields).
|
||||
|
||||
#+NAME: G5K-mergeCSV
|
||||
#+BEGIN_SRC sh
|
||||
#!/bin/bash
|
||||
|
||||
whichLog="second-final"
|
||||
|
||||
|
||||
logFile="$(dirname $(readlink -f $0))"/$whichLog/simLogs.txt
|
||||
dataFile=$(dirname "$logFile")/data.csv
|
||||
|
||||
|
||||
getValue () {
|
||||
line=$(echo "$1" | grep "Simulation para"|sed "s/Simulation parameters: //g")
|
||||
key=$2
|
||||
echo "$line"|awk 'BEGIN{RS=" ";FS=":"}"'$key'"==$1{gsub("\n","",$0);print $2}'
|
||||
}
|
||||
|
||||
##### Add extract info to energy #####
|
||||
IFS=$'\n'
|
||||
for cmd in $(cat $logFile|grep "Simulation parameters")
|
||||
do
|
||||
nodeName=$(getValue $cmd serverNodeName)
|
||||
from=$(getValue $cmd simStart)
|
||||
to=$(getValue $cmd simEnd)
|
||||
vmSize=$(getValue $cmd vmSize)
|
||||
nbSensors=$(getValue $cmd nbSensors)
|
||||
simKey=$(getValue $cmd simKey)
|
||||
csvFile="$whichLog/${simKey}_${vmSize}VMSIZE_${nbSensors}NBSENSORS_${from}${to}.csv"
|
||||
csvFileIDLE="$whichLog/${simKey}_${vmSize}VMSIZE_${nbSensors}NBSENSORS_${from}${to}_IDLE.csv"
|
||||
tmpFile=${csvFile}_tmp
|
||||
echo ts,energy,simKey,vmSize,nbSensors,time,state > $tmpFile
|
||||
minTs=$(tail -n+2 $csvFile|awk -F"," 'BEGIN{min=0}$1<min||min==0{min=$1}END{print(min)}') # To compute ts field
|
||||
minTsIDLE=$(tail -n+2 $csvFileIDLE|awk -F"," 'BEGIN{min=0}$1<min||min==0{min=$1}END{print(min)}') # To compute ts field
|
||||
tail -n+2 ${csvFile} | awk -F"," '{print $0",'$simKey','$vmSize','$nbSensors',"$1-'$minTs'",sim"}' >> $tmpFile
|
||||
tail -n+2 ${csvFileIDLE} | awk -F"," '{print $0",'$simKey','$vmSize','$nbSensors',"$1-'$minTsIDLE'",IDLE"}' >> $tmpFile
|
||||
done
|
||||
|
||||
|
||||
##### Fill dataFile #####
|
||||
echo ts,energy,simKey,vmSize,nbSensors,time,state > $dataFile
|
||||
for tmpFile in $(find ${whichLog}/*_tmp -type f)
|
||||
do
|
||||
tail -n+2 $tmpFile >> $dataFile
|
||||
rm $tmpFile # Pay attention to this line :D
|
||||
done
|
||||
#+END_SRC
|
||||
|
||||
#+RESULTS: mergeCSV
|
||||
*** Final Plots
|
||||
|
||||
|
||||
#+BEGIN_SRC R :noweb yes :results graphics :file plots/final.png :session *R*
|
||||
library("tidyverse")
|
||||
|
||||
# Load data
|
||||
data=read_csv("./logs/g5k/second-final/data.csv")
|
||||
data=data%>%filter(state=="sim",simKey=="nbSensors")
|
||||
|
||||
# Cloud
|
||||
data10=data%>%filter(nbSensors==20)%>%mutate(energy=mean(energy)) %>% slice(1L)
|
||||
data100=data%>%filter(nbSensors==100)%>%mutate(energy=mean(energy)) %>% slice(1L)
|
||||
data300=data%>%filter(nbSensors==300)%>%mutate(energy=mean(energy)) %>% slice(1L)
|
||||
dataCloud=rbind(data10,data100,data300)%>%mutate(sensorsNumber=nbSensors)%>%mutate(type="Cloud")%>%select(sensorsNumber,energy,type)
|
||||
|
||||
|
||||
|
||||
approx=function(data1, data2,nbSensors){
|
||||
x1=data1$sensorsNumber
|
||||
y1=data1$energy
|
||||
|
||||
x2=data2$sensorsNumber
|
||||
y2=data2$energy
|
||||
|
||||
a=((y2-y1)/(x2-x1))
|
||||
b=y1-a*x1
|
||||
|
||||
return(a*nbSensors+b)
|
||||
|
||||
}
|
||||
|
||||
|
||||
simTime=1800
|
||||
|
||||
# Network
|
||||
data=read_csv("./logs/ns3/last/data.csv")
|
||||
data=data%>%filter(simKey=="NBSENSORS")
|
||||
dataC5=data%>%filter(sensorsNumber==5)%>% mutate(energy=networkEnergy/simTime) %>%select(energy,sensorsNumber)
|
||||
dataC10=data%>%filter(sensorsNumber==10)%>%mutate(energy=networkEnergy/simTime) %>%select(energy,sensorsNumber)
|
||||
dataNet=rbind(dataC5,dataC10)%>%mutate(type="Network")
|
||||
|
||||
# Sensors
|
||||
dataS5=data%>%filter(sensorsNumber==5)%>% mutate(energy=sensorsEnergy/simTime) %>%select(energy,sensorsNumber)
|
||||
dataS10=data%>%filter(sensorsNumber==10)%>%mutate(energy=sensorsEnergy/simTime) %>%select(energy,sensorsNumber)
|
||||
dataS=rbind(dataS5,dataS10)%>%mutate(type="Sensors")
|
||||
|
||||
fakeNetS=tibble(
|
||||
sensorsNumber=c(20,100,300,20,100,300),
|
||||
energy=c(dataC10$energy,approx(dataC5,dataC10,100),approx(dataC5,dataC10,300),dataS10$energy,approx(dataS5,dataS10,100),approx(dataS5,dataS10,300)),
|
||||
type=c("Network","Network","Network","Sensors","Sensors","Sensors")
|
||||
)
|
||||
|
||||
fakeNetS=fakeNetS%>%mutate(sensorsNumber=as.character(sensorsNumber))
|
||||
dataCloud=dataCloud%>%mutate(sensorsNumber=as.character(sensorsNumber))
|
||||
|
||||
data=rbind(fakeNetS,dataCloud)%>%mutate(sensorsNumber=as.character(sensorsNumber))
|
||||
|
||||
|
||||
data=data%>%mutate(sensorsNumber=fct_reorder(sensorsNumber,as.numeric(sensorsNumber)))
|
||||
|
||||
ggplot(data)+geom_bar(position="dodge2",colour="black",aes(x=sensorsNumber,y=energy,fill=type),stat="identity")+
|
||||
xlab("Sensors Number")+ylab("Power Consumption (W)")+guides(fill=guide_legend(title="Part"))
|
||||
ggsave("plots/final.png",dpi=80)
|
||||
|
||||
#+END_SRC
|
||||
|
||||
#+RESULTS:
|
||||
[[file:plots/final.png]]
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
* Emacs settings :noexport:
|
||||
# Local Variables:
|
||||
# eval: (unless (boundp 'org-latex-classes) (setq org-latex-classes nil))
|
||||
# eval: (add-to-list 'org-latex-classes
|
||||
# '("IEEEtran" "\\documentclass[conference]{IEEEtran}\n \[NO-DEFAULT-PACKAGES]\n \[EXTRA]\n" ("\\section{%s}" . "\\section*{%s}") ("\\subsection{%s}" . "\\subsection*{%s}") ("\\subsubsection{%s}" . "\\subsubsection*{%s}") ("\\paragraph{%s}" . "\\paragraph*{%s}") ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
|
||||
# End:
|
||||
|
||||
|
||||
|
||||
|
|
BIN
2019-Mascots.pdf
BIN
2019-Mascots.pdf
Binary file not shown.
|
@ -1 +0,0 @@
|
|||
## OAR [2019-05-16 15:38:38] Job 1028994 KILLED ##
|
|
@ -1,48 +0,0 @@
|
|||
#!/usr/bin/python
|
||||
from __future__ import division
|
||||
import os,sys,random, time,datetime
|
||||
from subprocess import Popen
|
||||
|
||||
# Check script argument
|
||||
if len(sys.argv) != 6:
|
||||
print("Usage: "+sys.argv[0]+" <mysqlServerIp> <nbSensors> <nbSensorsFactor> <requestPerSensor> <sendInterval>")
|
||||
exit(1)
|
||||
|
||||
# Init script parameters
|
||||
serverIp=sys.argv[1]
|
||||
nbSensors=int(sys.argv[2])
|
||||
nbSensorsFactor=int(sys.argv[3])
|
||||
effectiveNbSensors=nbSensors*nbSensorsFactor
|
||||
requestPerSensor=int(sys.argv[4])
|
||||
sendInterval=int(sys.argv[5])
|
||||
avgSiteTemp=list()
|
||||
for i in range(0,effectiveNbSensors):
|
||||
avgSiteTemp.append(random.randint(-10,30))
|
||||
|
||||
|
||||
def insert(sensorId, value):
|
||||
""" Send value of sensorId into the database """
|
||||
stamp=int(time.mktime(datetime.datetime.today().timetuple()))
|
||||
insertCMD = "mysql -u user --password=mysql --host="+serverIp+" experiment -e"
|
||||
insertCMD=insertCMD.split()
|
||||
insertCMD.append("INSERT INTO temperature (id,stamp,val) VALUES("+str(sensorId)+","+str(stamp)+","+str(value)+");")
|
||||
Popen(insertCMD) # Run command asynchronously
|
||||
|
||||
def send():
|
||||
""" Send temperature of each sensors into the database """
|
||||
for i in range(0,effectiveNbSensors):
|
||||
insert(i,random.gauss(avgSiteTemp[i], 3))
|
||||
|
||||
|
||||
# Print infos
|
||||
print("Launching clients with:")
|
||||
print(" - Mysql Server IP {:>20}".format(serverIp))
|
||||
print(" - Number of sensors {:>18}".format(effectiveNbSensors))
|
||||
print(" - Number of request per sensor {:>7}".format(effectiveNbSensors))
|
||||
|
||||
# Send data
|
||||
for i in range(0, requestPerSensor):
|
||||
send()
|
||||
time.sleep(sendInterval) # We assume send() take no time
|
||||
|
||||
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -1,153 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
##### Parameters #####
|
||||
if [ -z ${nbSensors+x} ] # If nbSensors exists, so all parameters are already define
|
||||
then
|
||||
delay=60 # Delay before starting simulation (let CPU energy going down on the server)
|
||||
nbSensors=30 # Number of sensors that will send request to de server
|
||||
nbSensorsFactor=3 # nbSensors*nbSensorFactor
|
||||
simulationTime=300 # Approximative
|
||||
sensorsSendInterval=10 # Delay between sensors requests
|
||||
vmSize=2048 # Number of alocated ram
|
||||
simKey="NONE"
|
||||
fi
|
||||
nHours=3 # Reservation dutation
|
||||
requestPerSensor=$(( simulationTime / sensorsSendInterval )) # Theorical simulation time is $requestPerSensor*$sensorsSendInterval
|
||||
######################
|
||||
|
||||
|
||||
logFile="./simLogs.txt"
|
||||
log () {
|
||||
echo -e "\033[0;34m$@\033[0m"
|
||||
}
|
||||
|
||||
sshWait () {
|
||||
log "Waiting for for an ssh connection to a vm ($1)"
|
||||
error=255
|
||||
until [ $error -eq 0 ]
|
||||
do
|
||||
ssh -q root@$1 echo "Connected to $(hostname)"
|
||||
error=$?
|
||||
sleep 4
|
||||
done
|
||||
}
|
||||
|
||||
if [ "$1" = "subscribe" ] && [ $# -eq 1 ]
|
||||
then
|
||||
log "Subscribing..."
|
||||
oarsub -l slash_22=1+{"virtual!='NO' AND cluster='nova'"}/nodes=2,walltime=$nHours 'sleep "10d"' # On node send request to the other
|
||||
elif [ "$1" = "deploy" ] && [ $# -eq 1 ]
|
||||
then
|
||||
# Get machine mac address
|
||||
serverSubnet=$(g5k-subnets -im|sed "1q;d")
|
||||
clientSubnet=$(g5k-subnets -im|sed "2q;d")
|
||||
serverMac=$(echo "$serverSubnet"|sed "s/^.*\t//g")
|
||||
clientMac=$(echo "$clientSubnet"|sed "s/^.*\t//g")
|
||||
serverIp=$(echo "$serverSubnet"|sed "s/\t.*$//g")
|
||||
clientIp=$(echo "$clientSubnet"|sed "s/\t.*$//g")
|
||||
serverNode=""
|
||||
clientNode=""
|
||||
|
||||
# Run vms
|
||||
log "Run vms..."
|
||||
isServer=1
|
||||
finished=0
|
||||
for node in $(cat $OAR_NODE_FILE|uniq)
|
||||
do
|
||||
# Init vm images
|
||||
log "Create $node vm image"
|
||||
oarsh $node cp -n /grid5000/virt-images/debian9-x64-base.qcow2 /tmp/
|
||||
oarsh $node qemu-img create -f qcow2 -o backing_file=/tmp/debian9-x64-base.qcow2 /tmp/img.qcow2
|
||||
sleep 1 # Wait for fun
|
||||
|
||||
# Build cloud init iso (to have ssh access witouth password
|
||||
log "Create $node cloud-init image"
|
||||
oarsh $node cp /grid5000/virt-images/cloud-init-example.sh /tmp/
|
||||
oarsh $node "cd /tmp && export cloud_init_key=\$(cat ~/.ssh/id_rsa.pub) && ./cloud-init-example.sh"
|
||||
oarsh $node "cd /tmp && genisoimage -output cloud-init-data.iso -volid cidata -joliet -rock cloud-init-data/user-data cloud-init-data/meta-data"
|
||||
# Refresh loop state
|
||||
[ $isServer -eq 1 ] && { curMac=$serverMac; isServer=0; serverNode=$node; } || { curMac=$clientMac; finished=1; clientNode=$node; }
|
||||
|
||||
# Launch vm
|
||||
log "Launch vm $node"
|
||||
oarsh $node kvm -m ${vmSize}M -hda /tmp/img.qcow2 -netdev bridge,id=br0 -device virtio-net-pci,netdev=br0,id=nic1,mac=$curMac -cdrom /tmp/cloud-init-data.iso -display none -daemonize &
|
||||
|
||||
# Stop looping if we finish
|
||||
[ $finished -eq 1 ] && break
|
||||
done
|
||||
|
||||
log "Installing mysql on $serverIp"
|
||||
onNode="ssh -q root@$serverIp" # For convenience
|
||||
|
||||
##### Server #####
|
||||
sshWait $serverIp
|
||||
# One apt-get update seems to be not enought to get mysql-server
|
||||
$onNode "apt-get update && apt-get update"
|
||||
$onNode apt-get -y install mysql-server
|
||||
# Enable mysql connection from outside
|
||||
$onNode sed -i "s/bind-address/#bind-address/g" /etc/mysql/mariadb.conf.d/50-server.cnf
|
||||
$onNode systemctl restart mysql
|
||||
rsync -avh setup-mysql.sql root@$serverIp:/tmp/
|
||||
# Then execute it
|
||||
$onNode "mysql < /tmp/setup-mysql.sql"
|
||||
|
||||
##### Client #####
|
||||
$sshWait $clientIp
|
||||
onNode="ssh -q root@$clientIp"
|
||||
$onNode "apt-get update && apt-get update"
|
||||
$onNode apt-get -y install mysql-server
|
||||
rsync -avh clients.py root@$clientIp:/tmp/
|
||||
|
||||
##### Start Simulation #####
|
||||
log "Simulation will start in ${delay}s"
|
||||
sleep $delay
|
||||
simStart=$(date "+%s")
|
||||
echo "---------- Simulation (key=${simKey}) start at $simStart ($(date -d @${simStart}))" >> $logFile
|
||||
$onNode python /tmp/clients.py $serverIp $nbSensors $nbSensorsFactor $requestPerSensor $sensorsSendInterval
|
||||
simEnd=$(date "+%s")
|
||||
echo "Simulation parameters: serverNode:$serverNode serverIp:$serverIp serverMac:$serverMac clientNode:$clientNode clientNode:$clientNode clientMac:$clientMac delay:$delay nbSensors:$nbSensors nbSensorsFactor:$nbSensorsFactor requestPerSensors:$requestPerSensor sensorsRequestPerSec:$sensorsRequestPerSec simKey:${simKey} duration:$(( simEnd - simStart ))" >> $logFile
|
||||
echo "./recordEnergy.sh nova $(echo serverNode|grep -o ^.*[-][0-9]*) $simStart $simEnd energy_${simStart}_${simEnd}.csv" >> $logFile
|
||||
echo -e "---------- Simulation (key=${simKey}) end at ${simEnd} ($(date -d @${simEnd}))\n" >> $logFile
|
||||
log "Simulation end ! Please see $logFile for more infos"
|
||||
##### End Simulation #####
|
||||
|
||||
##### Print some infos #####
|
||||
log "Network Settings:"
|
||||
log " - Server $serverNode, $serverIp, $serverMac"
|
||||
log " - Client $clientNode, $clientIp, $clientMac"
|
||||
log "Simulation Settings:"
|
||||
log " - Simulation delay ${delay}s"
|
||||
log " - Number of sensors $(( nbSensors * nbSensorsFactor))"
|
||||
log " - Number of request per sensors $requestPerSensor"
|
||||
log " - Number of request per seconds on eachsensors $sensorsRequestPerSec"
|
||||
|
||||
elif [ "$1" = "kill" ] && [ $# -eq 1 ]
|
||||
then
|
||||
##### Kill all kvm on the subscribed nodes #####
|
||||
isServer=1
|
||||
finished=0
|
||||
for node in $(cat $OAR_NODE_FILE|uniq)
|
||||
do
|
||||
[ $isServer -eq 1 ] && { curMac=$serverMac; isServer=0; serverNode=$node; } || { curMac=$clientMac; finished=1; clientNode=$node; }
|
||||
log "Killing vm on node $node"
|
||||
oarsh $node pkill -9 qemu &
|
||||
[ $finished -eq 1 ] && break
|
||||
done
|
||||
elif [ "$1" = "inspect" ] && [ $# -eq 2 ]
|
||||
then
|
||||
##### Show content of the database #####
|
||||
mysql --host="$2" -u user --password="mysql" experiment -e "SELECT * FROM temperature;"
|
||||
elif [ "$1" = "flush" ] && [ $# -eq 2 ]
|
||||
then
|
||||
##### Flush content of the temperature table #####
|
||||
log "Cleaning database table..."
|
||||
mysql --host="$2" -u user --password="mysql" experiment -e "TRUNCATE TABLE temperature;"
|
||||
else
|
||||
echo "Usage:"
|
||||
echo " - $0 subscribe"
|
||||
echo " - $0 deploy"
|
||||
echo " - $0 kill"
|
||||
echo " - $0 inspect <serverIP>"
|
||||
echo " - $0 flush <serverIP>"
|
||||
fi
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Parse argument
|
||||
[ $# != 5 ] && { echo "Usage: $0 <cluster-name> <node-name> <from> <to> <output-file>"; exit 1; }
|
||||
|
||||
# Init arguments
|
||||
clusterName="$1"
|
||||
nodeName="$2"
|
||||
outputFile="$5"
|
||||
wattmeter=$(curl -s https://api.grid5000.fr/stable/sites/lyon/clusters/${clusterName}/nodes/${nodeName}.json | jq -r '.sensors.power.via.pdu[0].uid')
|
||||
port=$(curl -s https://api.grid5000.fr/stable/sites/lyon/pdus/${wattmeter}.json | jq -r '.ports|to_entries|map(select(.value=="'${nodeName}'"))[0].key')
|
||||
energyEntry=$(( 5 + port) # Define the entry in the CSV that correspond to the correct energy value
|
||||
|
||||
if [ -z $wattmeter ] || [ -z $port ]
|
||||
then
|
||||
echo -ne "\nCannot find energy informations (wattmeter/port) for node $nodeName\n"
|
||||
echo -ne "\nCheck the node name (do not use hostname! only node name ex: nova-7)\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Node ${nodeName} is connected on wattmeter ${wattmeter} on port ${port}"
|
||||
|
||||
# Fetching energy and save in csv format
|
||||
from=$(date -d "@$3" "+%s")
|
||||
to=$(date -d "@$4" "+%s")
|
||||
echo "ts,energy" > $outputFile # Write CSV header
|
||||
for time in $(seq $from 3600 $to)
|
||||
do
|
||||
# We need gz extension if it is not the current hour
|
||||
[ $(date -d "@$time" "+%Y-%m-%dT%H") != $(date "+%Y-%m-%dT%H") ] && ext='.gz' || ext=''
|
||||
powerFilename=$(date -d "@$time" "+power.csv.%Y-%m-%dT%H${ext}")
|
||||
url="http://wattmetre.lyon.grid5000.fr/data/${wattmeter}-log/${powerFilename}"
|
||||
echo "- Fetching logs from ${url}"
|
||||
|
||||
# Fetch logs data
|
||||
[ ! -z $ext ] && csvContent=$(curl -s "${url}" | zcat) || csvContent=$(curl -s "${url}")
|
||||
|
||||
# Parse data and extract the right values in csv format
|
||||
toSave=$(echo "$csvContent" | awk -F, 'int($3)>='$from'&& int($3)<='$to'{printf "%s,%s\n",$3,$5+'$port'};')
|
||||
echo "$toSave" >> $outputFile # Save data in csv
|
||||
done
|
||||
echo "Done"
|
|
@ -1,41 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Parse argument
|
||||
[ $# != 5 ] && { echo "Usage: $0 <cluster-name> <node-name> <from> <to> <output-file>"; exit 1; }
|
||||
|
||||
# Init arguments
|
||||
clusterName="$1"
|
||||
nodeName="$2"
|
||||
outputFile="$5"
|
||||
wattmeter=$(curl -s https://api.grid5000.fr/stable/sites/lyon/clusters/${clusterName}/nodes/${nodeName}.json | jq -r '.sensors.power.via.pdu[0].uid')
|
||||
port=$(curl -s https://api.grid5000.fr/stable/sites/lyon/pdus/${wattmeter}.json | jq -r '.ports|to_entries|map(select(.value=="'${nodeName}'"))[0].key')
|
||||
energyEntry=$(( 5 + port )) # Define the entry in the CSV that correspond to the correct energy value
|
||||
|
||||
if [ -z $wattmeter ] || [ -z $port ]
|
||||
then
|
||||
echo -ne "\nCannot find energy informations (wattmeter/port) for node $nodeName\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Node ${nodeName} is connected on wattmeter ${wattmeter} on port ${port}"
|
||||
|
||||
# Fetching energy and save in csv format
|
||||
from=$(date -d "@$3" "+%s")
|
||||
to=$(date -d "@$4" "+%s")
|
||||
echo "ts,energy" > $outputFile # Write CSV header
|
||||
for time in $(seq $from 3600 $to)
|
||||
do
|
||||
# We need gz extension if it is not the current hour
|
||||
[ $(date -d "@$time" "+%Y-%m-%dT%H") != $(date "+%Y-%m-%dT%H") ] && ext='.gz' || ext=''
|
||||
powerFilename=$(date -d "@$time" "+power.csv.%Y-%m-%dT%H${ext}")
|
||||
url="http://wattmetre.lyon.grid5000.fr/data/${wattmeter}-log/${powerFilename}"
|
||||
echo "- Fetching logs from ${url}"
|
||||
|
||||
# Fetch logs data
|
||||
[ ! -z $ext ] && csvContent=$(curl -s "${url}" | zcat) || csvContent=$(curl -s "${url}")
|
||||
|
||||
# Parse data and extract the right values in csv format
|
||||
toSave=$(echo "$csvContent" | awk -F, 'int($3)>='$from'&& int($3)<='$to'{printf "%s,%s\n",$3,$5+'$port'};')
|
||||
echo "$toSave" >> $outputFile # Save data in csv
|
||||
done
|
||||
echo "Done"
|
|
@ -1,49 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Parameters
|
||||
delay=60 # Delay before starting simulation (let CPU energy going down on the server)
|
||||
nbSensors=20 # Number of sensors that will send request to de server
|
||||
nbSensorsFactor=3 # nbSensors*nbSensorFactor
|
||||
simulationTime=300 # Approximative
|
||||
sensorsSendInterval=10 # Delay between sensors requests
|
||||
# requestPerSensor dynamically computed inside init-nodes
|
||||
vmSize=2048 # Number of alocated ram
|
||||
simKey="NONE"
|
||||
|
||||
# Where script is located
|
||||
simScript=$(dirname $(readlink -f "$0"))/init-nodes.sh
|
||||
|
||||
# Build a function using the script
|
||||
initNodes () {
|
||||
source "$simScript"
|
||||
}
|
||||
|
||||
|
||||
##### Test VM RAM #####
|
||||
simKey="vmSize"
|
||||
for vmSize in $(echo 1024 2048 4096)
|
||||
do
|
||||
initNodes deploy
|
||||
initNodes kill # Kill all vms (do not forget :D)
|
||||
done
|
||||
|
||||
vmSize=2048 # Reset vmSize
|
||||
|
||||
simKey="nbSensors"
|
||||
##### Test number of sensors #####
|
||||
for nbSensors in $(echo 20 100 300)
|
||||
do
|
||||
initNodes deploy
|
||||
initNodes kill # Kill all vms
|
||||
done
|
||||
|
||||
|
||||
|
||||
simKey="SENDINTERVAL"
|
||||
nbSensors=100 # Now set nb sensors to 100
|
||||
##### Test number of sensors #####
|
||||
for sensorsSendInterval in $(echo 10 30 60)
|
||||
do
|
||||
initNodes deploy
|
||||
initNodes kill # Kill all vms
|
||||
done
|
|
@ -1,8 +0,0 @@
|
|||
create DATABASE IF NOT EXISTS experiment;
|
||||
use experiment;
|
||||
create TABLE IF NOT EXISTS temperature (id INTEGER,stamp INTEGER, val INTEGER);
|
||||
|
||||
use mysql;
|
||||
CREATE USER 'user'@'%' IDENTIFIED BY 'mysql';
|
||||
GRANT ALL ON experiment.* TO 'user'@'%';
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
---------- Simulation (key=vmSize) start at 1558010372 (Thu May 16 14:39:32 CEST 2019)
|
||||
Simulation parameters: serverNode:nova-7.lyon.grid5000.fr serverIp:10.140.16.1 serverMac:00:16:3E:8C:10:01 clientNode:nova-8.lyon.grid5000.fr clientNode:nova-8.lyon.grid5000.fr clientMac:00:16:3E:8C:10:02 delay:60 nbSensors:20 nbSensorsFactor:3 requestPerSensors:30 sensorsRequestPerSec: simKey:vmSize duration:308
|
||||
./recordEnergy.sh nova nova-7.lyon.grid5000.fr 1558010372 1558010680 energy_1558010372_1558010680.csv
|
||||
---------- Simulation (key=vmSize) end at 1558010680 (Thu May 16 14:44:40 CEST 2019)
|
||||
|
||||
---------- Simulation (key=vmSize) start at 1558010868 (Thu May 16 14:47:48 CEST 2019)
|
||||
Simulation parameters: serverNode:nova-7.lyon.grid5000.fr serverIp:10.140.16.1 serverMac:00:16:3E:8C:10:01 clientNode:nova-8.lyon.grid5000.fr clientNode:nova-8.lyon.grid5000.fr clientMac:00:16:3E:8C:10:02 delay:60 nbSensors:20 nbSensorsFactor:3 requestPerSensors:30 sensorsRequestPerSec: simKey:vmSize duration:308
|
||||
./recordEnergy.sh nova nova-7.lyon.grid5000.fr 1558010868 1558011176 energy_1558010868_1558011176.csv
|
||||
---------- Simulation (key=vmSize) end at 1558011176 (Thu May 16 14:52:56 CEST 2019)
|
||||
|
||||
---------- Simulation (key=vmSize) start at 1558011366 (Thu May 16 14:56:06 CEST 2019)
|
||||
Simulation parameters: serverNode:nova-7.lyon.grid5000.fr serverIp:10.140.16.1 serverMac:00:16:3E:8C:10:01 clientNode:nova-8.lyon.grid5000.fr clientNode:nova-8.lyon.grid5000.fr clientMac:00:16:3E:8C:10:02 delay:60 nbSensors:20 nbSensorsFactor:3 requestPerSensors:30 sensorsRequestPerSec: simKey:vmSize duration:308
|
||||
./recordEnergy.sh nova nova-7.lyon.grid5000.fr 1558011366 1558011674 energy_1558011366_1558011674.csv
|
||||
---------- Simulation (key=vmSize) end at 1558011674 (Thu May 16 15:01:14 CEST 2019)
|
||||
|
|
@ -1,48 +0,0 @@
|
|||
#!/usr/bin/python
|
||||
from __future__ import division
|
||||
import os,sys,random, time,datetime
|
||||
from subprocess import Popen
|
||||
|
||||
# Check script argument
|
||||
if len(sys.argv) != 6:
|
||||
print("Usage: "+sys.argv[0]+" <mysqlServerIp> <nbSensors> <nbSensorsFactor> <requestPerSensor> <sendInterval>")
|
||||
exit(1)
|
||||
|
||||
# Init script parameters
|
||||
serverIp=sys.argv[1]
|
||||
nbSensors=int(sys.argv[2])
|
||||
nbSensorsFactor=int(sys.argv[3])
|
||||
effectiveNbSensors=nbSensors*nbSensorsFactor
|
||||
requestPerSensor=int(sys.argv[4])
|
||||
sendInterval=int(sys.argv[5])
|
||||
avgSiteTemp=list()
|
||||
for i in range(0,effectiveNbSensors):
|
||||
avgSiteTemp.append(random.randint(-10,30))
|
||||
|
||||
|
||||
def insert(sensorId, value):
|
||||
""" Send value of sensorId into the database """
|
||||
stamp=int(time.mktime(datetime.datetime.today().timetuple()))
|
||||
insertCMD = "mysql -u user --password=mysql --host="+serverIp+" experiment -e"
|
||||
insertCMD=insertCMD.split()
|
||||
insertCMD.append("INSERT INTO temperature (id,stamp,val) VALUES("+str(sensorId)+","+str(stamp)+","+str(value)+");")
|
||||
Popen(insertCMD) # Run command asynchronously
|
||||
|
||||
def send():
|
||||
""" Send temperature of each sensors into the database """
|
||||
for i in range(0,effectiveNbSensors):
|
||||
insert(i,random.gauss(avgSiteTemp[i], 3))
|
||||
|
||||
|
||||
# Print infos
|
||||
print("Launching clients with:")
|
||||
print(" - Mysql Server IP {:>20}".format(serverIp))
|
||||
print(" - Number of sensors {:>18}".format(effectiveNbSensors))
|
||||
print(" - Number of request per sensor {:>7}".format(effectiveNbSensors))
|
||||
|
||||
# Send data
|
||||
for i in range(0, requestPerSensor):
|
||||
send()
|
||||
time.sleep(sendInterval) # We assume send() take no time
|
||||
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
|
||||
logFile="$(dirname $(readlink -f $0))"/simLogs.txt
|
||||
|
||||
|
||||
getValue () {
|
||||
line=$(echo "$1" | grep "Simulation para"|sed "s/Simulation parameters: //g")
|
||||
key=$2
|
||||
echo "$line"|awk 'BEGIN{RS=" ";FS=":"}"'$key'"==$1{gsub("\n","",$0);print $2}'
|
||||
}
|
||||
|
||||
IFS=$'\n'
|
||||
for cmd in $(cat $logFile|grep "Simulation parameters")
|
||||
do
|
||||
nodeName=$(getValue $cmd serverNodeName)
|
||||
from=$(getValue $cmd simStart)
|
||||
to=$(getValue $cmd simEnd)
|
||||
vmSize=$(getValue $cmd vmSize)
|
||||
nbSensors=$(getValue $cmd nbSensors)
|
||||
simKey=$(getValue $cmd simKey)
|
||||
delayStart=$(getValue $cmd delayStart)
|
||||
./recordEnergy.sh nova $nodeName $from $to "${simKey}_${vmSize}VMSIZE_${nbSensors}NBSENSORS_${from}${to}.csv"
|
||||
./recordEnergy.sh nova $nodeName $delayStart $from "${simKey}_${vmSize}VMSIZE_${nbSensors}NBSENSORS_${from}${to}_IDLE.csv"
|
||||
done
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
|
||||
logFile="$(dirname $(readlink -f $0))"/simLogs.txt
|
||||
|
||||
|
||||
getValue () {
|
||||
line=$(echo "$1" | grep "Simulation para"|sed "s/Simulation parameters: //g")
|
||||
key=$2
|
||||
echo "$line"|awk 'BEGIN{RS=" ";FS=":"}"'$key'"==$1{gsub("\n","",$0);print $2}'
|
||||
}
|
||||
|
||||
IFS=$'\n'
|
||||
for cmd in $(cat $logFile|grep "Simulation parameters")
|
||||
do
|
||||
nodeName=$(getValue $cmd serverNodeName)
|
||||
from=$(getValue $cmd startSim)
|
||||
to=$(getValue $cmd endSim)
|
||||
vmSize=$(getValue $cmd vmSize)
|
||||
nbSensors=$(getValue $cmd nbSensors)
|
||||
simKey=$(getValue $cmd simKey)
|
||||
./recordEnergy.sh nova $nodeName $from $to "${simKey}_${vmSize}VMSIZE_${nbSensors}NBSENSORS_${from}${to}.csv"
|
||||
done
|
||||
|
|
@ -1,137 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
##### Parameters #####
|
||||
if [ -z ${nbSensors+x} ] # If nbSensors exists, so all parameters are already define
|
||||
then
|
||||
delay=60 # Delay before starting simulation (let CPU energy going down on the server)
|
||||
nbSensors=30 # Number of sensors that will send request to de server
|
||||
nbSensorsFactor=3 # nbSensors*nbSensorFactor
|
||||
simulationTime=300 # Approximative
|
||||
sensorsSendInterval=10 # Delay between sensors requests
|
||||
vmSize=2048 # Number of alocated ram
|
||||
simKey="NONE"
|
||||
fi
|
||||
nHours=3 # Reservation dutation
|
||||
requestPerSensor=$(( simulationTime / sensorsSendInterval )) # Theorical simulation time is $requestPerSensor*$sensorsSendInterval
|
||||
######################
|
||||
|
||||
|
||||
logFile="./simLogs.txt"
|
||||
log () {
|
||||
echo -e "\033[0;34m$@\033[0m"
|
||||
}
|
||||
|
||||
sshWait () {
|
||||
log "Waiting for for an ssh connection to a vm ($1)"
|
||||
error=255
|
||||
until [ $error -eq 0 ]
|
||||
do
|
||||
ssh -q root@$1 echo "Connected to $(hostname)"
|
||||
error=$?
|
||||
sleep 4
|
||||
done
|
||||
}
|
||||
|
||||
if [ "$1" = "subscribe" ] && [ $# -eq 1 ]
|
||||
then
|
||||
log "Subscribing..."
|
||||
oarsub -l slash_22=1+{"virtual!='NO' AND cluster='nova'"}/nodes=2,walltime=$nHours 'sleep "10d"' # On node send request to the other
|
||||
# oarsub -l slash_22=1+{"virtual!='NO'"}/nodes=2,walltime=$nHours 'sleep "10d"' # On node send request to the other
|
||||
|
||||
elif [ "$1" = "deploy" ] && [ $# -eq 1 ]
|
||||
then
|
||||
# Get machine mac address
|
||||
serverSubnet=$(g5k-subnets -im|sed "1q;d")
|
||||
serverMac=$(echo "$serverSubnet"|sed "s/^.*\t//g")
|
||||
serverIp=$(echo "$serverSubnet"|sed "s/\t.*$//g")
|
||||
clientIp=$(hostname) # Not really a IP but :P
|
||||
clientNode=$(hostname)
|
||||
serverNode=$(cat $OAR_NODE_FILE|uniq|sed "s/$clientNode//g"|sed "s/ //g")
|
||||
onS="oarsh $serverNode" # For convenience
|
||||
|
||||
|
||||
# Init vm images
|
||||
log "Create server vm image"
|
||||
$onS cp -n /grid5000/virt-images/debian9-x64-base.qcow2 /tmp/
|
||||
$onS qemu-img create -f qcow2 -o backing_file=/tmp/debian9-x64-base.qcow2 /tmp/img.qcow2
|
||||
sleep 1 # Wait for fun
|
||||
|
||||
# Build cloud init iso (to have ssh access witouth password
|
||||
log "Create server cloud-init image"
|
||||
$onS cp /grid5000/virt-images/cloud-init-example.sh /tmp/
|
||||
$onS "cd /tmp && export cloud_init_key=\$(cat ~/.ssh/id_rsa.pub) && ./cloud-init-example.sh"
|
||||
$onS "cd /tmp && genisoimage -output cloud-init-data.iso -volid cidata -joliet -rock cloud-init-data/user-data cloud-init-data/meta-data"
|
||||
|
||||
# Launch vm
|
||||
log "Launch server vm"
|
||||
$onS kvm -m ${vmSize}M -hda /tmp/img.qcow2 -netdev bridge,id=br0 -device virtio-net-pci,netdev=br0,id=nic1,mac=$serverMac -cdrom /tmp/cloud-init-data.iso -display none -daemonize &
|
||||
|
||||
|
||||
##### Server #####
|
||||
onS="ssh root@$serverIp" # Don't forget to use vm
|
||||
sshWait $serverIp
|
||||
# One apt-get update seems to be not enought to get mysql-server
|
||||
$onS "apt-get update && apt-get update"
|
||||
$onS apt-get -y install mysql-server
|
||||
# Enable mysql connection from outside
|
||||
$onS sed -i "s/bind-address/#bind-address/g" /etc/mysql/mariadb.conf.d/50-server.cnf
|
||||
$onS 'echo -e "[mysqld]\nmax_connections = 100000" >> /etc/mysql/my.cnf' # Otherwise you will have the error "TOO MANY CONNECTION"
|
||||
$onS systemctl restart mysql
|
||||
rsync -avh setup-mysql.sql root@$serverIp:/tmp/ # Send mysl setup script
|
||||
$onS "mysql < /tmp/setup-mysql.sql" # Then execute it
|
||||
|
||||
##### Start Simulation #####
|
||||
serverNodeName=$(echo $serverNode|grep -o ^.*[-][0-9]*|tr -d '\n') # For logging
|
||||
log "Simulation will start in ${delay}s"
|
||||
delayStart=$(date "+%s") # Used to compute the idle energy consumption
|
||||
sleep $delay
|
||||
simStart=$(date "+%s")
|
||||
echo "---------- Simulation (key=${simKey}) start at $simStart ($(date -d @${simStart}))" >> $logFile
|
||||
python ./clients.py $serverIp $nbSensors $nbSensorsFactor $requestPerSensor $sensorsSendInterval
|
||||
simEnd=$(date "+%s")
|
||||
echo "Simulation parameters: serverNode:$serverNode serverIp:$serverIp serverMac:$serverMac clientNode:$clientNode clientNode:$clientNode clientMac:$clientMac delay:$delay delayStart:${delayStart} nbSensors:$nbSensors nbSensorsFactor:$nbSensorsFactor requestPerSensors:$requestPerSensor sensorsSendInterval:${sensorsSendInterval} simKey:${simKey} simStart:${simStart} simEnd:${simEnd} duration:$(( simEnd - simStart )) serverNodeName:${serverNodeName} vmSize:${vmSize}" >> $logFile
|
||||
echo "./recordEnergy.sh nova $serverNodeName $simStart $simEnd energy_${simKey}_${nbSensors}NS_${vmSize}vmSize_${simStart}_${simEnd}.csv" >> $logFile
|
||||
echo -e "---------- Simulation (key=${simKey}) end at ${simEnd} ($(date -d @${simEnd}))\n" >> $logFile
|
||||
log "Simulation end ! Please see $logFile for more infos"
|
||||
##### End Simulation #####
|
||||
|
||||
##### Print some infos #####
|
||||
log "Network Settings:"
|
||||
log " - Server $serverNode, $serverIp, $serverMac"
|
||||
log " - Client $clientNode, $clientIp, $clientMac"
|
||||
log "Simulation Settings:"
|
||||
log " - Simulation delay ${delay}s"
|
||||
log " - Number of sensors $(( nbSensors * nbSensorsFactor))"
|
||||
log " - Number of request per sensors $requestPerSensor"
|
||||
log " - Number of request per seconds on eachsensors $sensorsRequestPerSec"
|
||||
|
||||
elif [ "$1" = "kill" ] && [ $# -eq 1 ]
|
||||
then
|
||||
##### Kill all kvm on the subscribed nodes #####
|
||||
isServer=1
|
||||
finished=0
|
||||
for node in $(cat $OAR_NODE_FILE|uniq)
|
||||
do
|
||||
[ $isServer -eq 1 ] && { curMac=$serverMac; isServer=0; serverNode=$node; } || { curMac=$clientMac; finished=1; clientNode=$node; }
|
||||
log "Killing vm on node $node"
|
||||
oarsh $node pkill -9 qemu &
|
||||
[ $finished -eq 1 ] && break
|
||||
done
|
||||
elif [ "$1" = "inspect" ] && [ $# -eq 2 ]
|
||||
then
|
||||
##### Show content of the database #####
|
||||
mysql --host="$2" -u user --password="mysql" experiment -e "SELECT * FROM temperature;"
|
||||
elif [ "$1" = "flush" ] && [ $# -eq 2 ]
|
||||
then
|
||||
##### Flush content of the temperature table #####
|
||||
log "Cleaning database table..."
|
||||
mysql --host="$2" -u user --password="mysql" experiment -e "TRUNCATE TABLE temperature;"
|
||||
else
|
||||
echo "Usage:"
|
||||
echo " - $0 subscribe"
|
||||
echo " - $0 deploy"
|
||||
echo " - $0 kill"
|
||||
echo " - $0 inspect <serverIP>"
|
||||
echo " - $0 flush <serverIP>"
|
||||
fi
|
||||
|
|
@ -1,154 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
##### Parameters #####
|
||||
if [ -z ${nbSensors+x} ] # If nbSensors exists, so all parameters are already define
|
||||
then
|
||||
delay=60 # Delay before starting simulation (let CPU energy going down on the server)
|
||||
nbSensors=30 # Number of sensors that will send request to de server
|
||||
nbSensorsFactor=3 # nbSensors*nbSensorFactor
|
||||
simulationTime=300 # Approximative
|
||||
sensorsSendInterval=10 # Delay between sensors requests
|
||||
vmSize=2048 # Number of alocated ram
|
||||
simKey="NONE"
|
||||
fi
|
||||
nHours=3 # Reservation dutation
|
||||
requestPerSensor=$(( simulationTime / sensorsSendInterval )) # Theorical simulation time is $requestPerSensor*$sensorsSendInterval
|
||||
######################
|
||||
|
||||
|
||||
logFile="./simLogs.txt"
|
||||
log () {
|
||||
echo -e "\033[0;34m$@\033[0m"
|
||||
}
|
||||
|
||||
sshWait () {
|
||||
log "Waiting for for an ssh connection to a vm ($1)"
|
||||
error=255
|
||||
until [ $error -eq 0 ]
|
||||
do
|
||||
ssh -q root@$1 echo "Connected to $(hostname)"
|
||||
error=$?
|
||||
sleep 4
|
||||
done
|
||||
}
|
||||
|
||||
if [ "$1" = "subscribe" ] && [ $# -eq 1 ]
|
||||
then
|
||||
log "Subscribing..."
|
||||
oarsub -l slash_22=1+{"virtual!='NO' AND cluster='nova'"}/nodes=2,walltime=$nHours 'sleep "10d"' # On node send request to the other
|
||||
elif [ "$1" = "deploy" ] && [ $# -eq 1 ]
|
||||
then
|
||||
# Get machine mac address
|
||||
serverSubnet=$(g5k-subnets -im|sed "1q;d")
|
||||
clientSubnet=$(g5k-subnets -im|sed "2q;d")
|
||||
serverMac=$(echo "$serverSubnet"|sed "s/^.*\t//g")
|
||||
clientMac=$(echo "$clientSubnet"|sed "s/^.*\t//g")
|
||||
serverIp=$(echo "$serverSubnet"|sed "s/\t.*$//g")
|
||||
clientIp=$(echo "$clientSubnet"|sed "s/\t.*$//g")
|
||||
serverNode=""
|
||||
clientNode=""
|
||||
|
||||
# Run vms
|
||||
log "Run vms..."
|
||||
isServer=1
|
||||
finished=0
|
||||
for node in $(cat $OAR_NODE_FILE|uniq)
|
||||
do
|
||||
# Init vm images
|
||||
log "Create $node vm image"
|
||||
oarsh $node cp -n /grid5000/virt-images/debian9-x64-base.qcow2 /tmp/
|
||||
oarsh $node qemu-img create -f qcow2 -o backing_file=/tmp/debian9-x64-base.qcow2 /tmp/img.qcow2
|
||||
sleep 1 # Wait for fun
|
||||
|
||||
# Build cloud init iso (to have ssh access witouth password
|
||||
log "Create $node cloud-init image"
|
||||
oarsh $node cp /grid5000/virt-images/cloud-init-example.sh /tmp/
|
||||
oarsh $node "cd /tmp && export cloud_init_key=\$(cat ~/.ssh/id_rsa.pub) && ./cloud-init-example.sh"
|
||||
oarsh $node "cd /tmp && genisoimage -output cloud-init-data.iso -volid cidata -joliet -rock cloud-init-data/user-data cloud-init-data/meta-data"
|
||||
# Refresh loop state
|
||||
[ $isServer -eq 1 ] && { curMac=$serverMac; isServer=0; serverNode=$node; } || { curMac=$clientMac; finished=1; clientNode=$node; }
|
||||
|
||||
# Launch vm
|
||||
log "Launch vm $node"
|
||||
oarsh $node kvm -m ${vmSize}M -hda /tmp/img.qcow2 -netdev bridge,id=br0 -device virtio-net-pci,netdev=br0,id=nic1,mac=$curMac -cdrom /tmp/cloud-init-data.iso -display none -daemonize &
|
||||
|
||||
# Stop looping if we finish
|
||||
[ $finished -eq 1 ] && break
|
||||
done
|
||||
|
||||
log "Installing mysql on $serverIp"
|
||||
serverNodeName=$(echo $serverNode|grep -o ^.*[-][0-9]*) # For logging
|
||||
onNode="ssh -q root@$serverIp" # For convenience
|
||||
|
||||
##### Server #####
|
||||
sshWait $serverIp
|
||||
# One apt-get update seems to be not enought to get mysql-server
|
||||
$onNode "apt-get update && apt-get update"
|
||||
$onNode apt-get -y install mysql-server
|
||||
# Enable mysql connection from outside
|
||||
$onNode sed -i "s/bind-address/#bind-address/g" /etc/mysql/mariadb.conf.d/50-server.cnf
|
||||
$onNode systemctl restart mysql
|
||||
rsync -avh setup-mysql.sql root@$serverIp:/tmp/
|
||||
# Then execute it
|
||||
$onNode "mysql < /tmp/setup-mysql.sql"
|
||||
|
||||
##### Client #####
|
||||
$sshWait $clientIp
|
||||
onNode="ssh -q root@$clientIp"
|
||||
$onNode "apt-get update && apt-get update"
|
||||
$onNode apt-get -y install mysql-server
|
||||
rsync -avh clients.py root@$clientIp:/tmp/
|
||||
|
||||
##### Start Simulation #####
|
||||
log "Simulation will start in ${delay}s"
|
||||
sleep $delay
|
||||
simStart=$(date "+%s")
|
||||
echo "---------- Simulation (key=${simKey}) start at $simStart ($(date -d @${simStart}))" >> $logFile
|
||||
$onNode python /tmp/clients.py $serverIp $nbSensors $nbSensorsFactor $requestPerSensor $sensorsSendInterval
|
||||
simEnd=$(date "+%s")
|
||||
echo "Simulation parameters: serverNode:$serverNode serverIp:$serverIp serverMac:$serverMac clientNode:$clientNode clientNode:$clientNode clientMac:$clientMac delay:$delay nbSensors:$nbSensors nbSensorsFactor:$nbSensorsFactor requestPerSensors:$requestPerSensor sensorsRequestPerSec:$sensorsRequestPerSec simKey:${simKey} simStart:${simStart} simEnd:${simEnd} duration:$(( simEnd - simStart )) serverNodeName:${serverNodeName} vmSize:${vmSize}" >> $logFile
|
||||
echo "./recordEnergy.sh nova $serverNodeName $simStart $simEnd energy_${simKey}_${nbSensors}NS_${vmSize}vmSize_${simStart}_${simEnd}.csv" >> $logFile
|
||||
echo -e "---------- Simulation (key=${simKey}) end at ${simEnd} ($(date -d @${simEnd}))\n" >> $logFile
|
||||
log "Simulation end ! Please see $logFile for more infos"
|
||||
##### End Simulation #####
|
||||
|
||||
##### Print some infos #####
|
||||
log "Network Settings:"
|
||||
log " - Server $serverNode, $serverIp, $serverMac"
|
||||
log " - Client $clientNode, $clientIp, $clientMac"
|
||||
log "Simulation Settings:"
|
||||
log " - Simulation delay ${delay}s"
|
||||
log " - Number of sensors $(( nbSensors * nbSensorsFactor))"
|
||||
log " - Number of request per sensors $requestPerSensor"
|
||||
log " - Number of request per seconds on eachsensors $sensorsRequestPerSec"
|
||||
|
||||
elif [ "$1" = "kill" ] && [ $# -eq 1 ]
|
||||
then
|
||||
##### Kill all kvm on the subscribed nodes #####
|
||||
isServer=1
|
||||
finished=0
|
||||
for node in $(cat $OAR_NODE_FILE|uniq)
|
||||
do
|
||||
[ $isServer -eq 1 ] && { curMac=$serverMac; isServer=0; serverNode=$node; } || { curMac=$clientMac; finished=1; clientNode=$node; }
|
||||
log "Killing vm on node $node"
|
||||
oarsh $node pkill -9 qemu &
|
||||
[ $finished -eq 1 ] && break
|
||||
done
|
||||
elif [ "$1" = "inspect" ] && [ $# -eq 2 ]
|
||||
then
|
||||
##### Show content of the database #####
|
||||
mysql --host="$2" -u user --password="mysql" experiment -e "SELECT * FROM temperature;"
|
||||
elif [ "$1" = "flush" ] && [ $# -eq 2 ]
|
||||
then
|
||||
##### Flush content of the temperature table #####
|
||||
log "Cleaning database table..."
|
||||
mysql --host="$2" -u user --password="mysql" experiment -e "TRUNCATE TABLE temperature;"
|
||||
else
|
||||
echo "Usage:"
|
||||
echo " - $0 subscribe"
|
||||
echo " - $0 deploy"
|
||||
echo " - $0 kill"
|
||||
echo " - $0 inspect <serverIP>"
|
||||
echo " - $0 flush <serverIP>"
|
||||
fi
|
||||
|
|
@ -1 +0,0 @@
|
|||
loic@lguegan.8702:1558336539
|
BIN
g5k/logs/.RData
BIN
g5k/logs/.RData
Binary file not shown.
|
@ -1,25 +0,0 @@
|
|||
library("tidyverse")
|
||||
read_csv("nbSensors_2048VMSIZE_100NBSENSORS_15580778521558078188.csv")
|
||||
energy=read_csv("nbSensors_2048VMSIZE_100NBSENSORS_15580778521558078188.csv")
|
||||
ggplot(energy, aes(x=ts,y=energy))+geom_line()
|
||||
ggplot(energy, aes(x=ts,y=energy))+geom_point()
|
||||
ggplot(energy, aes(x=ts,y=energy))+geom_line() + expand_limits(x=,y=)
|
||||
ggplot(energy, aes(x=ts,y=energy))+geom_line() + expand_limits(x=0,y=0)
|
||||
ggplot(energy, aes(x=ts,y=energy))+geom_line() + expand_limits(y=0)
|
||||
ggplot(energy, aes(x=ts,y=energy))+geom_line() + expand_limits(y=0) + scale_x_datetime()
|
||||
energy$ts
|
||||
as.POSIXct(energy$ts)
|
||||
as.POSIXct(energy$ts,origin="1970-01-01")
|
||||
energy %>% mutate(ts=as.POSIXct(energy$ts,origin="1970-01-01"))
|
||||
energy %>% mutate(ts=as.POSIXct(ts,origin="1970-01-01"))
|
||||
energy=energy %>% mutate(ts=as.POSIXct(ts,origin="1970-01-01"))
|
||||
ggplot(energy, aes(x=ts,y=energy))+geom_line() + expand_limits(y=0) + scale_x_datetime()
|
||||
energy=read_csv("nbSensors_2048VMSIZE_100NBSENSORS_15580778521558078188.csv")
|
||||
energy
|
||||
energy=energy%>%mutate(ts=ts-min(ts))
|
||||
energy
|
||||
ggplot(energy, aes(x=ts,y=energy))+geom_line() + expand_limits(y=0)
|
||||
ggplot(energy, aes(x=ts,y=energy))+geom_line() + expand_limits(y=0)+geom_jitter
|
||||
ggplot(energy, aes(x=ts,y=energy))+geom_line() + expand_limits(y=0)+geom_jitter()
|
||||
ggplot(energy, aes(x=ts,y=energy)) + expand_limits(y=0)+geom_jitter()
|
||||
ggplot(energy, aes(x=ts,y=energy)) + expand_limits(y=0)+geom_jitter(position = position_jitter(width = 0.4))
|
|
@ -4,20 +4,146 @@
|
|||
|
||||
* Logs Analysis
|
||||
** R Scripts
|
||||
*** Generate all plots script
|
||||
#+BEGIN_SRC R :results graphics :file third-try/plot.png :noweb yes
|
||||
*** Plots script
|
||||
#+BEGIN_SRC R :results output :noweb yes :file second-final/plot.png
|
||||
<<RUtils>>
|
||||
data=loadData("./third-try/data.csv")
|
||||
dataOrig=loadData("./second-final/data.csv")
|
||||
|
||||
data=data%>%filter(simKey=="nbSensors") %>% filter(nbSensors==200)
|
||||
ggplot(data,aes(x=time,y=energy,color=nbSensors))+geom_point(position="jitter")+xlab(getLabel("time"))+expand_limits(y=0)#+geom_hline(aes(group=nbSensors,color=nbSensors,yintercept=mean(energy)))
|
||||
ggsave("./third-try/plot.png",dpi=180)
|
||||
data=dataOrig%>%filter(simKey=="nbSensors")%>%filter(state=="sim",nbSensors==100)
|
||||
dataIDLE=dataOrig%>%filter(simKey=="nbSensors")%>%filter(state!="sim",nbSensors==100)
|
||||
data=data%>%mutate(meanEnergy=mean(energy))
|
||||
dataIDLE=dataIDLE%>%mutate(meanEnergy=mean(energy))
|
||||
data=rbind(data,dataIDLE)
|
||||
ggplot(data,aes(x=time,y=energy))+geom_point(position="jitter")+xlab(getLabel("time"))+expand_limits(y=0)+facet_wrap(~state)+geom_hline(aes(color=state,yintercept=mean(meanEnergy)))
|
||||
ggsave("./second-final/plot.png",dpi=180)
|
||||
#+END_SRC
|
||||
|
||||
#+RESULTS:
|
||||
[[file:third-try/plot.png]]
|
||||
#+begin_example
|
||||
# A tibble: 3,050 x 8
|
||||
ts energy simKey vmSize nbSensors time state meanEnergy
|
||||
<dbl> <dbl> <chr> <dbl> <dbl> <dbl> <chr> <dbl>
|
||||
1 1558429001. 90.2 nbSensors 2048 100 0 IDLE 90.8
|
||||
2 1558429001. 89 nbSensors 2048 100 0.0199 IDLE 90.8
|
||||
3 1558429001. 89 nbSensors 2048 100 0.0399 IDLE 90.8
|
||||
4 1558429001. 90.8 nbSensors 2048 100 0.0599 IDLE 90.8
|
||||
5 1558429001. 91 nbSensors 2048 100 0.0799 IDLE 90.8
|
||||
6 1558429001. 90.5 nbSensors 2048 100 0.1000 IDLE 90.8
|
||||
7 1558429001. 89.9 nbSensors 2048 100 0.120 IDLE 90.8
|
||||
8 1558429001. 88.6 nbSensors 2048 100 0.140 IDLE 90.8
|
||||
9 1558429001. 88.6 nbSensors 2048 100 0.160 IDLE 90.8
|
||||
10 1558429001. 90.5 nbSensors 2048 100 0.180 IDLE 90.8
|
||||
# … with 3,040 more rows
|
||||
#+end_example
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
**** Final plot
|
||||
|
||||
#+BEGIN_SRC R :results graphics :noweb yes :file second-final/plot-final.png :session *R*
|
||||
<<RUtils>>
|
||||
data=loadData("./second-final/data.csv")
|
||||
data=data%>%filter(state=="sim",simKey=="nbSensors")
|
||||
|
||||
|
||||
# Cloud
|
||||
data10=data%>%filter(nbSensors==20)%>%mutate(meanEnergy=mean(energy)) %>% slice(1L)
|
||||
data100=data%>%filter(nbSensors==100)%>%mutate(meanEnergy=mean(energy)) %>% slice(1L)
|
||||
data300=data%>%filter(nbSensors==300)%>%mutate(meanEnergy=mean(energy)) %>% slice(1L)
|
||||
dataCloud=rbind(data10,data100,data300)%>%mutate(nbSensors=as.character(nbSensors))
|
||||
|
||||
# Network
|
||||
dataNet=loadData("../../ns3-simulations/logs/data.csv")
|
||||
dataNet=dataNet%>%filter(simKey=="NBSENSORS")
|
||||
data5=dataNet%>%filter(sensorsNumber==5)%>%select(networkEnergy,sensorsNumber)
|
||||
data10=dataNet%>%filter(sensorsNumber==10)%>%select(networkEnergy,sensorsNumber)
|
||||
|
||||
print(data20)
|
||||
|
||||
ggplot(dataCloud)+geom_bar(aes(x=nbSensors,y=meanEnergy),stat="identity")+xlab("Sensors Number")+ylab("Power Consumption (W)")
|
||||
ggsave("./second-final/plot-final.png",dpi=80)
|
||||
|
||||
#+END_SRC
|
||||
|
||||
#+RESULTS:
|
||||
|
||||
|
||||
|
||||
|
||||
#+BEGIN_SRC R :noweb yes :results graphics :file final.png :session *R*
|
||||
<<RUtils>>
|
||||
|
||||
|
||||
data=loadData("./second-final/data.csv")
|
||||
data=data%>%filter(state=="sim",simKey=="nbSensors")
|
||||
|
||||
# Cloud
|
||||
data10=data%>%filter(nbSensors==20)%>%mutate(energy=mean(energy)) %>% slice(1L)
|
||||
data100=data%>%filter(nbSensors==100)%>%mutate(energy=mean(energy)) %>% slice(1L)
|
||||
data300=data%>%filter(nbSensors==300)%>%mutate(energy=mean(energy)) %>% slice(1L)
|
||||
dataCloud=rbind(data10,data100,data300)%>%mutate(sensorsNumber=nbSensors)%>%mutate(type="Cloud")%>%select(sensorsNumber,energy,type)
|
||||
|
||||
|
||||
|
||||
approx=function(data1, data2,nbSensors){
|
||||
x1=data1$sensorsNumber
|
||||
y1=data1$energy
|
||||
|
||||
x2=data2$sensorsNumber
|
||||
y2=data2$energy
|
||||
|
||||
a=((y2-y1)/(x2-x1))
|
||||
b=y1-a*x1
|
||||
|
||||
return(a*nbSensors+b)
|
||||
|
||||
}
|
||||
|
||||
|
||||
simTime=1800
|
||||
|
||||
# Network
|
||||
data=read_csv("../../ns3-simulations/logs/data.csv")
|
||||
data=data%>%filter(simKey=="NBSENSORS")
|
||||
dataC5=data%>%filter(sensorsNumber==5)%>% mutate(energy=networkEnergy/simTime) %>%select(energy,sensorsNumber)
|
||||
dataC10=data%>%filter(sensorsNumber==10)%>%mutate(energy=networkEnergy/simTime) %>%select(energy,sensorsNumber)
|
||||
dataNet=rbind(dataC5,dataC10)%>%mutate(type="Network")
|
||||
|
||||
# Sensors
|
||||
dataS5=data%>%filter(sensorsNumber==5)%>% mutate(energy=sensorsEnergy/simTime) %>%select(energy,sensorsNumber)
|
||||
dataS10=data%>%filter(sensorsNumber==10)%>%mutate(energy=sensorsEnergy/simTime) %>%select(energy,sensorsNumber)
|
||||
dataS=rbind(dataS5,dataS10)%>%mutate(type="Sensors")
|
||||
|
||||
fakeNetS=tibble(
|
||||
sensorsNumber=c(20,100,300,20,100,300),
|
||||
energy=c(dataC10$energy,approx(dataC5,dataC10,100),approx(dataC5,dataC10,300),dataS10$energy,approx(dataS5,dataS10,100),approx(dataS5,dataS10,300)),
|
||||
type=c("Network","Network","Network","Sensors","Sensors","Sensors")
|
||||
)
|
||||
|
||||
fakeNetS=fakeNetS%>%mutate(sensorsNumber=as.character(sensorsNumber))
|
||||
dataCloud=dataCloud%>%mutate(sensorsNumber=as.character(sensorsNumber))
|
||||
|
||||
data=rbind(fakeNetS,dataCloud)%>%mutate(sensorsNumber=as.character(sensorsNumber))
|
||||
|
||||
|
||||
data=data%>%mutate(sensorsNumber=fct_reorder(sensorsNumber,as.numeric(sensorsNumber)))
|
||||
|
||||
ggplot(data)+geom_bar(position="dodge2",colour="black",aes(x=sensorsNumber,y=energy,fill=type),stat="identity")+
|
||||
xlab("Sensors Number")+ylab("Power Consumption (W)")+guides(fill=guide_legend(title="Part"))
|
||||
ggsave("final.png",dpi=80)
|
||||
|
||||
#+END_SRC
|
||||
|
||||
#+RESULTS:
|
||||
[[file:final.png]]
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
*** R Utils
|
||||
RUtils is intended to load logs (data.csv) and providing
|
||||
simple plot function for them.
|
||||
|
@ -81,7 +207,7 @@
|
|||
emacs $orgFile --batch -f org-latex-export-to-pdf --kill
|
||||
#+END_SRC
|
||||
|
||||
|
||||
|
||||
** CSVs -> CSV
|
||||
Merge all energy file into one (and add additional fields).
|
||||
|
||||
|
@ -89,7 +215,7 @@
|
|||
#+BEGIN_SRC sh
|
||||
#!/bin/bash
|
||||
|
||||
whichLog="third-try"
|
||||
whichLog="second-final"
|
||||
|
||||
|
||||
logFile="$(dirname $(readlink -f $0))"/$whichLog/simLogs.txt
|
||||
|
@ -113,15 +239,18 @@
|
|||
nbSensors=$(getValue $cmd nbSensors)
|
||||
simKey=$(getValue $cmd simKey)
|
||||
csvFile="$whichLog/${simKey}_${vmSize}VMSIZE_${nbSensors}NBSENSORS_${from}${to}.csv"
|
||||
csvFileIDLE="$whichLog/${simKey}_${vmSize}VMSIZE_${nbSensors}NBSENSORS_${from}${to}_IDLE.csv"
|
||||
tmpFile=${csvFile}_tmp
|
||||
echo ts,energy,simKey,vmSize,nbSensors,time > $tmpFile
|
||||
minEnergy=$(tail -n+2 $csvFile|awk -F"," 'BEGIN{min=0}$1<min||min==0{min=$1}END{print(min)}') # To compute ts field
|
||||
tail -n+2 ${csvFile} | awk -F"," '{print $0",'$simKey','$vmSize','$nbSensors',"$1-'$minEnergy'}' >> $tmpFile
|
||||
echo ts,energy,simKey,vmSize,nbSensors,time,state > $tmpFile
|
||||
minTs=$(tail -n+2 $csvFile|awk -F"," 'BEGIN{min=0}$1<min||min==0{min=$1}END{print(min)}') # To compute ts field
|
||||
minTsIDLE=$(tail -n+2 $csvFileIDLE|awk -F"," 'BEGIN{min=0}$1<min||min==0{min=$1}END{print(min)}') # To compute ts field
|
||||
tail -n+2 ${csvFile} | awk -F"," '{print $0",'$simKey','$vmSize','$nbSensors',"$1-'$minTs'",sim"}' >> $tmpFile
|
||||
tail -n+2 ${csvFileIDLE} | awk -F"," '{print $0",'$simKey','$vmSize','$nbSensors',"$1-'$minTsIDLE'",IDLE"}' >> $tmpFile
|
||||
done
|
||||
|
||||
|
||||
##### File dataFile #####
|
||||
echo ts,energy,simKey,vmSize,nbSensors,time > $dataFile
|
||||
##### Fill dataFile #####
|
||||
echo ts,energy,simKey,vmSize,nbSensors,time,state > $dataFile
|
||||
for tmpFile in $(find ${whichLog}/*_tmp -type f)
|
||||
do
|
||||
tail -n+2 $tmpFile >> $dataFile
|
||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -1,30 +0,0 @@
|
|||
---------- Simulation (key=vmSize) start at 1558075866 (Fri May 17 08:51:06 CEST 2019)
|
||||
Simulation parameters: serverNode:nova-20.lyon.grid5000.fr serverIp:10.140.0.1 serverMac:00:16:3E:8C:00:01 clientNode:nova-21.lyon.grid5000.fr clientNode:nova-21.lyon.grid5000.fr clientMac:00:16:3E:8C:00:02 delay:60 nbSensors:20 nbSensorsFactor:3 requestPerSensors:30 sensorsRequestPerSec: simKey:vmSize simStart:1558075866 simEnd:1558076173 duration:307 serverNodeName:nova-20 vmSize:1024
|
||||
./recordEnergy.sh nova nova-20 1558075866 1558076173 energy_vmSize_20NS_1024vmSize_1558075866_1558076173.csv
|
||||
---------- Simulation (key=vmSize) end at 1558076173 (Fri May 17 08:56:13 CEST 2019)
|
||||
|
||||
---------- Simulation (key=vmSize) start at 1558076362 (Fri May 17 08:59:22 CEST 2019)
|
||||
Simulation parameters: serverNode:nova-20.lyon.grid5000.fr serverIp:10.140.0.1 serverMac:00:16:3E:8C:00:01 clientNode:nova-21.lyon.grid5000.fr clientNode:nova-21.lyon.grid5000.fr clientMac:00:16:3E:8C:00:02 delay:60 nbSensors:20 nbSensorsFactor:3 requestPerSensors:30 sensorsRequestPerSec: simKey:vmSize simStart:1558076362 simEnd:1558076670 duration:308 serverNodeName:nova-20 vmSize:2048
|
||||
./recordEnergy.sh nova nova-20 1558076362 1558076670 energy_vmSize_20NS_2048vmSize_1558076362_1558076670.csv
|
||||
---------- Simulation (key=vmSize) end at 1558076670 (Fri May 17 09:04:30 CEST 2019)
|
||||
|
||||
---------- Simulation (key=vmSize) start at 1558076859 (Fri May 17 09:07:39 CEST 2019)
|
||||
Simulation parameters: serverNode:nova-20.lyon.grid5000.fr serverIp:10.140.0.1 serverMac:00:16:3E:8C:00:01 clientNode:nova-21.lyon.grid5000.fr clientNode:nova-21.lyon.grid5000.fr clientMac:00:16:3E:8C:00:02 delay:60 nbSensors:20 nbSensorsFactor:3 requestPerSensors:30 sensorsRequestPerSec: simKey:vmSize simStart:1558076859 simEnd:1558077167 duration:308 serverNodeName:nova-20 vmSize:4096
|
||||
./recordEnergy.sh nova nova-20 1558076859 1558077167 energy_vmSize_20NS_4096vmSize_1558076859_1558077167.csv
|
||||
---------- Simulation (key=vmSize) end at 1558077167 (Fri May 17 09:12:47 CEST 2019)
|
||||
|
||||
---------- Simulation (key=nbSensors) start at 1558077356 (Fri May 17 09:15:56 CEST 2019)
|
||||
Simulation parameters: serverNode:nova-20.lyon.grid5000.fr serverIp:10.140.0.1 serverMac:00:16:3E:8C:00:01 clientNode:nova-21.lyon.grid5000.fr clientNode:nova-21.lyon.grid5000.fr clientMac:00:16:3E:8C:00:02 delay:60 nbSensors:20 nbSensorsFactor:3 requestPerSensors:30 sensorsRequestPerSec: simKey:nbSensors simStart:1558077356 simEnd:1558077664 duration:308 serverNodeName:nova-20 vmSize:2048
|
||||
./recordEnergy.sh nova nova-20 1558077356 1558077664 energy_nbSensors_20NS_2048vmSize_1558077356_1558077664.csv
|
||||
---------- Simulation (key=nbSensors) end at 1558077664 (Fri May 17 09:21:04 CEST 2019)
|
||||
|
||||
---------- Simulation (key=nbSensors) start at 1558077852 (Fri May 17 09:24:12 CEST 2019)
|
||||
Simulation parameters: serverNode:nova-20.lyon.grid5000.fr serverIp:10.140.0.1 serverMac:00:16:3E:8C:00:01 clientNode:nova-21.lyon.grid5000.fr clientNode:nova-21.lyon.grid5000.fr clientMac:00:16:3E:8C:00:02 delay:60 nbSensors:100 nbSensorsFactor:3 requestPerSensors:30 sensorsRequestPerSec: simKey:nbSensors simStart:1558077852 simEnd:1558078188 duration:336 serverNodeName:nova-20 vmSize:2048
|
||||
./recordEnergy.sh nova nova-20 1558077852 1558078188 energy_nbSensors_100NS_2048vmSize_1558077852_1558078188.csv
|
||||
---------- Simulation (key=nbSensors) end at 1558078188 (Fri May 17 09:29:48 CEST 2019)
|
||||
|
||||
---------- Simulation (key=nbSensors) start at 1558078377 (Fri May 17 09:32:57 CEST 2019)
|
||||
Simulation parameters: serverNode:nova-20.lyon.grid5000.fr serverIp:10.140.0.1 serverMac:00:16:3E:8C:00:01 clientNode:nova-21.lyon.grid5000.fr clientNode:nova-21.lyon.grid5000.fr clientMac:00:16:3E:8C:00:02 delay:60 nbSensors:300 nbSensorsFactor:3 requestPerSensors:30 sensorsRequestPerSec: simKey:nbSensors simStart:1558078377 simEnd:1558078782 duration:405 serverNodeName:nova-20 vmSize:2048
|
||||
./recordEnergy.sh nova nova-20 1558078377 1558078782 energy_nbSensors_300NS_2048vmSize_1558078377_1558078782.csv
|
||||
---------- Simulation (key=nbSensors) end at 1558078782 (Fri May 17 09:39:42 CEST 2019)
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
ts,energy
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -1,4 +0,0 @@
|
|||
Some energies values are missing for the file:
|
||||
nbSensors_2048VMSIZE_20NBSENSORS_15581087311558109034.csv
|
||||
|
||||
I don't know whether G5K add somes bugs or whatever.
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
Binary file not shown.
Before Width: | Height: | Size: 19 KiB |
|
@ -1,30 +0,0 @@
|
|||
---------- Simulation (key=vmSize) start at 1558107414 (Fri May 17 17:36:54 CEST 2019)
|
||||
Simulation parameters: serverNode:nova-15.lyon.grid5000.fr serverIp:10.140.16.1 serverMac:00:16:3E:8C:10:01 clientNode:nova-10.lyon.grid5000.fr clientNode:nova-10.lyon.grid5000.fr clientMac: delay:60 nbSensors:20 nbSensorsFactor:3 requestPerSensors:30 sensorsRequestPerSec: simKey:vmSize simStart:1558107414 simEnd:1558107717 duration:303 serverNodeName:nova-15 vmSize:1024
|
||||
./recordEnergy.sh nova nova-15 1558107414 1558107717 energy_vmSize_20NS_1024vmSize_1558107414_1558107717.csv
|
||||
---------- Simulation (key=vmSize) end at 1558107717 (Fri May 17 17:41:57 CEST 2019)
|
||||
|
||||
---------- Simulation (key=vmSize) start at 1558107853 (Fri May 17 17:44:13 CEST 2019)
|
||||
Simulation parameters: serverNode:nova-15.lyon.grid5000.fr serverIp:10.140.16.1 serverMac:00:16:3E:8C:10:01 clientNode:nova-10.lyon.grid5000.fr clientNode:nova-10.lyon.grid5000.fr clientMac: delay:60 nbSensors:20 nbSensorsFactor:3 requestPerSensors:30 sensorsRequestPerSec: simKey:vmSize simStart:1558107853 simEnd:1558108156 duration:303 serverNodeName:nova-15 vmSize:2048
|
||||
./recordEnergy.sh nova nova-15 1558107853 1558108156 energy_vmSize_20NS_2048vmSize_1558107853_1558108156.csv
|
||||
---------- Simulation (key=vmSize) end at 1558108156 (Fri May 17 17:49:16 CEST 2019)
|
||||
|
||||
---------- Simulation (key=vmSize) start at 1558108293 (Fri May 17 17:51:33 CEST 2019)
|
||||
Simulation parameters: serverNode:nova-15.lyon.grid5000.fr serverIp:10.140.16.1 serverMac:00:16:3E:8C:10:01 clientNode:nova-10.lyon.grid5000.fr clientNode:nova-10.lyon.grid5000.fr clientMac: delay:60 nbSensors:20 nbSensorsFactor:3 requestPerSensors:30 sensorsRequestPerSec: simKey:vmSize simStart:1558108293 simEnd:1558108595 duration:302 serverNodeName:nova-15 vmSize:4096
|
||||
./recordEnergy.sh nova nova-15 1558108293 1558108595 energy_vmSize_20NS_4096vmSize_1558108293_1558108595.csv
|
||||
---------- Simulation (key=vmSize) end at 1558108595 (Fri May 17 17:56:35 CEST 2019)
|
||||
|
||||
---------- Simulation (key=nbSensors) start at 1558108731 (Fri May 17 17:58:51 CEST 2019)
|
||||
Simulation parameters: serverNode:nova-15.lyon.grid5000.fr serverIp:10.140.16.1 serverMac:00:16:3E:8C:10:01 clientNode:nova-10.lyon.grid5000.fr clientNode:nova-10.lyon.grid5000.fr clientMac: delay:60 nbSensors:20 nbSensorsFactor:3 requestPerSensors:30 sensorsRequestPerSec: simKey:nbSensors simStart:1558108731 simEnd:1558109034 duration:303 serverNodeName:nova-15 vmSize:2048
|
||||
./recordEnergy.sh nova nova-15 1558108731 1558109034 energy_nbSensors_20NS_2048vmSize_1558108731_1558109034.csv
|
||||
---------- Simulation (key=nbSensors) end at 1558109034 (Fri May 17 18:03:54 CEST 2019)
|
||||
|
||||
---------- Simulation (key=nbSensors) start at 1558109171 (Fri May 17 18:06:11 CEST 2019)
|
||||
Simulation parameters: serverNode:nova-15.lyon.grid5000.fr serverIp:10.140.16.1 serverMac:00:16:3E:8C:10:01 clientNode:nova-10.lyon.grid5000.fr clientNode:nova-10.lyon.grid5000.fr clientMac: delay:60 nbSensors:100 nbSensorsFactor:3 requestPerSensors:30 sensorsRequestPerSec: simKey:nbSensors simStart:1558109171 simEnd:1558109482 duration:311 serverNodeName:nova-15 vmSize:2048
|
||||
./recordEnergy.sh nova nova-15 1558109171 1558109482 energy_nbSensors_100NS_2048vmSize_1558109171_1558109482.csv
|
||||
---------- Simulation (key=nbSensors) end at 1558109482 (Fri May 17 18:11:22 CEST 2019)
|
||||
|
||||
---------- Simulation (key=nbSensors) start at 1558109621 (Fri May 17 18:13:41 CEST 2019)
|
||||
Simulation parameters: serverNode:nova-15.lyon.grid5000.fr serverIp:10.140.16.1 serverMac:00:16:3E:8C:10:01 clientNode:nova-10.lyon.grid5000.fr clientNode:nova-10.lyon.grid5000.fr clientMac: delay:60 nbSensors:300 nbSensorsFactor:3 requestPerSensors:30 sensorsRequestPerSec: simKey:nbSensors simStart:1558109621 simEnd:1558109955 duration:334 serverNodeName:nova-15 vmSize:2048
|
||||
./recordEnergy.sh nova nova-15 1558109621 1558109955 energy_nbSensors_300NS_2048vmSize_1558109621_1558109955.csv
|
||||
---------- Simulation (key=nbSensors) end at 1558109955 (Fri May 17 18:19:15 CEST 2019)
|
||||
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
Binary file not shown.
Before Width: | Height: | Size: 177 KiB |
|
@ -1,30 +0,0 @@
|
|||
---------- Simulation (key=vmSize) start at 1558336590 (Mon May 20 09:16:30 CEST 2019)
|
||||
Simulation parameters: serverNode:nova-2.lyon.grid5000.fr serverIp:10.140.0.1 serverMac:00:16:3E:8C:00:01 clientNode:nova-19.lyon.grid5000.fr clientNode:nova-19.lyon.grid5000.fr clientMac: delay:60 nbSensors:20 nbSensorsFactor:3 requestPerSensors:30 sensorsRequestPerSec: simKey:vmSize simStart:1558336590 simEnd:1558336892 duration:302 serverNodeName:nova-2 vmSize:1024
|
||||
./recordEnergy.sh nova nova-2 1558336590 1558336892 energy_vmSize_20NS_1024vmSize_1558336590_1558336892.csv
|
||||
---------- Simulation (key=vmSize) end at 1558336892 (Mon May 20 09:21:32 CEST 2019)
|
||||
|
||||
---------- Simulation (key=vmSize) start at 1558337031 (Mon May 20 09:23:51 CEST 2019)
|
||||
Simulation parameters: serverNode:nova-2.lyon.grid5000.fr serverIp:10.140.0.1 serverMac:00:16:3E:8C:00:01 clientNode:nova-19.lyon.grid5000.fr clientNode:nova-19.lyon.grid5000.fr clientMac: delay:60 nbSensors:20 nbSensorsFactor:3 requestPerSensors:30 sensorsRequestPerSec: simKey:vmSize simStart:1558337031 simEnd:1558337334 duration:303 serverNodeName:nova-2 vmSize:2048
|
||||
./recordEnergy.sh nova nova-2 1558337031 1558337334 energy_vmSize_20NS_2048vmSize_1558337031_1558337334.csv
|
||||
---------- Simulation (key=vmSize) end at 1558337334 (Mon May 20 09:28:54 CEST 2019)
|
||||
|
||||
---------- Simulation (key=vmSize) start at 1558337473 (Mon May 20 09:31:13 CEST 2019)
|
||||
Simulation parameters: serverNode:nova-2.lyon.grid5000.fr serverIp:10.140.0.1 serverMac:00:16:3E:8C:00:01 clientNode:nova-19.lyon.grid5000.fr clientNode:nova-19.lyon.grid5000.fr clientMac: delay:60 nbSensors:20 nbSensorsFactor:3 requestPerSensors:30 sensorsRequestPerSec: simKey:vmSize simStart:1558337473 simEnd:1558337776 duration:303 serverNodeName:nova-2 vmSize:4096
|
||||
./recordEnergy.sh nova nova-2 1558337473 1558337776 energy_vmSize_20NS_4096vmSize_1558337473_1558337776.csv
|
||||
---------- Simulation (key=vmSize) end at 1558337776 (Mon May 20 09:36:16 CEST 2019)
|
||||
|
||||
---------- Simulation (key=nbSensors) start at 1558337912 (Mon May 20 09:38:32 CEST 2019)
|
||||
Simulation parameters: serverNode:nova-2.lyon.grid5000.fr serverIp:10.140.0.1 serverMac:00:16:3E:8C:00:01 clientNode:nova-19.lyon.grid5000.fr clientNode:nova-19.lyon.grid5000.fr clientMac: delay:60 nbSensors:100 nbSensorsFactor:3 requestPerSensors:30 sensorsRequestPerSec: simKey:nbSensors simStart:1558337912 simEnd:1558338224 duration:312 serverNodeName:nova-2 vmSize:2048
|
||||
./recordEnergy.sh nova nova-2 1558337912 1558338224 energy_nbSensors_100NS_2048vmSize_1558337912_1558338224.csv
|
||||
---------- Simulation (key=nbSensors) end at 1558338224 (Mon May 20 09:43:44 CEST 2019)
|
||||
|
||||
---------- Simulation (key=nbSensors) start at 1558338361 (Mon May 20 09:46:01 CEST 2019)
|
||||
Simulation parameters: serverNode:nova-2.lyon.grid5000.fr serverIp:10.140.0.1 serverMac:00:16:3E:8C:00:01 clientNode:nova-19.lyon.grid5000.fr clientNode:nova-19.lyon.grid5000.fr clientMac: delay:60 nbSensors:300 nbSensorsFactor:3 requestPerSensors:30 sensorsRequestPerSec: simKey:nbSensors simStart:1558338361 simEnd:1558338695 duration:334 serverNodeName:nova-2 vmSize:2048
|
||||
./recordEnergy.sh nova nova-2 1558338361 1558338695 energy_nbSensors_300NS_2048vmSize_1558338361_1558338695.csv
|
||||
---------- Simulation (key=nbSensors) end at 1558338695 (Mon May 20 09:51:35 CEST 2019)
|
||||
|
||||
---------- Simulation (key=nbSensors) start at 1558338832 (Mon May 20 09:53:52 CEST 2019)
|
||||
Simulation parameters: serverNode:nova-2.lyon.grid5000.fr serverIp:10.140.0.1 serverMac:00:16:3E:8C:00:01 clientNode:nova-19.lyon.grid5000.fr clientNode:nova-19.lyon.grid5000.fr clientMac: delay:60 nbSensors:800 nbSensorsFactor:3 requestPerSensors:30 sensorsRequestPerSec: simKey:nbSensors simStart:1558338832 simEnd:1558339221 duration:389 serverNodeName:nova-2 vmSize:2048
|
||||
./recordEnergy.sh nova nova-2 1558338832 1558339221 energy_nbSensors_800NS_2048vmSize_1558338832_1558339221.csv
|
||||
---------- Simulation (key=nbSensors) end at 1558339221 (Mon May 20 10:00:21 CEST 2019)
|
||||
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -1,42 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Parse argument
|
||||
[ $# != 5 ] && { echo "Usage: $0 <cluster-name> <node-name> <from> <to> <output-file>"; exit 1; }
|
||||
|
||||
# Init arguments
|
||||
clusterName="$1"
|
||||
nodeName="$2"
|
||||
outputFile="$5"
|
||||
wattmeter=$(curl -s https://api.grid5000.fr/stable/sites/lyon/clusters/${clusterName}/nodes/${nodeName}.json | jq -r '.sensors.power.via.pdu[0].uid')
|
||||
port=$(curl -s https://api.grid5000.fr/stable/sites/lyon/pdus/${wattmeter}.json | jq -r '.ports|to_entries|map(select(.value=="'${nodeName}'"))[0].key')
|
||||
energyEntry=$(( 5 + port )) # Define the entry in the CSV that correspond to the correct energy value
|
||||
|
||||
if [ -z $wattmeter ] || [ -z $port ]
|
||||
then
|
||||
echo -ne "\nCannot find energy informations (wattmeter/port) for node $nodeName\n"
|
||||
echo -ne "\nCheck the node name (do not use hostname! only node name ex: nova-7)\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Node ${nodeName} is connected on wattmeter ${wattmeter} on port ${port}"
|
||||
|
||||
# Fetching energy and save in csv format
|
||||
from=$(date -d "@$3" "+%s")
|
||||
to=$(date -d "@$4" "+%s")
|
||||
echo "ts,energy" > $outputFile # Write CSV header
|
||||
for time in $(seq $from 3600 $to)
|
||||
do
|
||||
# We need gz extension if it is not the current hour
|
||||
[ $(date -d "@$time" "+%Y-%m-%dT%H") != $(date "+%Y-%m-%dT%H") ] && ext='.gz' || ext=''
|
||||
powerFilename=$(date -d "@$time" "+power.csv.%Y-%m-%dT%H${ext}")
|
||||
url="http://wattmetre.lyon.grid5000.fr/data/${wattmeter}-log/${powerFilename}"
|
||||
echo "- Fetching logs from ${url}"
|
||||
|
||||
# Fetch logs data
|
||||
[ ! -z $ext ] && csvContent=$(curl -s "${url}" | zcat) || csvContent=$(curl -s "${url}")
|
||||
|
||||
# Parse data and extract the right values in csv format
|
||||
toSave=$(echo "$csvContent" | awk -F, 'int($3)>='$from'&& int($3)<='$to'{printf "%s,%s\n",$3,$5+'$port'};')
|
||||
echo "$toSave" >> $outputFile # Save data in csv
|
||||
done
|
||||
echo "Done"
|
|
@ -1,39 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Parameters
|
||||
delay=60 # Delay before starting simulation (let CPU energy going down on the server)
|
||||
nbSensors=20 # Number of sensors that will send request to de server
|
||||
nbSensorsFactor=3 # nbSensors*nbSensorFactor
|
||||
simulationTime=300 # Approximative
|
||||
sensorsSendInterval=10 # Delay between sensors requests
|
||||
# requestPerSensor dynamically computed inside init-nodes
|
||||
vmSize=2048 # Number of alocated ram
|
||||
simKey="NONE"
|
||||
|
||||
# Where script is located
|
||||
simScript=$(dirname $(readlink -f "$0"))/init-nodes-opt.sh
|
||||
|
||||
# Build a function using the script
|
||||
initNodes () {
|
||||
source "$simScript"
|
||||
}
|
||||
|
||||
|
||||
##### Test VM RAM #####
|
||||
simKey="vmSize"
|
||||
for vmSize in $(echo 1024 2048 4096)
|
||||
do
|
||||
initNodes deploy
|
||||
initNodes kill # Kill all vms (do not forget :D)
|
||||
done
|
||||
|
||||
vmSize=2048 # Reset vmSize
|
||||
|
||||
simKey="nbSensors"
|
||||
##### Test number of sensors #####
|
||||
for nbSensors in $(echo 20 100 300)
|
||||
do
|
||||
initNodes deploy
|
||||
initNodes kill # Kill all vms
|
||||
done
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
create DATABASE IF NOT EXISTS experiment;
|
||||
use experiment;
|
||||
create TABLE IF NOT EXISTS temperature (id INTEGER,stamp INTEGER, val INTEGER);
|
||||
|
||||
use mysql;
|
||||
CREATE USER 'user'@'%' IDENTIFIED BY 'mysql';
|
||||
GRANT ALL ON experiment.* TO 'user'@'%';
|
||||
|
|
@ -1,48 +0,0 @@
|
|||
#!/usr/bin/python
|
||||
from __future__ import division
|
||||
import os,sys,random, time,datetime
|
||||
from subprocess import Popen
|
||||
|
||||
# Check script argument
|
||||
if len(sys.argv) != 6:
|
||||
print("Usage: "+sys.argv[0]+" <mysqlServerIp> <nbSensors> <nbSensorsFactor> <requestPerSensor> <sendInterval>")
|
||||
exit(1)
|
||||
|
||||
# Init script parameters
|
||||
serverIp=sys.argv[1]
|
||||
nbSensors=int(sys.argv[2])
|
||||
nbSensorsFactor=int(sys.argv[3])
|
||||
effectiveNbSensors=nbSensors*nbSensorsFactor
|
||||
requestPerSensor=int(sys.argv[4])
|
||||
sendInterval=int(sys.argv[5])
|
||||
avgSiteTemp=list()
|
||||
for i in range(0,effectiveNbSensors):
|
||||
avgSiteTemp.append(random.randint(-10,30))
|
||||
|
||||
|
||||
def insert(sensorId, value):
|
||||
""" Send value of sensorId into the database """
|
||||
stamp=int(time.mktime(datetime.datetime.today().timetuple()))
|
||||
insertCMD = "mysql -u user --password=mysql --host="+serverIp+" experiment -e"
|
||||
insertCMD=insertCMD.split()
|
||||
insertCMD.append("INSERT INTO temperature (id,stamp,val) VALUES("+str(sensorId)+","+str(stamp)+","+str(value)+");")
|
||||
Popen(insertCMD) # Run command asynchronously
|
||||
|
||||
def send():
|
||||
""" Send temperature of each sensors into the database """
|
||||
for i in range(0,effectiveNbSensors):
|
||||
insert(i,random.gauss(avgSiteTemp[i], 3))
|
||||
|
||||
|
||||
# Print infos
|
||||
print("Launching clients with:")
|
||||
print(" - Mysql Server IP {:>20}".format(serverIp))
|
||||
print(" - Number of sensors {:>18}".format(effectiveNbSensors))
|
||||
print(" - Number of request per sensor {:>7}".format(effectiveNbSensors))
|
||||
|
||||
# Send data
|
||||
for i in range(0, requestPerSensor):
|
||||
send()
|
||||
time.sleep(sendInterval) # We assume send() take no time
|
||||
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
|
||||
logFile="$(dirname $(readlink -f $0))"/simLogs.txt
|
||||
|
||||
|
||||
getValue () {
|
||||
line=$(echo "$1" | grep "Simulation para"|sed "s/Simulation parameters: //g")
|
||||
key=$2
|
||||
echo "$line"|awk 'BEGIN{RS=" ";FS=":"}"'$key'"==$1{gsub("\n","",$0);print $2}'
|
||||
}
|
||||
|
||||
IFS=$'\n'
|
||||
for cmd in $(cat $logFile|grep "Simulation parameters")
|
||||
do
|
||||
nodeName=$(getValue $cmd serverNodeName)
|
||||
from=$(getValue $cmd startSim)
|
||||
to=$(getValue $cmd endSim)
|
||||
vmSize=$(getValue $cmd vmSize)
|
||||
nbSensors=$(getValue $cmd nbSensors)
|
||||
simKey=$(getValue $cmd simKey)
|
||||
./recordEnergy.sh nova $nodeName $from $to nova $nodeName $from $to "${simKey}_${vmSize}VMSIZE_${nbSensors}NBSENSORS_${from}${to}.csv"
|
||||
done
|
||||
|
|
@ -1,154 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
##### Parameters #####
|
||||
if [ -z ${nbSensors+x} ] # If nbSensors exists, so all parameters are already define
|
||||
then
|
||||
delay=60 # Delay before starting simulation (let CPU energy going down on the server)
|
||||
nbSensors=30 # Number of sensors that will send request to de server
|
||||
nbSensorsFactor=3 # nbSensors*nbSensorFactor
|
||||
simulationTime=300 # Approximative
|
||||
sensorsSendInterval=10 # Delay between sensors requests
|
||||
vmSize=2048 # Number of alocated ram
|
||||
simKey="NONE"
|
||||
fi
|
||||
nHours=3 # Reservation dutation
|
||||
requestPerSensor=$(( simulationTime / sensorsSendInterval )) # Theorical simulation time is $requestPerSensor*$sensorsSendInterval
|
||||
######################
|
||||
|
||||
|
||||
logFile="./simLogs.txt"
|
||||
log () {
|
||||
echo -e "\033[0;34m$@\033[0m"
|
||||
}
|
||||
|
||||
sshWait () {
|
||||
log "Waiting for for an ssh connection to a vm ($1)"
|
||||
error=255
|
||||
until [ $error -eq 0 ]
|
||||
do
|
||||
ssh -q root@$1 echo "Connected to $(hostname)"
|
||||
error=$?
|
||||
sleep 4
|
||||
done
|
||||
}
|
||||
|
||||
if [ "$1" = "subscribe" ] && [ $# -eq 1 ]
|
||||
then
|
||||
log "Subscribing..."
|
||||
oarsub -l slash_22=1+{"virtual!='NO' AND cluster='nova'"}/nodes=2,walltime=$nHours 'sleep "10d"' # On node send request to the other
|
||||
elif [ "$1" = "deploy" ] && [ $# -eq 1 ]
|
||||
then
|
||||
# Get machine mac address
|
||||
serverSubnet=$(g5k-subnets -im|sed "1q;d")
|
||||
clientSubnet=$(g5k-subnets -im|sed "2q;d")
|
||||
serverMac=$(echo "$serverSubnet"|sed "s/^.*\t//g")
|
||||
clientMac=$(echo "$clientSubnet"|sed "s/^.*\t//g")
|
||||
serverIp=$(echo "$serverSubnet"|sed "s/\t.*$//g")
|
||||
clientIp=$(echo "$clientSubnet"|sed "s/\t.*$//g")
|
||||
serverNode=""
|
||||
clientNode=""
|
||||
|
||||
# Run vms
|
||||
log "Run vms..."
|
||||
isServer=1
|
||||
finished=0
|
||||
for node in $(cat $OAR_NODE_FILE|uniq)
|
||||
do
|
||||
# Init vm images
|
||||
log "Create $node vm image"
|
||||
oarsh $node cp -n /grid5000/virt-images/debian9-x64-base.qcow2 /tmp/
|
||||
oarsh $node qemu-img create -f qcow2 -o backing_file=/tmp/debian9-x64-base.qcow2 /tmp/img.qcow2
|
||||
sleep 1 # Wait for fun
|
||||
|
||||
# Build cloud init iso (to have ssh access witouth password
|
||||
log "Create $node cloud-init image"
|
||||
oarsh $node cp /grid5000/virt-images/cloud-init-example.sh /tmp/
|
||||
oarsh $node "cd /tmp && export cloud_init_key=\$(cat ~/.ssh/id_rsa.pub) && ./cloud-init-example.sh"
|
||||
oarsh $node "cd /tmp && genisoimage -output cloud-init-data.iso -volid cidata -joliet -rock cloud-init-data/user-data cloud-init-data/meta-data"
|
||||
# Refresh loop state
|
||||
[ $isServer -eq 1 ] && { curMac=$serverMac; isServer=0; serverNode=$node; } || { curMac=$clientMac; finished=1; clientNode=$node; }
|
||||
|
||||
# Launch vm
|
||||
log "Launch vm $node"
|
||||
oarsh $node kvm -m ${vmSize}M -hda /tmp/img.qcow2 -netdev bridge,id=br0 -device virtio-net-pci,netdev=br0,id=nic1,mac=$curMac -cdrom /tmp/cloud-init-data.iso -display none -daemonize &
|
||||
|
||||
# Stop looping if we finish
|
||||
[ $finished -eq 1 ] && break
|
||||
done
|
||||
|
||||
log "Installing mysql on $serverIp"
|
||||
serverNodeName=$(echo $serverNode|grep -o ^.*[-][0-9]*) # For logging
|
||||
onNode="ssh -q root@$serverIp" # For convenience
|
||||
|
||||
##### Server #####
|
||||
sshWait $serverIp
|
||||
# One apt-get update seems to be not enought to get mysql-server
|
||||
$onNode "apt-get update && apt-get update"
|
||||
$onNode apt-get -y install mysql-server
|
||||
# Enable mysql connection from outside
|
||||
$onNode sed -i "s/bind-address/#bind-address/g" /etc/mysql/mariadb.conf.d/50-server.cnf
|
||||
$onNode systemctl restart mysql
|
||||
rsync -avh setup-mysql.sql root@$serverIp:/tmp/
|
||||
# Then execute it
|
||||
$onNode "mysql < /tmp/setup-mysql.sql"
|
||||
|
||||
##### Client #####
|
||||
$sshWait $clientIp
|
||||
onNode="ssh -q root@$clientIp"
|
||||
$onNode "apt-get update && apt-get update"
|
||||
$onNode apt-get -y install mysql-server
|
||||
rsync -avh clients.py root@$clientIp:/tmp/
|
||||
|
||||
##### Start Simulation #####
|
||||
log "Simulation will start in ${delay}s"
|
||||
sleep $delay
|
||||
simStart=$(date "+%s")
|
||||
echo "---------- Simulation (key=${simKey}) start at $simStart ($(date -d @${simStart}))" >> $logFile
|
||||
$onNode python /tmp/clients.py $serverIp $nbSensors $nbSensorsFactor $requestPerSensor $sensorsSendInterval
|
||||
simEnd=$(date "+%s")
|
||||
echo "Simulation parameters: serverNode:$serverNode serverIp:$serverIp serverMac:$serverMac clientNode:$clientNode clientNode:$clientNode clientMac:$clientMac delay:$delay nbSensors:$nbSensors nbSensorsFactor:$nbSensorsFactor requestPerSensors:$requestPerSensor sensorsRequestPerSec:$sensorsRequestPerSec simKey:${simKey} simStart:${simStart} simEnd:${simEnd} duration:$(( simEnd - simStart )) serverNodeName:${serverNodeName} vmSize:${vmSize}" >> $logFile
|
||||
echo "./recordEnergy.sh nova $serverNodeName $simStart $simEnd energy_${simKey}_${nbSensors}NS_${vmSize}vmSize_${simStart}_${simEnd}.csv" >> $logFile
|
||||
echo -e "---------- Simulation (key=${simKey}) end at ${simEnd} ($(date -d @${simEnd}))\n" >> $logFile
|
||||
log "Simulation end ! Please see $logFile for more infos"
|
||||
##### End Simulation #####
|
||||
|
||||
##### Print some infos #####
|
||||
log "Network Settings:"
|
||||
log " - Server $serverNode, $serverIp, $serverMac"
|
||||
log " - Client $clientNode, $clientIp, $clientMac"
|
||||
log "Simulation Settings:"
|
||||
log " - Simulation delay ${delay}s"
|
||||
log " - Number of sensors $(( nbSensors * nbSensorsFactor))"
|
||||
log " - Number of request per sensors $requestPerSensor"
|
||||
log " - Number of request per seconds on eachsensors $sensorsRequestPerSec"
|
||||
|
||||
elif [ "$1" = "kill" ] && [ $# -eq 1 ]
|
||||
then
|
||||
##### Kill all kvm on the subscribed nodes #####
|
||||
isServer=1
|
||||
finished=0
|
||||
for node in $(cat $OAR_NODE_FILE|uniq)
|
||||
do
|
||||
[ $isServer -eq 1 ] && { curMac=$serverMac; isServer=0; serverNode=$node; } || { curMac=$clientMac; finished=1; clientNode=$node; }
|
||||
log "Killing vm on node $node"
|
||||
oarsh $node pkill -9 qemu &
|
||||
[ $finished -eq 1 ] && break
|
||||
done
|
||||
elif [ "$1" = "inspect" ] && [ $# -eq 2 ]
|
||||
then
|
||||
##### Show content of the database #####
|
||||
mysql --host="$2" -u user --password="mysql" experiment -e "SELECT * FROM temperature;"
|
||||
elif [ "$1" = "flush" ] && [ $# -eq 2 ]
|
||||
then
|
||||
##### Flush content of the temperature table #####
|
||||
log "Cleaning database table..."
|
||||
mysql --host="$2" -u user --password="mysql" experiment -e "TRUNCATE TABLE temperature;"
|
||||
else
|
||||
echo "Usage:"
|
||||
echo " - $0 subscribe"
|
||||
echo " - $0 deploy"
|
||||
echo " - $0 kill"
|
||||
echo " - $0 inspect <serverIP>"
|
||||
echo " - $0 flush <serverIP>"
|
||||
fi
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Parse argument
|
||||
[ $# != 5 ] && { echo "Usage: $0 <cluster-name> <node-name> <from> <to> <output-file>"; exit 1; }
|
||||
|
||||
# Init arguments
|
||||
clusterName="$1"
|
||||
nodeName="$2"
|
||||
outputFile="$5"
|
||||
wattmeter=$(curl -s https://api.grid5000.fr/stable/sites/lyon/clusters/${clusterName}/nodes/${nodeName}.json | jq -r '.sensors.power.via.pdu[0].uid')
|
||||
port=$(curl -s https://api.grid5000.fr/stable/sites/lyon/pdus/${wattmeter}.json | jq -r '.ports|to_entries|map(select(.value=="'${nodeName}'"))[0].key')
|
||||
energyEntry=$(( 5 + port) # Define the entry in the CSV that correspond to the correct energy value
|
||||
|
||||
if [ -z $wattmeter ] || [ -z $port ]
|
||||
then
|
||||
echo -ne "\nCannot find energy informations (wattmeter/port) for node $nodeName\n"
|
||||
echo -ne "\nCheck the node name (do not use hostname! only node name ex: nova-7)\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Node ${nodeName} is connected on wattmeter ${wattmeter} on port ${port}"
|
||||
|
||||
# Fetching energy and save in csv format
|
||||
from=$(date -d "@$3" "+%s")
|
||||
to=$(date -d "@$4" "+%s")
|
||||
echo "ts,energy" > $outputFile # Write CSV header
|
||||
for time in $(seq $from 3600 $to)
|
||||
do
|
||||
# We need gz extension if it is not the current hour
|
||||
[ $(date -d "@$time" "+%Y-%m-%dT%H") != $(date "+%Y-%m-%dT%H") ] && ext='.gz' || ext=''
|
||||
powerFilename=$(date -d "@$time" "+power.csv.%Y-%m-%dT%H${ext}")
|
||||
url="http://wattmetre.lyon.grid5000.fr/data/${wattmeter}-log/${powerFilename}"
|
||||
echo "- Fetching logs from ${url}"
|
||||
|
||||
# Fetch logs data
|
||||
[ ! -z $ext ] && csvContent=$(curl -s "${url}" | zcat) || csvContent=$(curl -s "${url}")
|
||||
|
||||
# Parse data and extract the right values in csv format
|
||||
toSave=$(echo "$csvContent" | awk -F, 'int($3)>='$from'&& int($3)<='$to'{printf "%s,%s\n",$3,$5+'$port'};')
|
||||
echo "$toSave" >> $outputFile # Save data in csv
|
||||
done
|
||||
echo "Done"
|
|
@ -1,39 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Parameters
|
||||
delay=60 # Delay before starting simulation (let CPU energy going down on the server)
|
||||
nbSensors=20 # Number of sensors that will send request to de server
|
||||
nbSensorsFactor=3 # nbSensors*nbSensorFactor
|
||||
simulationTime=300 # Approximative
|
||||
sensorsSendInterval=10 # Delay between sensors requests
|
||||
# requestPerSensor dynamically computed inside init-nodes
|
||||
vmSize=2048 # Number of alocated ram
|
||||
simKey="NONE"
|
||||
|
||||
# Where script is located
|
||||
simScript=$(dirname $(readlink -f "$0"))/init-nodes.sh
|
||||
|
||||
# Build a function using the script
|
||||
initNodes () {
|
||||
source "$simScript"
|
||||
}
|
||||
|
||||
|
||||
##### Test VM RAM #####
|
||||
simKey="vmSize"
|
||||
for vmSize in $(echo 1024 2048 4096)
|
||||
do
|
||||
initNodes deploy
|
||||
initNodes kill # Kill all vms (do not forget :D)
|
||||
done
|
||||
|
||||
vmSize=2048 # Reset vmSize
|
||||
|
||||
simKey="nbSensors"
|
||||
##### Test number of sensors #####
|
||||
for nbSensors in $(echo 20 100 300)
|
||||
do
|
||||
initNodes deploy
|
||||
initNodes kill # Kill all vms
|
||||
done
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
create DATABASE IF NOT EXISTS experiment;
|
||||
use experiment;
|
||||
create TABLE IF NOT EXISTS temperature (id INTEGER,stamp INTEGER, val INTEGER);
|
||||
|
||||
use mysql;
|
||||
CREATE USER 'user'@'%' IDENTIFIED BY 'mysql';
|
||||
GRANT ALL ON experiment.* TO 'user'@'%';
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
---------- Simulation (key=vmSize) start at 1558010372 (Thu May 16 14:39:32 CEST 2019)
|
||||
Simulation parameters: serverNode:nova-7.lyon.grid5000.fr serverIp:10.140.16.1 serverMac:00:16:3E:8C:10:01 clientNode:nova-8.lyon.grid5000.fr clientNode:nova-8.lyon.grid5000.fr clientMac:00:16:3E:8C:10:02 delay:60 nbSensors:20 nbSensorsFactor:3 requestPerSensors:30 sensorsRequestPerSec: simKey:vmSize duration:308
|
||||
./recordEnergy.sh nova nova-7.lyon.grid5000.fr 1558010372 1558010680 energy_1558010372_1558010680.csv
|
||||
---------- Simulation (key=vmSize) end at 1558010680 (Thu May 16 14:44:40 CEST 2019)
|
||||
|
||||
---------- Simulation (key=vmSize) start at 1558010868 (Thu May 16 14:47:48 CEST 2019)
|
||||
Simulation parameters: serverNode:nova-7.lyon.grid5000.fr serverIp:10.140.16.1 serverMac:00:16:3E:8C:10:01 clientNode:nova-8.lyon.grid5000.fr clientNode:nova-8.lyon.grid5000.fr clientMac:00:16:3E:8C:10:02 delay:60 nbSensors:20 nbSensorsFactor:3 requestPerSensors:30 sensorsRequestPerSec: simKey:vmSize duration:308
|
||||
./recordEnergy.sh nova nova-7.lyon.grid5000.fr 1558010868 1558011176 energy_1558010868_1558011176.csv
|
||||
---------- Simulation (key=vmSize) end at 1558011176 (Thu May 16 14:52:56 CEST 2019)
|
||||
|
||||
---------- Simulation (key=vmSize) start at 1558011366 (Thu May 16 14:56:06 CEST 2019)
|
||||
Simulation parameters: serverNode:nova-7.lyon.grid5000.fr serverIp:10.140.16.1 serverMac:00:16:3E:8C:10:01 clientNode:nova-8.lyon.grid5000.fr clientNode:nova-8.lyon.grid5000.fr clientMac:00:16:3E:8C:10:02 delay:60 nbSensors:20 nbSensorsFactor:3 requestPerSensors:30 sensorsRequestPerSec: simKey:vmSize duration:308
|
||||
./recordEnergy.sh nova nova-7.lyon.grid5000.fr 1558011366 1558011674 energy_1558011366_1558011674.csv
|
||||
---------- Simulation (key=vmSize) end at 1558011674 (Thu May 16 15:01:14 CEST 2019)
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
|
||||
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)))))
|
||||
|
||||
all: wifi-test
|
||||
|
||||
wifi-test: wifi-test.cc
|
||||
g++ $(NS3_ARGS) $^ -o $@
|
||||
|
||||
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
|
||||
|
||||
clean:
|
||||
- rm wifi-test
|
|
@ -1,334 +0,0 @@
|
|||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation;
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include "ns3/core-module.h"
|
||||
#include "ns3/point-to-point-module.h"
|
||||
#include "ns3/network-module.h"
|
||||
#include "ns3/config-store-module.h"
|
||||
#include "ns3/energy-module.h"
|
||||
#include "ns3/applications-module.h"
|
||||
#include "ns3/wifi-module.h"
|
||||
#include "ns3/mobility-module.h"
|
||||
#include "ns3/internet-module.h"
|
||||
#include "ns3/ipv4-global-routing-helper.h"
|
||||
#include "ns3/flow-monitor-module.h"
|
||||
|
||||
// Default Network Topology
|
||||
//
|
||||
// Number of wifi Sta or Edge nodes can be increased up to 250
|
||||
// |
|
||||
// Rank 0 | Rank 1
|
||||
// -------------------------|----------------------------
|
||||
// Wifi Sta 10.1.3.0
|
||||
// AP
|
||||
// * * * *
|
||||
// | | | | 10.1.1.0
|
||||
// n3 n4 n5 n0 -------------- n1 n2
|
||||
// point-to-point | |
|
||||
// * *
|
||||
// Ap
|
||||
// WiFi Edge 10.1.2.0
|
||||
|
||||
using namespace ns3;
|
||||
|
||||
NS_LOG_COMPONENT_DEFINE ("WifiEnergyExample");
|
||||
|
||||
uint32_t PhyTxDropCount =0;
|
||||
uint32_t PhyRxDropCount =0;
|
||||
double offeredLoad = 0.0;
|
||||
double throughput = 0.0;
|
||||
double lastPacketTime = 0.0;
|
||||
|
||||
//FlowMonitorHelper flowmon;
|
||||
|
||||
/// Trace function for remaining energy at node.
|
||||
void
|
||||
RemainingEnergy (double oldValue, double remainingEnergy)
|
||||
{
|
||||
NS_LOG_UNCOND (Simulator::Now ().GetSeconds ()
|
||||
<< "s Current remaining energy = " << remainingEnergy << "J");
|
||||
}
|
||||
|
||||
/// Trace function for total energy consumption at node.
|
||||
void
|
||||
TotalEnergy (double oldValue, double newValue)
|
||||
{
|
||||
NS_LOG_UNCOND (Simulator::Now ().GetSeconds ()
|
||||
<< "AIE\t"<< newValue-oldValue<<"\t"<<newValue);
|
||||
}
|
||||
|
||||
void
|
||||
PhyTxDrop(Ptr<const Packet> p)
|
||||
{
|
||||
NS_LOG_UNCOND(Simulator::Now ().GetSeconds ()<<" Tx Packet Drop "<<++PhyTxDropCount);
|
||||
}
|
||||
|
||||
void
|
||||
PhyRxDrop(Ptr<const Packet> p)
|
||||
{
|
||||
NS_LOG_UNCOND(Simulator::Now ().GetSeconds ()<<" Rx Packet Drop "<<++PhyRxDropCount);
|
||||
}
|
||||
void ThroughputMonitor (FlowMonitorHelper *fmhelper, Ptr<FlowMonitor> flowMon)
|
||||
{
|
||||
std::map<FlowId, FlowMonitor::FlowStats> flowStats = flowMon->GetFlowStats();
|
||||
Ptr<Ipv4FlowClassifier> classing = DynamicCast<Ipv4FlowClassifier> (fmhelper->GetClassifier());
|
||||
for (std::map<FlowId, FlowMonitor::FlowStats>::const_iterator stats = flowStats.begin (); stats != flowStats.end (); ++stats)
|
||||
{
|
||||
Ipv4FlowClassifier::FiveTuple fiveTuple = classing->FindFlow (stats->first);
|
||||
std::cout<<"---------------------------------------------------------------------------"<<std::endl;
|
||||
std::cout<<"Flow ID : " << stats->first <<" ; "<< fiveTuple.sourceAddress <<" -----> "<<fiveTuple.destinationAddress<<std::endl;
|
||||
std::cout<<"Tx Packets = " << stats->second.txPackets<<std::endl;
|
||||
std::cout<<"Rx Packets = " << stats->second.rxPackets<<std::endl;
|
||||
std::cout<<"Duration : "<<stats->second.timeLastRxPacket.GetSeconds()-stats->second.timeFirstTxPacket.GetSeconds()<<std::endl;
|
||||
std::cout<<"Last Received Packet : "<< stats->second.timeLastRxPacket.GetSeconds()<<" Seconds"<<std::endl;
|
||||
std::cout<<"Throughput: " << stats->second.rxBytes * 8.0 / (stats->second.timeLastRxPacket.GetSeconds()-stats->second.timeFirstTxPacket.GetSeconds())/1024/1024 << " Mbps"<<std::endl;
|
||||
std::cout<<"---------------------------------------------------------------------------"<<std::endl;
|
||||
}
|
||||
Simulator::Schedule(Seconds(0.1),&ThroughputMonitor, fmhelper, flowMon);
|
||||
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
bool verbose = true;
|
||||
uint32_t nWifiEdge = 1;
|
||||
bool tracing = false;
|
||||
double interval = 0.01; // ms
|
||||
uint32_t maxPackets = 100000;
|
||||
double simulationTime = 2.1;
|
||||
|
||||
CommandLine cmd;
|
||||
cmd.AddValue ("nWifiEdge", "Number of wifi edge nodes/devices", nWifiEdge);
|
||||
cmd.AddValue ("verbose", "Tell echo applications to log if true", verbose);
|
||||
cmd.AddValue ("tracing", "Enable pcap tracing", tracing);
|
||||
cmd.AddValue ("interval", "Interval between packets", interval);
|
||||
cmd.AddValue ("maxPackets", "Maximum number of packets", maxPackets);
|
||||
|
||||
|
||||
cmd.Parse (argc,argv);
|
||||
|
||||
// turn off RTS/CTS for frames below 2200 bytes
|
||||
//Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold", StringValue ("2200"));
|
||||
|
||||
NodeContainer edgeApNode;
|
||||
edgeApNode.Create (1);
|
||||
NodeContainer wifiEdgeNodes;
|
||||
wifiEdgeNodes.Create (nWifiEdge);
|
||||
|
||||
YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
|
||||
YansWifiPhyHelper phyEdge = YansWifiPhyHelper::Default ();
|
||||
phyEdge.SetChannel (channel.Create ());
|
||||
phyEdge.Set ("TxAntennas", UintegerValue (4));
|
||||
phyEdge.Set ("RxAntennas", UintegerValue (4));
|
||||
|
||||
|
||||
WifiHelper wifi;
|
||||
wifi.SetStandard (WIFI_PHY_STANDARD_80211n_5GHZ);
|
||||
wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager","DataMode", StringValue("HtMcs31"),"ControlMode",StringValue("HtMcs31"));
|
||||
|
||||
|
||||
|
||||
WifiMacHelper macEdge;
|
||||
Ssid ssid = Ssid ("ns-3-ssid-edge");
|
||||
macEdge.SetType ("ns3::StaWifiMac",
|
||||
"Ssid", SsidValue (ssid),
|
||||
"ActiveProbing", BooleanValue (false));
|
||||
|
||||
NetDeviceContainer edgeDevices;
|
||||
edgeDevices = wifi.Install (phyEdge, macEdge, wifiEdgeNodes);
|
||||
|
||||
macEdge.SetType ("ns3::ApWifiMac",
|
||||
"Ssid", SsidValue (ssid));
|
||||
|
||||
NetDeviceContainer edgeApDevices;
|
||||
edgeApDevices = wifi.Install (phyEdge, macEdge, edgeApNode);
|
||||
|
||||
MobilityHelper mobility;
|
||||
|
||||
mobility.SetPositionAllocator ("ns3::GridPositionAllocator",
|
||||
"MinX", DoubleValue (0.0),
|
||||
"MinY", DoubleValue (0.0),
|
||||
"DeltaX", DoubleValue (0.5),
|
||||
"DeltaY", DoubleValue (0.5),
|
||||
"GridWidth", UintegerValue (3),
|
||||
"LayoutType", StringValue ("RowFirst"));
|
||||
|
||||
mobility.SetMobilityModel ("ns3::RandomWalk2dMobilityModel",
|
||||
"Bounds", RectangleValue (Rectangle (-50, 50, -50, 50)));
|
||||
|
||||
mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
|
||||
mobility.Install (edgeApNode);
|
||||
mobility.Install (wifiEdgeNodes);
|
||||
|
||||
InternetStackHelper stack;
|
||||
stack.Install (edgeApNode);
|
||||
stack.Install (wifiEdgeNodes);
|
||||
|
||||
Ipv4AddressHelper address;
|
||||
|
||||
address.SetBase ("10.1.2.0", "255.255.255.0");
|
||||
Ipv4InterfaceContainer edgeInterfaces;
|
||||
Ipv4InterfaceContainer edgeApInterfaces;
|
||||
edgeInterfaces = address.Assign (edgeDevices);
|
||||
edgeApInterfaces = address.Assign(edgeApDevices);
|
||||
|
||||
|
||||
/** Energy Model **/
|
||||
/***************************************************************************/
|
||||
/* energy source */
|
||||
BasicEnergySourceHelper edgeBasicSourceHelper;
|
||||
// configure energy source
|
||||
|
||||
edgeBasicSourceHelper.Set ("BasicEnergySourceInitialEnergyJ", DoubleValue (2.9009));
|
||||
edgeBasicSourceHelper.Set ("BasicEnergySupplyVoltageV", DoubleValue (3.3));
|
||||
// install source
|
||||
EnergySourceContainer wifiEdgeNodesSources = edgeBasicSourceHelper.Install (wifiEdgeNodes);
|
||||
EnergySourceContainer apEdgeNodesSources = edgeBasicSourceHelper.Install (edgeApNode);
|
||||
|
||||
/* device energy model */
|
||||
WifiRadioEnergyModelHelper radioEnergyHelper;
|
||||
// configure radio energy model
|
||||
radioEnergyHelper.Set ("TxCurrentA", DoubleValue (0.38));
|
||||
radioEnergyHelper.Set ("RxCurrentA", DoubleValue (0.313));
|
||||
radioEnergyHelper.Set ("IdleCurrentA", DoubleValue (0.273));
|
||||
// install device model
|
||||
DeviceEnergyModelContainer edgeDeviceModels = radioEnergyHelper.Install (edgeDevices, wifiEdgeNodesSources);
|
||||
DeviceEnergyModelContainer edgeApDeviceModels = radioEnergyHelper.Install (edgeApDevices, apEdgeNodesSources);
|
||||
|
||||
/***************************************************************************/
|
||||
//Setting applications
|
||||
UdpServerHelper myServer (9);
|
||||
|
||||
ApplicationContainer serverApps = myServer.Install (edgeApNode.Get (0));
|
||||
serverApps.Start (Seconds (0));
|
||||
serverApps.Stop (Seconds (simulationTime));
|
||||
|
||||
//UdpEchoClientHelper client (serverAddress, port);
|
||||
UdpClientHelper myClient (edgeApInterfaces.GetAddress (0), 9);
|
||||
myClient.SetAttribute ("MaxPackets", UintegerValue (maxPackets));
|
||||
myClient.SetAttribute ("Interval", TimeValue (Seconds ((interval/1000.0))));
|
||||
myClient.SetAttribute ("PacketSize", UintegerValue (1472)); // in Bytes
|
||||
|
||||
ApplicationContainer clientApps = myClient.Install (wifiEdgeNodes.Get (0));
|
||||
clientApps.Start (Seconds (1.0));
|
||||
clientApps.Stop (Seconds (simulationTime));
|
||||
|
||||
Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
|
||||
|
||||
/** connect trace sources **/
|
||||
/***************************************************************************/
|
||||
// all sources are connected to node 1
|
||||
// energy source
|
||||
|
||||
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));
|
||||
|
||||
|
||||
if (tracing == true)
|
||||
{
|
||||
//AsciiTraceHelper ascii;
|
||||
//pointToPoint.EnableAsciiAll(ascii.CreateFileStream ("energy-wifi.tr"));
|
||||
//pointToPoint.EnablePcapAll ("wifiEnergy");
|
||||
// phySta.EnablePcapAll ("wifiEnergy");
|
||||
phyEdge.EnablePcapAll ("wifiEnergy");
|
||||
|
||||
}
|
||||
|
||||
//Set simulation time and launch simulation
|
||||
Config::ConnectWithoutContext("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/PhyRxDrop", MakeCallback(&PhyRxDrop));
|
||||
Config::ConnectWithoutContext("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/PhyTxDrop", MakeCallback(&PhyTxDrop));
|
||||
|
||||
|
||||
// edgeDevices.Get(0)->TraceConnectWithoutContext("PhyTxDrop",MakeCallback(&PhyTxDrop));
|
||||
|
||||
|
||||
///
|
||||
// FlowMonitor
|
||||
///
|
||||
FlowMonitorHelper fmHelper;
|
||||
Ptr<FlowMonitor> allMon = fmHelper.InstallAll();
|
||||
Simulator::Schedule(Seconds(1),&ThroughputMonitor,&fmHelper, allMon);
|
||||
|
||||
|
||||
FlowMonitorHelper flowmon;
|
||||
Ptr<FlowMonitor> monitor = flowmon.InstallAll();
|
||||
Ptr<Ipv4FlowClassifier> classifier = DynamicCast<Ipv4FlowClassifier> (flowmon.GetClassifier ());
|
||||
|
||||
Simulator::Stop (Seconds (simulationTime));
|
||||
Simulator::Run ();
|
||||
|
||||
std::map<FlowId, FlowMonitor::FlowStats> stats = monitor->GetFlowStats ();
|
||||
|
||||
double totalThroughput = 0.0;
|
||||
double totalLostPackets = 0.0;
|
||||
for (std::map< FlowId, FlowMonitor::FlowStats>::iterator flow=stats.begin(); flow!=stats.end(); flow++)
|
||||
{
|
||||
Ipv4FlowClassifier::FiveTuple t = classifier->FindFlow(flow->first);
|
||||
NS_LOG_UNCOND( "\nFlowID: " << flow->first << " ("
|
||||
<< t.sourceAddress << " / " << t.sourcePort << " --> "
|
||||
<< t.destinationAddress << " / " << t.destinationPort << ")" );
|
||||
NS_LOG_UNCOND( " Tx Packets: " << flow->second.txPackets );
|
||||
NS_LOG_UNCOND( " Tx Bytes: " << flow->second.txBytes );
|
||||
|
||||
offeredLoad = flow->second.txBytes * 8.0 / (flow->second.timeLastTxPacket.GetSeconds () - flow->second.timeFirstTxPacket.GetSeconds ()) / 1000000 ;
|
||||
NS_LOG_UNCOND( " Offered Load: " << offeredLoad << " Mbps");
|
||||
|
||||
NS_LOG_UNCOND( " Rx Packets: " << flow->second.rxPackets );
|
||||
NS_LOG_UNCOND( " Rx Bytes: " << flow->second.rxBytes );
|
||||
|
||||
throughput = flow->second.rxBytes * 8.0 / (flow->second.timeLastRxPacket.GetSeconds () - flow->second.timeFirstRxPacket.GetSeconds ()) / 1000000;
|
||||
NS_LOG_UNCOND( " Throughput: " << throughput << " Mbps");
|
||||
|
||||
NS_LOG_UNCOND( " Lost Packets: " << flow->second.lostPackets );
|
||||
NS_LOG_UNCOND( " Time last packet Transmited: " << flow->second.timeLastTxPacket.GetSeconds() );
|
||||
NS_LOG_UNCOND( " Time last packet Received: " << flow->second.timeLastRxPacket.GetSeconds() );
|
||||
|
||||
if(t.destinationPort == 9){
|
||||
|
||||
totalThroughput = totalThroughput + throughput;
|
||||
totalLostPackets = totalLostPackets + flow->second.lostPackets;
|
||||
|
||||
}
|
||||
if(t.destinationPort == 9 && (lastPacketTime < flow->second.timeLastRxPacket.GetSeconds ())){
|
||||
|
||||
lastPacketTime = flow->second.timeLastRxPacket.GetSeconds ();
|
||||
}
|
||||
|
||||
}
|
||||
double averageThroughput = totalThroughput/nWifiEdge;
|
||||
double averageLostPackets = totalLostPackets/nWifiEdge;
|
||||
|
||||
NS_LOG_UNCOND( "\nLast Packet Time: " << lastPacketTime);
|
||||
NS_LOG_UNCOND( "Average Throughput: " << averageThroughput << " Mbps");
|
||||
NS_LOG_UNCOND( "Average Lost Packet : " << averageLostPackets);
|
||||
|
||||
|
||||
Simulator::Destroy ();
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,377 +0,0 @@
|
|||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation;
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include "ns3/core-module.h"
|
||||
#include "ns3/point-to-point-module.h"
|
||||
#include "ns3/network-module.h"
|
||||
#include "ns3/config-store-module.h"
|
||||
#include "ns3/energy-module.h"
|
||||
#include "ns3/applications-module.h"
|
||||
#include "ns3/wifi-module.h"
|
||||
#include "ns3/mobility-module.h"
|
||||
#include "ns3/internet-module.h"
|
||||
#include "ns3/ipv4-global-routing-helper.h"
|
||||
#include "ns3/flow-monitor-module.h"
|
||||
|
||||
// Default Network Topology
|
||||
//
|
||||
// Number of wifi Sta or Edge nodes can be increased up to 250
|
||||
// |
|
||||
// Rank 0 | Rank 1
|
||||
// -------------------------|----------------------------
|
||||
// Wifi Sta 10.1.3.0
|
||||
// AP
|
||||
// * * * *
|
||||
// | | | | 10.1.1.0
|
||||
// n3 n4 n5 n0 -------------- n1 n2
|
||||
// point-to-point | |
|
||||
// * *
|
||||
// Ap
|
||||
// WiFi Edge 10.1.2.0
|
||||
|
||||
using namespace ns3;
|
||||
|
||||
NS_LOG_COMPONENT_DEFINE ("WifiEnergyExample");
|
||||
|
||||
uint32_t PhyTxDropCount =0;
|
||||
uint32_t PhyRxDropCount =0;
|
||||
double offeredLoad = 0.0;
|
||||
double throughput = 0.0;
|
||||
double lastPacketTime = 0.0;
|
||||
|
||||
//FlowMonitorHelper flowmon;
|
||||
|
||||
/// Trace function for remaining energy at node.
|
||||
void
|
||||
RemainingEnergy (double oldValue, double remainingEnergy)
|
||||
{
|
||||
NS_LOG_UNCOND (Simulator::Now ().GetSeconds ()
|
||||
<< "s Current remaining energy = " << remainingEnergy << "J");
|
||||
}
|
||||
|
||||
/// Trace function for total energy consumption at node.
|
||||
void
|
||||
TotalEnergy (double oldValue, double newValue)
|
||||
{
|
||||
NS_LOG_UNCOND (Simulator::Now ().GetSeconds ()
|
||||
<< "\t"<< newValue-oldValue<<"\t"<<newValue);
|
||||
}
|
||||
|
||||
void
|
||||
PhyTxDrop(Ptr<const Packet> p)
|
||||
{
|
||||
NS_LOG_UNCOND(Simulator::Now ().GetSeconds ()<<" Tx Packet Drop "<<++PhyTxDropCount);
|
||||
}
|
||||
|
||||
void
|
||||
PhyRxDrop(Ptr<const Packet> p)
|
||||
{
|
||||
NS_LOG_UNCOND(Simulator::Now ().GetSeconds ()<<" Rx Packet Drop "<<++PhyRxDropCount);
|
||||
}
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
bool verbose = false;
|
||||
uint32_t nWifiSta = 1;
|
||||
uint32_t nWifiEdge = 1;
|
||||
bool tracing = false;
|
||||
double interval = 1.0;
|
||||
uint32_t maxPackets = 10;
|
||||
double simulationTime = 20.0;
|
||||
|
||||
CommandLine cmd;
|
||||
cmd.AddValue ("nWifiEdge", "Number of wifi edge nodes/devices", nWifiEdge);
|
||||
cmd.AddValue ("nWifiSta", "Number of wifi STA devices", nWifiSta);
|
||||
cmd.AddValue ("verbose", "Tell echo applications to log if true", verbose);
|
||||
cmd.AddValue ("tracing", "Enable pcap tracing", tracing);
|
||||
cmd.AddValue ("interval", "Interval between packets", interval);
|
||||
cmd.AddValue ("maxPackets", "Maximum number of packets", maxPackets);
|
||||
|
||||
|
||||
cmd.Parse (argc,argv);
|
||||
|
||||
// Check for valid number of csma or wifi nodes
|
||||
// 250 should be enough, otherwise IP addresses
|
||||
// soon become an issue
|
||||
if (nWifiEdge > 250 || nWifiSta > 250)
|
||||
{
|
||||
std::cout << "Too many wifi station/edge nodes, no more than 250 each." << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (verbose)
|
||||
{
|
||||
LogComponentEnable ("UdpEchoClientApplication", LOG_LEVEL_INFO);
|
||||
LogComponentEnable ("UdpEchoServerApplication", LOG_LEVEL_INFO);
|
||||
//LogComponentEnable("YansWifiPhy",LOG_LEVEL_INFO);
|
||||
}
|
||||
|
||||
NodeContainer p2pNodes;
|
||||
p2pNodes.Create (2);
|
||||
|
||||
PointToPointHelper pointToPoint;
|
||||
pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("250Mbps"));
|
||||
pointToPoint.SetChannelAttribute ("Delay", StringValue ("1ns"));
|
||||
|
||||
NetDeviceContainer p2pDevices;
|
||||
p2pDevices = pointToPoint.Install (p2pNodes);
|
||||
|
||||
NodeContainer wifiStaNodes;
|
||||
wifiStaNodes.Create (nWifiSta);
|
||||
NodeContainer staApNode = p2pNodes.Get (0);
|
||||
|
||||
NodeContainer wifiEdgeNodes;
|
||||
wifiEdgeNodes.Create (nWifiEdge);
|
||||
NodeContainer edgeApNode = p2pNodes.Get (1);
|
||||
|
||||
YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
|
||||
YansWifiPhyHelper phySta = YansWifiPhyHelper::Default ();
|
||||
phySta.SetChannel (channel.Create ());
|
||||
phySta.Set ("TxAntennas", UintegerValue (4));
|
||||
phySta.Set ("RxAntennas", UintegerValue (4));
|
||||
|
||||
YansWifiPhyHelper phyEdge = YansWifiPhyHelper::Default ();
|
||||
phyEdge.SetChannel (channel.Create ());
|
||||
phyEdge.Set ("TxAntennas", UintegerValue (4));
|
||||
phyEdge.Set ("RxAntennas", UintegerValue (4));
|
||||
|
||||
|
||||
WifiHelper wifi;
|
||||
wifi.SetStandard (WIFI_PHY_STANDARD_80211n_5GHZ);
|
||||
wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager","DataMode", StringValue("HtMcs31"),"ControlMode",StringValue("HtMcs31"));
|
||||
|
||||
WifiMacHelper macSta;
|
||||
Ssid ssid = Ssid ("ns-3-ssid-sta");
|
||||
macSta.SetType ("ns3::StaWifiMac",
|
||||
"Ssid", SsidValue (ssid),
|
||||
"ActiveProbing", BooleanValue (false));
|
||||
|
||||
NetDeviceContainer staDevices;
|
||||
staDevices = wifi.Install (phySta, macSta, wifiStaNodes);
|
||||
|
||||
macSta.SetType ("ns3::ApWifiMac",
|
||||
"Ssid", SsidValue (ssid));
|
||||
|
||||
NetDeviceContainer staApDevices;
|
||||
staApDevices = wifi.Install (phySta, macSta, staApNode);
|
||||
|
||||
WifiMacHelper macEdge;
|
||||
ssid = Ssid ("ns-3-ssid-edge");
|
||||
macEdge.SetType ("ns3::StaWifiMac",
|
||||
"Ssid", SsidValue (ssid),
|
||||
"ActiveProbing", BooleanValue (false));
|
||||
|
||||
NetDeviceContainer edgeDevices;
|
||||
edgeDevices = wifi.Install (phyEdge, macEdge, wifiEdgeNodes);
|
||||
|
||||
macEdge.SetType ("ns3::ApWifiMac",
|
||||
"Ssid", SsidValue (ssid));
|
||||
|
||||
NetDeviceContainer edgeApDevices;
|
||||
edgeApDevices = wifi.Install (phyEdge, macEdge, edgeApNode);
|
||||
|
||||
MobilityHelper mobility;
|
||||
|
||||
mobility.SetPositionAllocator ("ns3::GridPositionAllocator",
|
||||
"MinX", DoubleValue (0.0),
|
||||
"MinY", DoubleValue (0.0),
|
||||
"DeltaX", DoubleValue (0.5),
|
||||
"DeltaY", DoubleValue (0.5),
|
||||
"GridWidth", UintegerValue (3),
|
||||
"LayoutType", StringValue ("RowFirst"));
|
||||
|
||||
mobility.SetMobilityModel ("ns3::RandomWalk2dMobilityModel",
|
||||
"Bounds", RectangleValue (Rectangle (-50, 50, -50, 50)));
|
||||
mobility.Install (wifiStaNodes);
|
||||
|
||||
mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
|
||||
mobility.Install (staApNode);
|
||||
mobility.Install (edgeApNode);
|
||||
mobility.Install (wifiEdgeNodes);
|
||||
|
||||
InternetStackHelper stack;
|
||||
stack.Install (staApNode);
|
||||
stack.Install (edgeApNode);
|
||||
stack.Install (wifiStaNodes);
|
||||
stack.Install (wifiEdgeNodes);
|
||||
|
||||
Ipv4AddressHelper address;
|
||||
|
||||
address.SetBase ("10.1.1.0", "255.255.255.0");
|
||||
Ipv4InterfaceContainer p2pInterfaces;
|
||||
p2pInterfaces = address.Assign (p2pDevices);
|
||||
|
||||
address.SetBase ("10.1.2.0", "255.255.255.0");
|
||||
Ipv4InterfaceContainer edgeInterfaces;
|
||||
edgeInterfaces = address.Assign (edgeDevices);
|
||||
address.Assign(edgeApDevices);
|
||||
|
||||
address.SetBase ("10.1.3.0", "255.255.255.0");
|
||||
address.Assign (staDevices);
|
||||
address.Assign (staApDevices);
|
||||
|
||||
/** Energy Model **/
|
||||
/***************************************************************************/
|
||||
/* energy source */
|
||||
BasicEnergySourceHelper staBasicSourceHelper;
|
||||
BasicEnergySourceHelper edgeBasicSourceHelper;
|
||||
// configure energy source
|
||||
|
||||
staBasicSourceHelper.Set ("BasicEnergySourceInitialEnergyJ", DoubleValue (100));
|
||||
edgeBasicSourceHelper.Set ("BasicEnergySourceInitialEnergyJ", DoubleValue (100));
|
||||
// edgeBasicSourceHelper.Set ("BasicEnergySupplyVoltageV", DoubleValue (220));
|
||||
// install source
|
||||
EnergySourceContainer wifiStaNodesSources = staBasicSourceHelper.Install (wifiStaNodes);
|
||||
EnergySourceContainer wifiEdgeNodesSources = edgeBasicSourceHelper.Install (wifiEdgeNodes);
|
||||
|
||||
/* device energy model */
|
||||
WifiRadioEnergyModelHelper radioEnergyHelper;
|
||||
// configure radio energy model
|
||||
/*
|
||||
radioEnergyHelper.Set ("TxCurrentA", DoubleValue (0.0857));
|
||||
radioEnergyHelper.Set ("RxCurrentA", DoubleValue (0.0528));
|
||||
radioEnergyHelper.Set ("IdleCurrentA", DoubleValue (0.0188));
|
||||
*/
|
||||
// install device model
|
||||
DeviceEnergyModelContainer staDeviceModels = radioEnergyHelper.Install (staDevices, wifiStaNodesSources);
|
||||
DeviceEnergyModelContainer edgeDeviceModels = radioEnergyHelper.Install (edgeDevices, wifiEdgeNodesSources);
|
||||
|
||||
/***************************************************************************/
|
||||
UdpEchoServerHelper echoServer (9);
|
||||
|
||||
ApplicationContainer serverApps = echoServer.Install (wifiEdgeNodes.Get (0));
|
||||
serverApps.Start (Seconds (0));
|
||||
serverApps.Stop (Seconds (simulationTime));
|
||||
|
||||
UdpEchoClientHelper echoClient (edgeInterfaces.GetAddress (0), 9);
|
||||
echoClient.SetAttribute ("MaxPackets", UintegerValue (maxPackets));
|
||||
echoClient.SetAttribute ("Interval", TimeValue (Seconds ((interval/1000.0))));
|
||||
echoClient.SetAttribute ("PacketSize", UintegerValue (1472));
|
||||
|
||||
ApplicationContainer clientApps =
|
||||
echoClient.Install (wifiStaNodes);
|
||||
clientApps.Start (Seconds (0.5));
|
||||
clientApps.Stop (Seconds (simulationTime));
|
||||
|
||||
Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
|
||||
|
||||
/** connect trace sources **/
|
||||
/***************************************************************************/
|
||||
// all sources are connected to node 1
|
||||
// energy source
|
||||
|
||||
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));
|
||||
|
||||
/*
|
||||
|
||||
Ptr<BasicEnergySource> basicSourcePtr1 = DynamicCast<BasicEnergySource> (wifiStaNodesSources.Get (0));
|
||||
|
||||
Ptr<DeviceEnergyModel> basicRadioModelPtr1 =
|
||||
basicSourcePtr1->FindDeviceEnergyModels ("ns3::WifiRadioEnergyModel").Get (0);
|
||||
|
||||
NS_ASSERT (basicRadioModelPtr1 != NULL);
|
||||
basicRadioModelPtr1->TraceConnectWithoutContext ("TotalEnergyConsumption", MakeCallback (&TotalEnergy));
|
||||
*/
|
||||
|
||||
|
||||
|
||||
if (tracing == true)
|
||||
{
|
||||
//AsciiTraceHelper ascii;
|
||||
//pointToPoint.EnableAsciiAll(ascii.CreateFileStream ("energy-wifi.tr"));
|
||||
pointToPoint.EnablePcapAll ("wifiEnergy");
|
||||
// phySta.EnablePcapAll ("wifiEnergy");
|
||||
// phyEdge.EnablePcapAll ("wifiEnergy");
|
||||
|
||||
}
|
||||
|
||||
//Set simulation time and launch simulation
|
||||
Config::ConnectWithoutContext("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/PhyRxDrop", MakeCallback(&PhyRxDrop));
|
||||
Config::ConnectWithoutContext("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/PhyTxDrop", MakeCallback(&PhyTxDrop));
|
||||
|
||||
|
||||
// edgeDevices.Get(0)->TraceConnectWithoutContext("PhyTxDrop",MakeCallback(&PhyTxDrop));
|
||||
|
||||
|
||||
|
||||
FlowMonitorHelper flowmon;
|
||||
Ptr<FlowMonitor> monitor = flowmon.InstallAll();
|
||||
Ptr<Ipv4FlowClassifier> classifier = DynamicCast<Ipv4FlowClassifier> (flowmon.GetClassifier ());
|
||||
|
||||
Simulator::Stop (Seconds (simulationTime));
|
||||
Simulator::Run ();
|
||||
|
||||
std::map<FlowId, FlowMonitor::FlowStats> stats = monitor->GetFlowStats ();
|
||||
|
||||
double totalThroughput = 0.0;
|
||||
double totalLostPackets = 0.0;
|
||||
for (std::map< FlowId, FlowMonitor::FlowStats>::iterator flow=stats.begin(); flow!=stats.end(); flow++)
|
||||
{
|
||||
Ipv4FlowClassifier::FiveTuple t = classifier->FindFlow(flow->first);
|
||||
NS_LOG_UNCOND( "\nFlowID: " << flow->first << " ("
|
||||
<< t.sourceAddress << " / " << t.sourcePort << " --> "
|
||||
<< t.destinationAddress << " / " << t.destinationPort << ")" );
|
||||
NS_LOG_UNCOND( " Tx Packets: " << flow->second.txPackets );
|
||||
NS_LOG_UNCOND( " Tx Bytes: " << flow->second.txBytes );
|
||||
|
||||
offeredLoad = flow->second.txBytes * 8.0 / (flow->second.timeLastTxPacket.GetSeconds () - flow->second.timeFirstTxPacket.GetSeconds ()) / 1000000 ;
|
||||
NS_LOG_UNCOND( " Offered Load: " << offeredLoad << " Mbps");
|
||||
|
||||
NS_LOG_UNCOND( " Rx Packets: " << flow->second.rxPackets );
|
||||
NS_LOG_UNCOND( " Rx Bytes: " << flow->second.rxBytes );
|
||||
|
||||
throughput = flow->second.rxBytes * 8.0 / (flow->second.timeLastRxPacket.GetSeconds () - flow->second.timeFirstRxPacket.GetSeconds ()) / 1000000;
|
||||
NS_LOG_UNCOND( " Throughput: " << throughput << " Mbps");
|
||||
|
||||
NS_LOG_UNCOND( " Lost Packets: " << flow->second.lostPackets );
|
||||
NS_LOG_UNCOND( " Time last packet Transmited: " << flow->second.timeLastTxPacket.GetSeconds() );
|
||||
NS_LOG_UNCOND( " Time last packet Received: " << flow->second.timeLastRxPacket.GetSeconds() );
|
||||
|
||||
if(t.destinationPort == 9){
|
||||
|
||||
totalThroughput = totalThroughput + throughput;
|
||||
totalLostPackets = totalLostPackets + flow->second.lostPackets;
|
||||
|
||||
}
|
||||
if(t.destinationPort == 9 && (lastPacketTime < flow->second.timeLastRxPacket.GetSeconds ())){
|
||||
|
||||
lastPacketTime = flow->second.timeLastRxPacket.GetSeconds ();
|
||||
}
|
||||
|
||||
}
|
||||
double averageThroughput = totalThroughput/nWifiSta;
|
||||
double averageLostPackets = totalLostPackets/nWifiSta;
|
||||
|
||||
NS_LOG_UNCOND( "\nLast Packet Time: " << lastPacketTime);
|
||||
NS_LOG_UNCOND( "Average Throughput: " << averageThroughput << " Mbps");
|
||||
NS_LOG_UNCOND( "Average Lost Packet : " << averageLostPackets);
|
||||
|
||||
Simulator::Destroy ();
|
||||
|
||||
return 0;
|
||||
}
|
Binary file not shown.
|
@ -1,262 +0,0 @@
|
|||
// ns-3
|
||||
|
||||
#include "ns3/command-line.h"
|
||||
#include "ns3/config.h"
|
||||
#include "ns3/string.h"
|
||||
#include "ns3/log.h"
|
||||
#include "ns3/yans-wifi-helper.h"
|
||||
#include "ns3/ssid.h"
|
||||
#include "ns3/mobility-helper.h"
|
||||
#include "ns3/on-off-helper.h"
|
||||
#include "ns3/yans-wifi-channel.h"
|
||||
#include "ns3/mobility-model.h"
|
||||
#include "ns3/packet-sink.h"
|
||||
#include "ns3/packet-sink-helper.h"
|
||||
#include "ns3/udp-echo-helper.h"
|
||||
#include "ns3/tcp-westwood.h"
|
||||
#include "ns3/internet-stack-helper.h"
|
||||
#include "ns3/ipv4-address-helper.h"
|
||||
#include "ns3/ipv4-global-routing-helper.h"
|
||||
#include "ns3/constant-position-mobility-model.h"
|
||||
#include "ns3/energy-module.h"
|
||||
#include "ns3/wifi-radio-energy-model-helper.h"
|
||||
#include "ns3/point-to-point-helper.h"
|
||||
|
||||
// C++ library
|
||||
#include <iostream>
|
||||
#include <utility> // To use std::pair
|
||||
#include <iomanip>
|
||||
|
||||
using namespace ns3;
|
||||
NS_LOG_COMPONENT_DEFINE ("wifi-tcp");
|
||||
|
||||
Ipv4Address cloudIP;
|
||||
int cloudPort=50;
|
||||
|
||||
|
||||
// ---------- Code ----------
|
||||
// Cell tuple like ((APNode,SensorNodes),(APNetDev,SensorsNetDev))
|
||||
typedef std::pair<NodeContainer,NodeContainer> CellNodes;
|
||||
typedef std::pair<NetDeviceContainer,NetDeviceContainer> CellNetDevices;
|
||||
typedef std::pair<CellNodes,CellNetDevices> Cell;
|
||||
|
||||
|
||||
|
||||
void CloudSwitchRx(Ptr< const Packet > packet, const Address &address){
|
||||
NS_LOG_UNCOND(std::setw(7)<<Simulator::Now ().GetSeconds ()<< " Cloud switch receive a packet!");
|
||||
}
|
||||
|
||||
void
|
||||
TotalEnergy (std::string context,double oldValue, double newValue)
|
||||
{
|
||||
NS_LOG_UNCOND ("Energy Value of node " << context << " at time " <<Simulator::Now ().GetSeconds ()
|
||||
<< "\t"<< newValue);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Create a sensors cell base on
|
||||
* nbSensors Number of temperature sensors in the cell
|
||||
* ap the Access Point (usually linked to the cloud)
|
||||
*/
|
||||
Cell createCell(uint32_t nbSensors, Ptr<ns3::Node> ap){
|
||||
// Create sensors
|
||||
NodeContainer sensors;
|
||||
sensors.Create(nbSensors);
|
||||
|
||||
// Place nodes somehow, this is required by every wireless simulation
|
||||
for (uint8_t i = 0; i < nbSensors; ++i)
|
||||
{
|
||||
sensors.Get (i)->AggregateObject (CreateObject<ConstantPositionMobilityModel> ());
|
||||
}
|
||||
ap->AggregateObject (CreateObject<ConstantPositionMobilityModel> ());
|
||||
|
||||
// To apply XXWifiPhy and WifiMac on sensors
|
||||
WifiHelper wifiHelper;
|
||||
wifiHelper.SetStandard (WIFI_PHY_STANDARD_80211n_5GHZ);
|
||||
|
||||
/* Set up Legacy Channel */
|
||||
YansWifiChannelHelper wifiChannel;
|
||||
wifiChannel.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel");
|
||||
wifiChannel.AddPropagationLoss ("ns3::FriisPropagationLossModel", "Frequency", DoubleValue (5e9));
|
||||
|
||||
/* Setup Physical Layer */
|
||||
YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
|
||||
wifiPhy.SetChannel (wifiChannel.Create ());
|
||||
wifiPhy.Set ("TxPowerStart", DoubleValue (10.0));
|
||||
wifiPhy.Set ("TxPowerEnd", DoubleValue (10.0));
|
||||
wifiPhy.Set ("TxPowerLevels", UintegerValue (1));
|
||||
wifiPhy.Set ("TxGain", DoubleValue (0));
|
||||
wifiPhy.Set ("RxGain", DoubleValue (0));
|
||||
wifiPhy.Set ("RxNoiseFigure", DoubleValue (10));
|
||||
wifiPhy.Set ("CcaMode1Threshold", DoubleValue (-79));
|
||||
wifiPhy.Set ("EnergyDetectionThreshold", DoubleValue (-79 + 3));
|
||||
// wifiPhy.SetErrorRateModel ("ns3::YansErrorRateModel");
|
||||
wifiHelper.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
|
||||
"DataMode", StringValue ("HtMcs7"),
|
||||
"ControlMode", StringValue ("HtMcs0"));
|
||||
/* Configure AP */
|
||||
Ssid ssid = Ssid ("network");
|
||||
WifiMacHelper wifiMac;
|
||||
wifiMac.SetType ("ns3::ApWifiMac", "Ssid", SsidValue (ssid));
|
||||
NetDeviceContainer apNetDevice;
|
||||
apNetDevice = wifiHelper.Install (wifiPhy, wifiMac, ap);
|
||||
/* Configure STA */
|
||||
wifiMac.SetType ("ns3::StaWifiMac", "Ssid", SsidValue (ssid));
|
||||
NetDeviceContainer sensorsNetDevices;
|
||||
sensorsNetDevices = wifiHelper.Install (wifiPhy, wifiMac, sensors);
|
||||
|
||||
return(std::make_pair(std::make_pair(ap,sensors),std::make_pair(apNetDevice,sensorsNetDevices)));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Install network stack and applications
|
||||
*/
|
||||
void applyScenarios(Cell cell,int sensorsPktSize, int sensorsSendInterval){
|
||||
NodeContainer ap=cell.first.first;
|
||||
NodeContainer sensors=cell.first.second;
|
||||
NetDeviceContainer apNetDev= cell.second.first;
|
||||
NetDeviceContainer sensorsNetDev= cell.second.second;
|
||||
|
||||
// 6. Install TCP/IP stack & assign IP addresses
|
||||
InternetStackHelper internet;
|
||||
// internet.Install (ap);
|
||||
internet.Install (sensors);
|
||||
Ipv4AddressHelper ipv4;
|
||||
ipv4.SetBase ("10.0.0.0", "255.255.255.0");
|
||||
Ipv4InterfaceContainer apInt,sensorsInt;
|
||||
apInt=ipv4.Assign(apNetDev);
|
||||
sensorsInt=ipv4.Assign(sensorsNetDev);
|
||||
|
||||
UdpEchoClientHelper echoClientHelper (InetSocketAddress (cloudIP, cloudPort));
|
||||
// echoClientHelper.SetAttribute ("MaxPackets", UintegerValue (10));
|
||||
echoClientHelper.SetAttribute ("Interval", TimeValue (Seconds (sensorsSendInterval)));
|
||||
echoClientHelper.SetAttribute ("PacketSize", UintegerValue (sensorsPktSize));
|
||||
ApplicationContainer pingApps;
|
||||
|
||||
// again using different start times to workaround Bug 388 and Bug 912
|
||||
echoClientHelper.SetAttribute ("StartTime", TimeValue (Seconds (1))); // Start at 1 (WIFI seems to not work when t<1)
|
||||
echoClientHelper.Install (sensors);
|
||||
}
|
||||
|
||||
Ptr<ns3::Node> buildEdgeAndCloud(int nbOp){
|
||||
|
||||
NodeContainer OpNodes;
|
||||
OpNodes.Create(nbOp+1);
|
||||
|
||||
InternetStackHelper stack;
|
||||
stack.Install(OpNodes);
|
||||
|
||||
for(int i=0;i<nbOp;i++){ // Not nbOp-1 (We add a AP)
|
||||
NodeContainer curNodes(OpNodes.Get(i),OpNodes.Get(i+1));
|
||||
|
||||
PointToPointHelper pointToPoint;
|
||||
pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
|
||||
pointToPoint.SetChannelAttribute ("Delay", StringValue ("2ms"));
|
||||
|
||||
NetDeviceContainer p2pDevices;
|
||||
p2pDevices = pointToPoint.Install (curNodes);
|
||||
|
||||
Ipv4AddressHelper address;
|
||||
address.SetBase (("10.1."+std::to_string(i)+".0").c_str(), "255.255.255.0");
|
||||
Ipv4InterfaceContainer p2pInterfaces;
|
||||
p2pInterfaces = address.Assign (p2pDevices);
|
||||
|
||||
// NS_LOG_UNCOND(i);
|
||||
if(i==nbOp-1){ // If we are on the last Op
|
||||
cloudIP=p2pInterfaces.GetAddress (1);
|
||||
|
||||
PacketSinkHelper apSink("ns3::UdpSocketFactory",InetSocketAddress (Ipv4Address::GetAny (), cloudPort));
|
||||
ApplicationContainer sinkApp=apSink.Install(curNodes.Get(1));
|
||||
sinkApp.Get(0)->TraceConnectWithoutContext("Rx",MakeCallback(&CloudSwitchRx));
|
||||
sinkApp.Start (Seconds (0));
|
||||
}
|
||||
}
|
||||
return(OpNodes.Get(0));
|
||||
|
||||
}
|
||||
|
||||
|
||||
void setupEnergy(Cell cell){
|
||||
NodeContainer nodes(cell.first.first,cell.first.second);
|
||||
NetDeviceContainer nodesNetDev(cell.second.first,cell.second.second);
|
||||
|
||||
// Install energy source
|
||||
BasicEnergySourceHelper edgeBasicSourceHelper;
|
||||
edgeBasicSourceHelper.Set ("BasicEnergySourceInitialEnergyJ", DoubleValue (2.9009));
|
||||
edgeBasicSourceHelper.Set ("BasicEnergySupplyVoltageV", DoubleValue (3.3));
|
||||
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));
|
||||
DeviceEnergyModelContainer edgeApDeviceModels = radioEnergyHelper.Install (cell.second.first, apEdgeNodesSources);
|
||||
DeviceEnergyModelContainer edgeDeviceModels = radioEnergyHelper.Install (cell.second.second, wifiEdgeNodesSources);
|
||||
|
||||
|
||||
// Trace
|
||||
DeviceEnergyModelContainer energyModels(edgeApDeviceModels, edgeDeviceModels);
|
||||
DeviceEnergyModelContainer::Iterator it=energyModels.Begin();
|
||||
|
||||
int i=0;
|
||||
while(it!=energyModels.End()){
|
||||
(*it)->TraceConnect ("TotalEnergyConsumption", std::to_string(i),MakeCallback (&TotalEnergy));
|
||||
it++;
|
||||
i++;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// 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));
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char* argv[]){
|
||||
|
||||
//LogComponentEnable("UdpEchoClientApplication", LOG_LEVEL_INFO);
|
||||
// LogComponentEnable("PacketSink", LOG_LEVEL_INFO);
|
||||
|
||||
uint32_t sensorsFrequency=1;
|
||||
uint32_t sensorsPktSize=150;
|
||||
uint32_t sensorsNumber=2;
|
||||
uint32_t nbHop=5;
|
||||
|
||||
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.Parse (argc, argv);
|
||||
|
||||
|
||||
Cell c=createCell(sensorsNumber,buildEdgeAndCloud(nbHop));
|
||||
|
||||
applyScenarios(c,sensorsPktSize,sensorsFrequency);
|
||||
// setupEnergy(c);
|
||||
Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
|
||||
// Run simulators
|
||||
Simulator::Stop (Seconds (20));
|
||||
Simulator::Run ();
|
||||
|
||||
// Destroy
|
||||
Simulator::Destroy ();
|
||||
|
||||
return(0);
|
||||
}
|
|
@ -1,469 +0,0 @@
|
|||
|
||||
|
||||
|
||||
* Run simulations
|
||||
To run all the simulations, execute the following call:
|
||||
#+NAME: runSim
|
||||
#+CALL: runBW(lat=runLat(nbSens=runNbSensors(nbHop=runNbHop())))
|
||||
|
||||
#+RESULTS: runSim
|
||||
|
||||
** Experiments
|
||||
|
||||
*** Sensors Position
|
||||
#+NAME: runSensorsPos
|
||||
#+BEGIN_SRC bash :noweb yes :results output
|
||||
<<singleRun>>
|
||||
simKey="SENSORSPOS"
|
||||
for sensorsNumber in $(seq 5 5 20)
|
||||
do
|
||||
for positionSeed in $(seq 1 10)
|
||||
do
|
||||
run
|
||||
done
|
||||
done
|
||||
#+END_SRC
|
||||
|
||||
*** Sensors Send Interval
|
||||
#+NAME: runSendInterval
|
||||
#+BEGIN_SRC bash :noweb yes :results output
|
||||
<<singleRun>>
|
||||
simKey="SENDINTERVAL"
|
||||
for sensorsNumber in $(seq 5 5 20)
|
||||
do
|
||||
for sensorsSendInterval in $(seq 10 10 100)
|
||||
do
|
||||
run
|
||||
done
|
||||
done
|
||||
#+END_SRC
|
||||
|
||||
*** Bandwidth
|
||||
#+NAME: runBW
|
||||
#+BEGIN_SRC bash :noweb yes :results output
|
||||
<<singleRun>>
|
||||
simKey="BW"
|
||||
for sensorsNumber in $(seq 1 10)
|
||||
do
|
||||
for linksBandwidth in $(seq 10 20 100)
|
||||
do
|
||||
run
|
||||
done
|
||||
done
|
||||
#+END_SRC
|
||||
|
||||
#+RESULTS: runBW
|
||||
|
||||
#+RESULTS:
|
||||
|
||||
*** Latency
|
||||
#+NAME: runLat
|
||||
#+BEGIN_SRC bash :noweb yes :results output
|
||||
<<singleRun>>
|
||||
simKey="LATENCY"
|
||||
for sensorsNumber in $(seq 1 10)
|
||||
do
|
||||
for linksLatency in $(seq 1 1 10)
|
||||
do
|
||||
run
|
||||
done
|
||||
done
|
||||
#+END_SRC
|
||||
|
||||
#+RESULTS: runLat
|
||||
|
||||
#+RESULTS:
|
||||
|
||||
*** Number of sensors
|
||||
#+NAME: runNbSensors
|
||||
#+BEGIN_SRC bash :noweb yes :results output
|
||||
<<singleRun>>
|
||||
simKey="NBSENSORS"
|
||||
for sensorsNumber in $(seq 1 10)
|
||||
do
|
||||
run
|
||||
done
|
||||
#+END_SRC
|
||||
|
||||
#+RESULTS:
|
||||
|
||||
*** Number of Hop
|
||||
#+NAME: runNbHop
|
||||
#+BEGIN_SRC bash :noweb yes :results output
|
||||
<<singleRun>>
|
||||
simKey="NBHOP"
|
||||
for sensorsNumber in $(seq 1 10)
|
||||
do
|
||||
for nbHop in $(seq 1 10)
|
||||
do
|
||||
run
|
||||
done
|
||||
done
|
||||
#+END_SRC
|
||||
|
||||
#+RESULTS: runNbHop
|
||||
|
||||
|
||||
** Single Run
|
||||
|
||||
#+NAME: singleRun
|
||||
#+BEGIN_SRC bash :eval never :noweb yes :results output
|
||||
simulator="simulator/simulator"
|
||||
parseEnergyScript="./parseEnergy.awk"
|
||||
parseDelayScript="./parseDelay.awk"
|
||||
logFolder="logs/"
|
||||
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${NS3_PATH}/build/lib
|
||||
|
||||
# Default Parameters
|
||||
sensorsSendInterval=10 # DON'T GO BELOW 1 SECONDS !!!!!!! Simulator will stay stuck
|
||||
sensorsPktSize=5 # 1 byte temperature (-128 à +128 °C) and 4Byte sensorsId
|
||||
sensorsNumber=10
|
||||
nbHop=10 # Cf paper AC/Yunbo
|
||||
linksBandwidth=10
|
||||
linksLatency=2
|
||||
positionSeed=5
|
||||
simKey="NOKEY"
|
||||
|
||||
run () {
|
||||
# If another function want to handle simulation (tipically used on g5k)
|
||||
type -t handleSim > /dev/null && { handleSim; return; }
|
||||
|
||||
local logFile="${logFolder}/${simKey}_${sensorsSendInterval}SSI_${sensorsPktSize}SPS_${sensorsNumber}SN_${nbHop}NH_${linksBandwidth}LB_${linksLatency}LL_${positionSeed}PS.org"
|
||||
[ -f "$logFile" ] && return
|
||||
local simCMD="$simulator --sensorsSendInterval=${sensorsSendInterval} --sensorsPktSize=${sensorsPktSize} --sensorsNumber=${sensorsNumber} --nbHop=${nbHop} --linksBandwidth=${linksBandwidth} --linksLatency=${linksLatency} --positionSeed=${positionSeed} 2>&1"
|
||||
local log=$(bash -c "$simCMD")
|
||||
|
||||
# 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)}')
|
||||
sensorsEnergy=$(echo "$energyLog" |awk -F',' 'BEGIN{sumW=0}$1<0{sumW+=$2}END{print sumW}')
|
||||
networkEnergy=$(echo "$energyLog" |awk -F',' 'BEGIN{sumN=0}$1>=0{sumN+=$2}END{print sumN}')
|
||||
nbPacketCloud=$(echo "$log"|grep -c "CloudSwitch receive")
|
||||
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 (version ${ns3Version}) simulation\n" > $logFile
|
||||
echo "* Environment Variables" >> $logFile
|
||||
env >> $logFile
|
||||
echo "* Full Command" >> $logFile
|
||||
echo "$simCMD" >> $logFile
|
||||
echo "* Output" >> $logFile
|
||||
echo "$log" >> $logFile
|
||||
echo "* Energy CSV (negative nodeId = WIFI, 0 = AP (Wireless+Wired), positive nodeId = ECOFEN" >> $logFile
|
||||
echo "$energyLog" >> $logFile
|
||||
echo "* Metrics" >> $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} simKey:${simKey} positionSeed:${positionSeed} sensorsEnergy:${sensorsEnergy} networkEnergy:${networkEnergy}" >> $logFile
|
||||
}
|
||||
|
||||
#+END_SRC
|
||||
|
||||
** Grid 5000
|
||||
*** Master Node Script
|
||||
This code generate and distribute simulation argument to the slave worker nodes and
|
||||
run start their simulations processes:
|
||||
#+BEGIN_SRC sh :tangle ./g5k-root.sh :shebang "#!/bin/bash" :noweb yes
|
||||
##### Arguments #####
|
||||
nHost=20 # At least 20 host x)
|
||||
nProcesses=3 # Max number of parrallel simulations (don't go too high, your process will be killed (arround 8))
|
||||
nHours=4 # Reservation duration
|
||||
simArgsLoc=~/args/ # Don't change this path witouth changing it in workder scripts
|
||||
finishedFile="$simArgsLoc/finished-microBenchmarks.txt"
|
||||
logsFinalDst=~/logs/
|
||||
#####################
|
||||
|
||||
# Check
|
||||
[ "$1" == "subscribe" ] && subscribe=1 ||subscribe=0
|
||||
[ "$1" == "deploy" ] && deploy=1 || deploy=0
|
||||
[ "$1" == "-p" ] && progress=1 || progress=0
|
||||
|
||||
handleSim () {
|
||||
[ -z "${argId}" ] && argId=1 || argId=$(( argId + 1 ))
|
||||
outF="$simArgsLoc/${argId}.sh" # Args file based on host name (avoid conflict)
|
||||
|
||||
# Add Shebang
|
||||
echo '#!/bin/bash' > $outF
|
||||
echo "finishedFile=\"$finishedFile\"" >> $outF
|
||||
echo "nProcesses=$nProcesses" >> $outF
|
||||
echo "logsFinalDst=\"$logsFinalDst\"" >> $outF
|
||||
# Save arguments
|
||||
echo "sensorsSendInterval=${sensorsSendInterval}" >> $outF
|
||||
echo "sensorsPktSize=${sensorsPktSize}" >> $outF
|
||||
echo "nbHop=${nbHop}" >> $outF
|
||||
echo "simKey=\"${simKey}\"" >> $outF
|
||||
echo "sensorsNumber=${sensorsNumber}" >> $outF
|
||||
echo "linksLatency=${linksLatency}" >> $outF
|
||||
echo "sensorsNumber=${sensorsNumber}" >> $outF
|
||||
echo "linksBandwidth=${linksBandwidth}" >> $outF
|
||||
echo "positionSeed=${positionSeed}" >> $outF
|
||||
}
|
||||
|
||||
|
||||
# Start subscribe/deploy
|
||||
if [ $subscribe -eq 1 ]
|
||||
then
|
||||
echo "Starting oarsub..."
|
||||
oarsub -l host=$nHost,walltime=$nHours 'sleep "10d"' # Start reservation
|
||||
echo "Please join your node manually when your reservation is ready by using oarsub -C <job-id>"
|
||||
exit 0
|
||||
elif [ $deploy -eq 1 ]
|
||||
then
|
||||
echo "Starting deployment..."
|
||||
|
||||
##### Usefull Variables #####
|
||||
wai=$(dirname "$(readlink -f $0)") # Where Am I ?
|
||||
hostList=($(cat $OAR_NODE_FILE | uniq))
|
||||
#############################
|
||||
|
||||
# Initialize logsFinalDst
|
||||
mkdir -p $logsFinalDst
|
||||
rm -rf $logsFinalDst/* # Clean log dst just in case (it is dangerous but avoid conflict)
|
||||
mkdir -p $simArgsLoc
|
||||
rm -rf $simArgsLoc/* # Clean old args
|
||||
|
||||
# Add your simulation code block here
|
||||
<<runNbSensors>>
|
||||
<<runSendInterval>>
|
||||
<<runSensorsPos>>
|
||||
|
||||
# Distribute argument according to subsribed nodes
|
||||
cd $simArgsLoc
|
||||
curHostId=0
|
||||
for file in $(find ./ -type f)
|
||||
do
|
||||
[ $curHostId -eq $nHost ] && curHostId=0
|
||||
mv -- ${file} ${hostList[$curHostId]}-$(basename ${file})
|
||||
curHostId=$(( curHostId + 1 ))
|
||||
done
|
||||
cd -
|
||||
|
||||
|
||||
# Run simulations
|
||||
echo "Host who finished their work:" > $finishedFile
|
||||
for host in ${hostList[@]}
|
||||
do
|
||||
echo "Start simulations on node $host"
|
||||
oarsh lguegan@$host bash g5k-worker.sh &
|
||||
done
|
||||
|
||||
exit 0
|
||||
elif [ $progress -eq 1 ]
|
||||
then
|
||||
alreadyFinished=$(cat $finishedFile| tail -n +2| wc -l)
|
||||
percent=$(echo $alreadyFinished $nHost| awk '{print $1/$2*100}')
|
||||
echo "Progression: " $alreadyFinished/$nHost "(${percent}%)"
|
||||
else
|
||||
echo "Invalid arguments, make sure you know what you are doing !"
|
||||
exit 1
|
||||
fi
|
||||
#+END_SRC
|
||||
*** Worker Node Script
|
||||
Almost like the [[microBenchmarksSingle][single run script]] but with additionnal code to handle g5k simulation platform (arguments,logs etc..).
|
||||
#+BEGIN_SRC sh :tangle ./g5k-worker.sh :shebang "#!/bin/bash" :noweb yes
|
||||
export NS3_PATH=~/.bin/ns-3/ns-3.29/
|
||||
g5kLogFolder="/tmp/logs/"
|
||||
mkdir -p $g5kLogFolder # Create log folder just in case
|
||||
rm -rf $g5kLogFolder/* # Clean previous logs just in case
|
||||
|
||||
hostname=$(hostname)
|
||||
|
||||
# Run simulations with sourced arguments :D
|
||||
simArgsLoc=~/args/ # Don't change this path without changing it in root scripts
|
||||
|
||||
argsId=0
|
||||
argsFile="$simArgsLoc/${hostname}-args-${argsId}.sh" # Arguments generated by Root Node
|
||||
curNProcesses=0 # Start with no processes
|
||||
for argsFile in $(find $simArgsLoc -type f -name "$hostname*")
|
||||
do
|
||||
<<singleRun>>
|
||||
logFolder=$g5kLogFolder # Don't forget override default g5kLogFolder
|
||||
source $argsFile # Fetch argument
|
||||
run & # Run async
|
||||
((curNProcesses+=1)) # Increase by 2
|
||||
[ $curNProcesses -ge $nProcesses ] && { curNProcesses=0; wait; }
|
||||
done
|
||||
wait # Wait until the end of all simulations
|
||||
|
||||
cp -r $g5kLogFolder/* "$logsFinalDst" # Fetch log from tmp into nfs
|
||||
echo $(hostname) >> $finishedFile # Just say I finished
|
||||
#+END_SRC
|
||||
|
||||
* Logs Analysis
|
||||
To Generate all the plots, please execute the following line:
|
||||
#+NAME: runAnalysis
|
||||
#+CALL: plotToPDF(plots=genAllPlots(data=logToCSV()))
|
||||
|
||||
#+RESULTS: runAnalysis
|
||||
|
||||
** R Scripts
|
||||
*** Generate all plots script
|
||||
Available variables:
|
||||
|---------------------|
|
||||
| Name |
|
||||
|---------------------|
|
||||
| sensorsSendInterval |
|
||||
| sensorsPktSize |
|
||||
| sensorsNumber |
|
||||
| nbHop |
|
||||
| linksBandwidth |
|
||||
| linksLatency |
|
||||
| totalEnergy |
|
||||
| nbPacketCloud |
|
||||
| nbNodes |
|
||||
| avgDelay |
|
||||
| simKey |
|
||||
|---------------------|
|
||||
|
||||
#+NAME: genAllPlots
|
||||
#+BEGIN_SRC R :noweb yes :results output
|
||||
<<RUtils>>
|
||||
# easyPlotGroup("linksLatency","totalEnergy", "LATENCY","sensorsNumber")
|
||||
# easyPlotGroup("linksBandwidth","totalEnergy", "BW","sensorsNumber")
|
||||
easyPlot("sensorsNumber","totalEnergy", "NBSENSORS")
|
||||
easyPlotGroup("positionSeed", "totalEnergy","SENSORSPOS","sensorsNumber")
|
||||
easyPlotGroup("positionSeed", "avgDelay","SENSORSPOS","sensorsNumber")
|
||||
easyPlotGroup("sensorsSendInterval","sensorsEnergy","SENDINTERVAL","sensorsNumber")
|
||||
easyPlotGroup("sensorsSendInterval","networkEnergy","SENDINTERVAL","sensorsNumber")
|
||||
|
||||
#+END_SRC
|
||||
|
||||
#+RESULTS: genAllPlots
|
||||
|
||||
*** R Utils
|
||||
RUtils is intended to load logs (data.csv) and providing
|
||||
simple plot function for them.
|
||||
|
||||
#+NAME: RUtils
|
||||
#+BEGIN_SRC R :eval never
|
||||
library("tidyverse")
|
||||
|
||||
# Fell free to update the following
|
||||
labels=c(nbNodes="Number of nodes",sensorsNumber="Number of sensors",totalEnergy="Total Energy (J)",
|
||||
nbHop="Number of hop (AP to Cloud)", linksBandwidth="Links Bandwidth (Mbps)", avgDelay="Average Application Delay (s)",
|
||||
linksLatency="Links Latency (ms)", sensorsSendInterval="Sensors Send Interval (s)", positionSeed="Position Seed",
|
||||
sensorsEnergy="Sensors Wifi Energy Consumption (J)", networkEnergy="Network Energy Consumption (J)")
|
||||
|
||||
# Load Data
|
||||
data=read_csv("logs/data.csv")
|
||||
|
||||
# Get label according to varName
|
||||
getLabel=function(varName){
|
||||
if(is.na(labels[varName])){
|
||||
return(varName)
|
||||
}
|
||||
return(labels[varName])
|
||||
}
|
||||
|
||||
easyPlot=function(X,Y,KEY){
|
||||
curData=data%>%filter(simKey==KEY)
|
||||
stopifnot(NROW(curData)>0)
|
||||
ggplot(curData,aes_string(x=X,y=Y))+geom_point()+geom_line()+xlab(getLabel(X))+ylab(getLabel(Y))
|
||||
ggsave(paste0("plots/",KEY,"-",X,"_",Y,".png"))
|
||||
}
|
||||
|
||||
easyPlotGroup=function(X,Y,KEY,GRP){
|
||||
curData=data%>%filter(simKey==KEY) %>% mutate(!!GRP:=as.character(UQ(rlang::sym(GRP)))) # %>%mutate(sensorsNumber=as.character(sensorsNumber))
|
||||
stopifnot(NROW(curData)>0)
|
||||
ggplot(curData,aes_string(x=X,y=Y,color=GRP,group=GRP))+geom_point()+geom_line()+xlab(getLabel(X))+ylab(getLabel(Y)) + labs(color = getLabel(GRP))
|
||||
ggsave(paste0("plots/",KEY,"-",X,"_",Y,".png"))
|
||||
}
|
||||
#+END_SRC
|
||||
|
||||
** Plots -> PDF
|
||||
Merge all plots in plots/ folder into a pdf file.
|
||||
#+NAME: plotToPDF
|
||||
#+BEGIN_SRC bash :results output :noweb yes
|
||||
orgFile="plots/plots.org"
|
||||
<<singleRun>> # To get all default arguments
|
||||
|
||||
# Write helper function
|
||||
function write {
|
||||
echo "$1" >> $orgFile
|
||||
}
|
||||
|
||||
echo "#+TITLE: Analysis" > $orgFile
|
||||
write "#+LATEX_HEADER: \usepackage{fullpage}"
|
||||
write "#+OPTIONS: toc:nil"
|
||||
# Default arguments
|
||||
write '\begin{center}'
|
||||
write '\begin{tabular}{lr}'
|
||||
write 'Parameters & Values\\'
|
||||
write '\hline'
|
||||
write "sensorsPktSize & ${sensorsPktSize} bytes\\\\"
|
||||
write "sensorsSendInterval & ${sensorsSendInterval}s\\\\"
|
||||
write "sensorsNumber & ${sensorsNumber}\\\\"
|
||||
write "nbHop & ${nbHop}\\\\"
|
||||
write "linksBandwidth & ${linksBandwidth}Mbps\\\\"
|
||||
write "linksLatency & ${linksLatency}ms\\\\"
|
||||
write '\end{tabular}'
|
||||
write '\newline'
|
||||
write '\end{center}'
|
||||
|
||||
for plot in $(find plots/ -type f -name "*.png")
|
||||
do
|
||||
write "\includegraphics[width=0.5\linewidth]{$(basename ${plot})}"
|
||||
done
|
||||
|
||||
# Export to pdf
|
||||
emacs $orgFile --batch -f org-latex-export-to-pdf --kill
|
||||
#+END_SRC
|
||||
|
||||
#+RESULTS:
|
||||
|
||||
** Log -> CSV
|
||||
logToCSV extract usefull data from logs and put them into logs/data.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
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
** Custom Plots
|
||||
|
||||
#+NAME: ssiNet
|
||||
#+BEGIN_SRC R :noweb yes :results graphics :file plots/sensorsSendInterval-net.png
|
||||
<<RUtils>>
|
||||
|
||||
data%>%filter(simKey=="SENDINTERVAL",sensorsNumber==20) %>% ggplot(aes(x=sensorsSendInterval,y=networkEnergy))+xlab(getLabel("sensorsSendInterval"))+ylab(getLabel("networkEnergy"))+
|
||||
geom_line()+labs(title="For 20 sensors")
|
||||
ggsave("plots/sensorsSendInterval-net.png",dpi=80)
|
||||
#+END_SRC
|
||||
|
||||
#+RESULTS: ssiNet
|
||||
[[file:plots/sensorsSendInterval-net.png]]
|
||||
|
||||
#+RESULTS:
|
||||
[[file:plots/sensorsSendInterval-net.png]]
|
||||
|
||||
|
||||
#+NAME: ssiWifi
|
||||
#+BEGIN_SRC R :noweb yes :results graphics :file plots/sensorsSendInterval-wifi.png
|
||||
<<RUtils>>
|
||||
data%>%filter(simKey=="SENDINTERVAL",sensorsNumber==20) %>% ggplot(aes(x=sensorsSendInterval,y=sensorsEnergy))+xlab(getLabel("sensorsSendInterval"))+ylab(getLabel("sensorsEnergy"))+
|
||||
geom_line() + geom_line()+labs(title="For 20 sensors")
|
||||
ggsave("plots/sensorsSendInterval-wifi.png",dpi=80)
|
||||
#+END_SRC
|
||||
|
||||
#+RESULTS: ssiWifi
|
||||
[[file:plots/sensorsSendInterval-wifi.png]]
|
||||
|
||||
#+RESULTS:
|
||||
[[file:plots/sensorsSendInterval.png]]
|
|
@ -1,12 +0,0 @@
|
|||
-1,1622.11
|
||||
0,3422.92
|
||||
1,3600
|
||||
2,3600
|
||||
3,3600
|
||||
4,3600
|
||||
5,3600
|
||||
6,3600
|
||||
7,3600
|
||||
8,3600
|
||||
9,1800
|
||||
|
|
@ -1,259 +0,0 @@
|
|||
#!/bin/bash
|
||||
##### Arguments #####
|
||||
nHost=20 # At least 20 host x)
|
||||
nProcesses=3 # Max number of parrallel simulations (don't go too high, your process will be killed (arround 8))
|
||||
nHours=4 # Reservation duration
|
||||
simArgsLoc=~/args/ # Don't change this path witouth changing it in workder scripts
|
||||
finishedFile="$simArgsLoc/finished-microBenchmarks.txt"
|
||||
logsFinalDst=~/logs/
|
||||
#####################
|
||||
|
||||
# Check
|
||||
[ "$1" == "subscribe" ] && subscribe=1 ||subscribe=0
|
||||
[ "$1" == "deploy" ] && deploy=1 || deploy=0
|
||||
[ "$1" == "-p" ] && progress=1 || progress=0
|
||||
|
||||
handleSim () {
|
||||
[ -z "${argId}" ] && argId=1 || argId=$(( argId + 1 ))
|
||||
outF="$simArgsLoc/${argId}.sh" # Args file based on host name (avoid conflict)
|
||||
|
||||
# Add Shebang
|
||||
echo '#!/bin/bash' > $outF
|
||||
echo "finishedFile=\"$finishedFile\"" >> $outF
|
||||
echo "nProcesses=$nProcesses" >> $outF
|
||||
echo "logsFinalDst=\"$logsFinalDst\"" >> $outF
|
||||
# Save arguments
|
||||
echo "sensorsSendInterval=${sensorsSendInterval}" >> $outF
|
||||
echo "sensorsPktSize=${sensorsPktSize}" >> $outF
|
||||
echo "nbHop=${nbHop}" >> $outF
|
||||
echo "simKey=\"${simKey}\"" >> $outF
|
||||
echo "sensorsNumber=${sensorsNumber}" >> $outF
|
||||
echo "linksLatency=${linksLatency}" >> $outF
|
||||
echo "sensorsNumber=${sensorsNumber}" >> $outF
|
||||
echo "linksBandwidth=${linksBandwidth}" >> $outF
|
||||
echo "positionSeed=${positionSeed}" >> $outF
|
||||
}
|
||||
|
||||
|
||||
# Start subscribe/deploy
|
||||
if [ $subscribe -eq 1 ]
|
||||
then
|
||||
echo "Starting oarsub..."
|
||||
oarsub -l host=$nHost,walltime=$nHours 'sleep "10d"' # Start reservation
|
||||
echo "Please join your node manually when your reservation is ready by using oarsub -C <job-id>"
|
||||
exit 0
|
||||
elif [ $deploy -eq 1 ]
|
||||
then
|
||||
echo "Starting deployment..."
|
||||
|
||||
##### Usefull Variables #####
|
||||
wai=$(dirname "$(readlink -f $0)") # Where Am I ?
|
||||
hostList=($(cat $OAR_NODE_FILE | uniq))
|
||||
#############################
|
||||
|
||||
# Initialize logsFinalDst
|
||||
mkdir -p $logsFinalDst
|
||||
rm -rf $logsFinalDst/* # Clean log dst just in case (it is dangerous but avoid conflict)
|
||||
mkdir -p $simArgsLoc
|
||||
rm -rf $simArgsLoc/* # Clean old args
|
||||
|
||||
# Add your simulation code block here
|
||||
simulator="simulator/simulator"
|
||||
parseEnergyScript="./parseEnergy.awk"
|
||||
parseDelayScript="./parseDelay.awk"
|
||||
logFolder="logs/"
|
||||
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${NS3_PATH}/build/lib
|
||||
|
||||
# Default Parameters
|
||||
sensorsSendInterval=10 # DON'T GO BELOW 1 SECONDS !!!!!!! Simulator will stay stuck
|
||||
sensorsPktSize=5 # 1 byte temperature (-128 à +128 °C) and 4Byte sensorsId
|
||||
sensorsNumber=10
|
||||
nbHop=10 # Cf paper AC/Yunbo
|
||||
linksBandwidth=10
|
||||
linksLatency=2
|
||||
positionSeed=5
|
||||
simKey="NOKEY"
|
||||
|
||||
run () {
|
||||
# If another function want to handle simulation (tipically used on g5k)
|
||||
type -t handleSim > /dev/null && { handleSim; return; }
|
||||
|
||||
local logFile="${logFolder}/${simKey}_${sensorsSendInterval}SSI_${sensorsPktSize}SPS_${sensorsNumber}SN_${nbHop}NH_${linksBandwidth}LB_${linksLatency}LL_${positionSeed}PS.org"
|
||||
[ -f "$logFile" ] && return
|
||||
local simCMD="$simulator --sensorsSendInterval=${sensorsSendInterval} --sensorsPktSize=${sensorsPktSize} --sensorsNumber=${sensorsNumber} --nbHop=${nbHop} --linksBandwidth=${linksBandwidth} --linksLatency=${linksLatency} --positionSeed=${positionSeed} 2>&1"
|
||||
local log=$(bash -c "$simCMD")
|
||||
|
||||
# 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)}')
|
||||
sensorsEnergy=$(echo "$energyLog" |awk -F',' 'BEGIN{sumW=0}$1<0{sumW+=$2}END{print sumW}')
|
||||
networkEnergy=$(echo "$energyLog" |awk -F',' 'BEGIN{sumN=0}$1>=0{sumN+=$2}END{print sumN}')
|
||||
nbPacketCloud=$(echo "$log"|grep -c "CloudSwitch receive")
|
||||
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 (version ${ns3Version}) simulation\n" > $logFile
|
||||
echo "* Environment Variables" >> $logFile
|
||||
env >> $logFile
|
||||
echo "* Full Command" >> $logFile
|
||||
echo "$simCMD" >> $logFile
|
||||
echo "* Output" >> $logFile
|
||||
echo "$log" >> $logFile
|
||||
echo "* Energy CSV (negative nodeId = WIFI, 0 = AP (Wireless+Wired), positive nodeId = ECOFEN" >> $logFile
|
||||
echo "$energyLog" >> $logFile
|
||||
echo "* Metrics" >> $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} simKey:${simKey} positionSeed:${positionSeed} sensorsEnergy:${sensorsEnergy} networkEnergy:${networkEnergy}" >> $logFile
|
||||
}
|
||||
|
||||
simKey="NBSENSORS"
|
||||
for sensorsNumber in $(seq 1 10)
|
||||
do
|
||||
run
|
||||
done
|
||||
simulator="simulator/simulator"
|
||||
parseEnergyScript="./parseEnergy.awk"
|
||||
parseDelayScript="./parseDelay.awk"
|
||||
logFolder="logs/"
|
||||
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${NS3_PATH}/build/lib
|
||||
|
||||
# Default Parameters
|
||||
sensorsSendInterval=10 # DON'T GO BELOW 1 SECONDS !!!!!!! Simulator will stay stuck
|
||||
sensorsPktSize=5 # 1 byte temperature (-128 à +128 °C) and 4Byte sensorsId
|
||||
sensorsNumber=10
|
||||
nbHop=10 # Cf paper AC/Yunbo
|
||||
linksBandwidth=10
|
||||
linksLatency=2
|
||||
positionSeed=5
|
||||
simKey="NOKEY"
|
||||
|
||||
run () {
|
||||
# If another function want to handle simulation (tipically used on g5k)
|
||||
type -t handleSim > /dev/null && { handleSim; return; }
|
||||
|
||||
local logFile="${logFolder}/${simKey}_${sensorsSendInterval}SSI_${sensorsPktSize}SPS_${sensorsNumber}SN_${nbHop}NH_${linksBandwidth}LB_${linksLatency}LL_${positionSeed}PS.org"
|
||||
[ -f "$logFile" ] && return
|
||||
local simCMD="$simulator --sensorsSendInterval=${sensorsSendInterval} --sensorsPktSize=${sensorsPktSize} --sensorsNumber=${sensorsNumber} --nbHop=${nbHop} --linksBandwidth=${linksBandwidth} --linksLatency=${linksLatency} --positionSeed=${positionSeed} 2>&1"
|
||||
local log=$(bash -c "$simCMD")
|
||||
|
||||
# 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)}')
|
||||
sensorsEnergy=$(echo "$energyLog" |awk -F',' 'BEGIN{sumW=0}$1<0{sumW+=$2}END{print sumW}')
|
||||
networkEnergy=$(echo "$energyLog" |awk -F',' 'BEGIN{sumN=0}$1>=0{sumN+=$2}END{print sumN}')
|
||||
nbPacketCloud=$(echo "$log"|grep -c "CloudSwitch receive")
|
||||
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 (version ${ns3Version}) simulation\n" > $logFile
|
||||
echo "* Environment Variables" >> $logFile
|
||||
env >> $logFile
|
||||
echo "* Full Command" >> $logFile
|
||||
echo "$simCMD" >> $logFile
|
||||
echo "* Output" >> $logFile
|
||||
echo "$log" >> $logFile
|
||||
echo "* Energy CSV (negative nodeId = WIFI, 0 = AP (Wireless+Wired), positive nodeId = ECOFEN" >> $logFile
|
||||
echo "$energyLog" >> $logFile
|
||||
echo "* Metrics" >> $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} simKey:${simKey} positionSeed:${positionSeed} sensorsEnergy:${sensorsEnergy} networkEnergy:${networkEnergy}" >> $logFile
|
||||
}
|
||||
|
||||
simKey="SENDINTERVAL"
|
||||
for sensorsNumber in $(seq 5 5 20)
|
||||
do
|
||||
for sensorsSendInterval in $(seq 10 10 100)
|
||||
do
|
||||
run
|
||||
done
|
||||
done
|
||||
simulator="simulator/simulator"
|
||||
parseEnergyScript="./parseEnergy.awk"
|
||||
parseDelayScript="./parseDelay.awk"
|
||||
logFolder="logs/"
|
||||
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${NS3_PATH}/build/lib
|
||||
|
||||
# Default Parameters
|
||||
sensorsSendInterval=10 # DON'T GO BELOW 1 SECONDS !!!!!!! Simulator will stay stuck
|
||||
sensorsPktSize=5 # 1 byte temperature (-128 à +128 °C) and 4Byte sensorsId
|
||||
sensorsNumber=10
|
||||
nbHop=10 # Cf paper AC/Yunbo
|
||||
linksBandwidth=10
|
||||
linksLatency=2
|
||||
positionSeed=5
|
||||
simKey="NOKEY"
|
||||
|
||||
run () {
|
||||
# If another function want to handle simulation (tipically used on g5k)
|
||||
type -t handleSim > /dev/null && { handleSim; return; }
|
||||
|
||||
local logFile="${logFolder}/${simKey}_${sensorsSendInterval}SSI_${sensorsPktSize}SPS_${sensorsNumber}SN_${nbHop}NH_${linksBandwidth}LB_${linksLatency}LL_${positionSeed}PS.org"
|
||||
[ -f "$logFile" ] && return
|
||||
local simCMD="$simulator --sensorsSendInterval=${sensorsSendInterval} --sensorsPktSize=${sensorsPktSize} --sensorsNumber=${sensorsNumber} --nbHop=${nbHop} --linksBandwidth=${linksBandwidth} --linksLatency=${linksLatency} --positionSeed=${positionSeed} 2>&1"
|
||||
local log=$(bash -c "$simCMD")
|
||||
|
||||
# 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)}')
|
||||
sensorsEnergy=$(echo "$energyLog" |awk -F',' 'BEGIN{sumW=0}$1<0{sumW+=$2}END{print sumW}')
|
||||
networkEnergy=$(echo "$energyLog" |awk -F',' 'BEGIN{sumN=0}$1>=0{sumN+=$2}END{print sumN}')
|
||||
nbPacketCloud=$(echo "$log"|grep -c "CloudSwitch receive")
|
||||
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 (version ${ns3Version}) simulation\n" > $logFile
|
||||
echo "* Environment Variables" >> $logFile
|
||||
env >> $logFile
|
||||
echo "* Full Command" >> $logFile
|
||||
echo "$simCMD" >> $logFile
|
||||
echo "* Output" >> $logFile
|
||||
echo "$log" >> $logFile
|
||||
echo "* Energy CSV (negative nodeId = WIFI, 0 = AP (Wireless+Wired), positive nodeId = ECOFEN" >> $logFile
|
||||
echo "$energyLog" >> $logFile
|
||||
echo "* Metrics" >> $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} simKey:${simKey} positionSeed:${positionSeed} sensorsEnergy:${sensorsEnergy} networkEnergy:${networkEnergy}" >> $logFile
|
||||
}
|
||||
|
||||
simKey="SENSORSPOS"
|
||||
for sensorsNumber in $(seq 5 5 20)
|
||||
do
|
||||
for positionSeed in $(seq 1 10)
|
||||
do
|
||||
run
|
||||
done
|
||||
done
|
||||
|
||||
# Distribute argument according to subsribed nodes
|
||||
cd $simArgsLoc
|
||||
curHostId=0
|
||||
for file in $(find ./ -type f)
|
||||
do
|
||||
[ $curHostId -eq $nHost ] && curHostId=0
|
||||
mv -- ${file} ${hostList[$curHostId]}-$(basename ${file})
|
||||
curHostId=$(( curHostId + 1 ))
|
||||
done
|
||||
cd -
|
||||
|
||||
|
||||
# Run simulations
|
||||
echo "Host who finished their work:" > $finishedFile
|
||||
for host in ${hostList[@]}
|
||||
do
|
||||
echo "Start simulations on node $host"
|
||||
oarsh lguegan@$host bash g5k-worker.sh &
|
||||
done
|
||||
|
||||
exit 0
|
||||
elif [ $progress -eq 1 ]
|
||||
then
|
||||
alreadyFinished=$(cat $finishedFile| tail -n +2| wc -l)
|
||||
percent=$(echo $alreadyFinished $nHost| awk '{print $1/$2*100}')
|
||||
echo "Progression: " $alreadyFinished/$nHost "(${percent}%)"
|
||||
else
|
||||
echo "Invalid arguments, make sure you know what you are doing !"
|
||||
exit 1
|
||||
fi
|
|
@ -1,75 +0,0 @@
|
|||
#!/bin/bash
|
||||
export NS3_PATH=~/.bin/ns-3/ns-3.29/
|
||||
g5kLogFolder="/tmp/logs/"
|
||||
mkdir -p $g5kLogFolder # Create log folder just in case
|
||||
rm -rf $g5kLogFolder/* # Clean previous logs just in case
|
||||
|
||||
hostname=$(hostname)
|
||||
|
||||
# Run simulations with sourced arguments :D
|
||||
simArgsLoc=~/args/ # Don't change this path without changing it in root scripts
|
||||
|
||||
argsId=0
|
||||
argsFile="$simArgsLoc/${hostname}-args-${argsId}.sh" # Arguments generated by Root Node
|
||||
curNProcesses=0 # Start with no processes
|
||||
for argsFile in $(find $simArgsLoc -type f -name "$hostname*")
|
||||
do
|
||||
simulator="simulator/simulator"
|
||||
parseEnergyScript="./parseEnergy.awk"
|
||||
parseDelayScript="./parseDelay.awk"
|
||||
logFolder="logs/"
|
||||
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${NS3_PATH}/build/lib
|
||||
|
||||
# Default Parameters
|
||||
sensorsSendInterval=10 # DON'T GO BELOW 1 SECONDS !!!!!!! Simulator will stay stuck
|
||||
sensorsPktSize=5 # 1 byte temperature (-128 à +128 °C) and 4Byte sensorsId
|
||||
sensorsNumber=10
|
||||
nbHop=10 # Cf paper AC/Yunbo
|
||||
linksBandwidth=10
|
||||
linksLatency=2
|
||||
positionSeed=5
|
||||
simKey="NOKEY"
|
||||
|
||||
run () {
|
||||
# If another function want to handle simulation (tipically used on g5k)
|
||||
type -t handleSim > /dev/null && { handleSim; return; }
|
||||
|
||||
local logFile="${logFolder}/${simKey}_${sensorsSendInterval}SSI_${sensorsPktSize}SPS_${sensorsNumber}SN_${nbHop}NH_${linksBandwidth}LB_${linksLatency}LL_${positionSeed}PS.org"
|
||||
[ -f "$logFile" ] && return
|
||||
local simCMD="$simulator --sensorsSendInterval=${sensorsSendInterval} --sensorsPktSize=${sensorsPktSize} --sensorsNumber=${sensorsNumber} --nbHop=${nbHop} --linksBandwidth=${linksBandwidth} --linksLatency=${linksLatency} --positionSeed=${positionSeed} 2>&1"
|
||||
local log=$(bash -c "$simCMD")
|
||||
|
||||
# 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)}')
|
||||
sensorsEnergy=$(echo "$energyLog" |awk -F',' 'BEGIN{sumW=0}$1<0{sumW+=$2}END{print sumW}')
|
||||
networkEnergy=$(echo "$energyLog" |awk -F',' 'BEGIN{sumN=0}$1>=0{sumN+=$2}END{print sumN}')
|
||||
nbPacketCloud=$(echo "$log"|grep -c "CloudSwitch receive")
|
||||
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 (version ${ns3Version}) simulation\n" > $logFile
|
||||
echo "* Environment Variables" >> $logFile
|
||||
env >> $logFile
|
||||
echo "* Full Command" >> $logFile
|
||||
echo "$simCMD" >> $logFile
|
||||
echo "* Output" >> $logFile
|
||||
echo "$log" >> $logFile
|
||||
echo "* Energy CSV (negative nodeId = WIFI, 0 = AP (Wireless+Wired), positive nodeId = ECOFEN" >> $logFile
|
||||
echo "$energyLog" >> $logFile
|
||||
echo "* Metrics" >> $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} simKey:${simKey} positionSeed:${positionSeed} sensorsEnergy:${sensorsEnergy} networkEnergy:${networkEnergy}" >> $logFile
|
||||
}
|
||||
|
||||
logFolder=$g5kLogFolder # Don't forget override default g5kLogFolder
|
||||
source $argsFile # Fetch argument
|
||||
run & # Run async
|
||||
((curNProcesses+=1)) # Increase by 2
|
||||
[ $curNProcesses -ge $nProcesses ] && { curNProcesses=0; wait; }
|
||||
done
|
||||
wait # Wait until the end of all simulations
|
||||
|
||||
cp -r $g5kLogFolder/* "$logsFinalDst" # Fetch log from tmp into nfs
|
||||
echo $(hostname) >> $finishedFile # Just say I finished
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue