summaryrefslogtreecommitdiff
path: root/ns3-simulations/simulate.org
diff options
context:
space:
mode:
Diffstat (limited to 'ns3-simulations/simulate.org')
-rw-r--r--ns3-simulations/simulate.org131
1 files changed, 131 insertions, 0 deletions
diff --git a/ns3-simulations/simulate.org b/ns3-simulations/simulate.org
index 43aa253..c02aeca 100644
--- a/ns3-simulations/simulate.org
+++ b/ns3-simulations/simulate.org
@@ -74,6 +74,7 @@
#+RESULTS: runNbHop
+
** Single Run
#+NAME: singleRun
@@ -94,6 +95,9 @@
simKey="NOKEY"
run () {
+ # If another function want to handle simulation (tipically used on g5k)
+ type -t handleSim > /dev/null && { handleSim; return; }
+
logFile="${logFolder}/${simKey}_${sensorsSendInterval}SSI_${sensorsPktSize}SPS_${sensorsNumber}SN_${nbHop}NH_${linksBandwidth}LB_${linksLatency}LL.org"
[ -f "$logFile" ] && return
simCMD="$simulator --sensorsSendInterval=${sensorsSendInterval} --sensorsPktSize=${sensorsPktSize} --sensorsNumber=${sensorsNumber} --nbHop=${nbHop} --linksBandwidth=${linksBandwidth} --linksLatency=${linksLatency} 2>&1"
@@ -124,6 +128,133 @@
#+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=15
+ nProcesses=8 # Max number of parrallel simulations
+ nHours=3 # 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 () {
+ outF="$simArgsLoc/$(uuidgen).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
+ }
+
+
+ # 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
+ <<runNbHop>>
+ <<runBW>>
+ <<runLat>>
+ <<nbSens>>
+ <<runNbSensors>>
+
+ # 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
+ #oarsh lguegan@$host bash g5k-worker.sh &
+ echo "$host"
+ 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
+ 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
+ for argsFile in $(find $simArgsLoc -type f -name "$hostname*")
+ do
+ <<singleRun>>
+ logFolder=$g5kLogFolder # Don't forget override default g5kLogFolder
+ source $argsFile # Fetch argument
+ run
+ done
+
+ 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