rework
authorMathieu Lacage <mathieu.lacage@sophia.inria.fr>
Thu Feb 26 19:59:30 2009 +0100 (11 months ago)
changeset 5d6a17c05a731
parent 4 4ac1b8b45457
child 6 e24f63454eea
rework
wns3.tex
     1.1 --- a/wns3.tex	Thu Feb 26 17:10:03 2009 +0100
     1.2 +++ b/wns3.tex	Thu Feb 26 19:59:30 2009 +0100
     1.3 @@ -47,6 +47,7 @@
     1.4  
     1.5  \begin{frame}{The ns-3 API}
     1.6  There are two ways to interact with the ns-3 API:
     1.7 +
     1.8  \begin{itemize}
     1.9  \item Construct a simulation with the \emph{Container} API:
    1.10  \begin{itemize}
    1.11 @@ -60,12 +61,13 @@
    1.12  \item Very flexible but potentially complex to use
    1.13  \end{itemize}
    1.14  \end{itemize}
    1.15 +
    1.16  The best way to understand how they work and relate to each other
    1.17  is to use both on the same example
    1.18  \end{frame}
    1.19  
    1.20  
    1.21 -\begin{frame}{The testcase}
    1.22 +\begin{frame}{The Testcase}
    1.23  \begin{columns}
    1.24  \begin{column}{0.5\textwidth}
    1.25  \includegraphics[width=6cm]{scenario}
    1.26 @@ -83,130 +85,115 @@
    1.27  \end{columns}
    1.28  \end{frame}
    1.29  
    1.30 -\section{The Container Version}
    1.31 -
    1.32 -\begin{frame}[fragile]{Create Nodes}
    1.33 -\begin{verbatim}
    1.34 -using namespace ns3;
    1.35 -
    1.36 -int main (int argc, char *argv[])
    1.37 -{
    1.38 -  CommandLine cmd;
    1.39 -  cmd.Parse (argc, argv);
    1.40 -
    1.41 -  NodeContainer csmaNodes;
    1.42 -  csmaNodes.Create (2);
    1.43 -  NodeContainer wifiNodes;
    1.44 -  wifiNodes.Add (csmaNodes.Get (1));
    1.45 -  wifiNodes.Create (3);
    1.46 -\end{verbatim}
    1.47 +\begin{frame}{The \emph{Container} Version}
    1.48 +Fire up and editor and look at the code
    1.49  \end{frame}
    1.50  
    1.51 -\begin{frame}[fragile]{Create the MAC Network}
    1.52 -\begin{verbatim}
    1.53 -NetDeviceContainer csmaDevices;
    1.54 -CsmaHelper csma;
    1.55 -csma.SetChannelAttribute ("DataRate", StringValue ("5Mbps"));
    1.56 -csma.SetChannelAttribute ("Delay", StringValue ("2ms"));
    1.57 -csmaDevices = csma.Install (csmaNodes);
    1.58 -
    1.59 -NetDeviceContainer wifiDevices;
    1.60 -YansWifiChannelHelper wifiChannel = 
    1.61 -  YansWifiChannelHelper::Default ();
    1.62 -YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
    1.63 -wifiPhy.SetChannel (wifiChannel.Create ());
    1.64 -WifiHelper wifi = WifiHelper::Default ();
    1.65 -wifiDevices = wifi.Install (wifiPhy, wifiNodes);
    1.66 -\end{verbatim}
    1.67 -\end{frame}
    1.68 -
    1.69 -
    1.70 -\subsection{The point to point link}
    1.71 -
    1.72 -\begin{frame}{}
    1.73 -\end{frame}w
    1.74 -
    1.75 -\subsection{The wifi infrastructure network}
    1.76 -
    1.77 -\begin{frame}{}
    1.78 -\end{frame}
    1.79 -
    1.80 -\subsection{Generating UDP traffic}
    1.81 -
    1.82 -\begin{frame}{}
    1.83 -\end{frame}
    1.84 -
    1.85 -
    1.86 -\subsection{Running the simulation}
    1.87 -
    1.88 -\begin{frame}{}
    1.89 -\end{frame}
    1.90 -
    1.91 -\section{The low-level version}
    1.92 -
    1.93 -\begin{frame}{}
    1.94 -\end{frame}
    1.95 -
    1.96 -\subsection{The point to point link}
    1.97 -
    1.98 -\begin{frame}{}
    1.99 -\end{frame}
   1.100 -
   1.101 -\subsection{The wifi infrastructure network}
   1.102 -
   1.103 -\begin{frame}{}
   1.104 -\end{frame}
   1.105 -
   1.106 -\subsection{Generating UDP traffic}
   1.107 -
   1.108 -\begin{frame}{}
   1.109 +\begin{frame}{The \emph{Low-Level} Version}
   1.110 +Fire up and editor and look at the code
   1.111  \end{frame}
   1.112  
   1.113  \section{Diving in: topology construction}
   1.114  
   1.115 -\begin{frame}{}
   1.116 +\begin{frame}[fragile]{Why are objects so complicated to create ?}
   1.117 +We do:
   1.118 +\begin{verbatim}
   1.119 +  Ptr<Node> node0 = CreateObject<Node> ();
   1.120 +\end{verbatim}
   1.121 +Why not:
   1.122 +\begin{verbatim}
   1.123 +  Node *node0 = new Node ();
   1.124 +\end{verbatim}
   1.125  \end{frame}
   1.126  
   1.127 -\subsection{Memory management}
   1.128 -
   1.129 -\begin{frame}{}
   1.130 +\begin{frame}{Templates: the Nasty Brackets}
   1.131 +\begin{itemize}
   1.132 +\item Contain a list of \emph{type} arguments
   1.133 +\item Parameterize a class or function from input type
   1.134 +\item In ns-3, used for:
   1.135 +\begin{itemize}
   1.136 +\item Standard Template Library
   1.137 +\item Syntactical sugar for low-level facilities
   1.138 +\end{itemize}
   1.139 +\item Saves a lot of typing
   1.140 +\item No portability/compiler support problem
   1.141 +\item Sometimes painful to decipher error messages.
   1.142 +\end{itemize}
   1.143  \end{frame}
   1.144  
   1.145 -\subsection{Object aggregation}
   1.146 +\begin{frame}[fragile]{Memory Management}
   1.147 +It is hard in C++:
   1.148 +\begin{itemize}
   1.149 +\item No garbage collector
   1.150 +\item Easy to forget to delete an object
   1.151 +\item Pointer cycles
   1.152 +\end{itemize}
   1.153 +So, we use:
   1.154 +\begin{itemize}
   1.155 +\item Reference counting: track number of pointers
   1.156 +to an object (\code{Ref}+\code{Unref})
   1.157 +\item Smart pointers: \code{Ptr<>}, \code{Create<>} and, \code{CreateObject<>}
   1.158 +\item Sometimes, explicit \code{Dispose} to break cycles
   1.159 +\end{itemize}
   1.160  
   1.161 -\begin{frame}{}
   1.162  \end{frame}
   1.163  
   1.164 -\subsection{Configuration}
   1.165 +\begin{frame}{Object aggregation}
   1.166 +\begin{itemize}
   1.167 +\item Some nodes need an IPv4 stack, a position, an energy model. 
   1.168 +Some nodes need just two out of three. Others need other unknown features.
   1.169 +\item The obvious solution: add everything to the Node base class
   1.170 +\item Many problems:
   1.171 +\begin{itemize}
   1.172 +\item The class will grow uncontrolably over time
   1.173 +\item Everyone will need to patch the class
   1.174 +\item Slowly, every piece of code will depend on every other piece of code
   1.175 +\item A maintenance nightmare...
   1.176 +\end{itemize}
   1.177 +\item A better solution:
   1.178 +\begin{itemize}
   1.179 +\item Separate functionality belongs to separate classes
   1.180 +\item Objects can be aggregated to obtain extra functionality
   1.181 +\end{itemize}
   1.182 +\end{itemize}
   1.183 +\end{frame}
   1.184  
   1.185 -\begin{frame}{}
   1.186 +\begin{frame}[fragile]{Object aggregation}
   1.187 +
   1.188 +Connect together two objects:
   1.189 +\begin{verbatim}
   1.190 +Ptr<Node> node = CreateObject<Node> ();
   1.191 +Ptr<MobilityModel> mobility = CreateObject<...> ();
   1.192 +node->AddObject (mobility);
   1.193 +\end{verbatim}
   1.194 +
   1.195 +Get an object back:
   1.196 +\begin{verbatim}
   1.197 +mobility = node->GetObject<MobilityModel> ();
   1.198 +node = mobility->GetObject<Node> ();
   1.199 +\end{verbatim}
   1.200 +
   1.201 +\end{frame}
   1.202 +
   1.203 +\begin{frame}{Attributes}
   1.204 +\end{frame}
   1.205 +
   1.206 +\begin{frame}{TypeId}
   1.207  \end{frame}
   1.208  
   1.209  \section{Diving in: runtime}
   1.210  
   1.211 -\begin{frame}{}
   1.212 +\begin{frame}{Event scheduling}
   1.213  \end{frame}
   1.214  
   1.215 -\subsection{Event scheduling}
   1.216 -
   1.217 -\begin{frame}{}
   1.218 +\begin{frame}{Packets}
   1.219  \end{frame}
   1.220  
   1.221 -\subsection{Packets}
   1.222 -
   1.223 -\begin{frame}{}
   1.224 +\begin{frame}{Sockets}
   1.225  \end{frame}
   1.226  
   1.227 -\subsection{Sockets}
   1.228 -
   1.229 -\begin{frame}{}
   1.230 +\begin{frame}{Headers and Trailers}
   1.231  \end{frame}
   1.232  
   1.233 -\subsection{Headers and Trailers}
   1.234 -
   1.235 -\begin{frame}{}
   1.236 -\end{frame}
   1.237 -
   1.238 -
   1.239  
   1.240  \end{document}