A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ns3::GnuplotHelper Class Reference

Helper class used to make gnuplot plots. More...

#include "gnuplot-helper.h"

+ Collaboration diagram for ns3::GnuplotHelper:

Public Member Functions

 GnuplotHelper ()
 Constructs a gnuplot helper that will create a space separated gnuplot data file named "gnuplot-helper.dat", a gnuplot control file named "gnuplot-helper.plt", and a shell script to generate the gnuplot named "gnuplot-helper.sh" unless it is later configured otherwise.
 
 GnuplotHelper (const std::string &outputFileNameWithoutExtension, const std::string &title, const std::string &xLegend, const std::string &yLegend, const std::string &terminalType="png")
 
virtual ~GnuplotHelper ()
 
void AddTimeSeriesAdaptor (const std::string &adaptorName)
 Adds a time series adaptor to be used to make the plot.
 
void ConfigurePlot (const std::string &outputFileNameWithoutExtension, const std::string &title, const std::string &xLegend, const std::string &yLegend, const std::string &terminalType="png")
 
Ptr< GnuplotAggregatorGetAggregator ()
 Gets the aggregator.
 
Ptr< ProbeGetProbe (std::string probeName) const
 Gets the specified probe.
 
void PlotProbe (const std::string &typeId, const std::string &path, const std::string &probeTraceSource, const std::string &title, GnuplotAggregator::KeyLocation keyLocation=GnuplotAggregator::KEY_INSIDE)
 

Private Member Functions

void AddProbe (const std::string &typeId, const std::string &probeName, const std::string &path)
 Adds a probe to be used to make the plot.
 
void ConnectProbeToAggregator (const std::string &typeId, const std::string &matchIdentifier, const std::string &path, const std::string &probeTraceSource, const std::string &title)
 Connects the probe to the aggregator.
 
void ConstructAggregator ()
 Constructs the aggregator.
 

Private Attributes

Ptr< GnuplotAggregatorm_aggregator
 The aggregator used to make the plots.
 
ObjectFactory m_factory
 Used to create the probes and collectors as they are added.
 
std::string m_outputFileNameWithoutExtension
 The name of the output file to created without its extension.
 
uint32_t m_plotProbeCount
 Number of plot probes that have been created.
 
std::map< std::string, std::pair< Ptr< Probe >, std::string > > m_probeMap
 Maps probe names to probes.
 
std::string m_terminalType
 Terminal type for the plot.
 
std::map< std::string, Ptr< TimeSeriesAdaptor > > m_timeSeriesAdaptorMap
 Maps time series adaptor names to time series adaptors.
 
std::string m_title
 Title string to use for this plot.
 
std::string m_xLegend
 Legend for the x axis.
 
std::string m_yLegend
 Legend for the y axis.
 

Detailed Description

Helper class used to make gnuplot plots.

Definition at line 40 of file gnuplot-helper.h.

Constructor & Destructor Documentation

◆ GnuplotHelper() [1/2]

ns3::GnuplotHelper::GnuplotHelper ( )

Constructs a gnuplot helper that will create a space separated gnuplot data file named "gnuplot-helper.dat", a gnuplot control file named "gnuplot-helper.plt", and a shell script to generate the gnuplot named "gnuplot-helper.sh" unless it is later configured otherwise.

Definition at line 38 of file gnuplot-helper.cc.

References NS_LOG_FUNCTION.

◆ GnuplotHelper() [2/2]

ns3::GnuplotHelper::GnuplotHelper ( const std::string &  outputFileNameWithoutExtension,
const std::string &  title,
const std::string &  xLegend,
const std::string &  yLegend,
const std::string &  terminalType = "png" 
)
Parameters
outputFileNameWithoutExtensionname of gnuplot related files to write with no extension
titleplot title string to use for this plot.
xLegendthe legend for the x horizontal axis.
yLegendthe legend for the y vertical axis.
terminalTypeterminal type setting string for output. The default terminal type is "png"

Constructs a gnuplot helper that will create a space separated gnuplot data file named outputFileNameWithoutExtension + ".dat", a gnuplot control file named outputFileNameWithoutExtension + ".plt", and a shell script to generate the gnuplot named outputFileNameWithoutExtension + ".sh".

Definition at line 53 of file gnuplot-helper.cc.

References ConstructAggregator(), and NS_LOG_FUNCTION.

+ Here is the call graph for this function:

◆ ~GnuplotHelper()

ns3::GnuplotHelper::~GnuplotHelper ( )
virtual

Definition at line 72 of file gnuplot-helper.cc.

References NS_LOG_FUNCTION.

Member Function Documentation

◆ AddProbe()

void ns3::GnuplotHelper::AddProbe ( const std::string &  typeId,
const std::string &  probeName,
const std::string &  path 
)
private

Adds a probe to be used to make the plot.

Parameters
typeIdthe type ID for the probe used when it is created.
probeNamethe probe's name.
pathConfig path to access the probe.

Definition at line 200 of file gnuplot-helper.cc.

References ns3::ObjectFactory::Create(), ns3::Object::GetObject(), m_factory, m_probeMap, NS_ABORT_MSG, NS_LOG_FUNCTION, and ns3::ObjectFactory::SetTypeId().

Referenced by ConnectProbeToAggregator().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AddTimeSeriesAdaptor()

void ns3::GnuplotHelper::AddTimeSeriesAdaptor ( const std::string &  adaptorName)

Adds a time series adaptor to be used to make the plot.

Parameters
adaptorNamethe timeSeriesAdaptor's name.

Definition at line 236 of file gnuplot-helper.cc.

References m_timeSeriesAdaptorMap, NS_ABORT_MSG, and NS_LOG_FUNCTION.

Referenced by ConnectProbeToAggregator().

+ Here is the caller graph for this function:

◆ ConfigurePlot()

void ns3::GnuplotHelper::ConfigurePlot ( const std::string &  outputFileNameWithoutExtension,
const std::string &  title,
const std::string &  xLegend,
const std::string &  yLegend,
const std::string &  terminalType = "png" 
)
Parameters
outputFileNameWithoutExtensionname of gnuplot related files to write with no extension
titleplot title string to use for this plot.
xLegendthe legend for the x horizontal axis.
yLegendthe legend for the y vertical axis.
terminalTypeterminal type setting string for output. The default terminal type is "png"

Configures plot related parameters for this gnuplot helper so that it will create a space separated gnuplot data file named outputFileNameWithoutExtension + ".dat", a gnuplot control file named outputFileNameWithoutExtension + ".plt", and a shell script to generate the gnuplot named outputFileNameWithoutExtension + ".sh".

Definition at line 78 of file gnuplot-helper.cc.

References ConstructAggregator(), m_aggregator, m_outputFileNameWithoutExtension, m_terminalType, m_title, m_xLegend, m_yLegend, NS_LOG_FUNCTION, and NS_LOG_WARN.

+ Here is the call graph for this function:

◆ ConnectProbeToAggregator()

void ns3::GnuplotHelper::ConnectProbeToAggregator ( const std::string &  typeId,
const std::string &  matchIdentifier,
const std::string &  path,
const std::string &  probeTraceSource,
const std::string &  title 
)
private

Connects the probe to the aggregator.

Parameters
typeIdthe type ID for the probe used when it is created.
matchIdentifierthis string is used to make the probe's context be unique.
pathConfig path to access the probe.
probeTraceSourcethe probe trace source to access.
titlethe title to be associated to this dataset.

Definition at line 306 of file gnuplot-helper.cc.

References AddProbe(), AddTimeSeriesAdaptor(), GetAggregator(), m_plotProbeCount, m_probeMap, m_timeSeriesAdaptorMap, ns3::MakeCallback(), NS_FATAL_ERROR, NS_LOG_FUNCTION, ns3::TimeSeriesAdaptor::TraceSinkBoolean(), ns3::TimeSeriesAdaptor::TraceSinkDouble(), ns3::TimeSeriesAdaptor::TraceSinkUinteger16(), ns3::TimeSeriesAdaptor::TraceSinkUinteger32(), ns3::TimeSeriesAdaptor::TraceSinkUinteger8(), and ns3::GnuplotAggregator::Write2d().

Referenced by PlotProbe().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ConstructAggregator()

void ns3::GnuplotHelper::ConstructAggregator ( )
private

Constructs the aggregator.

Definition at line 289 of file gnuplot-helper.cc.

References m_aggregator, m_outputFileNameWithoutExtension, m_terminalType, m_title, m_xLegend, m_yLegend, and NS_LOG_FUNCTION.

Referenced by GnuplotHelper(), ConfigurePlot(), and GetAggregator().

+ Here is the caller graph for this function:

◆ GetAggregator()

Ptr< GnuplotAggregator > ns3::GnuplotHelper::GetAggregator ( )

Gets the aggregator.

Returns
Ptr to GnuplotAggregator object

This function is non-const because an aggregator may be lazily created by this method.

Definition at line 275 of file gnuplot-helper.cc.

References ConstructAggregator(), m_aggregator, and NS_LOG_FUNCTION.

Referenced by ConnectProbeToAggregator(), and PlotProbe().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetProbe()

Ptr< Probe > ns3::GnuplotHelper::GetProbe ( std::string  probeName) const

Gets the specified probe.

Parameters
probeNamethe probe's name.
Returns
Ptr to probe

Definition at line 257 of file gnuplot-helper.cc.

References m_probeMap, and NS_ABORT_MSG.

◆ PlotProbe()

void ns3::GnuplotHelper::PlotProbe ( const std::string &  typeId,
const std::string &  path,
const std::string &  probeTraceSource,
const std::string &  title,
GnuplotAggregator::KeyLocation  keyLocation = GnuplotAggregator::KEY_INSIDE 
)
Parameters
typeIdthe type ID for the probe used when it is created.
pathConfig path for underlying trace source to be probed
probeTraceSourcethe probe trace source to access.
titlethe title to be associated to this dataset
keyLocationthe location of the key in the plot.

Plots a dataset generated by hooking the ns-3 trace source with a probe, and then plot the values from the probeTraceSource. The dataset will have the provided title, and will consist of the 'newValue' at each timestamp.

This method will create one or more probes according to the TypeId provided, connect the probe(s) to the trace source specified by the config path, and hook the probeTraceSource(s) to the downstream aggregator.

If the config path has more than one match in the system (e.g. there is a wildcard), then one dataset for each match will be plotted. The dataset titles will be suffixed with the matched characters for each of the wildcards in the config path, separated by spaces. For example, if the proposed dataset title is the string "bytes", and there are two wildcards in the path, then dataset titles like "bytes-0 0" or "bytes-12 9" will be possible as labels for the datasets that are plotted.

Definition at line 106 of file gnuplot-helper.cc.

References ConnectProbeToAggregator(), GetAggregator(), ns3::Config::MatchContainer::GetMatchedPath(), ns3::Config::MatchContainer::GetN(), ns3::GetWildcardMatches(), ns3::Gnuplot2dDataset::LINES_POINTS, ns3::Config::LookupMatches(), m_title, NS_FATAL_ERROR, NS_LOG_DEBUG, and NS_LOG_FUNCTION.

+ Here is the call graph for this function:

Member Data Documentation

◆ m_aggregator

Ptr<GnuplotAggregator> ns3::GnuplotHelper::m_aggregator
private

The aggregator used to make the plots.

Definition at line 187 of file gnuplot-helper.h.

Referenced by ConfigurePlot(), ConstructAggregator(), and GetAggregator().

◆ m_factory

ObjectFactory ns3::GnuplotHelper::m_factory
private

Used to create the probes and collectors as they are added.

Definition at line 184 of file gnuplot-helper.h.

Referenced by AddProbe().

◆ m_outputFileNameWithoutExtension

std::string ns3::GnuplotHelper::m_outputFileNameWithoutExtension
private

The name of the output file to created without its extension.

Definition at line 199 of file gnuplot-helper.h.

Referenced by ConfigurePlot(), and ConstructAggregator().

◆ m_plotProbeCount

uint32_t ns3::GnuplotHelper::m_plotProbeCount
private

Number of plot probes that have been created.

Definition at line 196 of file gnuplot-helper.h.

Referenced by ConnectProbeToAggregator().

◆ m_probeMap

std::map<std::string, std::pair<Ptr<Probe>, std::string> > ns3::GnuplotHelper::m_probeMap
private

Maps probe names to probes.

Definition at line 190 of file gnuplot-helper.h.

Referenced by AddProbe(), ConnectProbeToAggregator(), and GetProbe().

◆ m_terminalType

std::string ns3::GnuplotHelper::m_terminalType
private

Terminal type for the plot.

Definition at line 211 of file gnuplot-helper.h.

Referenced by ConfigurePlot(), and ConstructAggregator().

◆ m_timeSeriesAdaptorMap

std::map<std::string, Ptr<TimeSeriesAdaptor> > ns3::GnuplotHelper::m_timeSeriesAdaptorMap
private

Maps time series adaptor names to time series adaptors.

Definition at line 193 of file gnuplot-helper.h.

Referenced by AddTimeSeriesAdaptor(), and ConnectProbeToAggregator().

◆ m_title

std::string ns3::GnuplotHelper::m_title
private

Title string to use for this plot.

Definition at line 202 of file gnuplot-helper.h.

Referenced by ConfigurePlot(), ConstructAggregator(), and PlotProbe().

◆ m_xLegend

std::string ns3::GnuplotHelper::m_xLegend
private

Legend for the x axis.

Definition at line 205 of file gnuplot-helper.h.

Referenced by ConfigurePlot(), and ConstructAggregator().

◆ m_yLegend

std::string ns3::GnuplotHelper::m_yLegend
private

Legend for the y axis.

Definition at line 208 of file gnuplot-helper.h.

Referenced by ConfigurePlot(), and ConstructAggregator().


The documentation for this class was generated from the following files: