View | Details | Raw Unified | Return to bug 938
Collapse All | Expand All

(-)a/src/flow-monitor/helper/flow-monitor-helper.h (-15 / +35 lines)
 Lines 31-68    Link Here 
31
class AttributeValue;
31
class AttributeValue;
32
class Ipv4FlowClassifier;
32
class Ipv4FlowClassifier;
33
33
34
/// \brief Helper to enable IPv4 flow monitoring on a set of Nodes
34
/**
35
 * \ingroup flow-monitor
36
 * \brief Helper to enable IPv4 flow monitoring on a set of Nodes
37
 */
35
class FlowMonitorHelper
38
class FlowMonitorHelper
36
{
39
{
37
public:
40
public:
38
  /// \brief Construct a FlowMonitorHelper class which makes it easier to 
41
39
  /// configure and use the FlowMonitor
40
  FlowMonitorHelper ();
42
  FlowMonitorHelper ();
41
  /// \brief Dispose of objects allocated by the helper
42
  ~FlowMonitorHelper ();
43
  ~FlowMonitorHelper ();
43
44
44
  /// \brief Set an attribute for the to-be-created FlowMonitor object
45
  /**
46
   * \brief Set an attribute for the to-be-created FlowMonitor object
47
   * \param n1 attribute name
48
   * \param v1 attibute value
49
   */
45
  void SetMonitorAttribute (std::string n1, const AttributeValue &v1);
50
  void SetMonitorAttribute (std::string n1, const AttributeValue &v1);
46
51
47
  /// \brief Enable flow monitoring on a set of nodes
52
  /**
48
  /// \param nodes A NodeContainer holding the set of nodes to work with.
53
   * \brief Enable flow monitoring on a set of nodes
54
   * \param nodes A NodeContainer holding the set of nodes to work with.
55
   * \returns a pointer to the FlowMonitor object
56
   */
49
  Ptr<FlowMonitor> Install (NodeContainer nodes);
57
  Ptr<FlowMonitor> Install (NodeContainer nodes);
50
  /// \brief Enable flow monitoring on a single node
58
  /**
51
  /// \param node A Ptr<Node> to the node on which to enable flow monitoring.
59
   * \brief Enable flow monitoring on a single node
60
   * \param node A Ptr<Node> to the node on which to enable flow monitoring.
61
   * \returns a pointer to the FlowMonitor object
62
   */
52
  Ptr<FlowMonitor> Install (Ptr<Node> node);
63
  Ptr<FlowMonitor> Install (Ptr<Node> node);
53
  /// \brief Enable flow monitoring on all nodes
64
  /**
65
   * \brief Enable flow monitoring on all nodes
66
   * \returns a pointer to the FlowMonitor object
67
   */
54
  Ptr<FlowMonitor> InstallAll ();
68
  Ptr<FlowMonitor> InstallAll ();
55
69
56
  /// \brief Retrieve the FlowMonitor object created by the Install* methods
70
  /**
71
   * \brief Retrieve the FlowMonitor object created by the Install* methods
72
   * \returns a pointer to the FlowMonitor object
73
   */
57
  Ptr<FlowMonitor> GetMonitor ();
74
  Ptr<FlowMonitor> GetMonitor ();
58
75
59
  /// \brief Retrieve the FlowClassifier object created by the Install* methods
76
  /**
77
   * \brief Retrieve the FlowClassifier object created by the Install* methods
78
   * \returns a pointer to the FlowClassifier object
79
   */
60
  Ptr<FlowClassifier> GetClassifier ();
80
  Ptr<FlowClassifier> GetClassifier ();
61
81
62
private:
82
private:
63
  ObjectFactory m_monitorFactory;
83
  ObjectFactory m_monitorFactory;       //!< Object factory
64
  Ptr<FlowMonitor> m_flowMonitor;
84
  Ptr<FlowMonitor> m_flowMonitor;       //!< the FlowMonitor object
65
  Ptr<FlowClassifier> m_flowClassifier;
85
  Ptr<FlowClassifier> m_flowClassifier; //!< the FlowClassifier object
66
};
86
};
67
87
68
} // namespace ns3
88
} // namespace ns3
(-)a/src/flow-monitor/model/flow-classifier.h (-4 / +22 lines)
 Lines 26-36    Link Here 
26
26
27
namespace ns3 {
27
namespace ns3 {
28
28
29
typedef uint32_t FlowId;          ///< \ingroup flow-monitor
29
/**
30
typedef uint32_t FlowPacketId;    ///< \ingroup flow-monitor
30
 * \ingroup flow-monitor
31
 * \brief Abstract identifier of a packet flow
32
 */
33
typedef uint32_t FlowId;
34
35
/**
36
 * \ingroup flow-monitor
37
 * \brief Abstract identifier of a packet within a flow
38
 */
39
typedef uint32_t FlowPacketId;
40
31
41
32
/// \ingroup flow-monitor
42
/// \ingroup flow-monitor
33
/// provides a method to translate raw packet data into abstract
43
/// Provides a method to translate raw packet data into abstract
34
/// ``flow identifier'' and ``packet identifier'' parameters.  These
44
/// ``flow identifier'' and ``packet identifier'' parameters.  These
35
/// identifiers are unsigned 32-bit integers that uniquely identify a
45
/// identifiers are unsigned 32-bit integers that uniquely identify a
36
/// flow and a packet within that flow, respectively, for the whole
46
/// flow and a packet within that flow, respectively, for the whole
 Lines 43-51    Link Here 
43
class FlowClassifier : public SimpleRefCount<FlowClassifier>
53
class FlowClassifier : public SimpleRefCount<FlowClassifier>
44
{
54
{
45
private:
55
private:
46
  FlowId m_lastNewFlowId;
56
  FlowId m_lastNewFlowId; //!< Last known Flow ID
47
57
58
  /// Defined and not implemented to avoid misuse
48
  FlowClassifier (FlowClassifier const &);
59
  FlowClassifier (FlowClassifier const &);
60
  /// Defined and not implemented to avoid misuse
61
  /// \returns
49
  FlowClassifier& operator= (FlowClassifier const &);
62
  FlowClassifier& operator= (FlowClassifier const &);
50
63
51
public:
64
public:
 Lines 53-61    Link Here 
53
  FlowClassifier ();
66
  FlowClassifier ();
54
  virtual ~FlowClassifier ();
67
  virtual ~FlowClassifier ();
55
68
69
  /// Serializes the results to an std::ostream in XML format
70
  /// \param os the output stream
71
  /// \param indent number of spaces to use as base indentation level
56
  virtual void SerializeToXmlStream (std::ostream &os, int indent) const = 0;
72
  virtual void SerializeToXmlStream (std::ostream &os, int indent) const = 0;
57
73
58
protected:
74
protected:
75
  /// Returns a new, unique Flow Identifier
76
  /// \returns a new FlowId
59
  FlowId GetNewFlowId ();
77
  FlowId GetNewFlowId ();
60
78
61
};
79
};
(-)a/src/flow-monitor/model/flow-monitor.h (-27 / +68 lines)
 Lines 34-47    Link Here 
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:
 Lines 81-86    Link Here 
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
 Lines 127-146    Link Here 
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 ();
 Lines 151-171    Link Here 
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
 Lines 175-180    Link Here 
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 ---
 Lines 182-190    Link Here 
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
 Lines 213-247    Link Here 
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
(-)a/src/flow-monitor/model/flow-probe.h (-3 / +22 lines)
 Lines 39-55    Link Here 
39
class FlowProbe : public Object
39
class FlowProbe : public Object
40
{
40
{
41
private:
41
private:
42
  /// Defined and not implemented to avoid misuse
42
  FlowProbe (FlowProbe const &);
43
  FlowProbe (FlowProbe const &);
44
  /// Defined and not implemented to avoid misuse
45
  /// \returns
43
  FlowProbe& operator= (FlowProbe const &);
46
  FlowProbe& operator= (FlowProbe const &);
44
47
45
protected:
48
protected:
46
49
  /// Constructor
50
  /// \param flowMonitor the FlowMonitor this probe is associated with
47
  FlowProbe (Ptr<FlowMonitor> flowMonitor);
51
  FlowProbe (Ptr<FlowMonitor> flowMonitor);
48
  virtual void DoDispose (void);
52
  virtual void DoDispose (void);
49
53
50
public:
54
public:
51
  virtual ~FlowProbe ();
55
  virtual ~FlowProbe ();
52
56
57
  /// Structure to hold the statistics of a flow
53
  struct FlowStats
58
  struct FlowStats
54
  {
59
  {
55
    FlowStats () : delayFromFirstProbeSum (Seconds (0)), bytes (0), packets (0) {}
60
    FlowStats () : delayFromFirstProbeSum (Seconds (0)), bytes (0), packets (0) {}
 Lines 67-87    Link Here 
67
    uint32_t packets;
72
    uint32_t packets;
68
  };
73
  };
69
74
75
  /// Container to map FlowId -> FlowStats
70
  typedef std::map<FlowId, FlowStats> Stats;
76
  typedef std::map<FlowId, FlowStats> Stats;
71
77
78
  /// Add a packet data to the flow stats
79
  /// \param flowId the flow Identifier
80
  /// \param packetSize the packet size
81
  /// \param delayFromFirstProbe packet delay
72
  void AddPacketStats (FlowId flowId, uint32_t packetSize, Time delayFromFirstProbe);
82
  void AddPacketStats (FlowId flowId, uint32_t packetSize, Time delayFromFirstProbe);
83
  /// Add a packet drop data to the flow stats
84
  /// \param flowId the flow Identifier
85
  /// \param packetSize the packet size
86
  /// \param reasonCode reason code for the drop
73
  void AddPacketDropStats (FlowId flowId, uint32_t packetSize, uint32_t reasonCode);
87
  void AddPacketDropStats (FlowId flowId, uint32_t packetSize, uint32_t reasonCode);
74
88
75
  /// Get the partial flow statistics stored in this probe.  With this
89
  /// Get the partial flow statistics stored in this probe.  With this
76
  /// information you can, for example, find out what is the delay
90
  /// information you can, for example, find out what is the delay
77
  /// from the first probe to this one.
91
  /// from the first probe to this one.
92
  /// \returns the partial flow statistics
78
  Stats GetStats () const;
93
  Stats GetStats () const;
79
94
95
  /// Serializes the results to an std::ostream in XML format
96
  /// \param os the output stream
97
  /// \param indent number of spaces to use as base indentation level
98
  /// \param index FlowProbe index
80
  void SerializeToXmlStream (std::ostream &os, int indent, uint32_t index) const;
99
  void SerializeToXmlStream (std::ostream &os, int indent, uint32_t index) const;
81
100
82
protected:
101
protected:
83
  Ptr<FlowMonitor> m_flowMonitor;
102
  Ptr<FlowMonitor> m_flowMonitor; //!< the FlowMonitor instance
84
  Stats m_stats;
103
  Stats m_stats; //!< The flow stats
85
104
86
};
105
};
87
106
(-)a/src/flow-monitor/model/histogram.h (-5 / +65 lines)
 Lines 27-60    Link Here 
27
27
28
namespace ns3 {
28
namespace ns3 {
29
29
30
/**
31
 * \brief Class used to store data and make an histogram of the data frequency.
32
 *
33
 * Data are grouped in "bins", i.e., intervals. Each value is assigned to the
34
 * bin according to the following formula: floor(value/binWidth).
35
 * Hence, bin \a i groups the data from [i*binWidth, (i+1)binWidth).
36
 *
37
 * This class only handles \a positive bins, i.e., it does \a not handles negative data.
38
 *
39
 * \todo Add support for negative data.
40
 *
41
 * \todo Add method(s) to estimate \f$N\f$, \f$\mu\f$, and \f$s^2\f$ from the histogram,
42
 * see http://www.dspguide.com/ch2/4.htm
43
 *
44
 */
30
class Histogram
45
class Histogram
31
{
46
{
32
public:
47
public:
33
48
34
  // --- basic methods ---
49
  // --- basic methods ---
50
  /**
51
   * \brief Constructor
52
   * \param binWidth width of the histogram "bin".
53
   */
35
  Histogram (double binWidth);
54
  Histogram (double binWidth);
36
  Histogram ();
55
  Histogram ();
37
56
38
  // Methods for Getting the Histogram Results
57
  // Methods for Getting the Histogram Results
58
  /**
59
   * \brief Returns the number of bins in the histogram.
60
   * \return the number of bins in the histogram
61
   */
39
  uint32_t GetNBins () const;
62
  uint32_t GetNBins () const;
63
  /**
64
   * \brief Returns the bin start, i.e., index*binWidth
65
   * \param index the bin index
66
   * \return the bin start
67
   */
40
  double GetBinStart (uint32_t index);
68
  double GetBinStart (uint32_t index);
69
  /**
70
   * \brief Returns the bin end, i.e., (index+1)*binWidth
71
   * \param index the bin index
72
   * \return the bin start
73
   */
41
  double GetBinEnd (uint32_t index);
74
  double GetBinEnd (uint32_t index);
75
  /**
76
   * \brief Returns the bin width.
77
   *
78
   * Note that all the bins have the same width.
79
   *
80
   * \param index the bin index
81
   * \return the bin width
82
   */
42
  double GetBinWidth (uint32_t index) const;
83
  double GetBinWidth (uint32_t index) const;
84
  /**
85
   * \brief Set the bin width.
86
   *
87
   * Note that you can change the bin width only if the histogram is empty.
88
   *
89
   * \param binWidth the bin width
90
   */
43
  void SetDefaultBinWidth (double binWidth);
91
  void SetDefaultBinWidth (double binWidth);
92
  /**
93
   * \brief Get the number of data added to the bin.
94
   * \param index the bin index
95
   * \return the number of data added to the bin
96
   */
44
  uint32_t GetBinCount (uint32_t index);
97
  uint32_t GetBinCount (uint32_t index);
45
98
46
  // Method for adding values
99
  // Method for adding values
100
  /**
101
   * \brief Add a value to the histogram
102
   * \param value the value to add
103
   */
47
  void AddValue (double value);
104
  void AddValue (double value);
48
105
49
106
  /**
107
   * \brief Serializes the results to an std::ostream in XML format.
108
   * \param os the output stream
109
   * \param indent number of spaces to use as base indentation level
110
   * \param elementName name of the element to serialize.
111
   */
50
  void SerializeToXmlStream (std::ostream &os, int indent, std::string elementName) const;
112
  void SerializeToXmlStream (std::ostream &os, int indent, std::string elementName) const;
51
113
52
  /// \todo add method(s) to estimate N, µ, and s² from the histogram,
53
  /// see http://www.dspguide.com/ch2/4.htm
54
114
55
private:
115
private:
56
  std::vector<uint32_t> m_histogram;
116
  std::vector<uint32_t> m_histogram; //!< Histogram data
57
  double m_binWidth;
117
  double m_binWidth; //!< Bin width
58
};
118
};
59
119
60
120
(-)a/src/flow-monitor/model/ipv4-flow-classifier.cc (-2 / +2 lines)
 Lines 27-34    Link Here 
27
namespace ns3 {
27
namespace ns3 {
28
28
29
/* see http://www.iana.org/assignments/protocol-numbers */
29
/* see http://www.iana.org/assignments/protocol-numbers */
30
const uint8_t TCP_PROT_NUMBER = 6;
30
const uint8_t TCP_PROT_NUMBER = 6;  //!< TCP Protocol number
31
const uint8_t UDP_PROT_NUMBER = 17;
31
const uint8_t UDP_PROT_NUMBER = 17; //!< UDP Protocol number
32
32
33
33
34
34
(-)a/src/flow-monitor/model/ipv4-flow-classifier.h (-6 / +28 lines)
 Lines 39-51    Link Here 
39
{
39
{
40
public:
40
public:
41
41
42
  /// Structure to classify a packet
42
  struct FiveTuple
43
  struct FiveTuple
43
  {
44
  {
44
    Ipv4Address sourceAddress;
45
    Ipv4Address sourceAddress;      //!< Source address
45
    Ipv4Address destinationAddress;
46
    Ipv4Address destinationAddress; //!< Destination address
46
    uint8_t protocol;
47
    uint8_t protocol;               //!< Protocol
47
    uint16_t sourcePort;
48
    uint16_t sourcePort;            //!< Source port
48
    uint16_t destinationPort;
49
    uint16_t destinationPort;       //!< Destination port
49
  };
50
  };
50
51
51
  Ipv4FlowClassifier ();
52
  Ipv4FlowClassifier ();
 Lines 53-74    Link Here 
53
  /// \brief try to classify the packet into flow-id and packet-id
54
  /// \brief try to classify the packet into flow-id and packet-id
54
  /// \return true if the packet was classified, false if not (i.e. it
55
  /// \return true if the packet was classified, false if not (i.e. it
55
  /// does not appear to be part of a flow).
56
  /// does not appear to be part of a flow).
57
  /// \param ipHeader packet's IP header
58
  /// \param ipPayload packet's IP payload
59
  /// \param out_flowId packet's FlowId
60
  /// \param out_packetId packet's identifier
56
  bool Classify (const Ipv4Header &ipHeader, Ptr<const Packet> ipPayload,
61
  bool Classify (const Ipv4Header &ipHeader, Ptr<const Packet> ipPayload,
57
                 uint32_t *out_flowId, uint32_t *out_packetId);
62
                 uint32_t *out_flowId, uint32_t *out_packetId);
58
63
59
  /// Searches for the FiveTuple corresponding to the given flowId
64
  /// Searches for the FiveTuple corresponding to the given flowId
65
  /// \param flowId the FlowId to search for
66
  /// \returns the FiveTuple corresponding to flowId
60
  FiveTuple FindFlow (FlowId flowId) const;
67
  FiveTuple FindFlow (FlowId flowId) const;
61
68
62
  virtual void SerializeToXmlStream (std::ostream &os, int indent) const;
69
  virtual void SerializeToXmlStream (std::ostream &os, int indent) const;
63
70
64
private:
71
private:
65
72
73
  /// Map to Flows Identifiers to FlowIds
66
  std::map<FiveTuple, FlowId> m_flowMap;
74
  std::map<FiveTuple, FlowId> m_flowMap;
67
75
68
};
76
};
69
77
78
/**
79
 * \brief Less than operator.
80
 *
81
 * \param t1 the first operand
82
 * \param t2 the first operand
83
 * \returns true if the operands are equal
84
 */
85
bool operator < (const Ipv4FlowClassifier::FiveTuple &t1, const Ipv4FlowClassifier::FiveTuple &t2);
70
86
71
bool operator < (const Ipv4FlowClassifier::FiveTuple &t1, const Ipv4FlowClassifier::FiveTuple &t2);
87
/**
88
 * \brief Equal to operator.
89
 *
90
 * \param t1 the first operand
91
 * \param t2 the first operand
92
 * \returns true if the operands are equal
93
 */
72
bool operator == (const Ipv4FlowClassifier::FiveTuple &t1, const Ipv4FlowClassifier::FiveTuple &t2);
94
bool operator == (const Ipv4FlowClassifier::FiveTuple &t1, const Ipv4FlowClassifier::FiveTuple &t2);
73
95
74
96
(-)a/src/flow-monitor/model/ipv4-flow-probe.cc (-3 / +46 lines)
 Lines 37-45    Link Here 
37
// Ipv4FlowProbeTag class implementation //
37
// Ipv4FlowProbeTag class implementation //
38
//////////////////////////////////////
38
//////////////////////////////////////
39
39
40
/**
41
 * \ingroup flow-monitor
42
 *
43
 * \brief Tag used to allow a fast identification of the packet
44
 *
45
 * This tag is added by FlowMonitor when a packet is seen for
46
 * the first time, and it is then used to classify the packet in
47
 * the following hops.
48
 */
40
class Ipv4FlowProbeTag : public Tag
49
class Ipv4FlowProbeTag : public Tag
41
{
50
{
42
public:
51
public:
52
  /**
53
   * \brief Get the type ID.
54
   * \return the object TypeId
55
   */
43
  static TypeId GetTypeId (void);
56
  static TypeId GetTypeId (void);
44
  virtual TypeId GetInstanceTypeId (void) const;
57
  virtual TypeId GetInstanceTypeId (void) const;
45
  virtual uint32_t GetSerializedSize (void) const;
58
  virtual uint32_t GetSerializedSize (void) const;
 Lines 47-63    Link Here 
47
  virtual void Deserialize (TagBuffer buf);
60
  virtual void Deserialize (TagBuffer buf);
48
  virtual void Print (std::ostream &os) const;
61
  virtual void Print (std::ostream &os) const;
49
  Ipv4FlowProbeTag ();
62
  Ipv4FlowProbeTag ();
63
  /**
64
   * \brief Consructor
65
   * \param flowId the flow identifier
66
   * \param packetId the packet identifier
67
   * \param packetSize the packet size
68
   */
50
  Ipv4FlowProbeTag (uint32_t flowId, uint32_t packetId, uint32_t packetSize);
69
  Ipv4FlowProbeTag (uint32_t flowId, uint32_t packetId, uint32_t packetSize);
70
  /**
71
   * \brief Set the flow identifier
72
   * \param flowId the flow identifier
73
   */
51
  void SetFlowId (uint32_t flowId);
74
  void SetFlowId (uint32_t flowId);
75
  /**
76
   * \brief Set the packet identifier
77
   * \param packetId the packet identifier
78
   */
52
  void SetPacketId (uint32_t packetId);
79
  void SetPacketId (uint32_t packetId);
80
  /**
81
   * \brief Set the packet size
82
   * \param packetSize the packet size
83
   */
53
  void SetPacketSize (uint32_t packetSize);
84
  void SetPacketSize (uint32_t packetSize);
85
  /**
86
   * \brief Set the flow identifier
87
   * \returns the flow identifier
88
   */
54
  uint32_t GetFlowId (void) const;
89
  uint32_t GetFlowId (void) const;
90
  /**
91
   * \brief Set the packet identifier
92
   * \returns the packet identifier
93
   */
55
  uint32_t GetPacketId (void) const;
94
  uint32_t GetPacketId (void) const;
95
  /**
96
   * \brief Get the packet size
97
   * \returns the packet size
98
   */
56
  uint32_t GetPacketSize (void) const;
99
  uint32_t GetPacketSize (void) const;
57
private:
100
private:
58
  uint32_t m_flowId;
101
  uint32_t m_flowId;      //!< flow identifier
59
  uint32_t m_packetId;
102
  uint32_t m_packetId;    //!< packet identifier
60
  uint32_t m_packetSize;
103
  uint32_t m_packetSize;  //!< packet size
61
104
62
};
105
};
63
106
(-)a/src/flow-monitor/model/ipv4-flow-probe.h (-4 / +28 lines)
 Lines 30-35    Link Here 
30
class FlowMonitor;
30
class FlowMonitor;
31
class Node;
31
class Node;
32
32
33
/// \ingroup flow-monitor
33
/// \brief Class that monitors flows at the IPv4 layer of a Node
34
/// \brief Class that monitors flows at the IPv4 layer of a Node
34
///
35
///
35
/// For each node in the simulation, one instance of the class
36
/// For each node in the simulation, one instance of the class
 Lines 40-45    Link Here 
40
{
41
{
41
42
42
public:
43
public:
44
  /// \brief Constructor
45
  /// \param monitor the FlowMonitor this probe is associated with
46
  /// \param classifier the Ipv4FlowClassifier this probe is associated with
47
  /// \param node the Node this probe is associated with
43
  Ipv4FlowProbe (Ptr<FlowMonitor> monitor, Ptr<Ipv4FlowClassifier> classifier, Ptr<Node> node);
48
  Ipv4FlowProbe (Ptr<FlowMonitor> monitor, Ptr<Ipv4FlowClassifier> classifier, Ptr<Node> node);
44
  virtual ~Ipv4FlowProbe ();
49
  virtual ~Ipv4FlowProbe ();
45
50
 Lines 65-87    Link Here 
65
    DROP_ROUTE_ERROR,   /**< Route error */
70
    DROP_ROUTE_ERROR,   /**< Route error */
66
    DROP_FRAGMENT_TIMEOUT, /**< Fragment timeout exceeded */
71
    DROP_FRAGMENT_TIMEOUT, /**< Fragment timeout exceeded */
67
72
68
    DROP_INVALID_REASON,
73
    DROP_INVALID_REASON, /**< Fallback reason (no known reason) */
69
  };
74
  };
70
75
71
protected:
76
protected:
72
77
73
    virtual void DoDispose (void);
78
  virtual void DoDispose (void);
74
79
75
private:
80
private:
76
81
  /// Log a packet being sent
82
  /// \param ipHeader IP header
83
  /// \param ipPayload IP payload
84
  /// \param interface outgoing interface
77
  void SendOutgoingLogger (const Ipv4Header &ipHeader, Ptr<const Packet> ipPayload, uint32_t interface);
85
  void SendOutgoingLogger (const Ipv4Header &ipHeader, Ptr<const Packet> ipPayload, uint32_t interface);
86
  /// Log a packet being forwarded
87
  /// \param ipHeader IP header
88
  /// \param ipPayload IP payload
89
  /// \param interface incoming interface
78
  void ForwardLogger (const Ipv4Header &ipHeader, Ptr<const Packet> ipPayload, uint32_t interface);
90
  void ForwardLogger (const Ipv4Header &ipHeader, Ptr<const Packet> ipPayload, uint32_t interface);
91
  /// Log a packet being received by the destination
92
  /// \param ipHeader IP header
93
  /// \param ipPayload IP payload
94
  /// \param interface incoming interface
79
  void ForwardUpLogger (const Ipv4Header &ipHeader, Ptr<const Packet> ipPayload, uint32_t interface);
95
  void ForwardUpLogger (const Ipv4Header &ipHeader, Ptr<const Packet> ipPayload, uint32_t interface);
96
  /// Log a packet being dropped
97
  /// \param ipHeader IP header
98
  /// \param ipPayload IP payload
99
  /// \param reason drop reason
100
  /// \param ipv4 pointer to the IP object dropping the packet
101
  /// \param ifIndex interface index
80
  void DropLogger (const Ipv4Header &ipHeader, Ptr<const Packet> ipPayload,
102
  void DropLogger (const Ipv4Header &ipHeader, Ptr<const Packet> ipPayload,
81
                   Ipv4L3Protocol::DropReason reason, Ptr<Ipv4> ipv4, uint32_t ifIndex);
103
                   Ipv4L3Protocol::DropReason reason, Ptr<Ipv4> ipv4, uint32_t ifIndex);
104
  /// Log a packet being dropped by a queue
105
  /// \param ipPayload IP payload
82
  void QueueDropLogger (Ptr<const Packet> ipPayload);
106
  void QueueDropLogger (Ptr<const Packet> ipPayload);
83
107
84
  Ptr<Ipv4FlowClassifier> m_classifier;
108
  Ptr<Ipv4FlowClassifier> m_classifier; //!< the Ipv4FlowClassifier this probe is associated with
85
};
109
};
86
110
87
111

Return to bug 938