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