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
packet-probe.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2011 Bucknell University
3
*
4
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Authors: L. Felipe Perrone (perrone@bucknell.edu)
7
* Tiago G. Rodrigues (tgr002@bucknell.edu)
8
*
9
* Modified by: Mitch Watrous (watrous@u.washington.edu)
10
*/
11
12
#ifndef PACKET_PROBE_H
13
#define PACKET_PROBE_H
14
15
#include "ns3/boolean.h"
16
#include "ns3/callback.h"
17
#include "ns3/nstime.h"
18
#include "ns3/object.h"
19
#include "ns3/packet.h"
20
#include "ns3/probe.h"
21
#include "ns3/simulator.h"
22
#include "ns3/traced-value.h"
23
24
namespace
ns3
25
{
26
27
/**
28
* This class is designed to probe an underlying ns3 TraceSource
29
* exporting a packet. This probe exports a trace source "Output"
30
* with argument of type Ptr<const Packet>. This probe exports
31
* another trace source "OutputBytes" with arguments of type uint32_t,
32
* which is the number of bytes in the packet. The trace sources emit
33
* values when either the probed trace source emits a new value, or
34
* when SetValue () is called.
35
*/
36
class
PacketProbe
:
public
Probe
37
{
38
public
:
39
/**
40
* \brief Get the type ID.
41
* \return the object TypeId
42
*/
43
static
TypeId
GetTypeId
();
44
PacketProbe
();
45
~PacketProbe
()
override
;
46
47
/**
48
* \brief Set a probe value
49
*
50
* \param packet set the traced packet equal to this
51
*/
52
void
SetValue
(
Ptr<const Packet>
packet);
53
54
/**
55
* \brief Set a probe value by its name in the Config system
56
*
57
* \param path config path to access the probe
58
* \param packet set the traced packet equal to this
59
*/
60
static
void
SetValueByPath
(std::string path,
Ptr<const Packet>
packet);
61
62
/**
63
* \brief connect to a trace source attribute provided by a given object
64
*
65
* \param traceSource the name of the attribute TraceSource to connect to
66
* \param obj ns3::Object to connect to
67
* \return true if the trace source was successfully connected
68
*/
69
bool
ConnectByObject
(std::string traceSource,
Ptr<Object>
obj)
override
;
70
71
/**
72
* \brief connect to a trace source provided by a config path
73
*
74
* \param path Config path to bind to
75
*
76
* Note, if an invalid path is provided, the probe will not be connected
77
* to anything.
78
*/
79
void
ConnectByPath
(std::string path)
override
;
80
81
private
:
82
/**
83
* \brief Method to connect to an underlying ns3::TraceSource with
84
* arguments of type Ptr<const Packet>
85
*
86
* \param packet the traced packet
87
*/
88
void
TraceSink
(
Ptr<const Packet>
packet);
89
90
/// Traced callback: packet received
91
TracedCallback<Ptr<const Packet>
>
m_output
;
92
/// Traced callback: size of previous packet receive, size of actual packet received
93
TracedCallback<uint32_t, uint32_t>
m_outputBytes
;
94
95
/// The traced packet.
96
Ptr<const Packet>
m_packet
;
97
98
/// The size of the traced packet.
99
uint32_t
m_packetSizeOld
;
100
};
101
102
}
// namespace ns3
103
104
#endif
// PACKET_PROBE_H
ns3::PacketProbe
This class is designed to probe an underlying ns3 TraceSource exporting a packet.
Definition
packet-probe.h:37
ns3::PacketProbe::~PacketProbe
~PacketProbe() override
Definition
packet-probe.cc:51
ns3::PacketProbe::m_outputBytes
TracedCallback< uint32_t, uint32_t > m_outputBytes
Traced callback: size of previous packet receive, size of actual packet received.
Definition
packet-probe.h:93
ns3::PacketProbe::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition
packet-probe.cc:28
ns3::PacketProbe::TraceSink
void TraceSink(Ptr< const Packet > packet)
Method to connect to an underlying ns3::TraceSource with arguments of type Ptr<const Packet>
Definition
packet-probe.cc:97
ns3::PacketProbe::ConnectByObject
bool ConnectByObject(std::string traceSource, Ptr< Object > obj) override
connect to a trace source attribute provided by a given object
Definition
packet-probe.cc:78
ns3::PacketProbe::PacketProbe
PacketProbe()
Definition
packet-probe.cc:45
ns3::PacketProbe::SetValueByPath
static void SetValueByPath(std::string path, Ptr< const Packet > packet)
Set a probe value by its name in the Config system.
Definition
packet-probe.cc:69
ns3::PacketProbe::m_packetSizeOld
uint32_t m_packetSizeOld
The size of the traced packet.
Definition
packet-probe.h:99
ns3::PacketProbe::ConnectByPath
void ConnectByPath(std::string path) override
connect to a trace source provided by a config path
Definition
packet-probe.cc:89
ns3::PacketProbe::m_output
TracedCallback< Ptr< const Packet > > m_output
Traced callback: packet received.
Definition
packet-probe.h:91
ns3::PacketProbe::SetValue
void SetValue(Ptr< const Packet > packet)
Set a probe value.
Definition
packet-probe.cc:57
ns3::PacketProbe::m_packet
Ptr< const Packet > m_packet
The traced packet.
Definition
packet-probe.h:96
ns3::Probe
Base class for probes.
Definition
probe.h:30
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition
mpi-test-fixtures.h:37
ns3::TracedCallback
Forward calls to a chain of Callback.
Definition
traced-callback.h:43
ns3::TypeId
a unique identifier for an interface.
Definition
type-id.h:48
uint32_t
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
src
network
utils
packet-probe.h
Generated on Fri Nov 8 2024 13:59:05 for ns-3 by
1.11.0