|
34 |
|
34 |
|
35 |
namespace ns3 { |
35 |
namespace ns3 { |
36 |
|
36 |
|
37 |
/// \defgroup flow-monitor Flow Monitor |
37 |
/** |
38 |
/// \brief Collect and store performance data from a simulation |
38 |
* \defgroup flow-monitor Flow Monitor |
|
|
39 |
* \brief Collect and store performance data from a simulation |
40 |
*/ |
39 |
|
41 |
|
40 |
/// \ingroup flow-monitor |
42 |
/** |
41 |
/// \brief An object that monitors and reports back packet flows observed during a simulation |
43 |
* \ingroup flow-monitor |
42 |
/// |
44 |
* \brief An object that monitors and reports back packet flows observed during a simulation |
43 |
/// The FlowMonitor class is responsible forcoordinating efforts |
45 |
* |
44 |
/// regarding probes, and collects end-to-end flowstatistics. |
46 |
* The FlowMonitor class is responsible for coordinating efforts |
|
|
47 |
* regarding probes, and collects end-to-end flow statistics. |
48 |
* |
49 |
*/ |
45 |
class FlowMonitor : public Object |
50 |
class FlowMonitor : public Object |
46 |
{ |
51 |
{ |
47 |
public: |
52 |
public: |
|
81 |
/// as defined in IETF \RFC{3393}. |
86 |
/// as defined in IETF \RFC{3393}. |
82 |
Time jitterSum; // jitterCount == rxPackets - 1 |
87 |
Time jitterSum; // jitterCount == rxPackets - 1 |
83 |
|
88 |
|
|
|
89 |
/// Contains the last measured delay of a packet |
90 |
/// It is stored to measure the packet's Jitter |
84 |
Time lastDelay; |
91 |
Time lastDelay; |
85 |
|
92 |
|
86 |
/// Total number of transmitted bytes for the flow |
93 |
/// Total number of transmitted bytes for the flow |
|
127 |
/// This attribute also tracks the number of lost bytes. See also |
134 |
/// This attribute also tracks the number of lost bytes. See also |
128 |
/// comment in attribute packetsDropped. |
135 |
/// comment in attribute packetsDropped. |
129 |
std::vector<uint64_t> bytesDropped; // bytesDropped[reasonCode] => number of dropped bytes |
136 |
std::vector<uint64_t> bytesDropped; // bytesDropped[reasonCode] => number of dropped bytes |
130 |
Histogram flowInterruptionsHistogram; // histogram of durations of flow interruptions |
137 |
Histogram flowInterruptionsHistogram; //!< histogram of durations of flow interruptions |
131 |
}; |
138 |
}; |
132 |
|
139 |
|
133 |
// --- basic methods --- |
140 |
// --- basic methods --- |
|
|
141 |
/** |
142 |
* \brief Get the type ID. |
143 |
* \return the object TypeId |
144 |
*/ |
134 |
static TypeId GetTypeId (); |
145 |
static TypeId GetTypeId (); |
135 |
TypeId GetInstanceTypeId () const; |
146 |
TypeId GetInstanceTypeId () const; |
136 |
FlowMonitor (); |
147 |
FlowMonitor (); |
137 |
|
148 |
|
138 |
/// Set the FlowClassifier to be used by the flow monitor. |
149 |
/// Set the FlowClassifier to be used by the flow monitor. |
|
|
150 |
/// \param classifier the FlowClassifier |
139 |
void SetFlowClassifier (Ptr<FlowClassifier> classifier); |
151 |
void SetFlowClassifier (Ptr<FlowClassifier> classifier); |
140 |
|
152 |
|
141 |
/// Set the time, counting from the current time, from which to start monitoring flows |
153 |
/// Set the time, counting from the current time, from which to start monitoring flows. |
|
|
154 |
/// \param time delta time to start |
142 |
void Start (const Time &time); |
155 |
void Start (const Time &time); |
143 |
/// Set the time, counting from the current time, from which to stop monitoring flows |
156 |
/// Set the time, counting from the current time, from which to stop monitoring flows. |
|
|
157 |
/// \param time delta time to stop |
144 |
void Stop (const Time &time); |
158 |
void Stop (const Time &time); |
145 |
/// Begin monitoring flows *right now* |
159 |
/// Begin monitoring flows *right now* |
146 |
void StartRightNow (); |
160 |
void StartRightNow (); |
|
151 |
/// Register a new FlowProbe that will begin monitoring and report |
165 |
/// Register a new FlowProbe that will begin monitoring and report |
152 |
/// events to this monitor. This method is normally only used by |
166 |
/// events to this monitor. This method is normally only used by |
153 |
/// FlowProbe implementations. |
167 |
/// FlowProbe implementations. |
|
|
168 |
/// \param probe the probe to add |
154 |
void AddProbe (Ptr<FlowProbe> probe); |
169 |
void AddProbe (Ptr<FlowProbe> probe); |
155 |
|
170 |
|
156 |
/// FlowProbe implementations are supposed to call this method to |
171 |
/// FlowProbe implementations are supposed to call this method to |
157 |
/// report that a new packet was transmitted (but keep in mind the |
172 |
/// report that a new packet was transmitted (but keep in mind the |
158 |
/// distinction between a new packet entering the system and a |
173 |
/// distinction between a new packet entering the system and a |
159 |
/// packet that is already known and is only being forwarded). |
174 |
/// packet that is already known and is only being forwarded). |
|
|
175 |
/// \param probe the reporting probe |
176 |
/// \param flowId flow identification |
177 |
/// \param packetId Packet ID |
178 |
/// \param packetSize packet size |
160 |
void ReportFirstTx (Ptr<FlowProbe> probe, FlowId flowId, FlowPacketId packetId, uint32_t packetSize); |
179 |
void ReportFirstTx (Ptr<FlowProbe> probe, FlowId flowId, FlowPacketId packetId, uint32_t packetSize); |
161 |
/// FlowProbe implementations are supposed to call this method to |
180 |
/// FlowProbe implementations are supposed to call this method to |
162 |
/// report that a known packet is being forwarded. |
181 |
/// report that a known packet is being forwarded. |
|
|
182 |
/// \param probe the reporting probe |
183 |
/// \param flowId flow identification |
184 |
/// \param packetId Packet ID |
185 |
/// \param packetSize packet size |
163 |
void ReportForwarding (Ptr<FlowProbe> probe, FlowId flowId, FlowPacketId packetId, uint32_t packetSize); |
186 |
void ReportForwarding (Ptr<FlowProbe> probe, FlowId flowId, FlowPacketId packetId, uint32_t packetSize); |
164 |
/// FlowProbe implementations are supposed to call this method to |
187 |
/// FlowProbe implementations are supposed to call this method to |
165 |
/// report that a known packet is being received. |
188 |
/// report that a known packet is being received. |
|
|
189 |
/// \param probe the reporting probe |
190 |
/// \param flowId flow identification |
191 |
/// \param packetId Packet ID |
192 |
/// \param packetSize packet size |
166 |
void ReportLastRx (Ptr<FlowProbe> probe, FlowId flowId, FlowPacketId packetId, uint32_t packetSize); |
193 |
void ReportLastRx (Ptr<FlowProbe> probe, FlowId flowId, FlowPacketId packetId, uint32_t packetSize); |
167 |
/// FlowProbe implementations are supposed to call this method to |
194 |
/// FlowProbe implementations are supposed to call this method to |
168 |
/// report that a known packet is being dropped due to some reason. |
195 |
/// report that a known packet is being dropped due to some reason. |
|
|
196 |
/// \param probe the reporting probe |
197 |
/// \param flowId flow identification |
198 |
/// \param packetId Packet ID |
199 |
/// \param packetSize packet size |
200 |
/// \param reasonCode drop reason code |
169 |
void ReportDrop (Ptr<FlowProbe> probe, FlowId flowId, FlowPacketId packetId, |
201 |
void ReportDrop (Ptr<FlowProbe> probe, FlowId flowId, FlowPacketId packetId, |
170 |
uint32_t packetSize, uint32_t reasonCode); |
202 |
uint32_t packetSize, uint32_t reasonCode); |
171 |
|
203 |
|
|
175 |
/// Check right now for packets that appear to be lost, considering |
207 |
/// Check right now for packets that appear to be lost, considering |
176 |
/// packets as lost if not seen in the network for a time larger |
208 |
/// packets as lost if not seen in the network for a time larger |
177 |
/// than maxDelay |
209 |
/// than maxDelay |
|
|
210 |
/// \param maxDelay the max delay for a packet |
178 |
void CheckForLostPackets (Time maxDelay); |
211 |
void CheckForLostPackets (Time maxDelay); |
179 |
|
212 |
|
180 |
// --- methods to get the results --- |
213 |
// --- methods to get the results --- |
|
182 |
/// FlowMonitor has not stopped monitoring yet, you should call |
215 |
/// FlowMonitor has not stopped monitoring yet, you should call |
183 |
/// CheckForLostPackets() to make sure all possibly lost packets are |
216 |
/// CheckForLostPackets() to make sure all possibly lost packets are |
184 |
/// accounted for. |
217 |
/// accounted for. |
|
|
218 |
/// \returns the flows statistics |
185 |
std::map<FlowId, FlowStats> GetFlowStats () const; |
219 |
std::map<FlowId, FlowStats> GetFlowStats () const; |
186 |
|
220 |
|
187 |
/// Get a list of all FlowProbe's associated with this FlowMonitor |
221 |
/// Get a list of all FlowProbe's associated with this FlowMonitor |
|
|
222 |
/// \returns a list of all the probes |
188 |
std::vector< Ptr<FlowProbe> > GetAllProbes () const; |
223 |
std::vector< Ptr<FlowProbe> > GetAllProbes () const; |
189 |
|
224 |
|
190 |
/// Serializes the results to an std::ostream in XML format |
225 |
/// Serializes the results to an std::ostream in XML format |
|
213 |
|
248 |
|
214 |
private: |
249 |
private: |
215 |
|
250 |
|
|
|
251 |
/// Structure to represent a single tracked packet data |
216 |
struct TrackedPacket |
252 |
struct TrackedPacket |
217 |
{ |
253 |
{ |
218 |
Time firstSeenTime; // absolute time when the packet was first seen by a probe |
254 |
Time firstSeenTime; //!< absolute time when the packet was first seen by a probe |
219 |
Time lastSeenTime; // absolute time when the packet was last seen by a probe |
255 |
Time lastSeenTime; //!< absolute time when the packet was last seen by a probe |
220 |
uint32_t timesForwarded; // number of times the packet was reportedly forwarded |
256 |
uint32_t timesForwarded; //!< number of times the packet was reportedly forwarded |
221 |
}; |
257 |
}; |
222 |
|
258 |
|
223 |
// FlowId --> FlowStats |
259 |
/// FlowId --> FlowStats |
224 |
std::map<FlowId, FlowStats> m_flowStats; |
260 |
std::map<FlowId, FlowStats> m_flowStats; |
225 |
|
261 |
|
226 |
// (FlowId,PacketId) --> TrackedPacket |
262 |
/// (FlowId,PacketId) --> TrackedPacket |
227 |
typedef std::map< std::pair<FlowId, FlowPacketId>, TrackedPacket> TrackedPacketMap; |
263 |
typedef std::map< std::pair<FlowId, FlowPacketId>, TrackedPacket> TrackedPacketMap; |
228 |
TrackedPacketMap m_trackedPackets; |
264 |
TrackedPacketMap m_trackedPackets; //!< Tracked packets |
229 |
Time m_maxPerHopDelay; |
265 |
Time m_maxPerHopDelay; //!< Minimum per-hop delay |
230 |
std::vector< Ptr<FlowProbe> > m_flowProbes; |
266 |
std::vector< Ptr<FlowProbe> > m_flowProbes; //!< all the FlowProbes |
231 |
|
267 |
|
232 |
// note: this is needed only for serialization |
268 |
// note: this is needed only for serialization |
233 |
Ptr<FlowClassifier> m_classifier; |
269 |
Ptr<FlowClassifier> m_classifier; //!< the FlowClassifier |
234 |
|
270 |
|
235 |
EventId m_startEvent; |
271 |
EventId m_startEvent; //!< Start event |
236 |
EventId m_stopEvent; |
272 |
EventId m_stopEvent; //!< Stop event |
237 |
bool m_enabled; |
273 |
bool m_enabled; //!< FlowMon is enabled |
238 |
double m_delayBinWidth; |
274 |
double m_delayBinWidth; //!< Delay bin width (for histograms) |
239 |
double m_jitterBinWidth; |
275 |
double m_jitterBinWidth; //!< Jitter bin width (for histograms) |
240 |
double m_packetSizeBinWidth; |
276 |
double m_packetSizeBinWidth; //!< packet size bin width (for histograms) |
241 |
double m_flowInterruptionsBinWidth; |
277 |
double m_flowInterruptionsBinWidth; //!< Flow interruptions bin width (for histograms) |
242 |
Time m_flowInterruptionsMinTime; |
278 |
Time m_flowInterruptionsMinTime; //!< Flow interruptions minimum time |
243 |
|
279 |
|
|
|
280 |
/// Get the stats for a given flow |
281 |
/// \param flowId the Flow identification |
282 |
/// \returns the stats of the flow |
244 |
FlowStats& GetStatsForFlow (FlowId flowId); |
283 |
FlowStats& GetStatsForFlow (FlowId flowId); |
|
|
284 |
|
285 |
/// Periodic function to check for lost packets and prune statistics |
245 |
void PeriodicCheckForLostPackets (); |
286 |
void PeriodicCheckForLostPackets (); |
246 |
}; |
287 |
}; |
247 |
|
288 |
|