1.1 --- a/wns3.tex Fri Feb 27 14:26:58 2009 +0100
1.2 +++ b/wns3.tex Fri Feb 27 15:54:41 2009 +0100
1.3 @@ -32,17 +32,6 @@
1.4
1.5 \section{How a simulation is built}
1.6
1.7 -\begin{frame}{A Typical Workflow}
1.8 -\begin{itemize}
1.9 -\item Write a C++ \code{main} function
1.10 -\item Drop file in \code{scratch} directory
1.11 -\item Build with \code{./waf}
1.12 -\item Enter run environment with \code{./waf --shell}
1.13 -\item Execute program \code{build/debug/scratch/test}
1.14 -\item Analyze pcap or ascii traces (wireshark)
1.15 -\end{itemize}
1.16 -\end{frame}
1.17 -
1.18 \begin{frame}{The ns-3 API}
1.19 There are two ways to interact with the ns-3 API:
1.20
1.21 @@ -84,11 +73,11 @@
1.22 \end{frame}
1.23
1.24 \begin{frame}{The \emph{Container} Version}
1.25 -Fire up and editor and look at the code
1.26 +Fire up an editor and look at the code
1.27 \end{frame}
1.28
1.29 \begin{frame}{The \emph{Low-Level} Version}
1.30 -Fire up and editor and look at the code
1.31 +Fire up an editor and look at the code
1.32 \end{frame}
1.33
1.34 \section{Diving in: topology construction}
1.35 @@ -185,85 +174,6 @@
1.36 \end{columns}
1.37 \end{frame}
1.38
1.39 -\begin{frame}[fragile]{Configuration: Object Attributes}
1.40 -
1.41 -\begin{itemize}
1.42 -\item Set the default value of an attribute from the command-line:
1.43 -\begin{verbatim}
1.44 -CommandLine cmd;
1.45 -cmd.Parse (argc, argv);
1.46 -\end{verbatim}
1.47 -\item Set the default value of an attribute with NS\_ATTRIBUTE\_DEFAULT
1.48 -\item Set the default value of an attribute in C++:
1.49 -\begin{verbatim}
1.50 -Config::SetDefault ("ns3::Ipv4L3Protocol::CalcChecksum",
1.51 - BooleanValue (true));
1.52 -\end{verbatim}
1.53 -\item Set an attribute directly on a specific object:
1.54 -\begin{verbatim}
1.55 -Ptr<CsmaChannel> csmaChannel = ...;
1.56 -csmaChannel->SetAttribute ("DataRate",
1.57 - StringValue ("5Mbps"));
1.58 -\end{verbatim}
1.59 -\end{itemize}
1.60 -\end{frame}
1.61 -
1.62 -\begin{frame}[fragile]{Configuration: Object Attributes}
1.63 -
1.64 -\begin{itemize}
1.65 -\item Set an attribute on a specific object with a path:
1.66 -\begin{verbatim}
1.67 -Config::Set ("/NodeList/3/DeviceList/1/Channel/DataRate",
1.68 - StringValue ("5Mbps"));
1.69 -\end{verbatim}
1.70 -\item Set an attribute on a specific object from a configuration file:
1.71 -\begin{verbatim}
1.72 -/NodeList/3/DeviceList/1/Channel/DataRate 5Mbps
1.73 -...
1.74 -\end{verbatim}
1.75 -with:
1.76 -\begin{verbatim}
1.77 -ConfigStore config;
1.78 -config.Configure ();
1.79 -\end{verbatim}
1.80 -\item Set an attribute on a specific object with a GUI:
1.81 -\begin{verbatim}
1.82 -GtkConfigStore config;
1.83 -config.Configure ();
1.84 -\end{verbatim}
1.85 -\end{itemize}
1.86 -
1.87 -\end{frame}
1.88 -
1.89 -\begin{frame}[fragile]{I don't care about pcap tracing !}
1.90 -
1.91 -Just change the call to WritePacket to do something
1.92 -smarter:
1.93 -\begin{verbatim}
1.94 -static void PcapPhyTxEvent (Ptr<PcapWriter> writer,
1.95 - Ptr<const Packet> packet,
1.96 - WifiMode mode,
1.97 - WifiPreamble preamble,
1.98 - uint8_t txLevel)
1.99 -{
1.100 - writer->WritePacket (packet);
1.101 -}
1.102 -...
1.103 - Config::ConnectWithoutContext (oss.str (),
1.104 - MakeBoundCallback (&PcapPhyTxEvent, pcap));
1.105 -\end{verbatim}
1.106 -\end{frame}
1.107 -
1.108 -\begin{frame}[fragile]{Tracing}
1.109 -
1.110 -\begin{itemize}
1.111 -\item Trace sinks are just normal C++ functions
1.112 -\item Config::Connect can associate any number of trace sinks
1.113 -to a trace source (or a set of trace sources)
1.114 -\item
1.115 -\end{itemize}
1.116 -\end{frame}
1.117 -
1.118 \begin{frame}{The ns-3 type system}
1.119
1.120 \begin{itemize}
1.121 @@ -318,56 +228,48 @@
1.122 \item Calls \code{OnOffApplication::StartApplication}
1.123 \item Creates a socket with \code{Socket::CreateSocket}
1.124 \begin{itemize}
1.125 -\item Calls \code {Node::GetObject (socketFactoryTypeId)}
1.126 +\item Calls \code {Node::GetObject ("ns3::UdpSocketFactory")}
1.127 \item Calls \code{SocketFactory::CreateSocket}
1.128 \end{itemize}
1.129 \item Calls \code{OnOffApplication::ScheduleStartEvent}
1.130 -\item Calls \code{Simulator::Schedule}
1.131 +\item Calls \code{Simulator::Schedule} on \code{OnOffApplication::StartSending}
1.132 \end{itemize}
1.133 \end{frame}
1.134
1.135 -\begin{frame}[fragile]{Event scheduling}
1.136 -
1.137 -\code{Simulator::Schedule} is magic:
1.138 -\begin{verbatim}
1.139 -void OnOffApplication::StartSending()
1.140 -{
1.141 -...
1.142 -}
1.143 -m_startStopEvent = Simulator::Schedule(offInterval, &OnOffApplication::StartSending, this);
1.144 -\end{verbatim}
1.145 -\begin{itemize}
1.146 -\item First argument is delay
1.147 -\item Second argument is a pointer to the function to execute when the event expires
1.148 -\item Third argument and all others (up to 7) are the arguments to pass to the
1.149 -event function when it is executed.
1.150 -\end{itemize}
1.151 -It works for simple functions, static functions,
1.152 -member methods, static member methods, etc.
1.153 -\end{frame}
1.154
1.155 \begin{frame}{The first packet created}
1.156
1.157 \begin{itemize}
1.158 -\item \code{OnOffApplication::StartSending}
1.159 +\item \code{OnOffApplication::StartSending}
1.160 \item Calls \code{OnOffApplication::ScheduleNextTx}
1.161 \item Calls \code{Simulator::Schedule} on \code{OnOffApplication::SendPacket}
1.162 \item \code{OnOffApplication::SendPacket}
1.163 \item Calls \code{Create<Packet>}
1.164 -\end{itemize}
1.165 -ns-3 packets are magic:
1.166 -\begin{itemize}
1.167 -\item They are reference-counted
1.168 -\item Payload is zero-filled and never allocated by default
1.169 -\item They are Copy On Write: \code{Packet::Copy} does not
1.170 -create a new packet buffer: it creates a new reference to the
1.171 -same packet buffer
1.172 +\item Calls \code{m\_txTrace::operator()}
1.173 +\item Calls all connected trace sinks
1.174 +\item Calls virtual \code{Socket::Send}
1.175 +\item Calls \code{UdpSocketImpl::Send}
1.176 +\item Calls \code{UdpSocketImpl::DoSendTo}
1.177 \end{itemize}
1.178 \end{frame}
1.179
1.180 -\begin{frame}{Magic COW packets}
1.181 +\begin{frame}{Summary: how applications access network stacks}
1.182
1.183 -\includegraphics[width=9cm]{buffer}
1.184 +Applications who wish to use protocol \code{Foo} must:
1.185 +\begin{itemize}
1.186 +\item Call \code{Node::GetObject<FooSocketFactory>}
1.187 +\item Call \code{SocketFactory::CreateSocket} (calls \code{FooSocketFactoryImpl::CreateSocket})
1.188 +\item Call \code{Socket::Send} (calls \code{FooSocketImpl::Send})
1.189 +\end{itemize}
1.190 +
1.191 +New protocol \code{Foo} must:
1.192 +\begin{itemize}
1.193 +\item Create \code{FooSocketFactory}, a subclass of \code{SocketFactory}
1.194 +\item Aggregate \code{FooSocketFactory} to a \code{Node} during
1.195 +topology construction (for UDP, done by InternetStackHelper::Install)
1.196 +\item Create \code{FooSocket}, a subclass of \code{Socket} from
1.197 +\code{FooSocketFactory::CreateSocket}
1.198 +\end{itemize}
1.199 \end{frame}
1.200
1.201 \begin{frame}{How the first packet is sent}