author | Pedro Silva <pmms@inesctec.pt> |
Wed, 29 Oct 2014 10:12:53 -0700 | |
changeset 11040 | cd2eda848730 |
parent 10440 | 1e48ff9185f1 |
child 11045 | 6024c150e4c8 |
permissions | -rw-r--r-- |
10118
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
2 |
/* |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
3 |
* Copyright (c) 2011 Bucknell University |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
4 |
* |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
5 |
* This program is free software; you can redistribute it and/or modify |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
6 |
* it under the terms of the GNU General Public License version 2 as |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation; |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
8 |
* |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
12 |
* GNU General Public License for more details. |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
13 |
* |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
14 |
* You should have received a copy of the GNU General Public License |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
15 |
* along with this program; if not, write to the Free Software |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
16 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
17 |
* |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
18 |
* Authors: L. Felipe Perrone (perrone@bucknell.edu) |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
19 |
* Tiago G. Rodrigues (tgr002@bucknell.edu) |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
20 |
* |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
21 |
* Modified by: Mitch Watrous (watrous@u.washington.edu) |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
22 |
*/ |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
23 |
|
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
24 |
#ifndef IPV4_PACKET_PROBE_H |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
25 |
#define IPV4_PACKET_PROBE_H |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
26 |
|
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
27 |
#include "ns3/object.h" |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
28 |
#include "ns3/callback.h" |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
29 |
#include "ns3/boolean.h" |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
30 |
#include "ns3/nstime.h" |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
31 |
#include "ns3/packet.h" |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
32 |
#include "ns3/ipv4.h" |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
33 |
#include "ns3/traced-value.h" |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
34 |
#include "ns3/simulator.h" |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
35 |
#include "ns3/probe.h" |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
36 |
|
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
37 |
namespace ns3 { |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
38 |
|
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
39 |
/** |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
40 |
* This class is designed to probe an underlying ns3 TraceSource |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
41 |
* exporting a packet, an IPv4 object, and an interface. This probe |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
42 |
* exports a trace source "Output" with arguments of type Ptr<const Packet>, |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
43 |
* Ptr<Ipv4>, and uint32_t. The Output trace source emits a value |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
44 |
* when either the trace source emits a new value, or when SetValue () |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
45 |
* is called. |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
46 |
*/ |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
47 |
class Ipv4PacketProbe : public Probe |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
48 |
{ |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
49 |
public: |
10440
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10118
diff
changeset
|
50 |
/** |
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10118
diff
changeset
|
51 |
* \brief Get the type ID. |
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10118
diff
changeset
|
52 |
* \return the object TypeId |
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10118
diff
changeset
|
53 |
*/ |
10118
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
54 |
static TypeId GetTypeId (); |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
55 |
Ipv4PacketProbe (); |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
56 |
virtual ~Ipv4PacketProbe (); |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
57 |
|
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
58 |
/** |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
59 |
* \brief Set a probe value |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
60 |
* |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
61 |
* \param packet set the traced packet equal to this |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
62 |
* \param ipv4 set the IPv4 object for the traced packet equal to this |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
63 |
* \param interface set the IPv4 interface for the traced packet equal to this |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
64 |
*/ |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
65 |
void SetValue (Ptr<const Packet> packet, Ptr<Ipv4> ipv4, uint32_t interface); |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
66 |
|
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
67 |
/** |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
68 |
* \brief Set a probe value by its name in the Config system |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
69 |
* |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
70 |
* \param path config path to access the probe |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
71 |
* \param packet set the traced packet equal to this |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
72 |
* \param ipv4 set the IPv4 object for the traced packet equal to this |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
73 |
* \param interface set the IPv4 interface for the traced packet equal to this |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
74 |
*/ |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
75 |
static void SetValueByPath (std::string path, Ptr<const Packet> packet, Ptr<Ipv4> ipv4, uint32_t interface); |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
76 |
|
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
77 |
/** |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
78 |
* \brief connect to a trace source attribute provided by a given object |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
79 |
* |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
80 |
* \param traceSource the name of the attribute TraceSource to connect to |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
81 |
* \param obj ns3::Object to connect to |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
82 |
* \return true if the trace source was successfully connected |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
83 |
*/ |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
84 |
virtual bool ConnectByObject (std::string traceSource, Ptr<Object> obj); |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
85 |
|
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
86 |
/** |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
87 |
* \brief connect to a trace source provided by a config path |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
88 |
* |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
89 |
* \param path Config path to bind to |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
90 |
* |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
91 |
* Note, if an invalid path is provided, the probe will not be connected |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
92 |
* to anything. |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
93 |
*/ |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
94 |
virtual void ConnectByPath (std::string path); |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
95 |
|
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
96 |
private: |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
97 |
/** |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
98 |
* \brief Method to connect to an underlying ns3::TraceSource with |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
99 |
* arguments of type Ptr<const Packet>, Ptr<Ipv4>, and uint32_t |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
100 |
* |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
101 |
* \param packet the traced packet |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
102 |
* \param ipv4 the IPv4 object for the traced packet |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
103 |
* \param interface the IPv4 interface for the traced packet |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
104 |
* |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
105 |
* \internal |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
106 |
*/ |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
107 |
void TraceSink (Ptr<const Packet> packet, Ptr<Ipv4> ipv4, uint32_t interface); |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
108 |
|
10440
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10118
diff
changeset
|
109 |
/// Traced Callback: the packet, the Ipv4 object and the interface. |
10118
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
110 |
TracedCallback<Ptr<const Packet>, Ptr<Ipv4>, uint32_t> m_output; |
10440
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10118
diff
changeset
|
111 |
/// Traced Callback: the previous packet's size and the actual packet's size. |
10118
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
112 |
TracedCallback<uint32_t, uint32_t> m_outputBytes; |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
113 |
|
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
114 |
/// The traced packet. |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
115 |
Ptr<const Packet> m_packet; |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
116 |
|
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
117 |
/// The IPv4 object for the traced packet. |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
118 |
Ptr<Ipv4> m_ipv4; |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
119 |
|
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
120 |
/// The IPv4 interface for the traced packet. |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
121 |
uint32_t m_interface; |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
122 |
|
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
123 |
/// The size of the traced packet. |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
124 |
uint32_t m_packetSizeOld; |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
125 |
}; |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
126 |
|
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
127 |
|
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
128 |
} // namespace ns3 |
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
129 |
|
848770c90669
data collection extensions for stats module
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
130 |
#endif // IPV4_PACKET_PROBE_H |