A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ipv4-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 IPV4_PACKET_PROBE_H
13#define IPV4_PACKET_PROBE_H
14
15#include "ipv4.h"
16
17#include "ns3/boolean.h"
18#include "ns3/callback.h"
19#include "ns3/nstime.h"
20#include "ns3/object.h"
21#include "ns3/packet.h"
22#include "ns3/probe.h"
23#include "ns3/simulator.h"
24#include "ns3/traced-value.h"
25
26namespace ns3
27{
28
29/**
30 * \ingroup ipv4
31 *
32 * This class is designed to probe an underlying ns3 TraceSource
33 * exporting a packet, an IPv4 object, and an interface. This probe
34 * exports a trace source "Output" with arguments of type Ptr<const Packet>,
35 * Ptr<Ipv4>, and uint32_t. The Output trace source emits a value
36 * when either the trace source emits a new value, or when SetValue ()
37 * is called.
38 */
39class Ipv4PacketProbe : public Probe
40{
41 public:
42 /**
43 * \brief Get the type ID.
44 * \return the object TypeId
45 */
46 static TypeId GetTypeId();
48 ~Ipv4PacketProbe() override;
49
50 /**
51 * \brief Set a probe value
52 *
53 * \param packet set the traced packet equal to this
54 * \param ipv4 set the IPv4 object for the traced packet equal to this
55 * \param interface set the IPv4 interface for the traced packet equal to this
56 */
57 void SetValue(Ptr<const Packet> packet, Ptr<Ipv4> ipv4, uint32_t interface);
58
59 /**
60 * \brief Set a probe value by its name in the Config system
61 *
62 * \param path config path to access the probe
63 * \param packet set the traced packet equal to this
64 * \param ipv4 set the IPv4 object for the traced packet equal to this
65 * \param interface set the IPv4 interface for the traced packet equal to this
66 */
67 static void SetValueByPath(std::string path,
68 Ptr<const Packet> packet,
69 Ptr<Ipv4> ipv4,
70 uint32_t interface);
71
72 /**
73 * \brief connect to a trace source attribute provided by a given object
74 *
75 * \param traceSource the name of the attribute TraceSource to connect to
76 * \param obj ns3::Object to connect to
77 * \return true if the trace source was successfully connected
78 */
79 bool ConnectByObject(std::string traceSource, Ptr<Object> obj) override;
80
81 /**
82 * \brief connect to a trace source provided by a config path
83 *
84 * \param path Config path to bind to
85 *
86 * Note, if an invalid path is provided, the probe will not be connected
87 * to anything.
88 */
89 void ConnectByPath(std::string path) override;
90
91 private:
92 /**
93 * \brief Method to connect to an underlying ns3::TraceSource with
94 * arguments of type Ptr<const Packet>, Ptr<Ipv4>, and uint32_t
95 *
96 * \param packet the traced packet
97 * \param ipv4 the IPv4 object for the traced packet
98 * \param interface the IPv4 interface for the traced packet
99 */
100 void TraceSink(Ptr<const Packet> packet, Ptr<Ipv4> ipv4, uint32_t interface);
101
102 /// Traced Callback: the packet, the Ipv4 object and the interface.
104 /// Traced Callback: the previous packet's size and the actual packet's size.
106
107 /// The traced packet.
109
110 /// The IPv4 object for the traced packet.
112
113 /// The IPv4 interface for the traced packet.
115
116 /// The size of the traced packet.
118};
119
120} // namespace ns3
121
122#endif // IPV4_PACKET_PROBE_H
This class is designed to probe an underlying ns3 TraceSource exporting a packet, an IPv4 object,...
void ConnectByPath(std::string path) override
connect to a trace source provided by a config path
static void SetValueByPath(std::string path, Ptr< const Packet > packet, Ptr< Ipv4 > ipv4, uint32_t interface)
Set a probe value by its name in the Config system.
uint32_t m_packetSizeOld
The size of the traced packet.
ns3::TracedCallback< uint32_t, uint32_t > m_outputBytes
Traced Callback: the previous packet's size and the actual packet's size.
bool ConnectByObject(std::string traceSource, Ptr< Object > obj) override
connect to a trace source attribute provided by a given object
ns3::TracedCallback< Ptr< const Packet >, Ptr< Ipv4 >, uint32_t > m_output
Traced Callback: the packet, the Ipv4 object and the interface.
void TraceSink(Ptr< const Packet > packet, Ptr< Ipv4 > ipv4, uint32_t interface)
Method to connect to an underlying ns3::TraceSource with arguments of type Ptr<const Packet>,...
uint32_t m_interface
The IPv4 interface for the traced packet.
static TypeId GetTypeId()
Get the type ID.
void SetValue(Ptr< const Packet > packet, Ptr< Ipv4 > ipv4, uint32_t interface)
Set a probe value.
Ptr< Ipv4 > m_ipv4
The IPv4 object for the traced packet.
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.