A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
gnuplot-aggregator-example.cc
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2013 University of Washington
4
*
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License version 2 as
7
* published by the Free Software Foundation;
8
*
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
*
18
* Author: Mitch Watrous (watrous@u.washington.edu)
19
*/
20
21
#include "ns3/core-module.h"
22
#include "ns3/stats-module.h"
23
24
using namespace
ns3
;
25
26
namespace
{
27
31
void
Create2dPlot
()
32
{
33
std::string fileNameWithoutExtension =
"gnuplot-aggregator"
;
34
std::string plotTitle =
"Gnuplot Aggregator Plot"
;
35
std::string plotXAxisHeading =
"Time (seconds)"
;
36
std::string plotYAxisHeading =
"Double Values"
;
37
std::string plotDatasetLabel =
"Data Values"
;
38
std::string datasetContext =
"Dataset/Context/String"
;
39
40
// Create an aggregator.
41
Ptr<GnuplotAggregator>
aggregator =
42
CreateObject<GnuplotAggregator> (fileNameWithoutExtension);
43
44
// Set the aggregator's properties.
45
aggregator->SetTerminal (
"png"
);
46
aggregator->SetTitle (plotTitle);
47
aggregator->SetLegend (plotXAxisHeading, plotYAxisHeading);
48
49
// Add a data set to the aggregator.
50
aggregator->Add2dDataset (datasetContext, plotDatasetLabel);
51
52
// aggregator must be turned on
53
aggregator->Enable ();
54
55
double
time;
56
double
value;
57
58
// Create the 2-D dataset.
59
for
(time = -5.0; time <= +5.0; time += 1.0)
60
{
61
// Calculate the 2-D curve
62
//
63
// 2
64
// value = time .
65
//
66
value = time * time;
67
68
// Add this point to the plot.
69
aggregator->Write2d (datasetContext, time, value);
70
}
71
72
// Disable logging of data for the aggregator.
73
aggregator->Disable ();
74
}
75
76
77
}
// unnamed namespace
78
79
80
int
main (
int
argc,
char
*argv[])
81
{
82
Create2dPlot
();
83
84
return
0;
85
}
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition:
ptr.h:74
anonymous_namespace{gnuplot-aggregator-example.cc}::Create2dPlot
void Create2dPlot()
This function creates a 2-Dimensional plot.
Definition:
gnuplot-aggregator-example.cc:31
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
src
stats
examples
gnuplot-aggregator-example.cc
Generated on Sat May 28 2022 18:23:05 for ns-3 by
1.9.3