|
|
| 75 |
const std::string &yLegend, |
75 |
const std::string &yLegend, |
| 76 |
const std::string &terminalType = ".png"); |
76 |
const std::string &terminalType = ".png"); |
| 77 |
|
77 |
|
| 78 |
The second statement hooks the ``Probe`` of interest: |
78 |
The second statement hooks the trace source of interest: |
| 79 |
|
79 |
|
| 80 |
:: |
80 |
:: |
| 81 |
|
81 |
|
|
|
| 87 |
The arguments are as follows: |
87 |
The arguments are as follows: |
| 88 |
|
88 |
|
| 89 |
* typeId: The |ns3| TypeId of the Probe |
89 |
* typeId: The |ns3| TypeId of the Probe |
| 90 |
* path: The path in the |ns3| configuration namespace to one or more probes |
90 |
* path: The path in the |ns3| configuration namespace to one or more trace sources |
| 91 |
* probeTraceSource: Which output of the probe should be connected to |
91 |
* probeTraceSource: Which output of the probe (itself a trace source) should be plotted |
| 92 |
* title: The title to associate with the dataset (in the gnuplot legend) |
92 |
* title: The title to associate with the dataset(s) (in the gnuplot legend) |
| 93 |
|
93 |
|
| 94 |
A variant on the PlotProbe above is to specify a fifth optional argument |
94 |
A variant on the PlotProbe above is to specify a fifth optional argument |
| 95 |
that controls where in the plot the key (legend) is placed. |
95 |
that controls where in the plot the key (legend) is placed. |
|
|
| 102 |
GnuplotHelper plotHelper; |
102 |
GnuplotHelper plotHelper; |
| 103 |
|
103 |
|
| 104 |
// Configure the plot. |
104 |
// Configure the plot. |
|
|
105 |
// Configure the plot. The first argument is the file name prefix |
| 106 |
// for the output files generated. The second, third, and fourth |
| 107 |
// arguments are, respectively, the plot title, x-axis, and y-axis labels |
| 105 |
plotHelper.ConfigurePlot ("seventh-packet-byte-count", |
108 |
plotHelper.ConfigurePlot ("seventh-packet-byte-count", |
| 106 |
"Packet Byte Count vs. Time", |
109 |
"Packet Byte Count vs. Time", |
| 107 |
"Time (Seconds)", |
110 |
"Time (Seconds)", |
| 108 |
"Packet Byte Count", |
111 |
"Packet Byte Count", |
| 109 |
"png"); |
112 |
"png"); |
| 110 |
|
113 |
|
| 111 |
// Plot the values generated by the probe. |
114 |
// Specify the probe type, trace source path (in configuration namespace), and |
| 112 |
plotHelper.PlotProbe ("ns3::Ipv4PacketProbe", |
115 |
// probe output trace source ("OutputBytes") to plot. The fourth argument |
| 113 |
"/NodeList/*/$ns3::Ipv4L3Protocol/Tx", |
116 |
// specifies the name of the data series label on the plot. The last |
|
|
117 |
// argument formats the plot by specifying where the key should be placed. |
| 118 |
plotHelper.PlotProbe (probeType, |
| 119 |
tracePath, |
| 114 |
"OutputBytes", |
120 |
"OutputBytes", |
| 115 |
"Packet Byte Count", |
121 |
"Packet Byte Count", |
| 116 |
GnuplotAggregator::KEY_BELOW); |
122 |
GnuplotAggregator::KEY_BELOW); |
| 117 |
|
123 |
|
| 118 |
Note that the path specified may contain wildcards. In this case, multiple |
124 |
In this example, the ``probeType`` and ``tracePath`` are as follows (for IPv4): |
|
|
125 |
|
| 126 |
:: |
| 127 |
|
| 128 |
probeType = "ns3::Ipv4PacketProbe"; |
| 129 |
tracePath = "/NodeList/*/$ns3::Ipv4L3Protocol/Tx"; |
| 130 |
|
| 131 |
The probeType is a key parameter for this helper to work. This TypeId |
| 132 |
must be registered in the system, and the signature on the Probe's trace |
| 133 |
sink must match that of the trace source it is being hooked to. Probe |
| 134 |
types are pre-defined for a number of data types corresponding to |ns3| |
| 135 |
traced values, and for a few other trace source signatures such as the |
| 136 |
'Tx' trace source of ``ns3::Ipv4L3Protocol`` class. |
| 137 |
|
| 138 |
Note that the trace source path specified may contain wildcards. |
| 139 |
In this case, multiple |
| 119 |
datasets are plotted on one plot; one for each matched path. |
140 |
datasets are plotted on one plot; one for each matched path. |
| 120 |
|
141 |
|
| 121 |
The main output produced will be three files: |
142 |
The main output produced will be three files: |
|
|
| 224 |
| Argument | Description | |
245 |
| Argument | Description | |
| 225 |
+==================+==============================+ |
246 |
+==================+==============================+ |
| 226 |
| typeId | The type ID for the probe | |
247 |
| typeId | The type ID for the probe | |
| 227 |
| | used when it is created. | |
248 |
| | created by this helper. | |
| 228 |
+------------------+------------------------------+ |
249 |
+------------------+------------------------------+ |
| 229 |
| path | Config path to access the | |
250 |
| path | Config path to access the | |
| 230 |
| | probe. | |
251 |
| | trace source. | |
| 231 |
+------------------+------------------------------+ |
252 |
+------------------+------------------------------+ |
| 232 |
| probeTraceSource | The probe trace source to | |
253 |
| probeTraceSource | The probe trace source to | |
| 233 |
| | access. | |
254 |
| | access. | |
|
|
| 242 |
|
263 |
|
| 243 |
The GnuplotHelper's ``PlotProbe()`` function |
264 |
The GnuplotHelper's ``PlotProbe()`` function |
| 244 |
plots a dataset generated by hooking the |ns3| trace source with a |
265 |
plots a dataset generated by hooking the |ns3| trace source with a |
| 245 |
probe, and then plotting the values from the probeTraceSource. |
266 |
probe created by the helper, and then plotting the values from the |
|
|
267 |
probeTraceSource. |
| 246 |
The dataset will have the provided title, and will consist of |
268 |
The dataset will have the provided title, and will consist of |
| 247 |
the 'newValue' at each timestamp. |
269 |
the 'newValue' at each timestamp. |
| 248 |
|
270 |
|
|
|
| 256 |
possible as labels for the datasets that are plotted. |
278 |
possible as labels for the datasets that are plotted. |
| 257 |
|
279 |
|
| 258 |
An example of how to use this function can be seen in the |
280 |
An example of how to use this function can be seen in the |
| 259 |
``seventh.cc`` code described above where it was used as follows: |
281 |
``seventh.cc`` code described above where it was used (with |
|
|
282 |
variable substitution) as follows: |
| 260 |
|
283 |
|
| 261 |
:: |
284 |
:: |
| 262 |
|
285 |
|
|
|
| 273 |
~~~~~~~~~~~~~~~~~~~~~~ |
296 |
~~~~~~~~~~~~~~~~~~~~~~ |
| 274 |
|
297 |
|
| 275 |
A slightly simpler example than the ``seventh.cc`` example can be |
298 |
A slightly simpler example than the ``seventh.cc`` example can be |
| 276 |
found in ``src/stats/examples/gnuplot-helper-example.cc``. It |
299 |
found in ``src/stats/examples/gnuplot-helper-example.cc``. The |
| 277 |
is more of a toy example than ``seventh.cc`` because it has |
300 |
following 2-D gnuplot was created using the example. |
| 278 |
a made-up trace source created for demonstration purposes. |
|
|
| 279 |
|
| 280 |
The following 2-D gnuplot was created using the example. |
| 281 |
|
301 |
|
| 282 |
.. _gnuplot-helper-example: |
302 |
.. _gnuplot-helper-example: |
| 283 |
|
303 |
|
|
|
| 286 |
2-D Gnuplot Created by gnuplot-helper-example.cc Example. |
306 |
2-D Gnuplot Created by gnuplot-helper-example.cc Example. |
| 287 |
|
307 |
|
| 288 |
In this example, there is an Emitter object that increments |
308 |
In this example, there is an Emitter object that increments |
| 289 |
its counter at various random times and then emits the counter's |
309 |
its counter according to a Poisson process and then emits the counter's |
| 290 |
value as a trace source. |
310 |
value as a trace source. |
| 291 |
|
311 |
|
| 292 |
:: |
312 |
:: |
|
|
| 294 |
Ptr<Emitter> emitter = CreateObject<Emitter> (); |
314 |
Ptr<Emitter> emitter = CreateObject<Emitter> (); |
| 295 |
Names::Add ("/Names/Emitter", emitter); |
315 |
Names::Add ("/Names/Emitter", emitter); |
| 296 |
|
316 |
|
| 297 |
The following code is probing the Counter exported by the |
|
|
| 298 |
emitter object. This DoubleProbe is using a path in the |
| 299 |
configuration namespace to make the connection. Note that |
| 300 |
the emitter registered itself in the configuration namespace |
| 301 |
after it was created; otherwise, the ConnectByPath would not work. |
| 302 |
|
| 303 |
:: |
| 304 |
|
| 305 |
Ptr<DoubleProbe> probe = CreateObject<DoubleProbe> (); |
| 306 |
probe->SetName ("PathProbe"); |
| 307 |
Names::Add ("/Names/Probe", probe); |
| 308 |
|
| 309 |
// Note, no return value is checked here. |
| 310 |
probe->ConnectByPath ("/Names/Emitter/Counter"); |
| 311 |
|
| 312 |
Note that because there are no wildcards in the path |
317 |
Note that because there are no wildcards in the path |
| 313 |
used below, only 1 datastream was drawn in the plot. |
318 |
used below, only 1 datastream was drawn in the plot. |
| 314 |
This single datastream in the plot is simply labeled |
319 |
This single datastream in the plot is simply labeled |
| 315 |
"Emitter Count", with no extra suffixes like you would |
320 |
"Emitter Count", with no extra suffixes like one would |
| 316 |
see if there were wildcards in the path. |
321 |
see if there were wildcards in the path. |
| 317 |
|
322 |
|
| 318 |
:: |
323 |
:: |
|
|
| 329 |
|
334 |
|
| 330 |
// Plot the values generated by the probe. The path that we provide |
335 |
// Plot the values generated by the probe. The path that we provide |
| 331 |
// helps to disambiguate the source of the trace. |
336 |
// helps to disambiguate the source of the trace. |
| 332 |
plotHelper.PlotProbe ("ns3::DoubleProbe", |
337 |
plotHelper.PlotProbe ("ns3::Uinteger32Probe", |
| 333 |
"/Names/Probe/Output", |
338 |
"/Names/Emitter/Counter", |
| 334 |
"Output", |
339 |
"Output", |
| 335 |
"Emitter Count", |
340 |
"Emitter Count", |
| 336 |
GnuplotAggregator::KEY_INSIDE); |
341 |
GnuplotAggregator::KEY_INSIDE); |
|
|
| 492 |
| Argument | Description | |
497 |
| Argument | Description | |
| 493 |
+==================+==============================+ |
498 |
+==================+==============================+ |
| 494 |
| typeId | The type ID for the probe | |
499 |
| typeId | The type ID for the probe | |
| 495 |
| | used when it is created. | |
500 |
| | to be created. | |
| 496 |
+------------------+------------------------------+ |
501 |
+------------------+------------------------------+ |
| 497 |
| path | Config path to access the | |
502 |
| path | Config path to access the | |
| 498 |
| | probe. | |
503 |
| | trace source. | |
| 499 |
+------------------+------------------------------+ |
504 |
+------------------+------------------------------+ |
| 500 |
| probeTraceSource | The probe trace source to | |
505 |
| probeTraceSource | The probe trace source to | |
| 501 |
| | access. | |
506 |
| | access. | |
|
|
| 503 |
|
508 |
|
| 504 |
The FileHelper's ``WriteProbe()`` function |
509 |
The FileHelper's ``WriteProbe()`` function |
| 505 |
creates output text files generated by hooking the ns-3 trace source |
510 |
creates output text files generated by hooking the ns-3 trace source |
| 506 |
with a probe, and then writing the values from the |
511 |
with a probe created by the helper, and then writing the values from the |
| 507 |
probeTraceSource. The output file names will have the text stored |
512 |
probeTraceSource. The output file names will have the text stored |
| 508 |
in the member variable m_outputFileNameWithoutExtension plus ".txt", |
513 |
in the member variable m_outputFileNameWithoutExtension plus ".txt", |
| 509 |
and will consist of the 'newValue' at each timestamp. |
514 |
and will consist of the 'newValue' at each timestamp. |
|
|
| 537 |
|
542 |
|
| 538 |
A slightly simpler example than the ``seventh.cc`` example can be |
543 |
A slightly simpler example than the ``seventh.cc`` example can be |
| 539 |
found in ``src/stats/examples/file-helper-example.cc``. |
544 |
found in ``src/stats/examples/file-helper-example.cc``. |
| 540 |
This example only uses the FileHelper, not the FileHelper. It |
545 |
This example only uses the FileHelper. |
| 541 |
is also more of a toy example than ``seventh.cc`` because it has |
|
|
| 542 |
a made-up trace source created for demonstration purposes. |
| 543 |
|
546 |
|
| 544 |
The following text file with 2 columns of formatted values named |
547 |
The following text file with 2 columns of formatted values named |
| 545 |
``file-helper-example.txt`` was created using the example. |
548 |
``file-helper-example.txt`` was created using the example. |
|
|
| 547 |
|
550 |
|
| 548 |
.. sourcecode:: text |
551 |
.. sourcecode:: text |
| 549 |
|
552 |
|
| 550 |
Time (Seconds) = 4.995e-01 Count = 1 |
553 |
Time (Seconds) = 0.203 Count = 1 |
| 551 |
Time (Seconds) = 1.463e+00 Count = 2 |
554 |
Time (Seconds) = 0.702 Count = 2 |
| 552 |
Time (Seconds) = 1.678e+00 Count = 3 |
555 |
Time (Seconds) = 1.404 Count = 3 |
| 553 |
Time (Seconds) = 3.972e+00 Count = 4 |
556 |
Time (Seconds) = 2.368 Count = 4 |
| 554 |
Time (Seconds) = 4.150e+00 Count = 5 |
557 |
Time (Seconds) = 3.364 Count = 5 |
| 555 |
Time (Seconds) = 8.066e+00 Count = 6 |
558 |
Time (Seconds) = 3.579 Count = 6 |
| 556 |
Time (Seconds) = 8.731e+00 Count = 7 |
559 |
Time (Seconds) = 5.873 Count = 7 |
| 557 |
Time (Seconds) = 9.807e+00 Count = 8 |
560 |
Time (Seconds) = 6.410 Count = 8 |
| 558 |
Time (Seconds) = 1.078e+01 Count = 9 |
561 |
Time (Seconds) = 6.472 Count = 9 |
| 559 |
Time (Seconds) = 1.083e+01 Count = 10 |
|
|
| 560 |
|
| 561 |
... |
562 |
... |
| 562 |
|
563 |
|
| 563 |
In this example, there is an Emitter object that increments |
564 |
In this example, there is an Emitter object that increments |
| 564 |
its counter at various random times and then emits the counter's |
565 |
its counter according to a Poisson process and then emits the counter's |
| 565 |
value as a trace source. |
566 |
value as a trace source. |
| 566 |
|
567 |
|
| 567 |
:: |
568 |
:: |
|
|
| 569 |
Ptr<Emitter> emitter = CreateObject<Emitter> (); |
570 |
Ptr<Emitter> emitter = CreateObject<Emitter> (); |
| 570 |
Names::Add ("/Names/Emitter", emitter); |
571 |
Names::Add ("/Names/Emitter", emitter); |
| 571 |
|
572 |
|
| 572 |
The following code is probing the Counter exported by the |
|
|
| 573 |
emitter object. This DoubleProbe is using a path in the |
| 574 |
configuration namespace to make the connection. Note that |
| 575 |
the emitter registered itself in the configuration namespace |
| 576 |
after it was created; otherwise, the ConnectByPath would not work. |
| 577 |
|
| 578 |
:: |
| 579 |
|
| 580 |
Ptr<DoubleProbe> probe = CreateObject<DoubleProbe> (); |
| 581 |
probe->SetName ("PathProbe"); |
| 582 |
Names::Add ("/Names/Probe", probe); |
| 583 |
|
| 584 |
// Note, no return value is checked here. |
| 585 |
probe->ConnectByPath ("/Names/Emitter/Counter"); |
| 586 |
|
| 587 |
Note that because there are no wildcards in the path |
573 |
Note that because there are no wildcards in the path |
| 588 |
used below, only 1 text file was created. |
574 |
used below, only 1 text file was created. |
| 589 |
This single text file is simply named |
575 |
This single text file is simply named |
|
|
| 604 |
|
590 |
|
| 605 |
// Write the values generated by the probe. The path that we |
591 |
// Write the values generated by the probe. The path that we |
| 606 |
// provide helps to disambiguate the source of the trace. |
592 |
// provide helps to disambiguate the source of the trace. |
| 607 |
fileHelper.WriteProbe ("ns3::DoubleProbe", |
593 |
fileHelper.WriteProbe ("ns3::Uinteger32Probe", |
| 608 |
"/Names/Probe/Output", |
594 |
"/Names/Emitter/Counter", |
| 609 |
"Output"); |
595 |
"Output"); |
| 610 |
|
596 |
|
| 611 |
Scope and Limitations |
597 |
Scope and Limitations |
|
|
| 623 |
- ApplicationPacketProbe |
609 |
- ApplicationPacketProbe |
| 624 |
- Ipv4PacketProbe |
610 |
- Ipv4PacketProbe |
| 625 |
|
611 |
|
| 626 |
These Probes, therefore, are the only ones available to be used |
612 |
These Probes, therefore, are the only TypeIds available to be used |
| 627 |
in ``PlotProbe()`` and ``WriteProbe()``. |
613 |
in ``PlotProbe()`` and ``WriteProbe()``. |
| 628 |
|
614 |
|
| 629 |
In the next few sections, we cover each of the fundamental object |
615 |
In the next few sections, we cover each of the fundamental object |