src/stats/doc/data-collection-helpers.rst
author Tom Henderson <tomh@tomh.org>
Wed, 15 Oct 2014 07:00:24 -0700
changeset 11027 e943837b17ad
parent 10408 5c604e8ec2e1
child 11028 abeb2185bce5
permissions -rw-r--r--
bug 1997: fix PlotProbe() documentation and usage for GnuplotHelper and FileHelper
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10120
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     1
.. include:: replace.txt
10408
5c604e8ec2e1 Models source highlighting
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10120
diff changeset
     2
.. highlight:: cpp
10120
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     3
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     4
.. heading hierarchy:
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     5
   ************* Section (#.#)
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     6
   ============= Subsection (#.#.#)
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     7
   ############# Paragraph (no number)
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     8
   ~~~~~~~~~~~~~ Sub-paragraph (no number)
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     9
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    10
Data Collection Helpers
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    11
***********************
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    12
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    13
The full flexibility of the data collection framework is provided by
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    14
the interconnection of probes, collectors, and aggregators.  Performing
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    15
all of these interconnections leads to many configuration statements
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    16
in user programs.  For ease of use, some of the most common operations
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    17
can be combined and encapsulated in helper functions.  In addition,
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    18
some statements involving |ns3| trace sources do not have Python
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    19
bindings, due to limitations in the bindings.
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    20
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    21
Data Collection Helpers Overview
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    22
================================
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    23
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    24
In this section, we provide an overview of some helper classes that
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    25
have been created to ease the configuration of the data collection
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    26
framework for some common use cases.  The helpers allow users to form
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    27
common operations with only a few statements in their C++ or Python
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    28
programs.  But, this ease of use comes at the cost of significantly
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    29
less flexibility than low-level configuration can provide, and the
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    30
need to explicitly code support for new Probe types into the helpers
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    31
(to work around an issue described below). 
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    32
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    33
The emphasis on the current helpers is to marshal data out of |ns3|
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    34
trace sources into gnuplot plots or text files, without a high degree
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    35
of output customization or statistical processing (initially).  Also,
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    36
the use is constrained to the available probe types in |ns3|.  Later
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    37
sections of this documentation will go into more detail about creating
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    38
new Probe types, as well as details about hooking together Probes,
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    39
Collectors, and Aggregators in custom arrangements.
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    40
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    41
To date, two Data Collection helpers have been implemented:
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    42
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    43
- GnuplotHelper
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    44
- FileHelper
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    45
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    46
GnuplotHelper
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    47
=============
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    48
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    49
The GnuplotHelper is a helper class for producing output files used to
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    50
make gnuplots.  The overall goal is to provide the ability for users
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    51
to quickly make plots from data exported in |ns3| trace sources.  By
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    52
default, a minimal amount of data transformation is performed; the
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    53
objective is to generate plots with as few (default) configuration
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    54
statements as possible.
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    55
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    56
GnuplotHelper Overview
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    57
######################
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    58
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    59
The GnuplotHelper will create 3 different files at the end of the
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    60
simulation:
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    61
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    62
- A space separated gnuplot data file
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    63
- A gnuplot control file
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    64
- A shell script to generate the gnuplot
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    65
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    66
There are two configuration statements that are needed to produce plots.
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    67
The first statement configures the plot (filename, title, legends, and 
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    68
output type, where the output type defaults to PNG if unspecified):
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    69
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    70
::
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    71
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    72
   void ConfigurePlot (const std::string &outputFileNameWithoutExtension,
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    73
                       const std::string &title,
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    74
                       const std::string &xLegend,
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    75
                       const std::string &yLegend,
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    76
                       const std::string &terminalType = ".png");
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    77
11027
e943837b17ad bug 1997: fix PlotProbe() documentation and usage for GnuplotHelper and FileHelper
Tom Henderson <tomh@tomh.org>
parents: 10408
diff changeset
    78
The second statement hooks the trace source of interest:
10120
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    79
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    80
::
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    81
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    82
   void PlotProbe (const std::string &typeId,
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    83
                   const std::string &path,
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    84
                   const std::string &probeTraceSource,
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    85
                   const std::string &title);
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    86
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    87
The arguments are as follows:
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    88
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    89
* typeId:  The |ns3| TypeId of the Probe
11027
e943837b17ad bug 1997: fix PlotProbe() documentation and usage for GnuplotHelper and FileHelper
Tom Henderson <tomh@tomh.org>
parents: 10408
diff changeset
    90
* path:  The path in the |ns3| configuration namespace to one or more trace sources 
e943837b17ad bug 1997: fix PlotProbe() documentation and usage for GnuplotHelper and FileHelper
Tom Henderson <tomh@tomh.org>
parents: 10408
diff changeset
    91
* probeTraceSource:  Which output of the probe (itself a trace source) should be plotted
e943837b17ad bug 1997: fix PlotProbe() documentation and usage for GnuplotHelper and FileHelper
Tom Henderson <tomh@tomh.org>
parents: 10408
diff changeset
    92
* title:  The title to associate with the dataset(s) (in the gnuplot legend)
10120
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    93
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    94
A variant on the PlotProbe above is to specify a fifth optional argument
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    95
that controls where in the plot the key (legend) is placed.
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    96
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    97
A fully worked example (from ``seventh.cc``) is shown below:
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    98
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    99
::
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   100
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   101
   // Create the gnuplot helper.
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   102
   GnuplotHelper plotHelper;
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   103
 
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   104
   // Configure the plot.
11027
e943837b17ad bug 1997: fix PlotProbe() documentation and usage for GnuplotHelper and FileHelper
Tom Henderson <tomh@tomh.org>
parents: 10408
diff changeset
   105
   // Configure the plot.  The first argument is the file name prefix
e943837b17ad bug 1997: fix PlotProbe() documentation and usage for GnuplotHelper and FileHelper
Tom Henderson <tomh@tomh.org>
parents: 10408
diff changeset
   106
   // for the output files generated.  The second, third, and fourth
e943837b17ad bug 1997: fix PlotProbe() documentation and usage for GnuplotHelper and FileHelper
Tom Henderson <tomh@tomh.org>
parents: 10408
diff changeset
   107
   // arguments are, respectively, the plot title, x-axis, and y-axis labels
10120
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   108
   plotHelper.ConfigurePlot ("seventh-packet-byte-count",
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   109
                             "Packet Byte Count vs. Time",
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   110
                             "Time (Seconds)",
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   111
                             "Packet Byte Count",
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   112
                             "png");
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   113
11027
e943837b17ad bug 1997: fix PlotProbe() documentation and usage for GnuplotHelper and FileHelper
Tom Henderson <tomh@tomh.org>
parents: 10408
diff changeset
   114
   // Specify the probe type, trace source path (in configuration namespace), and
e943837b17ad bug 1997: fix PlotProbe() documentation and usage for GnuplotHelper and FileHelper
Tom Henderson <tomh@tomh.org>
parents: 10408
diff changeset
   115
   // probe output trace source ("OutputBytes") to plot.  The fourth argument
e943837b17ad bug 1997: fix PlotProbe() documentation and usage for GnuplotHelper and FileHelper
Tom Henderson <tomh@tomh.org>
parents: 10408
diff changeset
   116
   // specifies the name of the data series label on the plot.  The last
e943837b17ad bug 1997: fix PlotProbe() documentation and usage for GnuplotHelper and FileHelper
Tom Henderson <tomh@tomh.org>
parents: 10408
diff changeset
   117
   // argument formats the plot by specifying where the key should be placed.
e943837b17ad bug 1997: fix PlotProbe() documentation and usage for GnuplotHelper and FileHelper
Tom Henderson <tomh@tomh.org>
parents: 10408
diff changeset
   118
   plotHelper.PlotProbe (probeType,
e943837b17ad bug 1997: fix PlotProbe() documentation and usage for GnuplotHelper and FileHelper
Tom Henderson <tomh@tomh.org>
parents: 10408
diff changeset
   119
                         tracePath,
10120
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   120
                         "OutputBytes",
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   121
                         "Packet Byte Count",
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   122
                         GnuplotAggregator::KEY_BELOW);
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   123
11027
e943837b17ad bug 1997: fix PlotProbe() documentation and usage for GnuplotHelper and FileHelper
Tom Henderson <tomh@tomh.org>
parents: 10408
diff changeset
   124
In this example, the ``probeType`` and ``tracePath`` are as follows (for IPv4):
e943837b17ad bug 1997: fix PlotProbe() documentation and usage for GnuplotHelper and FileHelper
Tom Henderson <tomh@tomh.org>
parents: 10408
diff changeset
   125
e943837b17ad bug 1997: fix PlotProbe() documentation and usage for GnuplotHelper and FileHelper
Tom Henderson <tomh@tomh.org>
parents: 10408
diff changeset
   126
::
e943837b17ad bug 1997: fix PlotProbe() documentation and usage for GnuplotHelper and FileHelper
Tom Henderson <tomh@tomh.org>
parents: 10408
diff changeset
   127
e943837b17ad bug 1997: fix PlotProbe() documentation and usage for GnuplotHelper and FileHelper
Tom Henderson <tomh@tomh.org>
parents: 10408
diff changeset
   128
   probeType = "ns3::Ipv4PacketProbe";
e943837b17ad bug 1997: fix PlotProbe() documentation and usage for GnuplotHelper and FileHelper
Tom Henderson <tomh@tomh.org>
parents: 10408
diff changeset
   129
   tracePath = "/NodeList/*/$ns3::Ipv4L3Protocol/Tx";
e943837b17ad bug 1997: fix PlotProbe() documentation and usage for GnuplotHelper and FileHelper
Tom Henderson <tomh@tomh.org>
parents: 10408
diff changeset
   130
e943837b17ad bug 1997: fix PlotProbe() documentation and usage for GnuplotHelper and FileHelper
Tom Henderson <tomh@tomh.org>
parents: 10408
diff changeset
   131
The probeType is a key parameter for this helper to work.  This TypeId
e943837b17ad bug 1997: fix PlotProbe() documentation and usage for GnuplotHelper and FileHelper
Tom Henderson <tomh@tomh.org>
parents: 10408
diff changeset
   132
must be registered in the system, and the signature on the Probe's trace
e943837b17ad bug 1997: fix PlotProbe() documentation and usage for GnuplotHelper and FileHelper
Tom Henderson <tomh@tomh.org>
parents: 10408
diff changeset
   133
sink must match that of the trace source it is being hooked to.  Probe
e943837b17ad bug 1997: fix PlotProbe() documentation and usage for GnuplotHelper and FileHelper
Tom Henderson <tomh@tomh.org>
parents: 10408
diff changeset
   134
types are pre-defined for a number of data types corresponding to |ns3|
e943837b17ad bug 1997: fix PlotProbe() documentation and usage for GnuplotHelper and FileHelper
Tom Henderson <tomh@tomh.org>
parents: 10408
diff changeset
   135
traced values, and for a few other trace source signatures such as the 
e943837b17ad bug 1997: fix PlotProbe() documentation and usage for GnuplotHelper and FileHelper
Tom Henderson <tomh@tomh.org>
parents: 10408
diff changeset
   136
'Tx' trace source of ``ns3::Ipv4L3Protocol`` class.
e943837b17ad bug 1997: fix PlotProbe() documentation and usage for GnuplotHelper and FileHelper
Tom Henderson <tomh@tomh.org>
parents: 10408
diff changeset
   137
e943837b17ad bug 1997: fix PlotProbe() documentation and usage for GnuplotHelper and FileHelper
Tom Henderson <tomh@tomh.org>
parents: 10408
diff changeset
   138
Note that the trace source path specified may contain wildcards.  
e943837b17ad bug 1997: fix PlotProbe() documentation and usage for GnuplotHelper and FileHelper
Tom Henderson <tomh@tomh.org>
parents: 10408
diff changeset
   139
In this case, multiple
10120
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   140
datasets are plotted on one plot; one for each matched path.
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   141
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   142
The main output produced will be three files:
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   143
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   144
::
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   145
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   146
   seventh-packet-byte-count.dat
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   147
   seventh-packet-byte-count.plt
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   148
   seventh-packet-byte-count.sh
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   149
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   150
At this point, users can either hand edit the .plt file for further
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   151
customizations, or just run it through gnuplot.  Running 
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   152
`sh seventh-packet-byte-count.sh` simply runs the plot through gnuplot,
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   153
as shown below. 
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   154
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   155
.. _seventh-packet-byte-count:
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   156
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   157
.. figure:: figures/seventh-packet-byte-count.png
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   158
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   159
  2-D Gnuplot Created by seventh.cc Example.
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   160
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   161
It can be seen that the key elements (legend, title, legend placement,
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   162
xlabel, ylabel, and path for the data) are all placed on the plot.
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   163
Since there were two matches to the configuration path provided, the
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   164
two data series are shown:
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   165
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   166
* Packet Byte Count-0 corresponds to /NodeList/0/$ns3::Ipv4L3Protocol/Tx
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   167
* Packet Byte Count-1 corresponds to /NodeList/1/$ns3::Ipv4L3Protocol/Tx
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   168
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   169
GnuplotHelper ConfigurePlot
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   170
###########################
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   171
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   172
The GnuplotHelper's ``ConfigurePlot()`` function can be used 
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   173
to configure plots.
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   174
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   175
It has the following prototype:
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   176
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   177
::
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   178
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   179
  void ConfigurePlot (const std::string &outputFileNameWithoutExtension,
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   180
                      const std::string &title,
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   181
                      const std::string &xLegend,
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   182
                      const std::string &yLegend,
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   183
                      const std::string &terminalType = ".png");
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   184
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   185
It has the following arguments:
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   186
10408
5c604e8ec2e1 Models source highlighting
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10120
diff changeset
   187
  +--------------------------------+------------------------------+
5c604e8ec2e1 Models source highlighting
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10120
diff changeset
   188
  | Argument                       | Description                  |
5c604e8ec2e1 Models source highlighting
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10120
diff changeset
   189
  +================================+==============================+
5c604e8ec2e1 Models source highlighting
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10120
diff changeset
   190
  | outputFileNameWithoutExtension | Name of gnuplot related files|
5c604e8ec2e1 Models source highlighting
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10120
diff changeset
   191
  |                                | to write with no extension.  |
5c604e8ec2e1 Models source highlighting
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10120
diff changeset
   192
  +--------------------------------+------------------------------+
5c604e8ec2e1 Models source highlighting
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10120
diff changeset
   193
  | title                          | Plot title string to use for |
5c604e8ec2e1 Models source highlighting
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10120
diff changeset
   194
  |                                | this plot.                   |
5c604e8ec2e1 Models source highlighting
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10120
diff changeset
   195
  +--------------------------------+------------------------------+
5c604e8ec2e1 Models source highlighting
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10120
diff changeset
   196
  | xLegend                        | The legend for the x         |
5c604e8ec2e1 Models source highlighting
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10120
diff changeset
   197
  |                                | horizontal axis.             |
5c604e8ec2e1 Models source highlighting
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10120
diff changeset
   198
  +--------------------------------+------------------------------+
5c604e8ec2e1 Models source highlighting
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10120
diff changeset
   199
  | yLegend                        | The legend for the y         |
5c604e8ec2e1 Models source highlighting
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10120
diff changeset
   200
  |                                | vertical axis.               |
5c604e8ec2e1 Models source highlighting
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10120
diff changeset
   201
  +--------------------------------+------------------------------+
5c604e8ec2e1 Models source highlighting
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10120
diff changeset
   202
  | terminalType                   | Terminal type setting string |
5c604e8ec2e1 Models source highlighting
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10120
diff changeset
   203
  |                                | for output.  The default     |
5c604e8ec2e1 Models source highlighting
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10120
diff changeset
   204
  |                                | terminal type is "png".      |
5c604e8ec2e1 Models source highlighting
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10120
diff changeset
   205
  +--------------------------------+------------------------------+
5c604e8ec2e1 Models source highlighting
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10120
diff changeset
   206
  
10120
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   207
The GnuplotHelper's ``ConfigurePlot()`` function configures plot 
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   208
related parameters for this gnuplot helper so
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   209
that it will create a space separated gnuplot data file named
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   210
outputFileNameWithoutExtension + ".dat", a gnuplot control file
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   211
named outputFileNameWithoutExtension + ".plt", and a shell script
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   212
to generate the gnuplot named outputFileNameWithoutExtension +
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   213
".sh".
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   214
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   215
An example of how to use this function can be seen in the 
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   216
``seventh.cc`` code described above where it was used as follows:
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   217
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   218
::
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   219
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   220
  plotHelper.ConfigurePlot ("seventh-packet-byte-count",
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   221
                            "Packet Byte Count vs. Time",
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   222
                            "Time (Seconds)",
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   223
                            "Packet Byte Count",
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   224
                            "png");
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   225
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   226
GnuplotHelper PlotProbe
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   227
#######################
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   228
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   229
The GnuplotHelper's ``PlotProbe()`` function can be used 
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   230
to plot values generated by probes.
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   231
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   232
It has the following prototype:
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   233
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   234
::
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   235
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   236
  void PlotProbe (const std::string &typeId,
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   237
                  const std::string &path,
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   238
                  const std::string &probeTraceSource,
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   239
                  const std::string &title,
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   240
                  enum GnuplotAggregator::KeyLocation keyLocation = GnuplotAggregator::KEY_INSIDE);
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   241
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   242
It has the following arguments:
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   243
10408
5c604e8ec2e1 Models source highlighting
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10120
diff changeset
   244
  +------------------+------------------------------+
5c604e8ec2e1 Models source highlighting
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10120
diff changeset
   245
  | Argument         | Description                  |
5c604e8ec2e1 Models source highlighting
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10120
diff changeset
   246
  +==================+==============================+
5c604e8ec2e1 Models source highlighting
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10120
diff changeset
   247
  | typeId           | The type ID for the probe    |
11027
e943837b17ad bug 1997: fix PlotProbe() documentation and usage for GnuplotHelper and FileHelper
Tom Henderson <tomh@tomh.org>
parents: 10408
diff changeset
   248
  |                  | created by this helper.      |
10408
5c604e8ec2e1 Models source highlighting
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10120
diff changeset
   249
  +------------------+------------------------------+
5c604e8ec2e1 Models source highlighting
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10120
diff changeset
   250
  | path             | Config path to access the    |
11027
e943837b17ad bug 1997: fix PlotProbe() documentation and usage for GnuplotHelper and FileHelper
Tom Henderson <tomh@tomh.org>
parents: 10408
diff changeset
   251
  |                  | trace source.                |
10408
5c604e8ec2e1 Models source highlighting
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10120
diff changeset
   252
  +------------------+------------------------------+
5c604e8ec2e1 Models source highlighting
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10120
diff changeset
   253
  | probeTraceSource | The probe trace source to    |
5c604e8ec2e1 Models source highlighting
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10120
diff changeset
   254
  |                  | access.                      |
5c604e8ec2e1 Models source highlighting
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10120
diff changeset
   255
  +------------------+------------------------------+
5c604e8ec2e1 Models source highlighting
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10120
diff changeset
   256
  | title            | The title to be associated   |
5c604e8ec2e1 Models source highlighting
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10120
diff changeset
   257
  |                  | to this dataset              |
5c604e8ec2e1 Models source highlighting
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10120
diff changeset
   258
  +------------------+------------------------------+
5c604e8ec2e1 Models source highlighting
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10120
diff changeset
   259
  | keyLocation      | The location of the key in   |
5c604e8ec2e1 Models source highlighting
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10120
diff changeset
   260
  |                  | the plot.  The default       |
5c604e8ec2e1 Models source highlighting
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10120
diff changeset
   261
  |                  | location is inside.          |
5c604e8ec2e1 Models source highlighting
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10120
diff changeset
   262
  +------------------+------------------------------+
5c604e8ec2e1 Models source highlighting
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10120
diff changeset
   263
  
10120
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   264
The GnuplotHelper's ``PlotProbe()`` function 
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   265
plots a dataset generated by hooking the |ns3| trace source with a
11027
e943837b17ad bug 1997: fix PlotProbe() documentation and usage for GnuplotHelper and FileHelper
Tom Henderson <tomh@tomh.org>
parents: 10408
diff changeset
   266
probe created by the helper, and then plotting the values from the 
e943837b17ad bug 1997: fix PlotProbe() documentation and usage for GnuplotHelper and FileHelper
Tom Henderson <tomh@tomh.org>
parents: 10408
diff changeset
   267
probeTraceSource. 
10120
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   268
The dataset will have the provided title, and will consist of 
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   269
the 'newValue' at each timestamp.
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   270
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   271
If the config path has more than one match in the system because 
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   272
there is a wildcard, then one dataset for each match will
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   273
be plotted.  The dataset titles will be suffixed with the matched
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   274
characters for each of the wildcards in the config path,
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   275
separated by spaces.  For example, if the proposed dataset title
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   276
is the string "bytes", and there are two wildcards in the path,
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   277
then dataset titles like "bytes-0 0" or "bytes-12 9" will be
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   278
possible as labels for the datasets that are plotted.
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   279
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   280
An example of how to use this function can be seen in the 
11027
e943837b17ad bug 1997: fix PlotProbe() documentation and usage for GnuplotHelper and FileHelper
Tom Henderson <tomh@tomh.org>
parents: 10408
diff changeset
   281
``seventh.cc`` code described above where it was used (with
e943837b17ad bug 1997: fix PlotProbe() documentation and usage for GnuplotHelper and FileHelper
Tom Henderson <tomh@tomh.org>
parents: 10408
diff changeset
   282
variable substitution) as follows:
10120
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   283
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   284
::
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   285
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   286
  plotHelper.PlotProbe ("ns3::Ipv4PacketProbe",
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   287
                        "/NodeList/*/$ns3::Ipv4L3Protocol/Tx",
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   288
                        "OutputBytes",
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   289
                        "Packet Byte Count",
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   290
                        GnuplotAggregator::KEY_BELOW);
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   291
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   292
Other Examples
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   293
##############
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   294
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   295
Gnuplot Helper Example
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   296
~~~~~~~~~~~~~~~~~~~~~~
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   297
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   298
A slightly simpler example than the ``seventh.cc`` example can be 
11027
e943837b17ad bug 1997: fix PlotProbe() documentation and usage for GnuplotHelper and FileHelper
Tom Henderson <tomh@tomh.org>
parents: 10408
diff changeset
   299
found in ``src/stats/examples/gnuplot-helper-example.cc``.  The 
e943837b17ad bug 1997: fix PlotProbe() documentation and usage for GnuplotHelper and FileHelper
Tom Henderson <tomh@tomh.org>
parents: 10408
diff changeset
   300
following 2-D gnuplot was created using the example.
10120
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   301
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   302
.. _gnuplot-helper-example:
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   303
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   304
.. figure:: figures/gnuplot-helper-example.png
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   305
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   306
  2-D Gnuplot Created by gnuplot-helper-example.cc Example.
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   307
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   308
In this example, there is an Emitter object that increments 
11027
e943837b17ad bug 1997: fix PlotProbe() documentation and usage for GnuplotHelper and FileHelper
Tom Henderson <tomh@tomh.org>
parents: 10408
diff changeset
   309
its counter according to a Poisson process and then emits the counter's 
10120
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   310
value as a trace source.
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   311
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   312
::
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   313
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   314
  Ptr<Emitter> emitter = CreateObject<Emitter> ();
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   315
  Names::Add ("/Names/Emitter", emitter);
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   316
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   317
Note that because there are no wildcards in the path 
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   318
used below, only 1 datastream was drawn in the plot.  
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   319
This single datastream in the plot is simply labeled 
11027
e943837b17ad bug 1997: fix PlotProbe() documentation and usage for GnuplotHelper and FileHelper
Tom Henderson <tomh@tomh.org>
parents: 10408
diff changeset
   320
"Emitter Count", with no extra suffixes like one would 
10120
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   321
see if there were wildcards in the path.
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   322
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   323
::
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   324
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   325
  // Create the gnuplot helper.
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   326
  GnuplotHelper plotHelper;
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   327
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   328
  // Configure the plot.
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   329
  plotHelper.ConfigurePlot ("gnuplot-helper-example",
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   330
                            "Emitter Counts vs. Time",
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   331
                            "Time (Seconds)",
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   332
                            "Emitter Count",
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   333
                            "png");
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   334
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   335
  // Plot the values generated by the probe.  The path that we provide
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   336
  // helps to disambiguate the source of the trace.
11027
e943837b17ad bug 1997: fix PlotProbe() documentation and usage for GnuplotHelper and FileHelper
Tom Henderson <tomh@tomh.org>
parents: 10408
diff changeset
   337
  plotHelper.PlotProbe ("ns3::Uinteger32Probe",
e943837b17ad bug 1997: fix PlotProbe() documentation and usage for GnuplotHelper and FileHelper
Tom Henderson <tomh@tomh.org>
parents: 10408
diff changeset
   338
                        "/Names/Emitter/Counter",
10120
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   339
                        "Output",
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   340
                        "Emitter Count",
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   341
                        GnuplotAggregator::KEY_INSIDE);
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   342
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   343
FileHelper
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   344
==========
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   345
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   346
The FileHelper is a helper class used to put data values into a file.
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   347
The overall goal is to provide the ability for users
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   348
to quickly make formatted text files from data exported in |ns3| 
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   349
trace sources.  By default, a minimal amount of data transformation is 
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   350
performed; the objective is to generate files with as few (default) 
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   351
configuration statements as possible.
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   352
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   353
FileHelper Overview
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   354
###################
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   355
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   356
The FileHelper will create 1 or more text files at the end of the
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   357
simulation.
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   358
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   359
The FileHelper can create 4 different types of text files:
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   360
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   361
- Formatted
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   362
- Space separated (the default)
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   363
- Comma separated
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   364
- Tab separated
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   365
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   366
Formatted files use C-style format strings and the sprintf() function
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   367
to print their values in the file being written.
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   368
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   369
The following text file with 2 columns of formatted values named 
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   370
``seventh-packet-byte-count-0.txt`` was created using more new 
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   371
code that was added to the original |ns3| Tutorial example's code.  
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   372
Only the first 10 lines of this file are shown here for brevity.
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   373
10408
5c604e8ec2e1 Models source highlighting
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10120
diff changeset
   374
.. sourcecode:: text
10120
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   375
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   376
  Time (Seconds) = 1.000e+00	Packet Byte Count = 40
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   377
  Time (Seconds) = 1.004e+00	Packet Byte Count = 40
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   378
  Time (Seconds) = 1.004e+00	Packet Byte Count = 576
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   379
  Time (Seconds) = 1.009e+00	Packet Byte Count = 576
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   380
  Time (Seconds) = 1.009e+00	Packet Byte Count = 576
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   381
  Time (Seconds) = 1.015e+00	Packet Byte Count = 512
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   382
  Time (Seconds) = 1.017e+00	Packet Byte Count = 576
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   383
  Time (Seconds) = 1.017e+00	Packet Byte Count = 544
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   384
  Time (Seconds) = 1.025e+00	Packet Byte Count = 576
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   385
  Time (Seconds) = 1.025e+00	Packet Byte Count = 544
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   386
  
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   387
  ...
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   388
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   389
The following different text file with 2 columns of formatted 
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   390
values named ``seventh-packet-byte-count-1.txt`` was also 
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   391
created using the same new code that was added to the original 
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   392
|ns3| Tutorial example's code.  Only the first 10 lines of this 
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   393
file are shown here for brevity.
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   394
10408
5c604e8ec2e1 Models source highlighting
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10120
diff changeset
   395
.. sourcecode:: text
10120
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   396
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   397
  Time (Seconds) = 1.002e+00	Packet Byte Count = 40
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   398
  Time (Seconds) = 1.007e+00	Packet Byte Count = 40
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   399
  Time (Seconds) = 1.013e+00	Packet Byte Count = 40
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   400
  Time (Seconds) = 1.020e+00	Packet Byte Count = 40
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   401
  Time (Seconds) = 1.028e+00	Packet Byte Count = 40
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   402
  Time (Seconds) = 1.036e+00	Packet Byte Count = 40
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   403
  Time (Seconds) = 1.045e+00	Packet Byte Count = 40
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   404
  Time (Seconds) = 1.053e+00	Packet Byte Count = 40
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   405
  Time (Seconds) = 1.061e+00	Packet Byte Count = 40
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   406
  Time (Seconds) = 1.069e+00	Packet Byte Count = 40
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   407
  
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   408
  ...
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   409
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   410
The new code that was added to produce the two text files is below.  
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   411
More details about this API will be covered in a later section. 
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   412
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   413
Note that because there were 2 matches for the wildcard in the path, 
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   414
2 separate text files were created.  The first text file, which is 
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   415
named "seventh-packet-byte-count-0.txt", corresponds to the 
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   416
wildcard match with the "*" replaced with "0".  The second text file, 
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   417
which is named "seventh-packet-byte-count-1.txt", corresponds to 
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   418
the wildcard match with the "*" replaced with "1".  Also, note that 
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   419
the function call to ``WriteProbe()`` will give an error message if 
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   420
there are no matches for a path that contains wildcards.
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   421
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   422
::
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   423
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   424
   // Create the file helper.
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   425
   FileHelper fileHelper;
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   426
 
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   427
   // Configure the file to be written.
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   428
   fileHelper.ConfigureFile ("seventh-packet-byte-count",
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   429
                             FileAggregator::FORMATTED);
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   430
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   431
   // Set the labels for this formatted output file.
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   432
   fileHelper.Set2dFormat ("Time (Seconds) = %.3e\tPacket Byte Count = %.0f");
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   433
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   434
   // Write the values generated by the probe.
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   435
   fileHelper.WriteProbe ("ns3::Ipv4PacketProbe",
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   436
                          "/NodeList/*/$ns3::Ipv4L3Protocol/Tx",
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   437
                          "OutputBytes");
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   438
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   439
FileHelper ConfigureFile
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   440
########################
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   441
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   442
The FileHelper's ``ConfigureFile()`` function can be used 
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   443
to configure text files.
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   444
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   445
It has the following prototype:
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   446
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   447
::
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   448
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   449
  void ConfigureFile (const std::string &outputFileNameWithoutExtension,
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   450
                      enum FileAggregator::FileType fileType = FileAggregator::SPACE_SEPARATED);
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   451
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   452
It has the following arguments:
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   453
10408
5c604e8ec2e1 Models source highlighting
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10120
diff changeset
   454
  +--------------------------------+------------------------------+
5c604e8ec2e1 Models source highlighting
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10120
diff changeset
   455
  | Argument                       | Description                  |
5c604e8ec2e1 Models source highlighting
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10120
diff changeset
   456
  +================================+==============================+
5c604e8ec2e1 Models source highlighting
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10120
diff changeset
   457
  | outputFileNameWithoutExtension | Name of output file to write |
5c604e8ec2e1 Models source highlighting
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10120
diff changeset
   458
  |                                | with no extension.           |
5c604e8ec2e1 Models source highlighting
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10120
diff changeset
   459
  +--------------------------------+------------------------------+
5c604e8ec2e1 Models source highlighting
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10120
diff changeset
   460
  | fileType                       | Type of file to write.  The  | 
5c604e8ec2e1 Models source highlighting
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10120
diff changeset
   461
  |                                | default type of file is space| 
5c604e8ec2e1 Models source highlighting
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10120
diff changeset
   462
  |                                | separated.                   |
5c604e8ec2e1 Models source highlighting
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10120
diff changeset
   463
  +--------------------------------+------------------------------+
5c604e8ec2e1 Models source highlighting
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10120
diff changeset
   464
  
10120
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   465
The FileHelper's ``ConfigureFile()`` function configures text file 
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   466
related parameters for the file helper so that
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   467
it will create a file named outputFileNameWithoutExtension plus
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   468
possible extra information from wildcard matches plus ".txt" with
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   469
values printed as specified by fileType.  The default file type
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   470
is space-separated.
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   471
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   472
An example of how to use this function can be seen in the 
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   473
``seventh.cc`` code described above where it was used as follows:
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   474
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   475
::
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   476
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   477
  fileHelper.ConfigureFile ("seventh-packet-byte-count",
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   478
                            FileAggregator::FORMATTED);
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   479
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   480
FileHelper WriteProbe
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   481
#####################
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   482
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   483
The FileHelper's ``WriteProbe()`` function can be used 
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   484
to write values generated by probes to text files.
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   485
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   486
It has the following prototype:
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   487
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   488
::
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   489
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   490
  void WriteProbe (const std::string &typeId,
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   491
                   const std::string &path,
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   492
                   const std::string &probeTraceSource);
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   493
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   494
It has the following arguments:
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   495
10408
5c604e8ec2e1 Models source highlighting
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10120
diff changeset
   496
  +------------------+------------------------------+
5c604e8ec2e1 Models source highlighting
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10120
diff changeset
   497
  | Argument         | Description                  |
5c604e8ec2e1 Models source highlighting
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10120
diff changeset
   498
  +==================+==============================+
5c604e8ec2e1 Models source highlighting
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10120
diff changeset
   499
  | typeId           | The type ID for the probe    |
11027
e943837b17ad bug 1997: fix PlotProbe() documentation and usage for GnuplotHelper and FileHelper
Tom Henderson <tomh@tomh.org>
parents: 10408
diff changeset
   500
  |                  | to be created.               |
10408
5c604e8ec2e1 Models source highlighting
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10120
diff changeset
   501
  +------------------+------------------------------+
5c604e8ec2e1 Models source highlighting
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10120
diff changeset
   502
  | path             | Config path to access the    |
11027
e943837b17ad bug 1997: fix PlotProbe() documentation and usage for GnuplotHelper and FileHelper
Tom Henderson <tomh@tomh.org>
parents: 10408
diff changeset
   503
  |                  | trace source.                |
10408
5c604e8ec2e1 Models source highlighting
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10120
diff changeset
   504
  +------------------+------------------------------+
5c604e8ec2e1 Models source highlighting
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10120
diff changeset
   505
  | probeTraceSource | The probe trace source to    |
5c604e8ec2e1 Models source highlighting
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10120
diff changeset
   506
  |                  | access.                      |
5c604e8ec2e1 Models source highlighting
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10120
diff changeset
   507
  +------------------+------------------------------+
5c604e8ec2e1 Models source highlighting
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10120
diff changeset
   508
  
10120
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   509
The FileHelper's ``WriteProbe()`` function
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   510
creates output text files generated by hooking the ns-3 trace source
11027
e943837b17ad bug 1997: fix PlotProbe() documentation and usage for GnuplotHelper and FileHelper
Tom Henderson <tomh@tomh.org>
parents: 10408
diff changeset
   511
with a probe created by the helper, and then writing the values from the
10120
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   512
probeTraceSource. The output file names will have the text stored
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   513
in the member variable  m_outputFileNameWithoutExtension plus ".txt", 
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   514
and will consist of the 'newValue' at each timestamp.
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   515
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   516
If the config path has more than one match in the system because
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   517
there is a wildcard, then one output file for each match
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   518
will be created.  The output file names will contain the text in
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   519
m_outputFileNameWithoutExtension plus the matched characters for
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   520
each of the wildcards in the config path, separated by dashes,
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   521
plus ".txt".  For example, if the value in
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   522
m_outputFileNameWithoutExtension is the string
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   523
"packet-byte-count", and there are two wildcards in the path,
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   524
then output file names like "packet-byte-count-0-0.txt" or
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   525
"packet-byte-count-12-9.txt" will be possible as names for the
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   526
files that will be created.
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   527
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   528
An example of how to use this function can be seen in the 
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   529
``seventh.cc`` code described above where it was used as follows:
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   530
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   531
::
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   532
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   533
  fileHelper.WriteProbe ("ns3::Ipv4PacketProbe",
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   534
                         "/NodeList/*/$ns3::Ipv4L3Protocol/Tx",
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   535
                         "OutputBytes");
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   536
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   537
Other Examples
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   538
##############
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   539
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   540
File Helper Example
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   541
~~~~~~~~~~~~~~~~~~~
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   542
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   543
A slightly simpler example than the ``seventh.cc`` example can be 
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   544
found in ``src/stats/examples/file-helper-example.cc``.  
11027
e943837b17ad bug 1997: fix PlotProbe() documentation and usage for GnuplotHelper and FileHelper
Tom Henderson <tomh@tomh.org>
parents: 10408
diff changeset
   545
This example only uses the FileHelper.
10120
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   546
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   547
The following text file with 2 columns of formatted values named 
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   548
``file-helper-example.txt`` was created using the example.  
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   549
Only the first 10 lines of this file are shown here for brevity.
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   550
10408
5c604e8ec2e1 Models source highlighting
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10120
diff changeset
   551
.. sourcecode:: text
10120
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   552
11027
e943837b17ad bug 1997: fix PlotProbe() documentation and usage for GnuplotHelper and FileHelper
Tom Henderson <tomh@tomh.org>
parents: 10408
diff changeset
   553
  Time (Seconds) = 0.203  Count = 1
e943837b17ad bug 1997: fix PlotProbe() documentation and usage for GnuplotHelper and FileHelper
Tom Henderson <tomh@tomh.org>
parents: 10408
diff changeset
   554
  Time (Seconds) = 0.702  Count = 2
e943837b17ad bug 1997: fix PlotProbe() documentation and usage for GnuplotHelper and FileHelper
Tom Henderson <tomh@tomh.org>
parents: 10408
diff changeset
   555
  Time (Seconds) = 1.404  Count = 3
e943837b17ad bug 1997: fix PlotProbe() documentation and usage for GnuplotHelper and FileHelper
Tom Henderson <tomh@tomh.org>
parents: 10408
diff changeset
   556
  Time (Seconds) = 2.368  Count = 4
e943837b17ad bug 1997: fix PlotProbe() documentation and usage for GnuplotHelper and FileHelper
Tom Henderson <tomh@tomh.org>
parents: 10408
diff changeset
   557
  Time (Seconds) = 3.364  Count = 5
e943837b17ad bug 1997: fix PlotProbe() documentation and usage for GnuplotHelper and FileHelper
Tom Henderson <tomh@tomh.org>
parents: 10408
diff changeset
   558
  Time (Seconds) = 3.579  Count = 6
e943837b17ad bug 1997: fix PlotProbe() documentation and usage for GnuplotHelper and FileHelper
Tom Henderson <tomh@tomh.org>
parents: 10408
diff changeset
   559
  Time (Seconds) = 5.873  Count = 7
e943837b17ad bug 1997: fix PlotProbe() documentation and usage for GnuplotHelper and FileHelper
Tom Henderson <tomh@tomh.org>
parents: 10408
diff changeset
   560
  Time (Seconds) = 6.410  Count = 8
e943837b17ad bug 1997: fix PlotProbe() documentation and usage for GnuplotHelper and FileHelper
Tom Henderson <tomh@tomh.org>
parents: 10408
diff changeset
   561
  Time (Seconds) = 6.472  Count = 9
10120
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   562
  ...
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   563
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   564
In this example, there is an Emitter object that increments 
11027
e943837b17ad bug 1997: fix PlotProbe() documentation and usage for GnuplotHelper and FileHelper
Tom Henderson <tomh@tomh.org>
parents: 10408
diff changeset
   565
its counter according to a Poisson process and then emits the counter's 
10120
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   566
value as a trace source.
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   567
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   568
::
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   569
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   570
  Ptr<Emitter> emitter = CreateObject<Emitter> ();
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   571
  Names::Add ("/Names/Emitter", emitter);
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   572
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   573
Note that because there are no wildcards in the path 
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   574
used below, only 1 text file was created.  
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   575
This single text file is simply named 
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   576
"file-helper-example.txt", with no extra suffixes like 
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   577
you would see if there were wildcards in the path.
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   578
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   579
::
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   580
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   581
  // Create the file helper.
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   582
  FileHelper fileHelper;
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   583
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   584
  // Configure the file to be written.
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   585
  fileHelper.ConfigureFile ("file-helper-example",
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   586
                            FileAggregator::FORMATTED);
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   587
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   588
  // Set the labels for this formatted output file.
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   589
  fileHelper.Set2dFormat ("Time (Seconds) = %.3e\tCount = %.0f");
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   590
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   591
  // Write the values generated by the probe.  The path that we
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   592
  // provide helps to disambiguate the source of the trace.
11027
e943837b17ad bug 1997: fix PlotProbe() documentation and usage for GnuplotHelper and FileHelper
Tom Henderson <tomh@tomh.org>
parents: 10408
diff changeset
   593
  fileHelper.WriteProbe ("ns3::Uinteger32Probe",
e943837b17ad bug 1997: fix PlotProbe() documentation and usage for GnuplotHelper and FileHelper
Tom Henderson <tomh@tomh.org>
parents: 10408
diff changeset
   594
                         "/Names/Emitter/Counter",
10120
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   595
                         "Output");
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   596
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   597
Scope and Limitations
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   598
=====================
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   599
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   600
Currently, only these Probes have been implemented and connected
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   601
to the GnuplotHelper and to the FileHelper:
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   602
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   603
- BooleanProbe
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   604
- DoubleProbe
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   605
- Uinteger8Probe
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   606
- Uinteger16Probe
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   607
- Uinteger32Probe
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   608
- PacketProbe
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   609
- ApplicationPacketProbe
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   610
- Ipv4PacketProbe
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   611
11027
e943837b17ad bug 1997: fix PlotProbe() documentation and usage for GnuplotHelper and FileHelper
Tom Henderson <tomh@tomh.org>
parents: 10408
diff changeset
   612
These Probes, therefore, are the only TypeIds available to be used 
10120
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   613
in ``PlotProbe()`` and ``WriteProbe()``.
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   614
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   615
In the next few sections, we cover each of the fundamental object
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   616
types (Probe, Collector, and Aggregator) in more detail, and show
177ccb85f714 data collection documentation
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   617
how they can be connected together using lower-level API.