A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
Loading...
Searching...
No Matches
gnuplot-aggregator-example.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2013 University of Washington
3
*
4
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Author: Mitch Watrous (watrous@u.washington.edu)
7
*/
8
9
#include "ns3/core-module.h"
10
#include "ns3/stats-module.h"
11
12
using namespace
ns3
;
13
14
namespace
15
{
16
17
/**
18
* This function creates a 2-Dimensional plot.
19
*/
20
void
21
Create2dPlot
()
22
{
23
std::string
fileNameWithoutExtension
=
"gnuplot-aggregator"
;
24
std::string
plotTitle
=
"Gnuplot Aggregator Plot"
;
25
std::string
plotXAxisHeading
=
"Time (seconds)"
;
26
std::string
plotYAxisHeading
=
"Double Values"
;
27
std::string
plotDatasetLabel
=
"Data Values"
;
28
std::string
datasetContext
=
"Dataset/Context/String"
;
29
30
// Create an aggregator.
31
Ptr<GnuplotAggregator>
aggregator =
CreateObject<GnuplotAggregator>
(
fileNameWithoutExtension
);
32
33
// Set the aggregator's properties.
34
aggregator->SetTerminal(
"png"
);
35
aggregator->SetTitle(
plotTitle
);
36
aggregator->SetLegend(
plotXAxisHeading
,
plotYAxisHeading
);
37
38
// Add a data set to the aggregator.
39
aggregator->Add2dDataset(
datasetContext
,
plotDatasetLabel
);
40
41
// aggregator must be turned on
42
aggregator->Enable();
43
44
double
time;
45
double
value
;
46
47
// Create the 2-D dataset.
48
for
(time = -5.0; time <= +5.0; time += 1.0)
49
{
50
// Calculate the 2-D curve
51
//
52
// 2
53
// value = time .
54
//
55
value
= time * time;
56
57
// Add this point to the plot.
58
aggregator->Write2d(
datasetContext
, time,
value
);
59
}
60
61
// Disable logging of data for the aggregator.
62
aggregator->Disable();
63
}
64
65
}
// unnamed namespace
66
67
int
68
main(
int
argc
,
char
*
argv
[])
69
{
70
Create2dPlot
();
71
72
return
0;
73
}
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition
ptr.h:66
ns3::Create
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Definition
ptr.h:436
anonymous_namespace{gnuplot-aggregator-example.cc}::Create2dPlot
void Create2dPlot()
This function creates a 2-Dimensional plot.
Definition
gnuplot-aggregator-example.cc:21
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::value
static unsigned int value(char c)
Definition
qkd-encryptor.cc:267
src
stats
examples
gnuplot-aggregator-example.cc
Generated on Mon Dec 15 2025 15:22:04 for ns-3 by
1.9.8