A Discrete-Event Network Simulator
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
24namespace 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 */
36class PacketProbe : public Probe
37{
38 public:
39 /**
40 * \brief Get the type ID.
41 * \return the object TypeId
42 */
43 static TypeId GetTypeId();
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
92 /// Traced callback: size of previous packet receive, size of actual packet received
94
95 /// The traced packet.
97
98 /// The size of the traced packet.
100};
101
102} // namespace ns3
103
104#endif // PACKET_PROBE_H
This class is designed to probe an underlying ns3 TraceSource exporting a packet.
~PacketProbe() override
TracedCallback< uint32_t, uint32_t > m_outputBytes
Traced callback: size of previous packet receive, size of actual packet received.
static TypeId GetTypeId()
Get the type ID.
void TraceSink(Ptr< const Packet > packet)
Method to connect to an underlying ns3::TraceSource with arguments of type Ptr<const Packet>
bool ConnectByObject(std::string traceSource, Ptr< Object > obj) override
connect to a trace source attribute provided by a given object
static void SetValueByPath(std::string path, Ptr< const Packet > packet)
Set a probe value by its name in the Config system.
uint32_t m_packetSizeOld
The size of the traced packet.
void ConnectByPath(std::string path) override
connect to a trace source provided by a config path
TracedCallback< Ptr< const Packet > > m_output
Traced callback: packet received.
void SetValue(Ptr< const Packet > packet)
Set a probe value.
Ptr< const Packet > m_packet
The traced packet.
Base class for probes.
Definition probe.h:30
Smart pointer class similar to boost::intrusive_ptr.
Forward calls to a chain of Callback.
a unique identifier for an interface.
Definition type-id.h:48
Every class exported by the ns3 library is enclosed in the ns3 namespace.