diff --git a/src/nix-vector-routing/examples/nms-p2p-nix.cc b/src/nix-vector-routing/examples/nms-p2p-nix.cc index ead1a3b19..1768d0d09 100644 --- a/src/nix-vector-routing/examples/nms-p2p-nix.cc +++ b/src/nix-vector-routing/examples/nms-p2p-nix.cc @@ -60,62 +60,91 @@ void Progress () Simulator::Schedule (Seconds (0.1), Progress); } +/** + * \ingroup nix-vector-routing + * 2D array used in nix-vector-routing example "nms-p2p-nix.cc" + */ template class Array2D { - public: - Array2D (const size_t x, const size_t y) : p (new T*[x]), m_xMax (x) - { - for (size_t i = 0; i < m_xMax; i++) - p[i] = new T[y]; - } +public: + /** + * Constructor + * \param x number of rows + * \param y number of columns + */ + Array2D (const size_t x, const size_t y) : + p (new T*[x]), m_xMax (x) + { + for (size_t i = 0; i < m_xMax; i++) + p[i] = new T[y]; + } - ~Array2D (void) - { - for (size_t i = 0; i < m_xMax; i++) - delete[] p[i]; - delete[] p; - p = 0; - } + ~Array2D (void) + { + for (size_t i = 0; i < m_xMax; i++) + delete[] p[i]; + delete[] p; + p = 0; + } - T* operator[] (const size_t i) - { - return p[i]; - } - private: - T** p; - const size_t m_xMax; + /** + * Accessor operator + * \param i index to be retrieved + * \return a pointer to the indexed element + */ + T* operator[] (const size_t i) + { + return p[i]; + } +private: + T** p; //!< Stored elements + const size_t m_xMax; //!< maximum number of rows }; +/** + * \ingroup nix-vector-routing + * 3D array used in nix-vector-routing example "nms-p2p-nix.cc" + */ template class Array3D { - public: - Array3D (const size_t x, const size_t y, const size_t z) - : p (new Array2D*[x]), m_xMax (x) - { - for (size_t i = 0; i < m_xMax; i++) - p[i] = new Array2D (y, z); - } +public: + /** + * Constructor + * \param x number of rows + * \param y number of columns + * \param z number of layers + */ + Array3D (const size_t x, const size_t y, const size_t z) : p (new Array2D*[x]), m_xMax (x) + { + for (size_t i = 0; i < m_xMax; i++) + p[i] = new Array2D (y, z); + } - ~Array3D (void) + ~Array3D (void) + { + for (size_t i = 0; i < m_xMax; i++) { - for (size_t i = 0; i < m_xMax; i++) - { - delete p[i]; - p[i] = 0; - } - delete[] p; - p = 0; + delete p[i]; + p[i] = 0; } + delete[] p; + p = 0; + } - Array2D& operator[] (const size_t i) - { - return *(p[i]); - } - private: - Array2D** p; - const size_t m_xMax; + /** + * Accessor operator + * \param i index to be retrieved + * \return a reference to an Array2D of the indexed element + */ + Array2D& operator[] (const size_t i) + { + return *(p[i]); + } +private: + Array2D** p; //!< Stored elements + const size_t m_xMax; //!< maximum number of rows }; int diff --git a/src/nix-vector-routing/helper/ipv4-nix-vector-helper.h b/src/nix-vector-routing/helper/ipv4-nix-vector-helper.h index acbaaa35a..cfa41e205 100644 --- a/src/nix-vector-routing/helper/ipv4-nix-vector-helper.h +++ b/src/nix-vector-routing/helper/ipv4-nix-vector-helper.h @@ -27,6 +27,8 @@ namespace ns3 { /** + * \ingroup nix-vector-routing + * * \brief Helper class that adds Nix-vector routing to nodes. * * This class is expected to be used in conjunction with @@ -68,6 +70,7 @@ private: /** * \brief Assignment operator declared private and not implemented to disallow * assignment and prevent the compiler from happily inserting its own. + * \return Nothing useful. */ Ipv4NixVectorHelper &operator = (const Ipv4NixVectorHelper &); diff --git a/src/nix-vector-routing/model/ipv4-nix-vector-routing.h b/src/nix-vector-routing/model/ipv4-nix-vector-routing.h index c248fe22c..fb793be45 100644 --- a/src/nix-vector-routing/model/ipv4-nix-vector-routing.h +++ b/src/nix-vector-routing/model/ipv4-nix-vector-routing.h @@ -57,7 +57,7 @@ public: ~Ipv4NixVectorRouting (); /** * @brief The Interface ID of the Global Router interface. - * + * @return The Interface ID * @see Object::GetObject () */ static TypeId GetTypeId (void); @@ -83,63 +83,117 @@ public: private: - /* flushes the cache which stores nix-vector based on - * destination IP */ + /** + * Flushes the cache which stores nix-vector based on + * destination IP + */ void FlushNixCache (void) const; - /* flushes the cache which stores the Ipv4 route - * based on the destination IP */ + /** + * Flushes the cache which stores the Ipv4 route + * based on the destination IP + */ void FlushIpv4RouteCache (void) const; - /* upon a run-time topology change caches are + /** + * Upon a run-time topology change caches are * flushed and the total number of neighbors is - * reset to zero */ + * reset to zero + */ void ResetTotalNeighbors (void); - /* takes in the source node and dest IP and calls GetNodeByIp, - * BFS, accounting for any output interface specified, and finally - * BuildNixVector to return the built nix-vector */ - Ptr GetNixVector (Ptr, Ipv4Address, Ptr); + /** + * Takes in the source node and dest IP and calls GetNodeByIp, + * BFS, accounting for any output interface specified, and finally + * BuildNixVector to return the built nix-vector + * + * \param source Source node + * \param dest Destination node address + * \param oif Preferred output interface + * \returns The NixVector to be used in routing. + */ + Ptr GetNixVector (Ptr source, Ipv4Address dest, Ptr oif); - /* checks the cache based on dest IP for the nix-vector */ - Ptr GetNixVectorInCache (Ipv4Address); + /** + * Checks the cache based on dest IP for the nix-vector + * \param address Address to check + * \returns The NixVector to be used in routing. + */ + Ptr GetNixVectorInCache (Ipv4Address address); - /* checks the cache based on dest IP for the Ipv4Route */ - Ptr GetIpv4RouteInCache (Ipv4Address); + /** + * Checks the cache based on dest IP for the Ipv4Route + * \param address Address to check + * \returns The cached route. + */ + Ptr GetIpv4RouteInCache (Ipv4Address address); - /* given a net-device returns all the adjacent net-devices, - * essentially getting the neighbors on that channel */ - void GetAdjacentNetDevices (Ptr, Ptr, NetDeviceContainer &); + /** + * Given a net-device returns all the adjacent net-devices, + * essentially getting the neighbors on that channel + * \param [in] netDevice the NetDevice attached to the channel. + * \param [in] channel the channel to check + * \param [out] netDeviceContainer the NetDeviceContainer of the NetDevices in the channel. + */ + void GetAdjacentNetDevices (Ptr netDevice, Ptr channel, NetDeviceContainer & netDeviceContainer); - /* iterates through the node list and finds the one - * corresponding to the given Ipv4Address */ - Ptr GetNodeByIp (Ipv4Address); + /** + * Iterates through the node list and finds the one + * corresponding to the given Ipv4Address + * \param dest detination node IP + * \return The node with the specified IP. + */ + Ptr GetNodeByIp (Ipv4Address dest); - /* Recurses the parent vector, created by BFS and actually builds the nixvector */ + /** + * Recurses the parent vector, created by BFS and actually builds the nixvector + * \param [in] parentVector Parent vector for retracing routes + * \param [in] source Source Node index + * \param [in] dest Destination Node index + * \param [out] nixVector the NixVector to be used for routing + * \returns true on success, false otherwise. + */ bool BuildNixVector (const std::vector< Ptr > & parentVector, uint32_t source, uint32_t dest, Ptr nixVector); - /* special variation of BuildNixVector for when a node is sending to itself */ + /** + * Special variation of BuildNixVector for when a node is sending to itself + * \param [out] nixVector the NixVector to be used for routing + * \returns true on success, false otherwise. + */ bool BuildNixVectorLocal (Ptr nixVector); - /* simple iterates through the nodes net-devices and determines - * how many neighbors it has */ + /** + * Simple iterates through the nodes net-devices and determines + * how many neighbors it has + * \returns the number of neighbors. + */ uint32_t FindTotalNeighbors (void); - /* determine if the netdevice is bridged */ + /** + * Determine if the NetDevice is bridged + * \param nd the NetDevice to check + * \returns the bridging NetDevice (or null if the NetDevice is not bridged) + */ Ptr NetDeviceIsBridged (Ptr nd) const; - /* Nix index is with respect to the neighbors. The net-device index must be - * derived from this */ + /** + * Nix index is with respect to the neighbors. The net-device index must be + * derived from this + * \param [in] nodeIndex Nix Node index + * \param [out] gatewayIp IP address of the gateway + * \returns the index of the NetDevice in the node. + */ uint32_t FindNetDeviceForNixIndex (uint32_t nodeIndex, Ipv4Address & gatewayIp); - /* Breadth first search algorithm - * Param1: total number of nodes - * Param2: Source Node - * Param3: Dest Node - * Param4: (returned) Parent vector for retracing routes - * Param5: specific output interface to use from source node, if not null - * Returns: false if dest not found, true o.w. + /** + * \brief Breadth first search algorithm. + * \param [in] numberOfNodes total number of nodes + * \param [in] source Source Node + * \param [in] dest Destination Node + * \param [out] parentVector Parent vector for retracing routes + * \param [in] oif specific output interface to use from source node, if not null + * \returns false if dest not found, true o.w. */ bool BFS (uint32_t numberOfNodes, Ptr source, @@ -161,28 +215,27 @@ private: virtual void SetIpv4 (Ptr ipv4); virtual void PrintRoutingTable (Ptr stream, Time::Unit unit = Time::S) const; - /* + /** * Flushes routing caches if required. */ void CheckCacheStateAndFlush (void) const; - /* + /** * Flag to mark when caches are dirty and need to be flushed. * Used for lazy cleanup of caches when there are many topology changes. */ static bool g_isCacheDirty; - /* Cache stores nix-vectors based on destination ip */ + /** Cache stores nix-vectors based on destination ip */ mutable NixMap_t m_nixCache; - /* Cache stores Ipv4Routes based on destination ip */ + /** Cache stores Ipv4Routes based on destination ip */ mutable Ipv4RouteMap_t m_ipv4RouteCache; - Ptr m_ipv4; - Ptr m_node; + Ptr m_ipv4; //!< IPv4 object + Ptr m_node; //!< Node object - /* Total neighbors used for nix-vector to determine - * number of bits */ + /** Total neighbors used for nix-vector to determine number of bits */ uint32_t m_totalNeighbors; }; } // namespace ns3