# HG changeset patch # Parent 05d3d9fc8f4bb190dd974c1240b9fbc2bbd2c5d3 # User Tommaso Pecorella # Date 1385062528 -3600 Bug 983 - missing Doxygen in ns-3 (flow-monitor model + helper) diff --git a/src/flow-monitor/helper/flow-monitor-helper.h b/src/flow-monitor/helper/flow-monitor-helper.h --- a/src/flow-monitor/helper/flow-monitor-helper.h +++ b/src/flow-monitor/helper/flow-monitor-helper.h @@ -31,38 +31,58 @@ class AttributeValue; class Ipv4FlowClassifier; -/// \brief Helper to enable IPv4 flow monitoring on a set of Nodes +/** + * \ingroup flow-monitor + * \brief Helper to enable IPv4 flow monitoring on a set of Nodes + */ class FlowMonitorHelper { public: - /// \brief Construct a FlowMonitorHelper class which makes it easier to - /// configure and use the FlowMonitor + FlowMonitorHelper (); - /// \brief Dispose of objects allocated by the helper ~FlowMonitorHelper (); - /// \brief Set an attribute for the to-be-created FlowMonitor object + /** + * \brief Set an attribute for the to-be-created FlowMonitor object + * \param n1 attribute name + * \param v1 attibute value + */ void SetMonitorAttribute (std::string n1, const AttributeValue &v1); - /// \brief Enable flow monitoring on a set of nodes - /// \param nodes A NodeContainer holding the set of nodes to work with. + /** + * \brief Enable flow monitoring on a set of nodes + * \param nodes A NodeContainer holding the set of nodes to work with. + * \returns a pointer to the FlowMonitor object + */ Ptr Install (NodeContainer nodes); - /// \brief Enable flow monitoring on a single node - /// \param node A Ptr to the node on which to enable flow monitoring. + /** + * \brief Enable flow monitoring on a single node + * \param node A Ptr to the node on which to enable flow monitoring. + * \returns a pointer to the FlowMonitor object + */ Ptr Install (Ptr node); - /// \brief Enable flow monitoring on all nodes + /** + * \brief Enable flow monitoring on all nodes + * \returns a pointer to the FlowMonitor object + */ Ptr InstallAll (); - /// \brief Retrieve the FlowMonitor object created by the Install* methods + /** + * \brief Retrieve the FlowMonitor object created by the Install* methods + * \returns a pointer to the FlowMonitor object + */ Ptr GetMonitor (); - /// \brief Retrieve the FlowClassifier object created by the Install* methods + /** + * \brief Retrieve the FlowClassifier object created by the Install* methods + * \returns a pointer to the FlowClassifier object + */ Ptr GetClassifier (); private: - ObjectFactory m_monitorFactory; - Ptr m_flowMonitor; - Ptr m_flowClassifier; + ObjectFactory m_monitorFactory; //!< Object factory + Ptr m_flowMonitor; //!< the FlowMonitor object + Ptr m_flowClassifier; //!< the FlowClassifier object }; } // namespace ns3 diff --git a/src/flow-monitor/model/flow-classifier.h b/src/flow-monitor/model/flow-classifier.h --- a/src/flow-monitor/model/flow-classifier.h +++ b/src/flow-monitor/model/flow-classifier.h @@ -26,11 +26,21 @@ namespace ns3 { -typedef uint32_t FlowId; ///< \ingroup flow-monitor -typedef uint32_t FlowPacketId; ///< \ingroup flow-monitor +/** + * \ingroup flow-monitor + * \brief Abstract identifier of a packet flow + */ +typedef uint32_t FlowId; + +/** + * \ingroup flow-monitor + * \brief Abstract identifier of a packet within a flow + */ +typedef uint32_t FlowPacketId; + /// \ingroup flow-monitor -/// provides a method to translate raw packet data into abstract +/// Provides a method to translate raw packet data into abstract /// ``flow identifier'' and ``packet identifier'' parameters. These /// identifiers are unsigned 32-bit integers that uniquely identify a /// flow and a packet within that flow, respectively, for the whole @@ -43,9 +53,12 @@ class FlowClassifier : public SimpleRefCount { private: - FlowId m_lastNewFlowId; + FlowId m_lastNewFlowId; //!< Last known Flow ID + /// Defined and not implemented to avoid misuse FlowClassifier (FlowClassifier const &); + /// Defined and not implemented to avoid misuse + /// \returns FlowClassifier& operator= (FlowClassifier const &); public: @@ -53,9 +66,14 @@ FlowClassifier (); virtual ~FlowClassifier (); + /// Serializes the results to an std::ostream in XML format + /// \param os the output stream + /// \param indent number of spaces to use as base indentation level virtual void SerializeToXmlStream (std::ostream &os, int indent) const = 0; protected: + /// Returns a new, unique Flow Identifier + /// \returns a new FlowId FlowId GetNewFlowId (); }; diff --git a/src/flow-monitor/model/flow-monitor.h b/src/flow-monitor/model/flow-monitor.h --- a/src/flow-monitor/model/flow-monitor.h +++ b/src/flow-monitor/model/flow-monitor.h @@ -34,14 +34,19 @@ namespace ns3 { -/// \defgroup flow-monitor Flow Monitor -/// \brief Collect and store performance data from a simulation +/** + * \defgroup flow-monitor Flow Monitor + * \brief Collect and store performance data from a simulation + */ -/// \ingroup flow-monitor -/// \brief An object that monitors and reports back packet flows observed during a simulation -/// -/// The FlowMonitor class is responsible forcoordinating efforts -/// regarding probes, and collects end-to-end flowstatistics. +/** + * \ingroup flow-monitor + * \brief An object that monitors and reports back packet flows observed during a simulation + * + * The FlowMonitor class is responsible for coordinating efforts + * regarding probes, and collects end-to-end flow statistics. + * + */ class FlowMonitor : public Object { public: @@ -81,6 +86,8 @@ /// as defined in IETF \RFC{3393}. Time jitterSum; // jitterCount == rxPackets - 1 + /// Contains the last measured delay of a packet + /// It is stored to measure the packet's Jitter Time lastDelay; /// Total number of transmitted bytes for the flow @@ -127,20 +134,27 @@ /// This attribute also tracks the number of lost bytes. See also /// comment in attribute packetsDropped. std::vector bytesDropped; // bytesDropped[reasonCode] => number of dropped bytes - Histogram flowInterruptionsHistogram; // histogram of durations of flow interruptions + Histogram flowInterruptionsHistogram; //!< histogram of durations of flow interruptions }; // --- basic methods --- + /** + * \brief Get the type ID. + * \return the object TypeId + */ static TypeId GetTypeId (); TypeId GetInstanceTypeId () const; FlowMonitor (); /// Set the FlowClassifier to be used by the flow monitor. + /// \param classifier the FlowClassifier void SetFlowClassifier (Ptr classifier); - /// Set the time, counting from the current time, from which to start monitoring flows + /// Set the time, counting from the current time, from which to start monitoring flows. + /// \param time delta time to start void Start (const Time &time); - /// Set the time, counting from the current time, from which to stop monitoring flows + /// Set the time, counting from the current time, from which to stop monitoring flows. + /// \param time delta time to stop void Stop (const Time &time); /// Begin monitoring flows *right now* void StartRightNow (); @@ -151,21 +165,39 @@ /// Register a new FlowProbe that will begin monitoring and report /// events to this monitor. This method is normally only used by /// FlowProbe implementations. + /// \param probe the probe to add void AddProbe (Ptr probe); /// FlowProbe implementations are supposed to call this method to /// report that a new packet was transmitted (but keep in mind the /// distinction between a new packet entering the system and a /// packet that is already known and is only being forwarded). + /// \param probe the reporting probe + /// \param flowId flow identification + /// \param packetId Packet ID + /// \param packetSize packet size void ReportFirstTx (Ptr probe, FlowId flowId, FlowPacketId packetId, uint32_t packetSize); /// FlowProbe implementations are supposed to call this method to /// report that a known packet is being forwarded. + /// \param probe the reporting probe + /// \param flowId flow identification + /// \param packetId Packet ID + /// \param packetSize packet size void ReportForwarding (Ptr probe, FlowId flowId, FlowPacketId packetId, uint32_t packetSize); /// FlowProbe implementations are supposed to call this method to /// report that a known packet is being received. + /// \param probe the reporting probe + /// \param flowId flow identification + /// \param packetId Packet ID + /// \param packetSize packet size void ReportLastRx (Ptr probe, FlowId flowId, FlowPacketId packetId, uint32_t packetSize); /// FlowProbe implementations are supposed to call this method to /// report that a known packet is being dropped due to some reason. + /// \param probe the reporting probe + /// \param flowId flow identification + /// \param packetId Packet ID + /// \param packetSize packet size + /// \param reasonCode drop reason code void ReportDrop (Ptr probe, FlowId flowId, FlowPacketId packetId, uint32_t packetSize, uint32_t reasonCode); @@ -175,6 +207,7 @@ /// Check right now for packets that appear to be lost, considering /// packets as lost if not seen in the network for a time larger /// than maxDelay + /// \param maxDelay the max delay for a packet void CheckForLostPackets (Time maxDelay); // --- methods to get the results --- @@ -182,9 +215,11 @@ /// FlowMonitor has not stopped monitoring yet, you should call /// CheckForLostPackets() to make sure all possibly lost packets are /// accounted for. + /// \returns the flows statistics std::map GetFlowStats () const; /// Get a list of all FlowProbe's associated with this FlowMonitor + /// \returns a list of all the probes std::vector< Ptr > GetAllProbes () const; /// Serializes the results to an std::ostream in XML format @@ -213,35 +248,41 @@ private: + /// Structure to represent a single tracked packet data struct TrackedPacket { - Time firstSeenTime; // absolute time when the packet was first seen by a probe - Time lastSeenTime; // absolute time when the packet was last seen by a probe - uint32_t timesForwarded; // number of times the packet was reportedly forwarded + Time firstSeenTime; //!< absolute time when the packet was first seen by a probe + Time lastSeenTime; //!< absolute time when the packet was last seen by a probe + uint32_t timesForwarded; //!< number of times the packet was reportedly forwarded }; - // FlowId --> FlowStats + /// FlowId --> FlowStats std::map m_flowStats; - // (FlowId,PacketId) --> TrackedPacket + /// (FlowId,PacketId) --> TrackedPacket typedef std::map< std::pair, TrackedPacket> TrackedPacketMap; - TrackedPacketMap m_trackedPackets; - Time m_maxPerHopDelay; - std::vector< Ptr > m_flowProbes; + TrackedPacketMap m_trackedPackets; //!< Tracked packets + Time m_maxPerHopDelay; //!< Minimum per-hop delay + std::vector< Ptr > m_flowProbes; //!< all the FlowProbes // note: this is needed only for serialization - Ptr m_classifier; + Ptr m_classifier; //!< the FlowClassifier - EventId m_startEvent; - EventId m_stopEvent; - bool m_enabled; - double m_delayBinWidth; - double m_jitterBinWidth; - double m_packetSizeBinWidth; - double m_flowInterruptionsBinWidth; - Time m_flowInterruptionsMinTime; + EventId m_startEvent; //!< Start event + EventId m_stopEvent; //!< Stop event + bool m_enabled; //!< FlowMon is enabled + double m_delayBinWidth; //!< Delay bin width (for histograms) + double m_jitterBinWidth; //!< Jitter bin width (for histograms) + double m_packetSizeBinWidth; //!< packet size bin width (for histograms) + double m_flowInterruptionsBinWidth; //!< Flow interruptions bin width (for histograms) + Time m_flowInterruptionsMinTime; //!< Flow interruptions minimum time + /// Get the stats for a given flow + /// \param flowId the Flow identification + /// \returns the stats of the flow FlowStats& GetStatsForFlow (FlowId flowId); + + /// Periodic function to check for lost packets and prune statistics void PeriodicCheckForLostPackets (); }; diff --git a/src/flow-monitor/model/flow-probe.h b/src/flow-monitor/model/flow-probe.h --- a/src/flow-monitor/model/flow-probe.h +++ b/src/flow-monitor/model/flow-probe.h @@ -39,17 +39,22 @@ class FlowProbe : public Object { private: + /// Defined and not implemented to avoid misuse FlowProbe (FlowProbe const &); + /// Defined and not implemented to avoid misuse + /// \returns FlowProbe& operator= (FlowProbe const &); protected: - + /// Constructor + /// \param flowMonitor the FlowMonitor this probe is associated with FlowProbe (Ptr flowMonitor); virtual void DoDispose (void); public: virtual ~FlowProbe (); + /// Structure to hold the statistics of a flow struct FlowStats { FlowStats () : delayFromFirstProbeSum (Seconds (0)), bytes (0), packets (0) {} @@ -67,21 +72,35 @@ uint32_t packets; }; + /// Container to map FlowId -> FlowStats typedef std::map Stats; + /// Add a packet data to the flow stats + /// \param flowId the flow Identifier + /// \param packetSize the packet size + /// \param delayFromFirstProbe packet delay void AddPacketStats (FlowId flowId, uint32_t packetSize, Time delayFromFirstProbe); + /// Add a packet drop data to the flow stats + /// \param flowId the flow Identifier + /// \param packetSize the packet size + /// \param reasonCode reason code for the drop void AddPacketDropStats (FlowId flowId, uint32_t packetSize, uint32_t reasonCode); /// Get the partial flow statistics stored in this probe. With this /// information you can, for example, find out what is the delay /// from the first probe to this one. + /// \returns the partial flow statistics Stats GetStats () const; + /// Serializes the results to an std::ostream in XML format + /// \param os the output stream + /// \param indent number of spaces to use as base indentation level + /// \param index FlowProbe index void SerializeToXmlStream (std::ostream &os, int indent, uint32_t index) const; protected: - Ptr m_flowMonitor; - Stats m_stats; + Ptr m_flowMonitor; //!< the FlowMonitor instance + Stats m_stats; //!< The flow stats }; diff --git a/src/flow-monitor/model/histogram.h b/src/flow-monitor/model/histogram.h --- a/src/flow-monitor/model/histogram.h +++ b/src/flow-monitor/model/histogram.h @@ -27,34 +27,94 @@ namespace ns3 { +/** + * \brief Class used to store data and make an histogram of the data frequency. + * + * Data are grouped in "bins", i.e., intervals. Each value is assigned to the + * bin according to the following formula: floor(value/binWidth). + * Hence, bin \a i groups the data from [i*binWidth, (i+1)binWidth). + * + * This class only handles \a positive bins, i.e., it does \a not handles negative data. + * + * \todo Add support for negative data. + * + * \todo Add method(s) to estimate \f$N\f$, \f$\mu\f$, and \f$s^2\f$ from the histogram, + * see http://www.dspguide.com/ch2/4.htm + * + */ class Histogram { public: // --- basic methods --- + /** + * \brief Constructor + * \param binWidth width of the histogram "bin". + */ Histogram (double binWidth); Histogram (); // Methods for Getting the Histogram Results + /** + * \brief Returns the number of bins in the histogram. + * \return the number of bins in the histogram + */ uint32_t GetNBins () const; + /** + * \brief Returns the bin start, i.e., index*binWidth + * \param index the bin index + * \return the bin start + */ double GetBinStart (uint32_t index); + /** + * \brief Returns the bin end, i.e., (index+1)*binWidth + * \param index the bin index + * \return the bin start + */ double GetBinEnd (uint32_t index); + /** + * \brief Returns the bin width. + * + * Note that all the bins have the same width. + * + * \param index the bin index + * \return the bin width + */ double GetBinWidth (uint32_t index) const; + /** + * \brief Set the bin width. + * + * Note that you can change the bin width only if the histogram is empty. + * + * \param binWidth the bin width + */ void SetDefaultBinWidth (double binWidth); + /** + * \brief Get the number of data added to the bin. + * \param index the bin index + * \return the number of data added to the bin + */ uint32_t GetBinCount (uint32_t index); // Method for adding values + /** + * \brief Add a value to the histogram + * \param value the value to add + */ void AddValue (double value); - + /** + * \brief Serializes the results to an std::ostream in XML format. + * \param os the output stream + * \param indent number of spaces to use as base indentation level + * \param elementName name of the element to serialize. + */ void SerializeToXmlStream (std::ostream &os, int indent, std::string elementName) const; - /// \todo add method(s) to estimate N, µ, and s² from the histogram, - /// see http://www.dspguide.com/ch2/4.htm private: - std::vector m_histogram; - double m_binWidth; + std::vector m_histogram; //!< Histogram data + double m_binWidth; //!< Bin width }; diff --git a/src/flow-monitor/model/ipv4-flow-classifier.cc b/src/flow-monitor/model/ipv4-flow-classifier.cc --- a/src/flow-monitor/model/ipv4-flow-classifier.cc +++ b/src/flow-monitor/model/ipv4-flow-classifier.cc @@ -27,8 +27,8 @@ namespace ns3 { /* see http://www.iana.org/assignments/protocol-numbers */ -const uint8_t TCP_PROT_NUMBER = 6; -const uint8_t UDP_PROT_NUMBER = 17; +const uint8_t TCP_PROT_NUMBER = 6; //!< TCP Protocol number +const uint8_t UDP_PROT_NUMBER = 17; //!< UDP Protocol number diff --git a/src/flow-monitor/model/ipv4-flow-classifier.h b/src/flow-monitor/model/ipv4-flow-classifier.h --- a/src/flow-monitor/model/ipv4-flow-classifier.h +++ b/src/flow-monitor/model/ipv4-flow-classifier.h @@ -39,13 +39,14 @@ { public: + /// Structure to classify a packet struct FiveTuple { - Ipv4Address sourceAddress; - Ipv4Address destinationAddress; - uint8_t protocol; - uint16_t sourcePort; - uint16_t destinationPort; + Ipv4Address sourceAddress; //!< Source address + Ipv4Address destinationAddress; //!< Destination address + uint8_t protocol; //!< Protocol + uint16_t sourcePort; //!< Source port + uint16_t destinationPort; //!< Destination port }; Ipv4FlowClassifier (); @@ -53,22 +54,43 @@ /// \brief try to classify the packet into flow-id and packet-id /// \return true if the packet was classified, false if not (i.e. it /// does not appear to be part of a flow). + /// \param ipHeader packet's IP header + /// \param ipPayload packet's IP payload + /// \param out_flowId packet's FlowId + /// \param out_packetId packet's identifier bool Classify (const Ipv4Header &ipHeader, Ptr ipPayload, uint32_t *out_flowId, uint32_t *out_packetId); /// Searches for the FiveTuple corresponding to the given flowId + /// \param flowId the FlowId to search for + /// \returns the FiveTuple corresponding to flowId FiveTuple FindFlow (FlowId flowId) const; virtual void SerializeToXmlStream (std::ostream &os, int indent) const; private: + /// Map to Flows Identifiers to FlowIds std::map m_flowMap; }; +/** + * \brief Less than operator. + * + * \param t1 the first operand + * \param t2 the first operand + * \returns true if the operands are equal + */ +bool operator < (const Ipv4FlowClassifier::FiveTuple &t1, const Ipv4FlowClassifier::FiveTuple &t2); -bool operator < (const Ipv4FlowClassifier::FiveTuple &t1, const Ipv4FlowClassifier::FiveTuple &t2); +/** + * \brief Equal to operator. + * + * \param t1 the first operand + * \param t2 the first operand + * \returns true if the operands are equal + */ bool operator == (const Ipv4FlowClassifier::FiveTuple &t1, const Ipv4FlowClassifier::FiveTuple &t2); diff --git a/src/flow-monitor/model/ipv4-flow-probe.cc b/src/flow-monitor/model/ipv4-flow-probe.cc --- a/src/flow-monitor/model/ipv4-flow-probe.cc +++ b/src/flow-monitor/model/ipv4-flow-probe.cc @@ -37,9 +37,22 @@ // Ipv4FlowProbeTag class implementation // ////////////////////////////////////// +/** + * \ingroup flow-monitor + * + * \brief Tag used to allow a fast identification of the packet + * + * This tag is added by FlowMonitor when a packet is seen for + * the first time, and it is then used to classify the packet in + * the following hops. + */ class Ipv4FlowProbeTag : public Tag { public: + /** + * \brief Get the type ID. + * \return the object TypeId + */ static TypeId GetTypeId (void); virtual TypeId GetInstanceTypeId (void) const; virtual uint32_t GetSerializedSize (void) const; @@ -47,17 +60,47 @@ virtual void Deserialize (TagBuffer buf); virtual void Print (std::ostream &os) const; Ipv4FlowProbeTag (); + /** + * \brief Consructor + * \param flowId the flow identifier + * \param packetId the packet identifier + * \param packetSize the packet size + */ Ipv4FlowProbeTag (uint32_t flowId, uint32_t packetId, uint32_t packetSize); + /** + * \brief Set the flow identifier + * \param flowId the flow identifier + */ void SetFlowId (uint32_t flowId); + /** + * \brief Set the packet identifier + * \param packetId the packet identifier + */ void SetPacketId (uint32_t packetId); + /** + * \brief Set the packet size + * \param packetSize the packet size + */ void SetPacketSize (uint32_t packetSize); + /** + * \brief Set the flow identifier + * \returns the flow identifier + */ uint32_t GetFlowId (void) const; + /** + * \brief Set the packet identifier + * \returns the packet identifier + */ uint32_t GetPacketId (void) const; + /** + * \brief Get the packet size + * \returns the packet size + */ uint32_t GetPacketSize (void) const; private: - uint32_t m_flowId; - uint32_t m_packetId; - uint32_t m_packetSize; + uint32_t m_flowId; //!< flow identifier + uint32_t m_packetId; //!< packet identifier + uint32_t m_packetSize; //!< packet size }; diff --git a/src/flow-monitor/model/ipv4-flow-probe.h b/src/flow-monitor/model/ipv4-flow-probe.h --- a/src/flow-monitor/model/ipv4-flow-probe.h +++ b/src/flow-monitor/model/ipv4-flow-probe.h @@ -30,6 +30,7 @@ class FlowMonitor; class Node; +/// \ingroup flow-monitor /// \brief Class that monitors flows at the IPv4 layer of a Node /// /// For each node in the simulation, one instance of the class @@ -40,6 +41,10 @@ { public: + /// \brief Constructor + /// \param monitor the FlowMonitor this probe is associated with + /// \param classifier the Ipv4FlowClassifier this probe is associated with + /// \param node the Node this probe is associated with Ipv4FlowProbe (Ptr monitor, Ptr classifier, Ptr node); virtual ~Ipv4FlowProbe (); @@ -65,23 +70,42 @@ DROP_ROUTE_ERROR, /**< Route error */ DROP_FRAGMENT_TIMEOUT, /**< Fragment timeout exceeded */ - DROP_INVALID_REASON, + DROP_INVALID_REASON, /**< Fallback reason (no known reason) */ }; protected: - virtual void DoDispose (void); + virtual void DoDispose (void); private: - + /// Log a packet being sent + /// \param ipHeader IP header + /// \param ipPayload IP payload + /// \param interface outgoing interface void SendOutgoingLogger (const Ipv4Header &ipHeader, Ptr ipPayload, uint32_t interface); + /// Log a packet being forwarded + /// \param ipHeader IP header + /// \param ipPayload IP payload + /// \param interface incoming interface void ForwardLogger (const Ipv4Header &ipHeader, Ptr ipPayload, uint32_t interface); + /// Log a packet being received by the destination + /// \param ipHeader IP header + /// \param ipPayload IP payload + /// \param interface incoming interface void ForwardUpLogger (const Ipv4Header &ipHeader, Ptr ipPayload, uint32_t interface); + /// Log a packet being dropped + /// \param ipHeader IP header + /// \param ipPayload IP payload + /// \param reason drop reason + /// \param ipv4 pointer to the IP object dropping the packet + /// \param ifIndex interface index void DropLogger (const Ipv4Header &ipHeader, Ptr ipPayload, Ipv4L3Protocol::DropReason reason, Ptr ipv4, uint32_t ifIndex); + /// Log a packet being dropped by a queue + /// \param ipPayload IP payload void QueueDropLogger (Ptr ipPayload); - Ptr m_classifier; + Ptr m_classifier; //!< the Ipv4FlowClassifier this probe is associated with };