doc/tutorial/source/data-collection.rst
author Tom Henderson <tomh@tomh.org>
Tue, 15 Sep 2015 12:13:38 -0700
changeset 11670 61dae169dc6a
parent 11244 2a117115b91f
permissions -rw-r--r--
update version numbers in tutorial
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10186
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     1
.. include:: replace.txt
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     2
.. highlight:: cpp
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     3
.. role:: raw-role(raw)
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     4
   :format: html latex
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     5
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     6
Data Collection
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     7
---------------
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     8
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     9
Our final tutorial chapter introduces some components that were added
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    10
to |ns3| in version 3.18, and that are still under development.  This
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    11
tutorial section is also a work-in-progress.
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    12
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    13
Motivation
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    14
**********
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    15
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    16
One of the main points of running simulations is to generate output data, 
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    17
either for research purposes or simply to learn about the system.
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    18
In the previous chapter, we introduced the tracing subsystem and
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    19
the example ``sixth.cc``. from which PCAP or ASCII trace files are 
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    20
generated.  These traces are valuable for data analysis using a
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    21
variety of external tools, and for many users, such output data is
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    22
a preferred means of gathering data (for analysis by external tools).
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    23
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    24
However, there are also use cases for more than trace file generation,
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    25
including the following:
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    26
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    27
* generation of data that does not map well to PCAP or ASCII traces, such
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    28
  as non-packet data (e.g. protocol state machine transitions),
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    29
* large simulations for which the disk I/O requirements for generating
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    30
  trace files is prohibitive or cumbersome, and
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    31
* the need for *online*  data reduction or computation, during the course
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    32
  of the simulation.  A good example of this is to define a termination
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    33
  condition for the simulation, to tell it when to stop when it has 
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    34
  received enough data to form a narrow-enough confidence interval around
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    35
  the estimate of some parameter.
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    36
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    37
The |ns3| data collection framework is designed to provide these
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    38
additional capabilities beyond trace-based output.  We recommend
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    39
that the reader interested in this topic consult the |ns3| Manual
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    40
for a more detailed treatment of this framework; here, we summarize
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    41
with an example program some of the developing capabilities. 
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    42
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    43
Example Code
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    44
************
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    45
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    46
The tutorial example ``examples/tutorial/seventh.cc`` resembles the
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    47
``sixth.cc`` example we previously reviewed, except for a few changes.
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    48
First, it has been enabled for IPv6 support with a command-line option:
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    49
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    50
::   
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    51
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    52
  CommandLine cmd;
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    53
  cmd.AddValue ("useIpv6", "Use Ipv6", useV6);
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    54
  cmd.Parse (argc, argv);
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    55
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    56
If the user specifies ``useIpv6``, option, the program will be run
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    57
using IPv6 instead of IPv4.  The ``help`` option, available on all |ns3| 
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    58
programs that support the CommandLine object as shown above, can
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    59
be invoked as follows (please note the use of double quotes):
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    60
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    61
::
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    62
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    63
  ./waf --run "seventh --help"
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    64
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    65
which produces:
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    66
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    67
::
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    68
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    69
  ns3-dev-seventh-debug [Program Arguments] [General Arguments]
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    70
  
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    71
  Program Arguments:
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    72
      --useIpv6:  Use Ipv6 [false]
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    73
  
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    74
  General Arguments:
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    75
      --PrintGlobals:              Print the list of globals.
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    76
      --PrintGroups:               Print the list of groups.
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    77
      --PrintGroup=[group]:        Print all TypeIds of group.
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    78
      --PrintTypeIds:              Print all TypeIds.
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    79
      --PrintAttributes=[typeid]:  Print all attributes of typeid.
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    80
      --PrintHelp:                 Print this help message.
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    81
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    82
This default (use of IPv4, since useIpv6 is false) can be changed by 
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    83
toggling the boolean value as follows:
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    84
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    85
::
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    86
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    87
  ./waf --run "seventh --useIpv6=1"
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    88
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    89
and have a look at the pcap generated, such as with ``tcpdump``:
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    90
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    91
::
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    92
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    93
  tcpdump -r seventh.pcap -nn -tt
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    94
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    95
This has been a short digression into IPv6 support and the command line,
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    96
which was also introduced earlier in this tutorial.  For a dedicated 
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    97
example of command line usage, please see 
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    98
``src/core/examples/command-line-example.cc``.
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    99
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   100
Now back to data collection.  In the ``examples/tutorial/`` directory, 
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   101
type the following command: ``diff -u sixth.cc seventh.cc``, and examine
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   102
some of the new lines of this diff:
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   103
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   104
::
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   105
11027
e943837b17ad bug 1997: fix PlotProbe() documentation and usage for GnuplotHelper and FileHelper
Tom Henderson <tomh@tomh.org>
parents: 10186
diff changeset
   106
  +  std::string probeType;
e943837b17ad bug 1997: fix PlotProbe() documentation and usage for GnuplotHelper and FileHelper
Tom Henderson <tomh@tomh.org>
parents: 10186
diff changeset
   107
  +  std::string tracePath;
10186
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   108
  +  if (useV6 == false)
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   109
  +    {
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   110
     ...
11027
e943837b17ad bug 1997: fix PlotProbe() documentation and usage for GnuplotHelper and FileHelper
Tom Henderson <tomh@tomh.org>
parents: 10186
diff changeset
   111
  +      probeType = "ns3::Ipv4PacketProbe";
e943837b17ad bug 1997: fix PlotProbe() documentation and usage for GnuplotHelper and FileHelper
Tom Henderson <tomh@tomh.org>
parents: 10186
diff changeset
   112
  +      tracePath = "/NodeList/*/$ns3::Ipv4L3Protocol/Tx";
10186
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   113
  +    }
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   114
  +  else
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   115
  +    {
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   116
     ...
11027
e943837b17ad bug 1997: fix PlotProbe() documentation and usage for GnuplotHelper and FileHelper
Tom Henderson <tomh@tomh.org>
parents: 10186
diff changeset
   117
  +      probeType = "ns3::Ipv6PacketProbe";
e943837b17ad bug 1997: fix PlotProbe() documentation and usage for GnuplotHelper and FileHelper
Tom Henderson <tomh@tomh.org>
parents: 10186
diff changeset
   118
  +      tracePath = "/NodeList/*/$ns3::Ipv6L3Protocol/Tx";
10186
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   119
  +    }
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   120
   ...
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   121
  +   // Use GnuplotHelper to plot the packet byte count over time
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   122
  +   GnuplotHelper plotHelper;
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   123
  + 
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   124
  +   // Configure the plot.  The first argument is the file name prefix
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   125
  +   // for the output files generated.  The second, third, and fourth
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   126
  +   // arguments are, respectively, the plot title, x-axis, and y-axis labels
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   127
  +   plotHelper.ConfigurePlot ("seventh-packet-byte-count",
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   128
  +                             "Packet Byte Count vs. Time",
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   129
  +                             "Time (Seconds)",
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   130
  +                             "Packet Byte Count");
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   131
  + 
11027
e943837b17ad bug 1997: fix PlotProbe() documentation and usage for GnuplotHelper and FileHelper
Tom Henderson <tomh@tomh.org>
parents: 10186
diff changeset
   132
  +   // Specify the probe type, trace source path (in configuration namespace), and
10186
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   133
  +   // probe output trace source ("OutputBytes") to plot.  The fourth argument
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   134
  +   // specifies the name of the data series label on the plot.  The last
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   135
  +   // argument formats the plot by specifying where the key should be placed.
11027
e943837b17ad bug 1997: fix PlotProbe() documentation and usage for GnuplotHelper and FileHelper
Tom Henderson <tomh@tomh.org>
parents: 10186
diff changeset
   136
  +   plotHelper.PlotProbe (probeType,
e943837b17ad bug 1997: fix PlotProbe() documentation and usage for GnuplotHelper and FileHelper
Tom Henderson <tomh@tomh.org>
parents: 10186
diff changeset
   137
  +                         tracePath,
10186
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   138
  +                         "OutputBytes",
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   139
  +                         "Packet Byte Count",
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   140
  +                         GnuplotAggregator::KEY_BELOW);
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   141
  + 
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   142
  +   // Use FileHelper to write out the packet byte count over time
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   143
  +   FileHelper fileHelper;
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   144
  + 
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   145
  +   // Configure the file to be written, and the formatting of output data.
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   146
  +   fileHelper.ConfigureFile ("seventh-packet-byte-count",
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   147
  +                             FileAggregator::FORMATTED);
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   148
  + 
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   149
  +   // Set the labels for this formatted output file.
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   150
  +   fileHelper.Set2dFormat ("Time (Seconds) = %.3e\tPacket Byte Count = %.0f");
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   151
  + 
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   152
  +   // Specify the probe type, probe path (in configuration namespace), and
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   153
  +   // probe output trace source ("OutputBytes") to write.
11027
e943837b17ad bug 1997: fix PlotProbe() documentation and usage for GnuplotHelper and FileHelper
Tom Henderson <tomh@tomh.org>
parents: 10186
diff changeset
   154
  +   fileHelper.WriteProbe (probeType,
e943837b17ad bug 1997: fix PlotProbe() documentation and usage for GnuplotHelper and FileHelper
Tom Henderson <tomh@tomh.org>
parents: 10186
diff changeset
   155
  +                          tracePath,
10186
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   156
  +                          "OutputBytes");
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   157
  + 
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   158
      Simulator::Stop (Seconds (20));
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   159
      Simulator::Run ();
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   160
      Simulator::Destroy ();
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   161
  
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   162
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   163
The careful reader will have noticed, when testing the IPv6 command
11027
e943837b17ad bug 1997: fix PlotProbe() documentation and usage for GnuplotHelper and FileHelper
Tom Henderson <tomh@tomh.org>
parents: 10186
diff changeset
   164
line attribute above, that ``seventh.cc`` had created a number of new output files:
10186
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   165
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   166
::
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   167
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   168
  seventh-packet-byte-count-0.txt
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   169
  seventh-packet-byte-count-1.txt
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   170
  seventh-packet-byte-count.dat
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   171
  seventh-packet-byte-count.plt
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   172
  seventh-packet-byte-count.png
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   173
  seventh-packet-byte-count.sh
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   174
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   175
These were created by the additional statements introduced above; in
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   176
particular, by a GnuplotHelper and a FileHelper.  This data was produced
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   177
by hooking the data collection components to |ns3| trace sources, and
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   178
marshaling the data into a formatted ``gnuplot`` and into a formatted
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   179
text file.  In the next sections, we'll review each of these.
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   180
11088
50e89dc6d8b1 [Sphinx] Update the Tracing chapter in the Tutorial.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 11028
diff changeset
   181
.. _GnuPlotHelper:
50e89dc6d8b1 [Sphinx] Update the Tracing chapter in the Tutorial.
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 11028
diff changeset
   182
10186
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   183
GnuplotHelper
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   184
*************
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   185
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   186
The GnuplotHelper is an |ns3| helper object aimed at the production of
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   187
``gnuplot`` plots with as few statements as possible, for common cases.
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   188
It hooks |ns3| trace sources with data types supported by the 
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   189
data collection system.  Not all |ns3| trace sources data types are 
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   190
supported, but many of the common trace types are, including TracedValues 
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   191
with plain old data (POD) types.
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   192
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   193
Let's look at the output produced by this helper:
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   194
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   195
::
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   196
  
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   197
  seventh-packet-byte-count.dat
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   198
  seventh-packet-byte-count.plt
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   199
  seventh-packet-byte-count.sh
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   200
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   201
The first is a gnuplot data file with a series of space-delimited 
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   202
timestamps and packet byte counts.  We'll cover how this particular
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   203
data output was configured below, but let's continue with the output
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   204
files.  The file ``seventh-packet-byte-count.plt`` is a gnuplot plot file,
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   205
that can be opened from within gnuplot.  Readers who understand gnuplot
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   206
syntax can see that this will produce a formatted output PNG file named
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   207
``seventh-packet-byte-count.png``.   Finally, a small shell script
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   208
``seventh-packet-byte-count.sh`` runs this plot file through gnuplot
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   209
to produce the desired PNG (which can be viewed in an image editor); that
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   210
is, the command:
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   211
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   212
:: 
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   213
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   214
  sh seventh-packet-byte-count.sh
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   215
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   216
will yield ``seventh-packet-byte-count.png``.  Why wasn't this PNG
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   217
produced in the first place?  The answer is that by providing the 
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   218
plt file, the user can hand-configure the result if desired, before
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   219
producing the PNG.
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   220
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   221
The PNG image title states that this plot is a plot of 
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   222
"Packet Byte Count vs. Time", and that it is plotting the probed data
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   223
corresponding to the trace source path:
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   224
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   225
::
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   226
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   227
  /NodeList/*/$ns3::Ipv6L3Protocol/Tx
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   228
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   229
Note the wild-card in the trace path.  In summary, what this plot is 
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   230
capturing is the plot of packet bytes observed at the transmit trace
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   231
source of the Ipv6L3Protocol object; largely 596-byte TCP segments
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   232
in one direction, and 60-byte TCP acks in the other (two node
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   233
trace sources were matched by this trace source).
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   234
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   235
How was this configured?  A few statements need to be provided.  First,
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   236
the GnuplotHelper object must be declared and configured:
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   237
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   238
::
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   239
  
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   240
  +  // Use GnuplotHelper to plot the packet byte count over time
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   241
  +  GnuplotHelper plotHelper;
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   242
  +
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   243
  +  // Configure the plot.  The first argument is the file name prefix
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   244
  +  // for the output files generated.  The second, third, and fourth
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   245
  +  // arguments are, respectively, the plot title, x-axis, and y-axis labels
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   246
  +  plotHelper.ConfigurePlot ("seventh-packet-byte-count",
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   247
  +                            "Packet Byte Count vs. Time",
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   248
  +                            "Time (Seconds)",
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   249
  +                            "Packet Byte Count");
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   250
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   251
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   252
To this point, an empty plot has been configured.  The filename prefix
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   253
is the first argument, the plot title is the second, the x-axis label
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   254
the third, and the y-axis label the fourth argument.
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   255
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   256
The next step is to configure the data, and here is where the trace
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   257
source is hooked.  First, note above in the program we declared a few 
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   258
variables for later use:
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   259
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   260
::
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   261
11027
e943837b17ad bug 1997: fix PlotProbe() documentation and usage for GnuplotHelper and FileHelper
Tom Henderson <tomh@tomh.org>
parents: 10186
diff changeset
   262
  +  std::string probeType;
e943837b17ad bug 1997: fix PlotProbe() documentation and usage for GnuplotHelper and FileHelper
Tom Henderson <tomh@tomh.org>
parents: 10186
diff changeset
   263
  +  std::string tracePath;
e943837b17ad bug 1997: fix PlotProbe() documentation and usage for GnuplotHelper and FileHelper
Tom Henderson <tomh@tomh.org>
parents: 10186
diff changeset
   264
  +  probeType = "ns3::Ipv6PacketProbe";
e943837b17ad bug 1997: fix PlotProbe() documentation and usage for GnuplotHelper and FileHelper
Tom Henderson <tomh@tomh.org>
parents: 10186
diff changeset
   265
  +  tracePath = "/NodeList/*/$ns3::Ipv6L3Protocol/Tx";
10186
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   266
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   267
We use them here:
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   268
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   269
::
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   270
   
11027
e943837b17ad bug 1997: fix PlotProbe() documentation and usage for GnuplotHelper and FileHelper
Tom Henderson <tomh@tomh.org>
parents: 10186
diff changeset
   271
  +  // Specify the probe type, trace source path (in configuration namespace), and
10186
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   272
  +  // probe output trace source ("OutputBytes") to plot.  The fourth argument
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   273
  +  // specifies the name of the data series label on the plot.  The last
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   274
  +  // argument formats the plot by specifying where the key should be placed.
11027
e943837b17ad bug 1997: fix PlotProbe() documentation and usage for GnuplotHelper and FileHelper
Tom Henderson <tomh@tomh.org>
parents: 10186
diff changeset
   275
  +  plotHelper.PlotProbe (probeType,
e943837b17ad bug 1997: fix PlotProbe() documentation and usage for GnuplotHelper and FileHelper
Tom Henderson <tomh@tomh.org>
parents: 10186
diff changeset
   276
  +                        tracePath,
10186
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   277
  +                        "OutputBytes",
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   278
  +                        "Packet Byte Count",
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   279
  +                        GnuplotAggregator::KEY_BELOW);
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   280
11027
e943837b17ad bug 1997: fix PlotProbe() documentation and usage for GnuplotHelper and FileHelper
Tom Henderson <tomh@tomh.org>
parents: 10186
diff changeset
   281
The first two arguments are the name of the probe type and the trace source path.
10186
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   282
These two are probably the hardest to determine when you try to use
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   283
this framework to plot other traces.  The probe trace here is the ``Tx``
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   284
trace source of class ``Ipv6L3Protocol``.  When we examine this class
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   285
implementation (``src/internet/model/ipv6-l3-protocol.cc``) we can
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   286
observe:
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   287
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   288
::
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   289
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   290
    .AddTraceSource ("Tx", "Send IPv6 packet to outgoing interface.",
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   291
                     MakeTraceSourceAccessor (&Ipv6L3Protocol::m_txTrace))
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   292
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   293
This says that ``Tx`` is a name for variable ``m_txTrace``, which has
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   294
a declaration of:
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   295
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   296
::
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   297
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   298
  /**
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   299
   * \brief Callback to trace TX (transmission) packets.
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   300
   */
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   301
  TracedCallback<Ptr<const Packet>, Ptr<Ipv6>, uint32_t> m_txTrace;
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   302
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   303
It turns out that this specific trace source signature is supported
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   304
by a Probe class (what we need here) of class Ipv6PacketProbe.
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   305
See the files ``src/internet/model/ipv6-packet-probe.{h,cc}``.
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   306
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   307
So, in the PlotProbe statement above, we see that the statement is
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   308
hooking the trace source (identified by path string) with a matching
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   309
|ns3| Probe type of ``Ipv6PacketProbe``.  If we did not support
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   310
this probe type (matching trace source signature), we could have not
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   311
used this statement (although some more complicated lower-level statements
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   312
could have been used, as described in the manual).
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   313
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   314
The Ipv6PacketProbe exports, itself, some trace sources that extract
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   315
the data out of the probed Packet object:
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   316
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   317
::
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   318
  
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   319
  TypeId
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   320
  Ipv6PacketProbe::GetTypeId ()
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   321
  {
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   322
    static TypeId tid = TypeId ("ns3::Ipv6PacketProbe")
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   323
      .SetParent<Probe> ()
11244
2a117115b91f update tutorial documentation for SetGroupName
Tom Henderson <tomh@tomh.org>
parents: 11088
diff changeset
   324
      .SetGroupName ("Stats")
10186
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   325
      .AddConstructor<Ipv6PacketProbe> ()
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   326
      .AddTraceSource ( "Output",
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   327
                        "The packet plus its IPv6 object and interface that serve as the output for this probe",
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   328
                        MakeTraceSourceAccessor (&Ipv6PacketProbe::m_output))
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   329
      .AddTraceSource ( "OutputBytes",
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   330
                        "The number of bytes in the packet",
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   331
                        MakeTraceSourceAccessor (&Ipv6PacketProbe::m_outputBytes))
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   332
    ;
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   333
    return tid;
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   334
  }
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   335
  
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   336
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   337
The third argument of our PlotProbe statement specifies that we are
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   338
interested in the number of bytes in this packet; specifically, the
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   339
"OutputBytes" trace source of Ipv6PacketProbe.
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   340
Finally, the last two arguments of the statement provide the plot
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   341
legend for this data series ("Packet Byte Count"), and an optional
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   342
gnuplot formatting statement (GnuplotAggregator::KEY_BELOW) that we want 
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   343
the plot key to be inserted below the plot.  Other options include
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   344
NO_KEY, KEY_INSIDE, and KEY_ABOVE.
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   345
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   346
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   347
Supported Trace Types
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   348
*********************
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   349
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   350
The following traced values are supported with Probes as of this writing:
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   351
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   352
  +------------------+-------------------+------------------------------------+
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   353
  | TracedValue type |   Probe type      |  File                              |
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   354
  +==================+=========+=========+====================================+
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   355
  | double           | DoubleProbe       | stats/model/double-probe.h         |
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   356
  +------------------+-------------------+------------------------------------+
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   357
  | uint8_t          | Uinteger8Probe    | stats/model/uinteger-8-probe.h     |
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   358
  +------------------+-------------------+------------------------------------+
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   359
  | uint16_t         | Uinteger16Probe   | stats/model/uinteger-16-probe.h    |
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   360
  +------------------+-------------------+------------------------------------+
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   361
  | uint32_t         | Uinteger32Probe   | stats/model/uinteger-32-probe.h    |
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   362
  +------------------+-------------------+------------------------------------+
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   363
  | bool             | BooleanProbe      | stats/model/uinteger-16-probe.h    |
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   364
  +------------------+-------------------+------------------------------------+
11028
abeb2185bce5 add TimeProbe class to data collection framework
Tom Henderson <tomh@tomh.org>
parents: 11027
diff changeset
   365
  | ns3::Time        | TimeProbe         | stats/model/time-probe.h           |
abeb2185bce5 add TimeProbe class to data collection framework
Tom Henderson <tomh@tomh.org>
parents: 11027
diff changeset
   366
  +------------------+-------------------+------------------------------------+
10186
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   367
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   368
The following TraceSource types are supported by Probes as of this writing:
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   369
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   370
  +------------------------------------------+------------------------+---------------+----------------------------------------------------+
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   371
  | TracedSource type                        |   Probe type           | Probe outputs |  File                                              |
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   372
  +==========================================+========================+===============+====================================================+
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   373
  | Ptr<const Packet>                        | PacketProbe            | OutputBytes   | network/utils/packet-probe.h                       |
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   374
  +------------------------------------------+------------------------+---------------+----------------------------------------------------+
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   375
  | Ptr<const Packet>, Ptr<Ipv4>, uint32_t   | Ipv4PacketProbe        | OutputBytes   | internet/model/ipv4-packet-probe.h                 |
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   376
  +------------------------------------------+------------------------+---------------+----------------------------------------------------+
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   377
  | Ptr<const Packet>, Ptr<Ipv6>, uint32_t   | Ipv6PacketProbe        | OutputBytes   | internet/model/ipv6-packet-probe.h                 |
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   378
  +------------------------------------------+------------------------+---------------+----------------------------------------------------+
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   379
  | Ptr<const Packet>, Ptr<Ipv6>, uint32_t   | Ipv6PacketProbe        | OutputBytes   | internet/model/ipv6-packet-probe.h                 |
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   380
  +------------------------------------------+------------------------+---------------+----------------------------------------------------+
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   381
  | Ptr<const Packet>, const Address&        | ApplicationPacketProbe | OutputBytes   | applications/model/application-packet-probe.h      |
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   382
  +------------------------------------------+------------------------+---------------+----------------------------------------------------+
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   383
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   384
As can be seen, only a few trace sources are supported, and they are all 
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   385
oriented towards outputting the Packet size (in bytes).  However,
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   386
most of the fundamental data types available as TracedValues can be
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   387
supported with these helpers.
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   388
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   389
FileHelper
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   390
**********
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   391
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   392
The FileHelper class is just a variation of the previous GnuplotHelper
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   393
example.  The example program provides formatted output of the
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   394
same timestamped data, such as follows:
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   395
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   396
::
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   397
  
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   398
  Time (Seconds) = 9.312e+00	Packet Byte Count = 596
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   399
  Time (Seconds) = 9.312e+00	Packet Byte Count = 564
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   400
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   401
Two files are provided, one for node "0" and one for node "1" as can
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   402
be seen in the filenames.  Let's look at the code piece-by-piece:
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   403
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   404
::
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   405
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   406
  +   // Use FileHelper to write out the packet byte count over time
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   407
  +   FileHelper fileHelper;
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   408
  + 
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   409
  +   // Configure the file to be written, and the formatting of output data.
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   410
  +   fileHelper.ConfigureFile ("seventh-packet-byte-count",
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   411
  +                             FileAggregator::FORMATTED);
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   412
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   413
The file helper file prefix is the first argument, and a format specifier
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   414
is next.
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   415
Some other options for formatting include SPACE_SEPARATED, COMMA_SEPARATED,
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   416
and TAB_SEPARATED.  Users are able to change the formatting (if
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   417
FORMATTED is specified) with a format string such as follows:  
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   418
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   419
::
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   420
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   421
  + 
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   422
  +   // Set the labels for this formatted output file.
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   423
  +   fileHelper.Set2dFormat ("Time (Seconds) = %.3e\tPacket Byte Count = %.0f");
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   424
11027
e943837b17ad bug 1997: fix PlotProbe() documentation and usage for GnuplotHelper and FileHelper
Tom Henderson <tomh@tomh.org>
parents: 10186
diff changeset
   425
Finally, the trace source of interest must be hooked.  Again, the probeType and
e943837b17ad bug 1997: fix PlotProbe() documentation and usage for GnuplotHelper and FileHelper
Tom Henderson <tomh@tomh.org>
parents: 10186
diff changeset
   426
tracePath variables in this example are used, and the probe's output
10186
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   427
trace source "OutputBytes" is hooked:
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   428
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   429
::
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   430
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   431
  + 
11027
e943837b17ad bug 1997: fix PlotProbe() documentation and usage for GnuplotHelper and FileHelper
Tom Henderson <tomh@tomh.org>
parents: 10186
diff changeset
   432
  +   // Specify the probe type, trace source path (in configuration namespace), and
10186
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   433
  +   // probe output trace source ("OutputBytes") to write.
11027
e943837b17ad bug 1997: fix PlotProbe() documentation and usage for GnuplotHelper and FileHelper
Tom Henderson <tomh@tomh.org>
parents: 10186
diff changeset
   434
  +   fileHelper.WriteProbe (probeType,
e943837b17ad bug 1997: fix PlotProbe() documentation and usage for GnuplotHelper and FileHelper
Tom Henderson <tomh@tomh.org>
parents: 10186
diff changeset
   435
  +                          tracePath,
10186
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   436
  +                          "OutputBytes");
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   437
  + 
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   438
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   439
The wildcard fields in this trace source specifier match two trace sources.
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   440
Unlike the GnuplotHelper example, in which two data series were overlaid
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   441
on the same plot, here, two separate files are written to disk. 
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   442
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   443
Summary
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   444
*******
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   445
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   446
Data collection support is new as of ns-3.18, and basic support for
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   447
providing time series output has been added.  The basic pattern described
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   448
above may be replicated within the scope of support of the existing
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   449
probes and trace sources.  More capabilities including statistics
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   450
processing will be added in future releases. 
cfbc9491d7e7 add data collection chapter to the tutorial
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   451