diff --git a/manual/.gitignore b/manual/.gitignore index 056aa14..14f1d99 100644 --- a/manual/.gitignore +++ b/manual/.gitignore @@ -1,3 +1,7 @@ _minted-manual -*.tex -*.bbl \ No newline at end of file +*.bbl +*.aux +*.log +*.out +*.pre +svg-inkscape \ No newline at end of file diff --git a/manual/Makefile b/manual/Makefile new file mode 100644 index 0000000..f07674c --- /dev/null +++ b/manual/Makefile @@ -0,0 +1,5 @@ + + + +manual.pdf: manual.tex + pdflatex -shell-escape manual diff --git a/manual/manual.org b/manual/manual.org deleted file mode 100644 index 7f51a6a..0000000 --- a/manual/manual.org +++ /dev/null @@ -1,205 +0,0 @@ -#+TITLE: ESDS: Extensible Simulator for Distributed Systems -#+AUTHOR: Loic GUEGAN -#+OPTIONS: toc:nil - -#+LATEX_HEADER: \usepackage{fullpage} -#+LATEX_HEADER: \usepackage{minted} -#+LATEX_HEADER: \usepackage{booktabs} -#+LATEX_HEADER: \usepackage{xspace} -#+LATEX_HEADER: \newcommand{\stateoff}{"\textit{off}"\xspace} -#+LATEX_HEADER: \newcommand{\stateon}{"\textit{on}"\xspace} - - -* Simulation Architecture -The ESDS simulator comprises two major components: 1) The Simulation Orchestrator(SO) 2) The Simulated -Nodes (SN). This architecture is depicted in Figure \ref{architecture}. - -\begin{figure}[!h] -\centering -\includegraphics[scale=0.5]{components.pdf} -\caption{Architecture of ESDS} -\label{architecture} -\end{figure} - -The SO is the main process in charge of implementing the simulation main loop. It instantiates the -network (e.g bandwidths andlatencies), collects and processes the events (e.g communications,turn -on/off). The nodes on the other hand are threads that simulate the nodes behaviors. - -* Example -To run a simulation, you need to provide at least 2 files. The first one instantiate the -orchestrator and the second one will simulate the node. In this section, you will learn how to write -both files. - -The simulated scenario comprises 2 nodes that wakes up randomly every hour for a duration called -"uptime". The sender try to transmit his data during that uptime. The other node is a receiver that -have similar random wake up parterns and strive to receive data from the sender. -** Orchestrator -#+attr_latex: :options fontsize=\small, breaklines -#+BEGIN_SRC python - #!/usr/bin/env python - - import esds # Load ESDS - import numpy as np # Use numpy to construct bandwidth and latencies matrix - - ##### Bandwidth matrix - # Bandwidth value can be 0 for unreachable nodes - # Regarding wireless interfaces the diagonals of the bandwidth and latency matrices are very important. - # They determine the duration of the tranmission for THE SENDER. It allows to have a different tx - # duration per node and per interface. Please cf esds.py for more informations. - n=2 # Number of nodes including the sender - B=np.full((n,n),5) # 5Mbps - - ##### Latency matrix - # If the latency entries match one with a bandwidth of 0 - # then it will be ignore since node is unreachable. - L=np.full((n,n),0) # 0s - - ##### Create the simulator - # esds.Simulator take at least a dictionnary as a parameter - # This dictionnary contains all the network interfaces (name as a key) of each node - s=esds.Simulator({"wlan0":{"bandwidth":B, "latency":L, "is_wired":False},"eth0":{"bandwidth":B, "latency":L, "is_wired":True}}) - - ##### Instantiate nodes - uptime=180 # 180s uptime - s.create_node("sender",args=uptime) # Load sender.py for the first node with 5 as argument (first row in B and L) - - # Aguments can be passed to nodes via: s.create_node("sender",args="my argument") - for n in range(0,n-1): # Load receiver.py for the remaining nodes - s.create_node("receiver",args=uptime) - - ##### Run the simulation - s.run() -#+END_SRC - -** Nodes -To implement a node, you should create a python file with the method execute(api). This method will be -called by the orchestrator to execute the code of your node. The api parameter provide you access to the following esds API: - - -\begin{table*}[] - \centering - \caption{Simulated Nodes blocking and non-blocking API calls} - \label{tab:api} - \small - \resizebox{\columnwidth}{!}{% - \begin{tabular}{@{}lll@{}} -\toprule -\textbf{Call} & \textbf{Blocking} & \textbf{Description} \\ \midrule -\verb!send(,,,,)! & yes & Send \verb!! of size \verb!! on interface \verb!! \\ -\verb!sendt(,,,,,)! & yes & Send \verb!! of size \verb!! on interface \verb!! with a timeout of \verb!! \\ -\verb!receive()! & yes & Wait for and fetch incoming data on interface \verb!! \\ -\verb!receivet(,)! & yes & Wait for and fetch incoming data on interface \verb!! with a timeout of \verb!! \\ -\verb!wait()! & yes & Wait for a specific amount of simulated time \verb!! \\ -\verb!wait_end()! & yes & Wait until the end of the simulation \\ -\verb!log()! & no & Report \verb!! to the SO that will print it to the standard output \\ -\verb!read()! & no & Read in the SO registers (e.g \textit{clock} to get the current simulated time) \\ -\verb!turn_off()/turn_on()! & no & Change the node state to \stateoff or \stateon respectively -\end{tabular}} -\end{table*} - -*** Sender -#+attr_latex: :options fontsize=\small, breaklines -#+BEGIN_SRC python - #!/usr/bin/env python - - import random - - # Note that the following is required to have different instance from thread to thread - lr=random.Random(6) - - def execute(api): - uptime=api.args - endoff=0 - for i in range(0,24): - startoff=random.randint(0,3600-uptime) - api.turn_off() - api.wait(startoff+endoff) - api.turn_on() - wakeat=api.read("clock") - wakeuntil=wakeat+uptime - # Send until uptime seconds if elapsed - while api.read("clock") < wakeuntil: - api.sendt("wlan0","hello",10,None, wakeuntil-api.read("clock")) - api.log("Was up for {}s".format(api.read("clock")-wakeat)) - endoff=3600*(i+1)-api.read("clock") - api.turn_off() - api.wait(endoff) - api.turn_on() - - - - -#+END_SRC -*** Receiver -#+attr_latex: :options fontsize=\small, breaklines -#+BEGIN_SRC python - #!/usr/bin/env python - - import sys, random, time - from esds import RCode - - lr=random.Random(6) - - def execute(api): - uptime=api.args - endoff=0 - for i in range(0,24): - startoff=random.randint(0,3600-uptime) - api.turn_off() - api.wait(startoff+endoff) - api.turn_on() - wakeat=api.read("clock") - wakeuntil=wakeat+uptime - # Receive until uptime seconds if elapsed - while api.read("clock") < wakeuntil: - code, data=api.receivet("wlan0",wakeuntil-api.read("clock")) - if code == RCode.SUCCESS: - api.log("Receive "+data) - api.log("Was up for {}s".format(api.read("clock")-wakeat)) - endoff=3600*(i+1)-api.read("clock") - api.turn_off() - api.wait(endoff) - api.turn_on() - - -#+END_SRC - -** Simulation Output -Here is part of the simulation output: -#+begin_example - [t=82626.000,src=n0] Send 10 bytes on wlan0 - [t=82630.000,src=n0] Was up for 180.0s - [t=82630.000,src=n0] Turned off - [t=83083.000,src=n1] Turned on - [t=83263.000,src=n1] Was up for 180.0s - [t=83263.000,src=n1] Turned off - [t=85910.000,src=n0] Turned on - [t=85910.000,src=n0] Send 10 bytes on wlan0 - [t=85926.000,src=n0] Send 10 bytes on wlan0 - [t=85942.000,src=n0] Send 10 bytes on wlan0 - [t=85958.000,src=n0] Send 10 bytes on wlan0 - [t=85974.000,src=n0] Send 10 bytes on wlan0 - [t=85990.000,src=n0] Send 10 bytes on wlan0 - [t=86006.000,src=n0] Send 10 bytes on wlan0 - [t=86022.000,src=n0] Send 10 bytes on wlan0 - [t=86038.000,src=n0] Send 10 bytes on wlan0 - [t=86054.000,src=n0] Send 10 bytes on wlan0 - [t=86070.000,src=n0] Send 10 bytes on wlan0 - [t=86086.000,src=n0] Send 10 bytes on wlan0 - [t=86090.000,src=n0] Was up for 180.0s - [t=86090.000,src=n0] Turned off - [t=86400.000,src=n0] Turned on - [t=86400.000,src=n1] Turned on - [t=86400.000,src=esds] Simulation ends -#+end_example -Brackets indicate additional informations related to the message (e.g source and simulated -time). All the send and received events are reported automatically by esds. - -# Local Variables: -# eval: (setq org-latex-listings 'minted) -# eval: (setq org-latex-pdf-process -# '("pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f" -# "bibtex %b" -# "pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f" -# "pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f")) -# End: diff --git a/manual/manual.pdf b/manual/manual.pdf index 037f976..31d5574 100644 Binary files a/manual/manual.pdf and b/manual/manual.pdf differ diff --git a/manual/manual.tex b/manual/manual.tex new file mode 100644 index 0000000..a7a3d21 --- /dev/null +++ b/manual/manual.tex @@ -0,0 +1,66 @@ +\documentclass[11pt]{article} + +% Packages +\usepackage{fullpage} +\usepackage{minted} +\usepackage{booktabs} +\usepackage{xspace} +\usepackage{graphicx} +\usepackage[utf8]{inputenc} +\usepackage[T1]{fontenc} +\usepackage{svg} +\usepackage{listings} + +% Commands +\newcommand{\stateoff}{"\textit{off}"\xspace} +\newcommand{\stateon}{"\textit{on}"\xspace} + +% Document +\begin{document} + +% Title page +\makeatletter +\begin{titlepage} + \begin{center} + \Huge + \textbf{\fontsize{90}{60}\selectfont ESDS User Manual\\} + \vspace{0.5cm} + {\Large \textbf{\today}} + \vspace{3cm} + + {\includesvg[scale=0.8]{../icon.svg}} + \vspace{3cm} + + \LARGE + \textbf{ESDS an Extensible Simulator for Distributed Systems\\} + \vspace{0.5cm} + \textbf{Written by Loic Guegan and Issam Raïs} + \end{center} +\end{titlepage} +\pagebreak + + +\section{Architecture of ESDS} + +\begin{figure}[!h] +\centering +\includegraphics[scale=0.5]{components.pdf} +\caption{Simulation architecture used by ESDS} +\label{architecture} +\end{figure} + +ESDS simulator comprises two major components: 1) The Simulation Orchestrator(SO) 2) The Simulated +Nodes (SN). This architecture is depicted in Figure \ref{architecture}. The SO is the main process +in charge of implementing the simulation main loop. It instantiates the network (e.g bandwidths +andlatencies), collects and processes the events (e.g communications,turn on/off). The nodes on the +other hand are threads that simulate the nodes behaviors. + +%\inputminted[autogobble]{yaml}{../example/platform.yaml} + +\end{document} + + + + + +