--- a/doc/manual/tracing.texi Sat Oct 17 16:02:25 2009 -0700
+++ b/doc/manual/tracing.texi Sun Oct 18 22:11:29 2009 -0700
@@ -1,12 +1,12 @@
@node Tracing
@chapter Tracing
-The tracing subsystem is one of the most important mechansisms to understand in
+The tracing subsystem is one of the most important mechanisms to understand in
@command{ns-3}. In most cases, @command{ns-3} users will have a brilliant idea
for some new and improved networking feature. In order to verify that this
idea works, the researcher will make changes to an existing system and then run
-experiments to see how the new feature behaves by gathering some form of statistic
-that captures the behavior of the feature.
+experiments to see how the new feature behaves by gathering statistics
+that capture the behavior of the feature.
In other words, the whole point of running a simulation is to generate output for
further study. In @command{ns-3}, the subsystem that enables a researcher to do
@@ -37,7 +37,7 @@
@end verbatim
This is workable in small environments, but as your simulations get more and more
-compliated, you end up with more and more prints and the task of parsing and
+complicated, you end up with more and more prints and the task of parsing and
performing computations on the output begins to get harder and harder.
Another thing to consider is that every time a new tidbit is needed, the software
@@ -74,7 +74,7 @@
provide access to interesting underlying data. For example, a trace source could
indicate when a packet is received by a net device and provide access to the
packet contents for interested trace sinks. A trace source might also indicate
-when an iteresting state change happens in a model. For example, the congestion
+when an interesting state change happens in a model. For example, the congestion
window of a TCP model is a prime candidate for a trace source.
Trace sources are not useful by themselves; they must be connected to other pieces
@@ -92,7 +92,7 @@
There can be zero or more consumers of trace events generated by a trace source.
One can think of a trace source as a kind of point-to-multipoint information link.
-The ``transport protocol'' for this conceptual point-to-multipoint link as an
+The ``transport protocol'' for this conceptual point-to-multipoint link is an
@code{ns-3} @code{Callback}.
Recall from the Callback Section that callback facility is a way to allow two
@@ -100,7 +100,8 @@
decoupling the calling function from the called class completely. This is the
same requirement as outlined above for the tracing system.
-Basically, a trace source @emph{is} a callback. When a trace sink expresses
+Basically, a trace source @emph{is} a callback to which multiple
+functions may be registered. When a trace sink expresses
interest in receiving trace events, it adds a callback to a list of callbacks
held by the trace source. When an interesting event happens, the trace source
invokes its @code{operator()} providing zero or more parameters. This tells
@@ -112,7 +113,8 @@
It will be useful to go walk a quick example just to reinforce what we've said.
-@verbatim
+@smallformat
+@example
#include ``ns3/object.h''
#include ``ns3/uinteger.h''
#include ``ns3/traced-value.h''
@@ -121,7 +123,8 @@
#include <iostream>
using namespace ns3;
-@end verbatim
+@end example
+@end smallformat
The first thing to do is include the required files. As mentioned above, the
trace system makes heavy use of the Object and Attribute systems. The first
@@ -139,7 +142,8 @@
What this all means is that you will be able to trace changes to an object
made using those operators.
-@verbatim
+@smallformat
+@example
class MyObject : public Object
{
public:
@@ -158,7 +162,8 @@
MyObject () {}
TracedValue<uint32_t> m_myInt;
};
-@end verbatim
+@end example
+@end smallformat
Since the tracing system is integrated with Attributes, and Attributes work
with Objects, there must be an @command{ns-3} @code{Object} for the trace source
@@ -170,29 +175,33 @@
infrastructure that overloads the operators mentioned above and drives the callback
process.
-@verbatim
+@smallformat
+@example
void
IntTrace (Int oldValue, Int newValue)
{
std::cout << ``Traced `` << oldValue << `` to `` << newValue << std::endl;
}
-@end verbatim
+@end example
+@end smallformat
This is the definition of the trace sink. It corresponds directly to a callback
function. This function will be called whenever one of the operators of the
@code{TracedValue} is executed.
-@verbatim
+@smallformat
+@example
int
main (int argc, char *argv[])
{
Ptr<MyObject> myObject = CreateObject<MyObject> ();
- myObject->TraceConnectWithoutContext ("MyInt", MakeCallback(&IntTrace));
+ myObject->TraceConnectWithoutContext ("MyInteger", MakeCallback(&IntTrace));
myObject->m_myInt = 1234;
}
-@end verbatim
+@end example
+@end smallformat
In this snippet, the first thing that needs to be done is to create the object
in which the trace source lives.
@@ -238,7 +247,8 @@
For example, one might find something that looks like the following in the system
(taken from @code{examples/tcp-large-transfer.cc})
-@verbatim
+@smallformat
+@example
void CwndTracer (uint32_t oldval, uint32_t newval) {}
...
@@ -246,7 +256,8 @@
Config::ConnectWithoutContext (
"/NodeList/0/$ns3::TcpL4Protocol/SocketList/0/CongestionWindow",
MakeCallback (&CwndTracer));
-@end verbatim
+@end example
+@end smallformat
This should look very familiar. It is the same thing as the previous example,
except that a static member function of class @code{Config} is being called instead
@@ -258,13 +269,15 @@
the @code{Object} that has the ``CongestionWindow'' @code{Attribute} handy (call it
@code{theObject}), you could write this just like the previous example:
-@verbatim
+@smallformat
+@example
void CwndTracer (uint32_t oldval, uint32_t newval) {}
...
theObject->TraceConnectWithoutContext ("CongestionWindow", MakeCallback (&CwndTracer));
-@end verbatim
+@end example
+@end smallformat
It turns out that the code for @code{Config::ConnectWithoutContext} does exactly that.
This function takes a path that represents a chain of @code{Object} pointers and follows
@@ -297,16 +310,18 @@
an attribute called ``CongestionWindow'' which is a @code{TracedValue<uint32_t>}.
The @code{Config::ConnectWithoutContext} now does a,
-@verbatim
+@smallformat
+@example
object->TraceConnectWithoutContext ("CongestionWindow", MakeCallback (&CwndTracer));
-@end verbatim
+@end example
+@end smallformat
using the object pointer from ``SocketList/0'' which makes the connection between
the trace source defined in the socket to the callback -- @code{CwndTracer}.
Now, whenever a change is made to the @code{TracedValue<uint32_t>} representing the
congestion window in the TCP socket, the registered callback will be executed and
-the function @code{Cwndtracer} will be called printing out the old and new values
+the function @code{CwndTracer} will be called printing out the old and new values
of the TCP congestion window.
@node Using the Tracing API