doc/manual/tracing.texi
author Craig Dowell <craigdo@ee.washington.edu>
Fri, 12 Feb 2010 21:02:49 -0800
changeset 6051 b988174aa30b
parent 6031 18776ed87c60
child 6053 b17ea72acee9
permissions -rw-r--r--
OutputStreamObject to OutputStreamKeeper
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5188
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     1
@node Tracing
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     2
@chapter Tracing
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     3
5431
01a657b8d1ef some cleanup of part 1 of manual
Tom Henderson <tomh@tomh.org>
parents: 5426
diff changeset
     4
The tracing subsystem is one of the most important mechanisms to understand in
5188
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     5
@command{ns-3}.  In most cases, @command{ns-3} users will have a brilliant idea
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     6
for some new and improved networking feature.  In order to verify that this
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     7
idea works, the researcher will make changes to an existing system and then run
5431
01a657b8d1ef some cleanup of part 1 of manual
Tom Henderson <tomh@tomh.org>
parents: 5426
diff changeset
     8
experiments to see how the new feature behaves by gathering statistics
01a657b8d1ef some cleanup of part 1 of manual
Tom Henderson <tomh@tomh.org>
parents: 5426
diff changeset
     9
that capture the behavior of the feature.
5188
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    10
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    11
In other words, the whole point of running a simulation is to generate output for
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    12
further study.  In @command{ns-3}, the subsystem that enables a researcher to do
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    13
this is the tracing subsystem.
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    14
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    15
@menu
5426
7b36d173c490 Manual organization
Tom Henderson <tomh@tomh.org>
parents: 5231
diff changeset
    16
* Tracing Motivation::
5188
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    17
* Overview::
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    18
* Using the Tracing API::
6031
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
    19
* Using the Tracing Helpers::
5426
7b36d173c490 Manual organization
Tom Henderson <tomh@tomh.org>
parents: 5231
diff changeset
    20
* Tracing implementation details::
5188
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    21
@end menu
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    22
5426
7b36d173c490 Manual organization
Tom Henderson <tomh@tomh.org>
parents: 5231
diff changeset
    23
@node Tracing Motivation
5188
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    24
@section Motivation
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    25
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    26
There are many ways to get information out of a program.  The most straightforward
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    27
way is to just directly print the information to the standard output, as in,
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    28
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    29
@verbatim
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    30
  #include <iostream>
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    31
  ...
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    32
  int main ()
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    33
  {
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    34
    ...
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    35
    std::cout << ``The value of x is `` << x << std::endl;
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    36
    ...
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    37
  } 
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    38
@end verbatim
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    39
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    40
This is workable in small environments, but as your simulations get more and more
5431
01a657b8d1ef some cleanup of part 1 of manual
Tom Henderson <tomh@tomh.org>
parents: 5426
diff changeset
    41
complicated, you end up with more and more prints and the task of parsing and 
5188
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    42
performing computations on the output begins to get harder and harder.
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    43
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    44
Another thing to consider is that every time a new tidbit is needed, the software
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    45
core must be edited and another print introduced.  There is no standardized way
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    46
to control all of this output, so the amount of output tends to grow without 
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    47
bounds.  Eventually, the bandwidth required for simply outputting this information
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    48
begins to limit the running time of the simulation.  The output files grow to 
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    49
enormous sizes and parsing them becomes a problem.
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    50
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    51
@command{ns-3} provides a simple mechanism for logging and providing some control 
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    52
over output via @emph{Log Components}, but the level of control is not very fine
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    53
grained at all.  The logging module is a relatively blunt instrument.
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    54
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    55
It is desirable to have a facility that allows one to reach into the core system
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    56
and only get the information required without having to change and recompile the
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    57
core system.  Even better would be a system that notified the user when an item
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    58
of interest changed or an interesting event happened.
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    59
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    60
The @command{ns-3} tracing system is designed to work along those lines and is 
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    61
well-integrated with the Attribute and Config substems allowing for relatively
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    62
simple use scenarios.
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    63
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    64
@node Overview
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    65
@section Overview
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    66
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    67
The tracing subsystem relies heavily on the @code{ns-3} Callback and Attribute
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    68
mechanisms.  You should read and understand the corresponding sections of the 
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    69
manual before attempting to understand the tracing system.
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    70
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    71
The ns-3 tracing system is built on the concepts of independent tracing sources
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    72
and tracing sinks; along with a uniform mechanism for connecting sources to sinks.
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    73
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    74
Trace sources are entities that can signal events that happen in a simulation and 
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    75
provide access to interesting underlying data.  For example, a trace source could
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    76
indicate when a packet is received by a net device and provide access to the 
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    77
packet contents for interested trace sinks.  A trace source might also indicate 
5431
01a657b8d1ef some cleanup of part 1 of manual
Tom Henderson <tomh@tomh.org>
parents: 5426
diff changeset
    78
when an interesting state change happens in a model.  For example, the congestion
5188
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    79
window of a TCP model is a prime candidate for a trace source.
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    80
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    81
Trace sources are not useful by themselves; they must be connected to other pieces
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    82
of code that actually do something useful with the information provided by the source.
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    83
The entities that consume trace information are called trace sinks.  Trace sources 
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    84
are generators of events and trace sinks are consumers. 
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    85
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    86
This explicit division allows for large numbers of trace sources to be scattered
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    87
around the system in places which model authors believe might be useful.  Unless
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    88
a user connects a trace sink to one of these sources, nothing is output.  This
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    89
arrangement allows relatively unsophisticated users to attach new types of sinks
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    90
to existing tracing sources, without requiring editing and recompiling the core 
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    91
or models of the simulator.  
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    92
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    93
There can be zero or more consumers of trace events generated by a trace source.  
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    94
One can think of a trace source as a kind of point-to-multipoint information link.  
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    95
5431
01a657b8d1ef some cleanup of part 1 of manual
Tom Henderson <tomh@tomh.org>
parents: 5426
diff changeset
    96
The ``transport protocol'' for this conceptual point-to-multipoint link is an 
5188
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    97
@code{ns-3} @code{Callback}.
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    98
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    99
Recall from the Callback Section that callback facility is a way to allow two
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   100
modules in the system to communicate via function calls while at the same time
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   101
decoupling the calling function from the called class completely.  This is the
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   102
same requirement as outlined above for the tracing system.
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   103
5431
01a657b8d1ef some cleanup of part 1 of manual
Tom Henderson <tomh@tomh.org>
parents: 5426
diff changeset
   104
Basically, a trace source @emph{is} a callback to which multiple
01a657b8d1ef some cleanup of part 1 of manual
Tom Henderson <tomh@tomh.org>
parents: 5426
diff changeset
   105
functions may be registered.  When a trace sink expresses
5188
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   106
interest in receiving trace events, it adds a callback to a list of callbacks
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   107
held by the trace source.  When an interesting event happens, the trace source
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   108
invokes its @code{operator()} providing zero or more parameters.  This tells
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   109
the source to go through its list of callbacks invoking each one in turn.  In
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   110
this way, the parameter(s) are communicated to the trace sinks, which are just
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   111
functions.
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   112
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   113
@subsection The Simplest Example
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   114
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   115
It will be useful to go walk a quick example just to reinforce what we've said.
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   116
5431
01a657b8d1ef some cleanup of part 1 of manual
Tom Henderson <tomh@tomh.org>
parents: 5426
diff changeset
   117
@smallformat
01a657b8d1ef some cleanup of part 1 of manual
Tom Henderson <tomh@tomh.org>
parents: 5426
diff changeset
   118
@example
5188
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   119
  #include ``ns3/object.h''
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   120
  #include ``ns3/uinteger.h''
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   121
  #include ``ns3/traced-value.h''
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   122
  #include ``ns3/trace-source-accessor.h''
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   123
  
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   124
  #include <iostream>
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   125
  
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   126
  using namespace ns3;
5431
01a657b8d1ef some cleanup of part 1 of manual
Tom Henderson <tomh@tomh.org>
parents: 5426
diff changeset
   127
@end example
01a657b8d1ef some cleanup of part 1 of manual
Tom Henderson <tomh@tomh.org>
parents: 5426
diff changeset
   128
@end smallformat
5188
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   129
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   130
The first thing to do is include the required files.  As mentioned above, the
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   131
trace system makes heavy use of the Object and Attribute systems.  The first
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   132
two includes bring in the declarations for those systems.  The file, 
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   133
@code{traced-value.h} brings in the required declarations for tracing data
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   134
that obeys value semantics.  
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   135
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   136
In general, value semantics just means that you can pass the object around,
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   137
not an address.  In order to use value semantics at all you have to have an
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   138
object with an associated copy constructor and assignment operator
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   139
available.  We extend the requirements to talk about the set of operators
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   140
that are pre-defined for plain-old-data (POD) types.  Operator=, operator++,
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   141
operator--, operator+, operator==, etc.
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   142
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   143
What this all means is that you will be able to trace changes to an object
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   144
made using those operators.
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   145
5431
01a657b8d1ef some cleanup of part 1 of manual
Tom Henderson <tomh@tomh.org>
parents: 5426
diff changeset
   146
@smallformat
01a657b8d1ef some cleanup of part 1 of manual
Tom Henderson <tomh@tomh.org>
parents: 5426
diff changeset
   147
@example
5188
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   148
  class MyObject : public Object
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   149
  {
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   150
  public:
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   151
    static TypeId GetTypeId (void)
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   152
    {
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   153
      static TypeId tid = TypeId ("MyObject")
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   154
        .SetParent (Object::GetTypeId ())
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   155
        .AddConstructor<MyObject> ()
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   156
        .AddTraceSource ("MyInteger",
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   157
                         "An integer value to trace.",
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   158
                         MakeTraceSourceAccessor (&MyObject::m_myInt))
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   159
        ;
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   160
      return tid;
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   161
    }
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   162
  
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   163
    MyObject () {}
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   164
    TracedValue<uint32_t> m_myInt;
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   165
  };
5431
01a657b8d1ef some cleanup of part 1 of manual
Tom Henderson <tomh@tomh.org>
parents: 5426
diff changeset
   166
@end example
01a657b8d1ef some cleanup of part 1 of manual
Tom Henderson <tomh@tomh.org>
parents: 5426
diff changeset
   167
@end smallformat
5188
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   168
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   169
Since the tracing system is integrated with Attributes, and Attributes work
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   170
with Objects, there must be an @command{ns-3} @code{Object} for the trace source
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   171
to live in.  The two important lines of code are the @code{.AddTraceSource} and 
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   172
the @code{TracedValue} declaration.
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   173
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   174
The @code{.AddTraceSource} provides the ``hooks'' used for connecting the trace
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   175
source to the outside world.  The @code{TracedValue} declaration provides the
5197
0401d439763e silly typos and add disclaimer
Craig Dowell <craigdo@ee.washington.edu>
parents: 5188
diff changeset
   176
infrastructure that overloads the operators mentioned above and drives the callback 
5188
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   177
process.
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   178
5431
01a657b8d1ef some cleanup of part 1 of manual
Tom Henderson <tomh@tomh.org>
parents: 5426
diff changeset
   179
@smallformat
01a657b8d1ef some cleanup of part 1 of manual
Tom Henderson <tomh@tomh.org>
parents: 5426
diff changeset
   180
@example
5188
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   181
  void
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   182
  IntTrace (Int oldValue, Int newValue)
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   183
  {
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   184
    std::cout << ``Traced `` << oldValue << `` to `` << newValue << std::endl;
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   185
  }
5431
01a657b8d1ef some cleanup of part 1 of manual
Tom Henderson <tomh@tomh.org>
parents: 5426
diff changeset
   186
@end example
01a657b8d1ef some cleanup of part 1 of manual
Tom Henderson <tomh@tomh.org>
parents: 5426
diff changeset
   187
@end smallformat
5188
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   188
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   189
This is the definition of the trace sink.  It corresponds directly to a callback
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   190
function.  This function will be called whenever one of the operators of the
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   191
@code{TracedValue} is executed.
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   192
5431
01a657b8d1ef some cleanup of part 1 of manual
Tom Henderson <tomh@tomh.org>
parents: 5426
diff changeset
   193
@smallformat
01a657b8d1ef some cleanup of part 1 of manual
Tom Henderson <tomh@tomh.org>
parents: 5426
diff changeset
   194
@example
5188
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   195
  int
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   196
  main (int argc, char *argv[])
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   197
  {
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   198
    Ptr<MyObject> myObject = CreateObject<MyObject> ();
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   199
  
5431
01a657b8d1ef some cleanup of part 1 of manual
Tom Henderson <tomh@tomh.org>
parents: 5426
diff changeset
   200
    myObject->TraceConnectWithoutContext ("MyInteger", MakeCallback(&IntTrace));
5188
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   201
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   202
    myObject->m_myInt = 1234;
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   203
  }
5431
01a657b8d1ef some cleanup of part 1 of manual
Tom Henderson <tomh@tomh.org>
parents: 5426
diff changeset
   204
@end example
01a657b8d1ef some cleanup of part 1 of manual
Tom Henderson <tomh@tomh.org>
parents: 5426
diff changeset
   205
@end smallformat
5188
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   206
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   207
In this snippet, the first thing that needs to be done is to create the object
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   208
in which the trace source lives.
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   209
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   210
The next step, the @code{TraceConnectWithoutContext}, forms the connection
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   211
between the trace source and the trace sink.  Notice the @code{MakeCallback}
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   212
template function.  Recall from the Callback section that this creates the
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   213
specialized functor responsible for providing the overloaded @code{operator()}
5197
0401d439763e silly typos and add disclaimer
Craig Dowell <craigdo@ee.washington.edu>
parents: 5188
diff changeset
   214
used to ``fire'' the callback.  The overloaded operators (++, --, etc.) will
0401d439763e silly typos and add disclaimer
Craig Dowell <craigdo@ee.washington.edu>
parents: 5188
diff changeset
   215
use this @code{operator()} to actually invoke the callback. The 
0401d439763e silly typos and add disclaimer
Craig Dowell <craigdo@ee.washington.edu>
parents: 5188
diff changeset
   216
@code{TraceConnectWithoutContext}, takes a string parameter that provides 
0401d439763e silly typos and add disclaimer
Craig Dowell <craigdo@ee.washington.edu>
parents: 5188
diff changeset
   217
the name of the Attribute assigned to the trace source.  Let's ignore the bit
0401d439763e silly typos and add disclaimer
Craig Dowell <craigdo@ee.washington.edu>
parents: 5188
diff changeset
   218
about context for now since it is not important yet.
5188
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   219
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   220
Finally, the line,
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   221
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   222
@verbatim
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   223
   myObject->m_myInt = 1234;
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   224
@end verbatim
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   225
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   226
should be interpreted as an invocation of @code{operator=} on the member 
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   227
variable @code{m_myInt} with the integer @code{1234} passed as a parameter.
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   228
It turns out that this operator is defined (by @code{TracedValue}) to execute
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   229
a callback that returns void and takes two integer values as parameters -- 
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   230
an old value and a new value for the integer in question.  That is exactly 
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   231
the function signature for the callback function we provided -- @code{IntTrace}.
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   232
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   233
To summarize, a trace source is, in essence, a variable that holds a list of
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   234
callbacks.  A trace sink is a function used as the target of a callback.  The
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   235
Attribute and object type information systems are used to provide a way to 
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   236
connect trace sources to trace sinks.  The act of ``hitting'' a trace source
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   237
is executing an operator on the trace source which fires callbacks.  This 
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   238
results in the trace sink callbacks registering interest in the source being 
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   239
called with the parameters provided by the source.
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   240
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   241
@subsection Using the Config Subsystem to Connect to Trace Sources
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   242
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   243
The @code{TraceConnectWithoutContext} call shown above in the simple example is
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   244
actually very rarely used in the system.  More typically, the @code{Config}
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   245
subsystem is used to allow selecting a trace source in the system using what is
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   246
called a @emph{config path}.
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   247
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   248
For example, one might find something that looks like the following in the system
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   249
(taken from @code{examples/tcp-large-transfer.cc})
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   250
5431
01a657b8d1ef some cleanup of part 1 of manual
Tom Henderson <tomh@tomh.org>
parents: 5426
diff changeset
   251
@smallformat
01a657b8d1ef some cleanup of part 1 of manual
Tom Henderson <tomh@tomh.org>
parents: 5426
diff changeset
   252
@example
5188
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   253
  void CwndTracer (uint32_t oldval, uint32_t newval) {}
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   254
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   255
  ...
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   256
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   257
  Config::ConnectWithoutContext (
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   258
    "/NodeList/0/$ns3::TcpL4Protocol/SocketList/0/CongestionWindow", 
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   259
    MakeCallback (&CwndTracer));
5431
01a657b8d1ef some cleanup of part 1 of manual
Tom Henderson <tomh@tomh.org>
parents: 5426
diff changeset
   260
@end example
01a657b8d1ef some cleanup of part 1 of manual
Tom Henderson <tomh@tomh.org>
parents: 5426
diff changeset
   261
@end smallformat
5188
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   262
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   263
This should look very familiar.  It is the same thing as the previous example,
5197
0401d439763e silly typos and add disclaimer
Craig Dowell <craigdo@ee.washington.edu>
parents: 5188
diff changeset
   264
except that a static member function of class @code{Config} is being called instead 
0401d439763e silly typos and add disclaimer
Craig Dowell <craigdo@ee.washington.edu>
parents: 5188
diff changeset
   265
of a method on @code{Object}; and instead of an @code{Attribute} name, a path is
5188
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   266
being provided.
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   267
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   268
The first thing to do is to read the path backward.  The last segment of the path
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   269
must be an @code{Attribute} of an @code{Object}.  In fact, if you had a pointer to
5197
0401d439763e silly typos and add disclaimer
Craig Dowell <craigdo@ee.washington.edu>
parents: 5188
diff changeset
   270
the @code{Object} that has the ``CongestionWindow'' @code{Attribute} handy (call it
0401d439763e silly typos and add disclaimer
Craig Dowell <craigdo@ee.washington.edu>
parents: 5188
diff changeset
   271
@code{theObject}), you could write this just like the previous example:
5188
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   272
5431
01a657b8d1ef some cleanup of part 1 of manual
Tom Henderson <tomh@tomh.org>
parents: 5426
diff changeset
   273
@smallformat
01a657b8d1ef some cleanup of part 1 of manual
Tom Henderson <tomh@tomh.org>
parents: 5426
diff changeset
   274
@example
5188
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   275
  void CwndTracer (uint32_t oldval, uint32_t newval) {}
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   276
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   277
  ...
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   278
5197
0401d439763e silly typos and add disclaimer
Craig Dowell <craigdo@ee.washington.edu>
parents: 5188
diff changeset
   279
  theObject->TraceConnectWithoutContext ("CongestionWindow", MakeCallback (&CwndTracer));
5431
01a657b8d1ef some cleanup of part 1 of manual
Tom Henderson <tomh@tomh.org>
parents: 5426
diff changeset
   280
@end example
01a657b8d1ef some cleanup of part 1 of manual
Tom Henderson <tomh@tomh.org>
parents: 5426
diff changeset
   281
@end smallformat
5188
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   282
5197
0401d439763e silly typos and add disclaimer
Craig Dowell <craigdo@ee.washington.edu>
parents: 5188
diff changeset
   283
It turns out that the code for @code{Config::ConnectWithoutContext} does exactly that.
0401d439763e silly typos and add disclaimer
Craig Dowell <craigdo@ee.washington.edu>
parents: 5188
diff changeset
   284
This function takes a path that represents a chain of @code{Object} pointers and follows 
5188
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   285
them until it gets to the end of the path and interprets the last segment as an
5197
0401d439763e silly typos and add disclaimer
Craig Dowell <craigdo@ee.washington.edu>
parents: 5188
diff changeset
   286
@code{Attribute} on the last object.  Let's walk through what happens.
5188
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   287
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   288
The leading ``/'' character in the path refers to a so-called namespace.  One of the
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   289
predefined namespaces in the config system is ``NodeList'' which is a list of all of
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   290
the nodes in the simulation.  Items in the list are referred to by indices into the 
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   291
list, so ``/NodeList/0'' refers to the zeroth node in the list of nodes created by
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   292
the simulation.  This node is actually a @code{Ptr<Node>} and so is a subclass of
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   293
an @code{ns3::Object}.  
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   294
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   295
As described in the Object Model section, @code{ns-3} supports an object aggregation
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   296
model.  The next path segment begins with the ``$'' character which indicates a
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   297
@code{GetObject} call should be made looking for the type that follows.  When a
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   298
node is initialized by an @code{InternetStackHelper} a number of interfaces are
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   299
aggregated to the node.  One of these is the TCP level four protocol.  The runtime
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   300
type of this protocol object is ``ns3::TcpL4Protocol''.  When the @code{GetObject}
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   301
is executed, it returns a pointer to the object of this type.
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   302
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   303
The @code{TcpL4Protocol} class defines an Attribute called ``SocketList'' which is
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   304
a list of sockets.  Each socket is actually an @code{ns3::Object} with its own 
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   305
@code{Attributes}.  The items in the list of sockets are referred to by index just
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   306
as in the NodeList, so ``SocketList/0'' refers to the zeroth socket in the list
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   307
of sockets on the zeroth node in the NodeList -- the first node constructed in the
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   308
simulation.
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   309
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   310
This socket, the type of which turns out to be an @code{ns3::TcpSocketImpl} defines
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   311
an attribute called ``CongestionWindow'' which is a @code{TracedValue<uint32_t>}.
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   312
The @code{Config::ConnectWithoutContext} now does a,
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   313
5431
01a657b8d1ef some cleanup of part 1 of manual
Tom Henderson <tomh@tomh.org>
parents: 5426
diff changeset
   314
@smallformat
01a657b8d1ef some cleanup of part 1 of manual
Tom Henderson <tomh@tomh.org>
parents: 5426
diff changeset
   315
@example
5188
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   316
  object->TraceConnectWithoutContext ("CongestionWindow", MakeCallback (&CwndTracer));
5431
01a657b8d1ef some cleanup of part 1 of manual
Tom Henderson <tomh@tomh.org>
parents: 5426
diff changeset
   317
@end example
01a657b8d1ef some cleanup of part 1 of manual
Tom Henderson <tomh@tomh.org>
parents: 5426
diff changeset
   318
@end smallformat
5188
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   319
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   320
using the object pointer from ``SocketList/0'' which makes the connection between
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   321
the trace source defined in the socket to the callback -- @code{CwndTracer}.
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   322
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   323
Now, whenever a change is made to the @code{TracedValue<uint32_t>} representing the
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   324
congestion window in the TCP socket, the registered callback will be executed and 
5431
01a657b8d1ef some cleanup of part 1 of manual
Tom Henderson <tomh@tomh.org>
parents: 5426
diff changeset
   325
the function @code{CwndTracer} will be called printing out the old and new values
5188
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   326
of the TCP congestion window.
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   327
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   328
@node Using the Tracing API
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   329
@section Using the Tracing API
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   330
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   331
  There 
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   332
are three levels of interaction with the tracing system:
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   333
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   334
@itemize @bullet
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   335
@item Beginning user can easily control which objects are participating in tracing;
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   336
@item Intermediate users can extend the tracing system to modify the output format 
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   337
generated or use existing trace sources in different ways, without modifying the 
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   338
core of the simulator;
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   339
@item Advanced users can modify the simulator core to add new tracing sources and 
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   340
sinks. 
5231
04dec13d474f fix manual build
Tom Henderson <tomh@tomh.org>
parents: 5197
diff changeset
   341
@end itemize
5188
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   342
6031
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   343
@node Using the Tracing Helpers
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   344
@section Using the Tracing Helpers
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   345
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   346
The @code{ns-3} trace helpers provide a rich environment for configuring and
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   347
selecting different trace events and writing them to files.  In previous
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   348
sections, primarily ``Building Topologies,'' we have seen several varieties
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   349
of the trace helper methods designed for use inside other (device) helpers.
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   350
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   351
Perhaps you will recall seeing some of these variations: 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   352
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   353
@verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   354
  pointToPoint.EnablePcapAll ("second");
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   355
  pointToPoint.EnablePcap ("second", p2pNodes.Get (0)->GetId (), 0);
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   356
  csma.EnablePcap ("third", csmaDevices.Get (0), true);
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   357
  pointToPoint.EnableAsciiAll (ascii.CreateFileStream ("myfirst.tr"));
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   358
@end verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   359
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   360
What may not be obvious, though, is that there is a consistent model for all of 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   361
the trace-related methods found in the system.  We will now take a little time
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   362
and take a look at the ``big picture''.
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   363
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   364
There are currently two primary use cases of the tracing helpers in @code{ns-3}:
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   365
Device helpers and protocol helpers.  Device helpers look at the problem
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   366
of specifying which traces should be enabled through a node, device pair.  For 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   367
example, you may want to specify that pcap tracing should be enabled on a 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   368
particular device on a specific node.  This follows from the @code{ns-3} device
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   369
conceptual model, and also the conceptual models of the various device helpers.
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   370
Following naturallyu from this, the files created follow a 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   371
<prefix>-<node>-<device> naming convention.  
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   372
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   373
Protocol helpers look at the problem of specifying which traces should be
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   374
enabled through a protocol and interface pair.  This follows from the @code{ns-3}
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   375
protocol stack conceptual model, and also the conceptual models of internet
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   376
stack helpers.  Naturally, the trace files should follow a 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   377
<prefix>-<protocol>-<interface> naming convention.
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   378
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   379
The trace helpers therefore fall naturally into a two-dimensional taxonomy.
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   380
There are subtleties that prevent all four classes from behaving identically,
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   381
but we do strive to make them all work as similarly as possible; and whenever
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   382
possible there are analogs for all methods in all classes.
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   383
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   384
@verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   385
                   | pcap | ascii |
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   386
  -----------------+------+-------|
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   387
  Device Helper    |      |       |
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   388
  -----------------+------+-------|
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   389
  Protocol Helper  |      |       |
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   390
  -----------------+------+-------|
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   391
@end verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   392
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   393
Let say at this point that @code{mixins} would probably be the best way to 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   394
approach the kind of class hierarchy found in @code{src/helper/trace-helper.h}
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   395
but our Python bindings generator does not support multiple inheritance and so
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   396
this choice is excluded for now.  We were forced to linearize the inheritance
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   397
tree and use single inheritance for the trace functionality.  This results in a
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   398
somewhat odd arrangement of classes, an unusual naming convention and implies
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   399
a hierarchy of functionality avialable in those classes. This isn't really a
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   400
concern for users of this functionality, but it does make our discussion here
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   401
a bit more difficult in some cases.
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   402
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   403
Let's take a quick look at all four of these cases.
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   404
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   405
@subsection Pcap Tracing Device Helpers
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   406
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   407
The goal of these helpers is to make it easy to add a consistent pcap trace
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   408
facility to an @code{ns-3} device.  We want all of the various flavors of
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   409
pcap tracing to work the same across all devices, so the methods of these 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   410
helpers are inherited by device helpers.  Take a look at 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   411
@code{src/helper/trace-helper.h} if you want to follow the discussion while 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   412
looking at real code.
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   413
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   414
The class @code{PcapHelperForDevice} provides the high level functionality
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   415
for using pcap tracing in an @code{ns-3} device.  Every device must implement a
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   416
single virtual method inherited from this class.
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   417
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   418
@verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   419
  virtual void EnablePcapInternal (std::string prefix, Ptr<NetDevice> nd, bool promiscuous) = 0;
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   420
@end verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   421
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   422
The signature of this method reflects the device-centric view of the situation
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   423
at this level.  All of the public methods inherited from class 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   424
2@code{PcapUserHelperForDevice} reduce to calling this single device-dependent
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   425
implementation method.  For example, the lowest level pcap method,
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   426
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   427
@verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   428
  void EnablePcap (std::string prefix, Ptr<NetDevice> nd, bool promiscuous = false);
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   429
@verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   430
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   431
will call the device implementation of @code{EnablePcapInternal} directly.  All
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   432
other public pcap tracing methods build on this implementation to provide 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   433
additional user-level functionality.  What this means to the user is that all 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   434
device helpers in the system will have all of the pcap trace methods available;
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   435
and these methods will all work in the same way across devices if the device 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   436
implements @code{EnablePcapInternal} correctly.
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   437
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   438
@subsubsection Pcap Tracing Device Helper Methods
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   439
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   440
@verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   441
  void EnablePcap (std::string prefix, Ptr<NetDevice> nd, bool promiscuous = false);
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   442
  void EnablePcap (std::string prefix, std::string ndName, bool promiscuous = false);
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   443
  void EnablePcap (std::string prefix, NetDeviceContainer d, bool promiscuous = false);
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   444
  void EnablePcap (std::string prefix, NodeContainer n, bool promiscuous = false);
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   445
  void EnablePcap (std::string prefix, uint32_t nodeid, uint32_t deviceid, bool promiscuous = false);
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   446
  void EnablePcapAll (std::string prefix, bool promiscuous = false);
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   447
@end verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   448
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   449
You are encouraged to peruse the Doxygen for class @code{PcapHelperForDevice}
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   450
to find the details of these methods; but to summarize ...
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   451
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   452
You can enable pcap tracing on a particular node/net-device pair by providing a
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   453
@code{Ptr<NetDevice>} to an @code{EnablePcap} method.  The @code{Ptr<Node>} is 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   454
implicit since the net device must belong to exactly one @code{Node}.
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   455
For example, 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   456
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   457
@verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   458
  Ptr<NetDevice> nd;
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   459
  ...
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   460
  helper.EnablePcap ("prefix", nd);
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   461
@end verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   462
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   463
You can enable pcap tracing on a particular node/net-device pair by providing a
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   464
@code{std::string} representing an object name service string to an 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   465
@code{EnablePcap} method.  The @code{Ptr<NetDevice>} is looked up from the name
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   466
string.  Again, the @code<Node> is implicit since the named net device must 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   467
belong to exactly one @code{Node}.  For example, 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   468
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   469
@verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   470
  Names::Add ("server" ...);
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   471
  Names::Add ("server/eth0" ...);
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   472
  ...
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   473
  helper.EnablePcap ("prefix", "server/ath0");
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   474
@end verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   475
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   476
You can enable pcap tracing on a collection of node/net-device pairs by 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   477
providing a @code{NetDeviceContainer}.  For each @code{NetDevice} in the container
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   478
the type is checked.  For each device of the proper type (the same type as is 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   479
managed by the device helper), tracing is enabled.    Again, the @code<Node> is 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   480
implicit since the found net device must belong to exactly one @code{Node}.
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   481
For example, 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   482
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   483
@verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   484
  NetDeviceContainer d = ...;
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   485
  ...
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   486
  helper.EnablePcap ("prefix", d);
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   487
@end verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   488
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   489
You can enable pcap tracing on a collection of node/net-device pairs by 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   490
providing a @code{NodeContainer}.  For each @code{Node} in the @code{NodeContainer}
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   491
its attached @code{NetDevices} are iterated.  For each @code{NetDevice} attached
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   492
to each node in the container, the type of that device is checked.  For each 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   493
device of the proper type (the same type as is managed by the device helper), 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   494
tracing is enabled.
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   495
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   496
@verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   497
  NodeContainer n;
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   498
  ...
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   499
  helper.EnablePcap ("prefix", n);
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   500
@end verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   501
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   502
You can enable pcap tracing on the basis of node ID and device ID as well as
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   503
with explicit @code{Ptr}.  Each @code{Node} in the system has an integer node ID
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   504
and each device connected to a node has an integer device ID.
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   505
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   506
@verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   507
  helper.EnablePcap ("prefix", 21, 1);
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   508
@end verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   509
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   510
Finally, you can enable pcap tracing for all devices in the system, with the
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   511
same type as that managed by the device helper.
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   512
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   513
@verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   514
  helper.EnablePcapAll ("prefix");
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   515
@end verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   516
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   517
In each of these cases, there is an additional parameter that defaults to false.
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   518
This parameter indicates that the trace should not be gathered in promiscuous
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   519
mode.  If you do want your traces to include all traffic seen by the device
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   520
(and the device supports promiscuous mode) simply add a true parameter to any
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   521
of the calls above.  For example,
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   522
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   523
@verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   524
  Ptr<NetDevice> nd;
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   525
  ...
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   526
  helper.EnablePcap ("prefix", nd, true);
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   527
@end verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   528
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   529
will enable promiscuous mode captures on the @code{NetDevice} specified by @code{nd}.
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   530
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   531
@subsubsection Pcap Tracing Device Helper Filename Selection
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   532
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   533
Implicit in all of the method descriptions above is the construction of the
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   534
complete filenames by the implementation method.  By convention, pcap traces
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   535
in the @code{ns-3} system are of the form ``<prefix>-<node id>-<device id>.pcap''
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   536
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   537
As previously mentioned, every node in the system will have a system-assigned
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   538
node id; and every device will have an interface index (also called a device id)
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   539
relative to its node.  By default, then, a pcap trace file created as a result
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   540
of enabling tracing on the first device of node 21 using the prefix ``prefix''
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   541
would be ``prefix-21-1.pcap''.
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   542
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   543
You can always use the @code{ns-3} object name service to make this more clear.
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   544
For example, if you use the object name service to assign the name ``server''
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   545
to node 21, the resulting pcap trace file name will automatically become,
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   546
``prefix-server-1.pcap'' and if you also assign the name ``eth0'' to the 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   547
device, your pcap file name will automatically pick this up and be called
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   548
``prefix-server-eth0.pcap''.
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   549
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   550
@subsection Ascii Tracing Device Helpers
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   551
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   552
The behavior of the ascii trace helpers is substantially similar to the pcap
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   553
case.  Take a look at @code{src/helper/trace-helper.h} if you want to 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   554
follow the discussion while looking at real code.
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   555
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   556
The class @code{TraceHelperForDevice} adds the high level functionality for 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   557
using ascii tracing to class @code{PcapHelperForDevice}.  If a device helper
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   558
inherits from class @code{TraceHelperForDevice} it gets both pcap and ascii
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   559
tracing powers.  Along with the internal pcap function, every device must 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   560
also implement a single virtual method inherited from the ascii trace additions
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   561
to this class.
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   562
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   563
@verbatim
6051
b988174aa30b OutputStreamObject to OutputStreamKeeper
Craig Dowell <craigdo@ee.washington.edu>
parents: 6031
diff changeset
   564
  virtual void EnableAsciiInternal (Ptr<OutputStreamKeeper> stream, std::string prefix, Ptr<NetDevice> nd) = 0;
6031
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   565
@end verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   566
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   567
The signature of this method reflects the device-centric view of the situation
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   568
at this level; and also the fact that the helper may be writing to a shared
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   569
output stream.  All of the public ascii-trace-related methods inherited from 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   570
class @code{TraceHelperForDevice} reduce to calling this single device-
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   571
dependent implementation method.  For example, the lowest level ascii trace
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   572
methods,
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   573
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   574
@verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   575
  void EnableAscii (std::string prefix, Ptr<NetDevice> nd);
6051
b988174aa30b OutputStreamObject to OutputStreamKeeper
Craig Dowell <craigdo@ee.washington.edu>
parents: 6031
diff changeset
   576
  void EnableAscii (Ptr<OutputStreamKeeper> stream, Ptr<NetDevice> nd);
6031
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   577
@verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   578
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   579
will call the device implementation of @code{EnableAsciiInternal} directly,
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   580
providing either a valid prefix or stream.  All other public ascii tracing 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   581
methods will build on these low-level functions to provide additional user-level
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   582
functionality.  What this means to the user is that all device helpers in the 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   583
system will have all of the ascii trace methods available; and these methods
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   584
will all work in the same way across devices if the devices implement 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   585
@code{EnablAsciiInternal} correctly.
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   586
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   587
@subsubsection Ascii Tracing Device Helper Methods
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   588
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   589
@verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   590
  void EnableAscii (std::string prefix, Ptr<NetDevice> nd);
6051
b988174aa30b OutputStreamObject to OutputStreamKeeper
Craig Dowell <craigdo@ee.washington.edu>
parents: 6031
diff changeset
   591
  void EnableAscii (Ptr<OutputStreamKeeper> stream, Ptr<NetDevice> nd);
6031
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   592
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   593
  void EnableAscii (std::string prefix, std::string ndName);
6051
b988174aa30b OutputStreamObject to OutputStreamKeeper
Craig Dowell <craigdo@ee.washington.edu>
parents: 6031
diff changeset
   594
  void EnableAscii (Ptr<OutputStreamKeeper> stream, std::string ndName);
6031
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   595
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   596
  void EnableAscii (std::string prefix, NetDeviceContainer d);
6051
b988174aa30b OutputStreamObject to OutputStreamKeeper
Craig Dowell <craigdo@ee.washington.edu>
parents: 6031
diff changeset
   597
  void EnableAscii (Ptr<OutputStreamKeeper> stream, NetDeviceContainer d);
6031
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   598
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   599
  void EnableAscii (std::string prefix, NodeContainer n);
6051
b988174aa30b OutputStreamObject to OutputStreamKeeper
Craig Dowell <craigdo@ee.washington.edu>
parents: 6031
diff changeset
   600
  void EnableAscii (Ptr<OutputStreamKeeper> stream, NodeContainer n);
6031
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   601
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   602
  void EnableAscii (std::string prefix, uint32_t nodeid, uint32_t deviceid);
6051
b988174aa30b OutputStreamObject to OutputStreamKeeper
Craig Dowell <craigdo@ee.washington.edu>
parents: 6031
diff changeset
   603
  void EnableAscii (Ptr<OutputStreamKeeper> stream, uint32_t nodeid, uint32_t deviceid);
6031
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   604
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   605
  void EnableAsciiAll (std::string prefix);
6051
b988174aa30b OutputStreamObject to OutputStreamKeeper
Craig Dowell <craigdo@ee.washington.edu>
parents: 6031
diff changeset
   606
  void EnableAsciiAll (Ptr<OutputStreamKeeper> stream);
6031
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   607
@end verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   608
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   609
You are encouraged to peruse the Doxygen for class @code{TraceHelperForDevice}
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   610
to find the details of these methods; but to summarize ...
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   611
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   612
There are twice as many methods available for ascii tracing as there were for
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   613
pcap tracing.  This is because, in addition to the pcap-style model where traces
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   614
from each unique node/device pair are written to a unique file, we support a model
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   615
in which trace information for many node/device pairs is written to a common file.
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   616
This means that the <prefix>-<node>-<device> file name generation mechanism is 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   617
replaced by a mechanism to refer to a common file; and the number of API methods
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   618
is doubled to allow all combinations.
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   619
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   620
Just as in pcap tracing, you can enable ascii tracing on a particular 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   621
node/net-device pair by providing a @code{Ptr<NetDevice>} to an @code{EnableAscii}
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   622
method.  The @code{Ptr<Node>} is implicit since the net device must belong to 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   623
exactly one @code{Node}.  For example, 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   624
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   625
@verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   626
  Ptr<NetDevice> nd;
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   627
  ...
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   628
  helper.EnableAscii ("prefix", nd);
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   629
@end verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   630
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   631
In this case, no trace contexts are written to the ascii trace file since they
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   632
would be redundant.  The system will pick the file name to be created using
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   633
the same rules as described in the pcap section, except that the file will
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   634
have the suffix ``.tr'' instead of ``.pcap''.
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   635
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   636
If you want to enable ascii tracing on more than one net device and have all 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   637
traces sent to a single file, you can do that as well by using an object to
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   638
refer to a single file.  We have already seen this in the ``cwnd'' example
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   639
above:
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   640
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   641
@verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   642
  Ptr<NetDevice> nd1;
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   643
  Ptr<NetDevice> nd2;
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   644
  ...
6051
b988174aa30b OutputStreamObject to OutputStreamKeeper
Craig Dowell <craigdo@ee.washington.edu>
parents: 6031
diff changeset
   645
  Ptr<OutputStreamKeeper> stream = asciiTraceHelper.CreateFileStream ("trace-file-name.tr");
6031
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   646
  ...
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   647
  helper.EnableAscii (stream, nd1);
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   648
  helper.EnableAscii (stream, nd2);
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   649
@verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   650
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   651
In this case, trace contexts are written to the ascii trace file since they
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   652
are required to disambiguate traces from the two devices.  Note that since the
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   653
user is completely specifying the file name, the string should include the ``,tr''
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   654
for consistency.
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   655
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   656
You can enable ascii tracing on a particular node/net-device pair by providing a
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   657
@code{std::string} representing an object name service string to an 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   658
@code{EnablePcap} method.  The @code{Ptr<NetDevice>} is looked up from the name
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   659
string.  Again, the @code<Node> is implicit since the named net device must 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   660
belong to exactly one @code{Node}.  For example, 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   661
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   662
@verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   663
  Names::Add ("client" ...);
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   664
  Names::Add ("client/eth0" ...);
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   665
  Names::Add ("server" ...);
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   666
  Names::Add ("server/eth0" ...);
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   667
  ...
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   668
  helper.EnableAscii ("prefix", "client/eth0");
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   669
  helper.EnableAscii ("prefix", "server/eth0");
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   670
@end verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   671
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   672
This would result in two files named ``prefix-client-eth0.tr'' and 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   673
``prefix-server-eth0.tr'' with traces for each device in the respective trace
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   674
file.  Since all of the EnableAscii functions are overloaded to take a stream object,
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   675
you can use that form as well:
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   676
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   677
@verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   678
  Names::Add ("client" ...);
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   679
  Names::Add ("client/eth0" ...);
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   680
  Names::Add ("server" ...);
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   681
  Names::Add ("server/eth0" ...);
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   682
  ...
6051
b988174aa30b OutputStreamObject to OutputStreamKeeper
Craig Dowell <craigdo@ee.washington.edu>
parents: 6031
diff changeset
   683
  Ptr<OutputStreamKeeper> stream = asciiTraceHelper.CreateFileStream ("trace-file-name.tr");
6031
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   684
  ...
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   685
  helper.EnableAscii (stream, "client/eth0");
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   686
  helper.EnableAscii (stream, "server/eth0");
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   687
@end verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   688
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   689
This would result in a single trace file called ``trace-file-name.tr'' that 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   690
contains all of the trace events for both devices.  The events would be 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   691
disambiguated by trace context strings.
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   692
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   693
You can enable ascii tracing on a collection of node/net-device pairs by 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   694
providing a @code{NetDeviceContainer}.  For each @code{NetDevice} in the container
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   695
the type is checked.  For each device of the proper type (the same type as is 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   696
managed by the device helper), tracing is enabled.    Again, the @code<Node> is 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   697
implicit since the found net device must belong to exactly one @code{Node}.
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   698
For example, 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   699
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   700
@verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   701
  NetDeviceContainer d = ...;
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   702
  ...
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   703
  helper.EnableAscii ("prefix", d);
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   704
@end verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   705
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   706
This would result in a number of ascii trace files being created, each of which
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   707
follows the <prefix>-<node id>-<device id>.tr convention.  Combining all of the
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   708
traces into a single file is accomplished similarly to the examples above:
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   709
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   710
@verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   711
  NetDeviceContainer d = ...;
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   712
  ...
6051
b988174aa30b OutputStreamObject to OutputStreamKeeper
Craig Dowell <craigdo@ee.washington.edu>
parents: 6031
diff changeset
   713
  Ptr<OutputStreamKeeper> stream = asciiTraceHelper.CreateFileStream ("trace-file-name.tr");
6031
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   714
  ...
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   715
  helper.EnableAscii (stream, d);
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   716
@end verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   717
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   718
You can enable ascii tracing on a collection of node/net-device pairs by 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   719
providing a @code{NodeContainer}.  For each @code{Node} in the @code{NodeContainer}
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   720
its attached @code{NetDevices} are iterated.  For each @code{NetDevice} attached
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   721
to each node in the container, the type of that device is checked.  For each 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   722
device of the proper type (the same type as is managed by the device helper), 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   723
tracing is enabled.
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   724
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   725
@verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   726
  NodeContainer n;
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   727
  ...
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   728
  helper.EnableAscii ("prefix", n);
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   729
@end verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   730
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   731
This would result in a number of ascii trace files being created, each of which
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   732
follows the <prefix>-<node id>-<device id>.tr convention.  Combining all of the
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   733
traces into a single file is accomplished similarly to the examples above:
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   734
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   735
You can enable pcap tracing on the basis of node ID and device ID as well as
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   736
with explicit @code{Ptr}.  Each @code{Node} in the system has an integer node ID
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   737
and each device connected to a node has an integer device ID.
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   738
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   739
@verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   740
  helper.EnableAscii ("prefix", 21, 1);
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   741
@end verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   742
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   743
Of course, the traces can be combined into a single file as shown above.
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   744
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   745
Finally, you can enable pcap tracing for all devices in the system, with the
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   746
same type as that managed by the device helper.
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   747
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   748
@verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   749
  helper.EnableAsciiAll ("prefix");
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   750
@end verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   751
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   752
This would result in a number of ascii trace files being created, one for
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   753
every device in the system of the type managed by the helper.  All of these
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   754
files will follow the <prefix>-<node id>-<device id>.tr convention.  Combining
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   755
all of the traces into a single file is accomplished similarly to the examples
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   756
above.
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   757
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   758
@subsubsection Ascii Tracing Device Helper Filename Selection
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   759
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   760
Implicit in the prefix-style method descriptions above is the construction of the
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   761
complete filenames by the implementation method.  By convention, ascii traces
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   762
in the @code{ns-3} system are of the form ``<prefix>-<node id>-<device id>.tr''
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   763
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   764
As previously mentioned, every node in the system will have a system-assigned
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   765
node id; and every device will have an interface index (also called a device id)
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   766
relative to its node.  By default, then, an ascii trace file created as a result
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   767
of enabling tracing on the first device of node 21, using the prefix ``prefix'',
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   768
would be ``prefix-21-1.tr''.
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   769
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   770
You can always use the @code{ns-3} object name service to make this more clear.
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   771
For example, if you use the object name service to assign the name ``server''
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   772
to node 21, the resulting ascii trace file name will automatically become,
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   773
``prefix-server-1.tr'' and if you also assign the name ``eth0'' to the 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   774
device, your ascii trace file name will automatically pick this up and be called
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   775
``prefix-server-eth0.tr''.
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   776
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   777
@subsection Pcap Tracing Protocol Helpers
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   778
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   779
The goal of these helpers is to make it easy to add a consistent pcap trace
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   780
facility to protocols.  We want all of the various flavors of pcap tracing to 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   781
work the same across all protocols, so the methods of these helpers are 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   782
inherited by stack helpers.  Take a look at @code{src/helper/trace-helper.h} 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   783
if you want to follow the discussion while looking at real code.
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   784
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   785
In this section we will be illustrating the methods as applied to the protocol
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   786
@code{Ipv4}.  To specify traces in similar protocols, just substitute the
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   787
appropriate type.  For example, use a @code{Ptr<Ipv6>} instead of a
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   788
@code{Ptr<Ipv4>} and call @code{EnablePcapIpv6} instead of @code{EnablePcapIpv4}.
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   789
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   790
The class @code{PcapHelperForIpv4} provides the high level functionality for
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   791
using pcap tracing in the @code{Ipv4} protocol.  Every protocol enabling these
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   792
methods must implement a single virtual method inherited from this class.  There
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   793
will be a separate implementation for @code{Ipv6}, for example, but the only
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   794
difference will be in the method names and signatures.  Different method names
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   795
are required to disambiguate class @code{Ipv4} from @coe{Ipv6} which are both 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   796
derived from class @code{Object}, and methods that share the same signature.
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   797
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   798
@verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   799
  virtual void EnablePcapIpv4Internal (std::string prefix, Ptr<Ipv4> ipv4, uint32_t interface) = 0;
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   800
@end verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   801
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   802
The signature of this method reflects the protocol and interface-centric view 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   803
of the situation at this level.  All of the public methods inherited from class 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   804
@code{PcapHelperForIpv4} reduce to calling this single device-dependent
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   805
implementation method.  For example, the lowest level pcap method,
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   806
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   807
@verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   808
  void EnablePcapIpv4 (std::string prefix, Ptr<Ipv4> ipv4, uint32_t interface);
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   809
@verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   810
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   811
will call the device implementation of @code{EnablePcapIpv4Internal} directly.
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   812
All other public pcap tracing methods build on this implementation to provide 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   813
additional user-level functionality.  What this means to the user is that all 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   814
protocol helpers in the system will have all of the pcap trace methods 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   815
available; and these methods will all work in the same way across 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   816
protocols if the helper implements @code{EnablePcapIpv4Internal} correctly.
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   817
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   818
@subsubsection Pcap Tracing Protocol Helper Methods
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   819
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   820
These methods are designed to be in one-to-one correspondence with the @code{Node}-
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   821
and @code{NetDevice}- centric versions of the device versions.  Instead of
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   822
@code{Node} and @code{NetDevice} pair constraints, we use protocol and interface
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   823
constraints.
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   824
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   825
Note that just like in the device version, there are six methods:
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   826
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   827
@verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   828
  void EnablePcapIpv4 (std::string prefix, Ptr<Ipv4> ipv4, uint32_t interface);
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   829
  void EnablePcapIpv4 (std::string prefix, std::string ipv4Name, uint32_t interface);
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   830
  void EnablePcapIpv4 (std::string prefix, Ipv4InterfaceContainer c);
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   831
  void EnablePcapIpv4 (std::string prefix, NodeContainer n);
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   832
  void EnablePcapIpv4 (std::string prefix, uint32_t nodeid, uint32_t interface);
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   833
  void EnablePcapIpv4All (std::string prefix);
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   834
@end verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   835
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   836
You are encouraged to peruse the Doxygen for class @code{PcapHelperForIpv4}
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   837
to find the details of these methods; but to summarize ...
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   838
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   839
You can enable pcap tracing on a particular protocol/interface pair by providing a
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   840
@code{Ptr<Ipv4>} and @code{interface} to an @code{EnablePcap} method.  For example, 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   841
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   842
@verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   843
  Ptr<Ipv4> ipv4 = node->GetObject<Ipv4> ();
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   844
  ...
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   845
  helper.EnablePcapIpv4 ("prefix", ipv4, 0);
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   846
@end verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   847
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   848
You can enable pcap tracing on a particular node/net-device pair by providing a
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   849
@code{std::string} representing an object name service string to an 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   850
@code{EnablePcap} method.  The @code{Ptr<Ipv4>} is looked up from the name
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   851
string.  For example, 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   852
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   853
@verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   854
  Names::Add ("serverIPv4" ...);
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   855
  ...
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   856
  helper.EnablePcapIpv4 ("prefix", "serverIpv4", 1);
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   857
@end verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   858
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   859
You can enable pcap tracing on a collection of protocol/interface pairs by 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   860
providing an @code{Ipv4InterfaceContainer}.  For each @code{Ipv4} / interface
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   861
pair in the container the protocol type is checked.  For each protocol of the 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   862
proper type (the same type as is managed by the device helper), tracing is 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   863
enabled for the corresponding interface.  For example, 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   864
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   865
@verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   866
  NodeContainer nodes;
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   867
  ...
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   868
  NetDeviceContainer devices = deviceHelper.Install (nodes);
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   869
  ... 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   870
  Ipv4AddressHelper ipv4;
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   871
  ipv4.SetBase ("10.1.1.0", "255.255.255.0");
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   872
  Ipv4InterfaceContainer interfaces = ipv4.Assign (devices);
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   873
  ...
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   874
  helper.EnablePcapIpv4 ("prefix", interfaces);
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   875
@end verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   876
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   877
You can enable pcap tracing on a collection of protocol/interface pairs by 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   878
providing a @code{NodeContainer}.  For each @code{Node} in the @code{NodeContainer}
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   879
the appropriate protocol is found.  For each protocol, its interfaces are 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   880
enumerated and tracing is enabled on the resulting pairs.  For example,
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   881
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   882
@verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   883
  NodeContainer n;
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   884
  ...
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   885
  helper.EnablePcapIpv4 ("prefix", n);
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   886
@end verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   887
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   888
You can enable pcap tracing on the basis of node ID and interface as well.  In
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   889
this case, the node-id is translated to a @code{Ptr{Node} and the appropriate
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   890
protocol is looked up in the node.  The resulting protocol and interface are
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   891
used to specify the resulting trace source.
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   892
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   893
@verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   894
  helper.EnablePcapIpv4 ("prefix", 21, 1);
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   895
@end verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   896
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   897
Finally, you can enable pcap tracing for all interfaces in the system, with
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   898
associated protocol being the same type as that managed by the device helper.
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   899
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   900
@verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   901
  helper.EnablePcapIpv4All ("prefix");
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   902
@end verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   903
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   904
@subsubsection Pcap Tracing Protocol Helper Filename Selection
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   905
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   906
Implicit in all of the method descriptions above is the construction of the
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   907
complete filenames by the implementation method.  By convention, pcap traces
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   908
taken for devices in the @code{ns-3} system are of the form 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   909
``<prefix>-<node id>-<device id>.pcap''.  In the case of protocol traces,
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   910
there is a one-to-one correspondence between protocols and @code{Nodes}.
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   911
This is because protocol @code{Objects} are aggregated to @code{Node Objects}.
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   912
Since there is no global protocol id in the system, we use the corresponding
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   913
node id in file naming.  Threfore there is a possibility for file name 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   914
collisions in automatically chosen trace file names.  For this reason, the
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   915
file name convention is changed for protocol traces.
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   916
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   917
As previously mentioned, every node in the system will have a system-assigned
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   918
node id.  Since there is a one-to-one correspondence between protocol instances
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   919
and node instances we use the node id.  Each interface has an interface id 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   920
relative to its protocol.  We use the convention 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   921
"<prefix>-n<node id>-i<interface id>.pcap" for trace file naming in protocol
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   922
helpers.
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   923
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   924
Therefore, by default, a pcap trace file created as a result of enabling tracing
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   925
on interface 1 of the Ipv4 protocol of node 21 using the prefix ``prefix''
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   926
would be ``prefix-n21-i1.pcap''.
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   927
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   928
You can always use the @code{ns-3} object name service to make this more clear.
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   929
For example, if you use the object name service to assign the name ``serverIpv4''
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   930
to the Ptr<Ipv4> on node 21, the resulting pcap trace file name will 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   931
automatically become, ``prefix-nserverIpv4-i1.pcap''.
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   932
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   933
@subsection Ascii Tracing Protocol Helpers
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   934
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   935
The behavior of the ascii trace helpers is substantially similar to the pcap
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   936
case.  Take a look at @code{src/helper/trace-helper.h} if you want to 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   937
follow the discussion while looking at real code.
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   938
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   939
In this section we will be illustrating the methods as applied to the protocol
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   940
@code{Ipv4}.  To specify traces in similar protocols, just substitute the
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   941
appropriate type.  For example, use a @code{Ptr<Ipv6>} instead of a
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   942
@code{Ptr<Ipv4>} and call @code{EnableAsciiIpv6} instead of @code{EnableAsciiIpv4}.
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   943
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   944
The class @code{PcapAndAsciiHelperForIpv4} adds the high level functionality
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   945
for using ascii tracing to the PcapHelperForIpv4.  Every protocol must 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   946
additionally implement a single virtual method inherited from this class.
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   947
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   948
@verbatim
6051
b988174aa30b OutputStreamObject to OutputStreamKeeper
Craig Dowell <craigdo@ee.washington.edu>
parents: 6031
diff changeset
   949
  virtual void EnableAsciiIpv4Internal (Ptr<OutputStreamKeeper> stream, std::string prefix, 
6031
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   950
                                        Ptr<Ipv4> ipv4, uint32_t interface) = 0;
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   951
@end verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   952
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   953
The signature of this method reflects the protocol- and interface-centric view 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   954
of the situation at this level; and also the fact that the helper may be writing
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   955
to a shared output stream.  All of the public methods inherited from class 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   956
@code{PcapAndAsciiTraceHelperForIpv4} reduce to calling this single device-
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   957
dependent implementation method.  For example, the lowest level ascii trace
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   958
methods,
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   959
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   960
@verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   961
  void EnableAsciiIpv4 (std::string prefix, Ptr<Ipv4> ipv4, uint32_t interface);
6051
b988174aa30b OutputStreamObject to OutputStreamKeeper
Craig Dowell <craigdo@ee.washington.edu>
parents: 6031
diff changeset
   962
  void EnableAsciiIpv4 (Ptr<OutputStreamKeeper> stream, Ptr<Ipv4> ipv4, uint32_t interface);
6031
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   963
@verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   964
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   965
will call the device implementation of @code{EnableAsciiIpv4Internal} directly,
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   966
providing either the prefix or the stream.  All other public ascii tracing 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   967
methods will build on these low-level functions to provide additional user-level
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   968
functionality.  What this means to the user is that all device helpers in the 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   969
system will have all of the ascii trace methods available; and these methods
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   970
will all work in the same way across protocols if the protocols implement 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   971
@code{EnablAsciiIpv4Internal} correctly.
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   972
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   973
@subsubsection Ascii Tracing Device Helper Methods
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   974
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   975
@verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   976
  void EnableAsciiIpv4 (std::string prefix, Ptr<Ipv4> ipv4, uint32_t interface);
6051
b988174aa30b OutputStreamObject to OutputStreamKeeper
Craig Dowell <craigdo@ee.washington.edu>
parents: 6031
diff changeset
   977
  void EnableAsciiIpv4 (Ptr<OutputStreamKeeper> stream, Ptr<Ipv4> ipv4, uint32_t interface);
6031
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   978
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   979
  void EnableAsciiIpv4 (std::string prefix, std::string ipv4Name, uint32_t interface);
6051
b988174aa30b OutputStreamObject to OutputStreamKeeper
Craig Dowell <craigdo@ee.washington.edu>
parents: 6031
diff changeset
   980
  void EnableAsciiIpv4 (Ptr<OutputStreamKeeper> stream, std::string ipv4Name, uint32_t interface);
6031
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   981
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   982
  void EnableAsciiIpv4 (std::string prefix, Ipv4InterfaceContainer c);
6051
b988174aa30b OutputStreamObject to OutputStreamKeeper
Craig Dowell <craigdo@ee.washington.edu>
parents: 6031
diff changeset
   983
  void EnableAsciiIpv4 (Ptr<OutputStreamKeeper> stream, Ipv4InterfaceContainer c);
6031
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   984
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   985
  void EnableAsciiIpv4 (std::string prefix, NodeContainer n);
6051
b988174aa30b OutputStreamObject to OutputStreamKeeper
Craig Dowell <craigdo@ee.washington.edu>
parents: 6031
diff changeset
   986
  void EnableAsciiIpv4 (Ptr<OutputStreamKeeper> stream, NodeContainer n);
6031
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   987
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   988
  void EnableAsciiIpv4 (std::string prefix, uint32_t nodeid, uint32_t deviceid);
6051
b988174aa30b OutputStreamObject to OutputStreamKeeper
Craig Dowell <craigdo@ee.washington.edu>
parents: 6031
diff changeset
   989
  void EnableAsciiIpv4 (Ptr<OutputStreamKeeper> stream, uint32_t nodeid, uint32_t interface);
6031
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   990
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   991
  void EnableAsciiIpv4All (std::string prefix);
6051
b988174aa30b OutputStreamObject to OutputStreamKeeper
Craig Dowell <craigdo@ee.washington.edu>
parents: 6031
diff changeset
   992
  void EnableAsciiIpv4All (Ptr<OutputStreamKeeper> stream);
6031
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   993
@end verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   994
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   995
You are encouraged to peruse the Doxygen for class @code{PcapAndAsciiHelperForIpv4}
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   996
to find the details of these methods; but to summarize ...
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   997
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   998
There are twice as many methods available for ascii tracing as there were for
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
   999
pcap tracing.  This is because, in addition to the pcap-style model where traces
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1000
from each unique protocol/interface pair are written to a unique file, we 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1001
support a model in which trace information for many protocol/interface pairs is 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1002
written to a common file.  This means that the <prefix>-n<node id>-<interface>
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1003
file name generation mechanism is replaced by a mechanism to refer to a common 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1004
file; and the number of API methods is doubled to allow all combinations.
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1005
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1006
Just as in pcap tracing, you can enable ascii tracing on a particular 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1007
protocol/interface pair by providing a @code{Ptr<Ipv4>} and an @code{interface}
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1008
to an @code{EnableAscii} method.
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1009
For example, 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1010
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1011
@verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1012
  Ptr<Ipv4> ipv4;
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1013
  ...
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1014
  helper.EnableAsciiIpv4 ("prefix", ipv4, 1);
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1015
@end verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1016
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1017
In this case, no trace contexts are written to the ascii trace file since they
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1018
would be redundant.  The system will pick the file name to be created using
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1019
the same rules as described in the pcap section, except that the file will
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1020
have the suffix ``.tr'' instead of ``.pcap''.
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1021
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1022
If you want to enable ascii tracing on more than one interface and have all 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1023
traces sent to a single file, you can do that as well by using an object to
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1024
refer to a single file.  We have already something similar to this in the
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1025
``cwnd'' example above:
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1026
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1027
@verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1028
  Ptr<Ipv4> protocol1 = node1->GetObject<Ipv4> ();
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1029
  Ptr<Ipv4> protocol2 = node2->GetObject<Ipv4> ();
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1030
  ...
6051
b988174aa30b OutputStreamObject to OutputStreamKeeper
Craig Dowell <craigdo@ee.washington.edu>
parents: 6031
diff changeset
  1031
  Ptr<OutputStreamKeeper> stream = asciiTraceHelper.CreateFileStream ("trace-file-name.tr");
6031
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1032
  ...
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1033
  helper.EnableAsciiIpv4 (stream, protocol1, 1);
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1034
  helper.EnableAsciiIpv4 (stream, protocol2, 1);
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1035
@verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1036
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1037
In this case, trace contexts are written to the ascii trace file since they
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1038
are required to disambiguate traces from the two interfaces.  Note that since 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1039
the user is completely specifying the file name, the string should include the
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1040
``,tr'' for consistency.
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1041
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1042
You can enable ascii tracing on a particular protocol by providing a 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1043
@code{std::string} representing an object name service string to an 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1044
@code{EnablePcap} method.  The @code{Ptr<Ipv4>} is looked up from the name
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1045
string.  The @code<Node> in the resulting filenames is implicit since there
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1046
is a one-to-one correspondence between protocol instances and nodes,
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1047
For example, 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1048
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1049
@verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1050
  Names::Add ("node1Ipv4" ...);
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1051
  Names::Add ("node2Ipv4" ...);
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1052
  ...
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1053
  helper.EnableAsciiIpv4 ("prefix", "node1Ipv4", 1);
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1054
  helper.EnableAsciiIpv4 ("prefix", "node2Ipv4", 1);
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1055
@end verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1056
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1057
This would result in two files named ``prefix-nnode1Ipv4-i1.tr'' and 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1058
``prefix-nnode2Ipv4-i1.tr'' with traces for each interface in the respective 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1059
trace file.  Since all of the EnableAscii functions are overloaded to take a 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1060
stream object, you can use that form as well:
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1061
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1062
@verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1063
  Names::Add ("node1Ipv4" ...);
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1064
  Names::Add ("node2Ipv4" ...);
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1065
  ...
6051
b988174aa30b OutputStreamObject to OutputStreamKeeper
Craig Dowell <craigdo@ee.washington.edu>
parents: 6031
diff changeset
  1066
  Ptr<OutputStreamKeeper> stream = asciiTraceHelper.CreateFileStream ("trace-file-name.tr");
6031
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1067
  ...
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1068
  helper.EnableAsciiIpv4 (stream, "node1Ipv4", 1);
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1069
  helper.EnableAsciiIpv4 (stream, "node2Ipv4", 1);
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1070
@end verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1071
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1072
This would result in a single trace file called ``trace-file-name.tr'' that 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1073
contains all of the trace events for both interfaces.  The events would be 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1074
disambiguated by trace context strings.
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1075
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1076
You can enable ascii tracing on a collection of protocol/interface pairs by 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1077
providing an @code{Ipv4InterfaceContainer}.  For each protocol of the proper 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1078
type (the same type as is managed by the device helper), tracing is enabled
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1079
for the corresponding interface.  Again, the @code<Node> is implicit since 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1080
there is a one-to-one correspondence between each protocol and its node.
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1081
For example, 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1082
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1083
@verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1084
  NodeContainer nodes;
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1085
  ...
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1086
  NetDeviceContainer devices = deviceHelper.Install (nodes);
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1087
  ... 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1088
  Ipv4AddressHelper ipv4;
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1089
  ipv4.SetBase ("10.1.1.0", "255.255.255.0");
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1090
  Ipv4InterfaceContainer interfaces = ipv4.Assign (devices);
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1091
  ...
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1092
  ...
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1093
  helper.EnableAsciiIpv4 ("prefix", interfaces);
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1094
@end verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1095
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1096
This would result in a number of ascii trace files being created, each of which
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1097
follows the <prefix>-n<node id>-i<interface>.tr convention.  Combining all of the
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1098
traces into a single file is accomplished similarly to the examples above:
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1099
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1100
@verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1101
  NodeContainer nodes;
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1102
  ...
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1103
  NetDeviceContainer devices = deviceHelper.Install (nodes);
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1104
  ... 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1105
  Ipv4AddressHelper ipv4;
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1106
  ipv4.SetBase ("10.1.1.0", "255.255.255.0");
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1107
  Ipv4InterfaceContainer interfaces = ipv4.Assign (devices);
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1108
  ...
6051
b988174aa30b OutputStreamObject to OutputStreamKeeper
Craig Dowell <craigdo@ee.washington.edu>
parents: 6031
diff changeset
  1109
  Ptr<OutputStreamKeeper> stream = asciiTraceHelper.CreateFileStream ("trace-file-name.tr");
6031
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1110
  ...
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1111
  helper.EnableAsciiIpv4 (stream, interfaces);
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1112
@end verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1113
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1114
You can enable ascii tracing on a collection of protocol/interface pairs by 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1115
providing a @code{NodeContainer}.  For each @code{Node} in the @code{NodeContainer}
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1116
the appropriate protocol is found.  For each protocol, its interfaces are 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1117
enumerated and tracing is enabled on the resulting pairs.  For example,
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1118
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1119
@verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1120
  NodeContainer n;
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1121
  ...
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1122
  helper.EnableAsciiIpv4 ("prefix", n);
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1123
@end verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1124
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1125
This would result in a number of ascii trace files being created, each of which
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1126
follows the <prefix>-<node id>-<device id>.tr convention.  Combining all of the
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1127
traces into a single file is accomplished similarly to the examples above:
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1128
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1129
You can enable pcap tracing on the basis of node ID and device ID as well.  In
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1130
this case, the node-id is translated to a @code{Ptr{Node} and the appropriate
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1131
protocol is looked up in the node.  The resulting protocol and interface are
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1132
used to specify the resulting trace source.
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1133
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1134
@verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1135
  helper.EnableAsciiIpv4 ("prefix", 21, 1);
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1136
@end verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1137
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1138
Of course, the traces can be combined into a single file as shown above.
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1139
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1140
Finally, you can enable ascii tracing for all interfaces in the system, with
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1141
associated protocol being the same type as that managed by the device helper.
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1142
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1143
@verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1144
  helper.EnableAsciiIpv4All ("prefix");
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1145
@end verbatim
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1146
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1147
This would result in a number of ascii trace files being created, one for
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1148
every interface in the system related to a protocol of the type managed by the
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1149
helper.  All of these files will follow the <prefix>-n<node id>-i<interface.tr
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1150
convention.  Combining all of the traces into a single file is accomplished 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1151
similarly to the examples above.
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1152
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1153
@subsubsection Ascii Tracing Device Helper Filename Selection
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1154
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1155
Implicit in the prefix-style method descriptions above is the construction of the
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1156
complete filenames by the implementation method.  By convention, ascii traces
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1157
in the @code{ns-3} system are of the form ``<prefix>-<node id>-<device id>.tr''
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1158
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1159
As previously mentioned, every node in the system will have a system-assigned
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1160
node id.  Since there is a one-to-one correspondence between protocols and nodes
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1161
we use to node-id to identify the protocol identity.  Every interface on a 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1162
given rotocol will have an interface index (also called simply an interface) 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1163
relative to its protocol.  By default, then, an ascii trace file created as a result
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1164
of enabling tracing on the first device of node 21, using the prefix ``prefix'',
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1165
would be ``prefix-n21-i1.tr''.  Use the prefix to disambiguate multiple protocols
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1166
per node.
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1167
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1168
You can always use the @code{ns-3} object name service to make this more clear.
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1169
For example, if you use the object name service to assign the name ``serverIpv4''
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1170
to the protocol on node 21, and also specify interface one, the resulting ascii 
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1171
trace file name will automatically become, ``prefix-nserverIpv4-1.tr''.
18776ed87c60 manual update
Craig Dowell <craigdo@ee.washington.edu>
parents: 5431
diff changeset
  1172
5426
7b36d173c490 Manual organization
Tom Henderson <tomh@tomh.org>
parents: 5231
diff changeset
  1173
@node Tracing implementation details
5188
799fdd8fc54a add some words about tracing to the manual
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1174
@section Implementation details