From 31bad4422dc13512a3db98183c13e646ec693671 Mon Sep 17 00:00:00 2001 From: Robert Ammon Date: Thu, 11 May 2017 11:53:24 -0700 Subject: [PATCH] aodv: Fix Doxygen warnings --- src/aodv/helper/aodv-helper.h | 11 +- src/aodv/model/aodv-dpd.h | 12 +- src/aodv/model/aodv-id-cache.h | 36 ++- src/aodv/model/aodv-neighbor.h | 51 +++- src/aodv/model/aodv-packet.h | 364 ++++++++++++++++++++++--- src/aodv/model/aodv-routing-protocol.h | 156 ++++++++--- src/aodv/model/aodv-rqueue.h | 174 ++++++++++-- src/aodv/model/aodv-rtable.h | 276 ++++++++++++++++--- 8 files changed, 899 insertions(+), 181 deletions(-) diff --git a/src/aodv/helper/aodv-helper.h b/src/aodv/helper/aodv-helper.h index d39fed424..bf83cc59c 100644 --- a/src/aodv/helper/aodv-helper.h +++ b/src/aodv/helper/aodv-helper.h @@ -26,8 +26,7 @@ #include "ns3/node-container.h" #include "ns3/ipv4-routing-helper.h" -namespace ns3 -{ +namespace ns3 { /** * \ingroup aodv * \brief Helper class that adds AODV routing to nodes. @@ -35,11 +34,11 @@ namespace ns3 class AodvHelper : public Ipv4RoutingHelper { public: - AodvHelper(); + AodvHelper (); /** - * \returns pointer to clone of this OlsrHelper - * + * \returns pointer to clone of this AodvHelper + * * \internal * This method is mainly for internal use by the other helpers; * clients are expected to free the dynamic memory allocated by this method @@ -51,7 +50,7 @@ public: * \returns a newly-created routing protocol * * This method will be called by ns3::InternetStackHelper::Install - * + * * \todo support installing AODV on the subset of all available IP interfaces */ virtual Ptr Create (Ptr node) const; diff --git a/src/aodv/model/aodv-dpd.h b/src/aodv/model/aodv-dpd.h index 6f886ae5c..d91a18a46 100644 --- a/src/aodv/model/aodv-dpd.h +++ b/src/aodv/model/aodv-dpd.h @@ -28,13 +28,11 @@ #include "ns3/packet.h" #include "ns3/ipv4-header.h" -namespace ns3 -{ -namespace aodv -{ +namespace ns3 { +namespace aodv { /** * \ingroup aodv - * + * * \brief Helper class used to remember already seen packets and detect duplicates. * * Currently duplicate detection is based on uinique packet ID given by Packet::GetUid () @@ -44,7 +42,9 @@ class DuplicatePacketDetection { public: /// C-tor - DuplicatePacketDetection (Time lifetime) : m_idCache (lifetime) {} + DuplicatePacketDetection (Time lifetime) : m_idCache (lifetime) + { + } /// Check that the packet is duplicated. If not, save information about this packet. bool IsDuplicate (Ptr p, const Ipv4Header & header); /// Set duplicate records lifetimes diff --git a/src/aodv/model/aodv-id-cache.h b/src/aodv/model/aodv-id-cache.h index 559827a98..863b23bac 100644 --- a/src/aodv/model/aodv-id-cache.h +++ b/src/aodv/model/aodv-id-cache.h @@ -33,20 +33,20 @@ #include "ns3/simulator.h" #include -namespace ns3 -{ -namespace aodv -{ +namespace ns3 { +namespace aodv { /** * \ingroup aodv - * + * * \brief Unique packets identification cache used for simple duplicate detection. */ class IdCache { public: /// c-tor - IdCache (Time lifetime) : m_lifetime (lifetime) {} + IdCache (Time lifetime) : m_lifetime (lifetime) + { + } /// Check that entry (addr, id) exists in cache. Add entry, if it doesn't exist. bool IsDuplicate (Ipv4Address addr, uint32_t id); /// Remove all expired entries @@ -54,9 +54,15 @@ public: /// Return number of entries in cache uint32_t GetSize (); /// Set lifetime for future added entries. - void SetLifetime (Time lifetime) { m_lifetime = lifetime; } + void SetLifetime (Time lifetime) + { + m_lifetime = lifetime; + } /// Return lifetime for existing entries in cache - Time GetLifeTime () const { return m_lifetime; } + Time GetLifeTime () const + { + return m_lifetime; + } private: /// Unique packet ID struct UniqueId @@ -68,8 +74,17 @@ private: /// When record will expire Time m_expire; }; + /** + * \brief IsExpired structure + */ struct IsExpired { + /** + * \brief Check if the entry is expired + * + * \param u UniqueId entry + * \return true if expired, false otherwise + */ bool operator() (const struct UniqueId & u) const { return (u.m_expire < Simulator::Now ()); @@ -81,6 +96,7 @@ private: Time m_lifetime; }; -} -} +} // namespace aodv +} // namespace ns3 + #endif /* AODV_ID_CACHE_H */ diff --git a/src/aodv/model/aodv-neighbor.h b/src/aodv/model/aodv-neighbor.h index 3e4952e38..d1bb4597a 100644 --- a/src/aodv/model/aodv-neighbor.h +++ b/src/aodv/model/aodv-neighbor.h @@ -37,10 +37,8 @@ #include "ns3/arp-cache.h" #include -namespace ns3 -{ -namespace aodv -{ +namespace ns3 { +namespace aodv { class RoutingProtocol; /** * \ingroup aodv @@ -54,14 +52,27 @@ public: /// Neighbor description struct Neighbor { + /// Neighbor IPv4 address Ipv4Address m_neighborAddress; + /// Neighbor MAC address Mac48Address m_hardwareAddress; + /// Neighbor expire time Time m_expireTime; + /// Neighbor close indicator bool close; - Neighbor (Ipv4Address ip, Mac48Address mac, Time t) : - m_neighborAddress (ip), m_hardwareAddress (mac), m_expireTime (t), - close (false) + /** + * \brief Neighbor structure constructor + * + * \param ip Ipv4Address entry + * \param mac Mac48Address entry + * \param t Time expire time + */ + Neighbor (Ipv4Address ip, Mac48Address mac, Time t) + : m_neighborAddress (ip), + m_hardwareAddress (mac), + m_expireTime (t), + close (false) { } }; @@ -76,19 +87,31 @@ public: /// Schedule m_ntimer. void ScheduleTimer (); /// Remove all entries - void Clear () { m_nb.clear (); } + void Clear () + { + m_nb.clear (); + } /// Add ARP cache to be used to allow layer 2 notifications processing void AddArpCache (Ptr); /// Don't use given ARP cache any more (interface is down) void DelArpCache (Ptr); /// Get callback to ProcessTxError - Callback GetTxErrorCallback () const { return m_txErrorCallback; } - + Callback GetTxErrorCallback () const + { + return m_txErrorCallback; + } + /// Handle link failure callback - void SetCallback (Callback cb) { m_handleLinkFailure = cb; } + void SetCallback (Callback cb) + { + m_handleLinkFailure = cb; + } /// Handle link failure callback - Callback GetCallback () const { return m_handleLinkFailure; } + Callback GetCallback () const + { + return m_handleLinkFailure; + } private: /// link failure callback @@ -108,7 +131,7 @@ private: void ProcessTxError (WifiMacHeader const &); }; -} -} +} // namespace aodv +} // namespace ns3 #endif /* AODVNEIGHBOR_H */ diff --git a/src/aodv/model/aodv-packet.h b/src/aodv/model/aodv-packet.h index b35c0e9a8..592da5b74 100644 --- a/src/aodv/model/aodv-packet.h +++ b/src/aodv/model/aodv-packet.h @@ -15,10 +15,10 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * Based on + * Based on * NS-2 AODV model developed by the CMU/MONARCH group and optimized and * tuned by Samir Das and Mahesh Marina, University of Cincinnati; - * + * * AODV-UU implementation by Erik Nordström of Uppsala University * http://core.it.uu.se/core/index.php/AODV-UU * @@ -38,6 +38,10 @@ namespace ns3 { namespace aodv { +/** +* \ingroup aodv +* \brief MessageType enumeration +*/ enum MessageType { AODVTYPE_RREQ = 1, //!< AODVTYPE_RREQ @@ -56,7 +60,10 @@ public: /// c-tor TypeHeader (MessageType t = AODVTYPE_RREQ); - // Header serialization/deserialization + /** + * \brief Get the type ID. + * \return the object TypeId + */ static TypeId GetTypeId (); TypeId GetInstanceTypeId () const; uint32_t GetSerializedSize () const; @@ -65,15 +72,31 @@ public: void Print (std::ostream &os) const; /// Return type - MessageType Get () const { return m_type; } + MessageType Get () const + { + return m_type; + } /// Check that type if valid - bool IsValid () const { return m_valid; } + bool IsValid () const + { + return m_valid; + } + /** + * \brief Comparison operator + * \param o header to compare + * \return true if the headers are equal + */ bool operator== (TypeHeader const & o) const; private: - MessageType m_type; - bool m_valid; + MessageType m_type; ///< type of the message + bool m_valid; ///< Indicates if the message is valid }; +/** + * \brief Stream output operator + * \param os output stream + * \return updated stream + */ std::ostream & operator<< (std::ostream & os, TypeHeader const & h); /** @@ -97,7 +120,7 @@ std::ostream & operator<< (std::ostream & os, TypeHeader const & h); +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ \endverbatim */ -class RreqHeader : public Header +class RreqHeader : public Header { public: /// c-tor @@ -106,7 +129,10 @@ public: uint32_t dstSeqNo = 0, Ipv4Address origin = Ipv4Address (), uint32_t originSeqNo = 0); - // Header serialization/deserialization + /** + * \brief Get the type ID. + * \return the object TypeId + */ static TypeId GetTypeId (); TypeId GetInstanceTypeId () const; uint32_t GetSerializedSize () const; @@ -115,31 +141,144 @@ public: void Print (std::ostream &os) const; // Fields - void SetHopCount (uint8_t count) { m_hopCount = count; } - uint8_t GetHopCount () const { return m_hopCount; } - void SetId (uint32_t id) { m_requestID = id; } - uint32_t GetId () const { return m_requestID; } - void SetDst (Ipv4Address a) { m_dst = a; } - Ipv4Address GetDst () const { return m_dst; } - void SetDstSeqno (uint32_t s) { m_dstSeqNo = s; } - uint32_t GetDstSeqno () const { return m_dstSeqNo; } - void SetOrigin (Ipv4Address a) { m_origin = a; } - Ipv4Address GetOrigin () const { return m_origin; } - void SetOriginSeqno (uint32_t s) { m_originSeqNo = s; } - uint32_t GetOriginSeqno () const { return m_originSeqNo; } + /** + * \brief Set the hop count + * \param count the hop count + */ + void SetHopCount (uint8_t count) + { + m_hopCount = count; + } + /** + * \brief Get the hop count + * \return the hop count + */ + uint8_t GetHopCount () const + { + return m_hopCount; + } + /** + * \brief Set the request ID + * \param id the request ID + */ + void SetId (uint32_t id) + { + m_requestID = id; + } + /** + * \brief Get the request ID + * \return the request ID + */ + uint32_t GetId () const + { + return m_requestID; + } + /** + * \brief Set the destination address + * \param a the destination address + */ + void SetDst (Ipv4Address a) + { + m_dst = a; + } + /** + * \brief Get the destination address + * \return the destination address + */ + Ipv4Address GetDst () const + { + return m_dst; + } + /** + * \brief Set the destination sequence number + * \param s the destination sequence number + */ + void SetDstSeqno (uint32_t s) + { + m_dstSeqNo = s; + } + /** + * \brief Get the destination sequence number + * \return the destination sequence number + */ + uint32_t GetDstSeqno () const + { + return m_dstSeqNo; + } + /** + * \brief Set the origin address + * \param a the origin address + */ + void SetOrigin (Ipv4Address a) + { + m_origin = a; + } + /** + * \brief Get the origin address + * \return the origin address + */ + Ipv4Address GetOrigin () const + { + return m_origin; + } + /** + * \brief Set the origin sequence number + * \param s the origin sequence number + */ + void SetOriginSeqno (uint32_t s) + { + m_originSeqNo = s; + } + /** + * \brief Get the origin sequence number + * \return the origin sequence number + */ + uint32_t GetOriginSeqno () const + { + return m_originSeqNo; + } // Flags + /** + * \brief Set the gratuitous RREP flag + * \param f the gratuitous RREP flag + */ void SetGratiousRrep (bool f); + /** + * \brief Get the gratuitous RREP flag + * \return the gratuitous RREP flag + */ bool GetGratiousRrep () const; + /** + * \brief Set the Destination only flag + * \param f the Destiantion only flag + */ void SetDestinationOnly (bool f); + /** + * \brief Get the Destination only flag + * \return the Destination only flag + */ bool GetDestinationOnly () const; + /** + * \brief Set the unknown sequence number flag + * \param f the unknown sequence number flag + */ void SetUnknownSeqno (bool f); + /** + * \brief Get the unknown sequence number flag + * \return the unknown sequence number flag + */ bool GetUnknownSeqno () const; + /** + * \brief Comparison operator + * \param o RREQ header to compare + * \return true if the RREQ headers are equal + */ bool operator== (RreqHeader const & o) const; private: uint8_t m_flags; ///< |J|R|G|D|U| bit flags, see RFC - uint8_t m_reserved; ///< Not used + uint8_t m_reserved; ///< Not used (must be 0) uint8_t m_hopCount; ///< Hop Count uint32_t m_requestID; ///< RREQ ID Ipv4Address m_dst; ///< Destination IP Address @@ -148,6 +287,11 @@ private: uint32_t m_originSeqNo; ///< Source Sequence Number }; +/** + * \brief Stream output operator + * \param os output stream + * \return updated stream + */ std::ostream & operator<< (std::ostream & os, RreqHeader const &); /** @@ -176,7 +320,10 @@ public: RrepHeader (uint8_t prefixSize = 0, uint8_t hopCount = 0, Ipv4Address dst = Ipv4Address (), uint32_t dstSeqNo = 0, Ipv4Address origin = Ipv4Address (), Time lifetime = MilliSeconds (0)); - // Header serialization/deserialization + /** + * \brief Get the type ID. + * \return the object TypeId + */ static TypeId GetTypeId (); TypeId GetInstanceTypeId () const; uint32_t GetSerializedSize () const; @@ -185,26 +332,111 @@ public: void Print (std::ostream &os) const; // Fields - void SetHopCount (uint8_t count) { m_hopCount = count; } - uint8_t GetHopCount () const { return m_hopCount; } - void SetDst (Ipv4Address a) { m_dst = a; } - Ipv4Address GetDst () const { return m_dst; } - void SetDstSeqno (uint32_t s) { m_dstSeqNo = s; } - uint32_t GetDstSeqno () const { return m_dstSeqNo; } - void SetOrigin (Ipv4Address a) { m_origin = a; } - Ipv4Address GetOrigin () const { return m_origin; } + /** + * \brief Set the hop count + * \param count the hop count + */ + void SetHopCount (uint8_t count) + { + m_hopCount = count; + } + /** + * \brief Get the hop count + * \return the hop count + */ + uint8_t GetHopCount () const + { + return m_hopCount; + } + /** + * \brief Set the destination address + * \param a the destination address + */ + void SetDst (Ipv4Address a) + { + m_dst = a; + } + /** + * \brief Get the destination address + * \return the destination address + */ + Ipv4Address GetDst () const + { + return m_dst; + } + /** + * \brief Set the destination sequence number + * \param s the destination sequence number + */ + void SetDstSeqno (uint32_t s) + { + m_dstSeqNo = s; + } + /** + * \brief Get the destination sequence number + * \return the destination sequence number + */ + uint32_t GetDstSeqno () const + { + return m_dstSeqNo; + } + /** + * \brief Set the origin address + * \param a the origin address + */ + void SetOrigin (Ipv4Address a) + { + m_origin = a; + } + /** + * \brief Get the origin address + * \return the origin address + */ + Ipv4Address GetOrigin () const + { + return m_origin; + } + /** + * \brief Set the lifetime + * \param t the lifetime + */ void SetLifeTime (Time t); + /** + * \brief Get the lifetime + * \return the lifetime + */ Time GetLifeTime () const; // Flags + /** + * \brief Set the ack required flag + * \param f the ack required flag + */ void SetAckRequired (bool f); + /** + * \brief get the ack required flag + * \return the ack required flag + */ bool GetAckRequired () const; + /** + * \brief Set the prefix size + * \param sz the prefix size + */ void SetPrefixSize (uint8_t sz); + /** + * \brief Set the pefix size + * \return the prefix size + */ uint8_t GetPrefixSize () const; /// Configure RREP to be a Hello message void SetHello (Ipv4Address src, uint32_t srcSeqNo, Time lifetime); + /** + * \brief Comparison operator + * \param o RREP header to compare + * \return true if the RREP headers are equal + */ bool operator== (RrepHeader const & o) const; private: uint8_t m_flags; ///< A - acknowledgment required flag @@ -216,6 +448,11 @@ private: uint32_t m_lifeTime; ///< Lifetime (in milliseconds) }; +/** + * \brief Stream output operator + * \param os output stream + * \return updated stream + */ std::ostream & operator<< (std::ostream & os, RrepHeader const &); /** @@ -235,7 +472,10 @@ public: /// c-tor RrepAckHeader (); - // Header serialization/deserialization + /** + * \brief Get the type ID. + * \return the object TypeId + */ static TypeId GetTypeId (); TypeId GetInstanceTypeId () const; uint32_t GetSerializedSize () const; @@ -243,10 +483,21 @@ public: uint32_t Deserialize (Buffer::Iterator start); void Print (std::ostream &os) const; + /** + * \brief Comparison operator + * \param o RREP header to compare + * \return true if the RREQ headers are equal + */ bool operator== (RrepAckHeader const & o) const; private: - uint8_t m_reserved; + uint8_t m_reserved; ///< Not used (must be 0) }; + +/** + * \brief Stream output operator + * \param os output stream + * \return updated stream + */ std::ostream & operator<< (std::ostream & os, RrepAckHeader const &); @@ -275,7 +526,10 @@ public: /// c-tor RerrHeader (); - // Header serialization/deserialization + /** + * \brief Get the type ID. + * \return the object TypeId + */ static TypeId GetTypeId (); TypeId GetInstanceTypeId () const; uint32_t GetSerializedSize () const; @@ -284,32 +538,60 @@ public: void Print (std::ostream &os) const; // No delete flag + /** + * \brief Set the no delete flag + * \param f the no delete flag + */ void SetNoDelete (bool f); + /** + * \brief Get the no delete flag + * \return the no delete flag + */ bool GetNoDelete () const; /** - * Add unreachable node address and its sequence number in RERR header - *\return false if we already added maximum possible number of unreachable destinations + * \brief Add unreachable node address and its sequence number in RERR header + * \param dst unreachable IPv4 address + * \param seqNo unreachable sequence number + * \return false if we already added maximum possible number of unreachable destinations */ bool AddUnDestination (Ipv4Address dst, uint32_t seqNo); - /** Delete pair (address + sequence number) from REER header, if the number of unreachable destinations > 0 + /** + * \brief Delete pair (address + sequence number) from REER header, if the number of unreachable destinations > 0 + * \param un unreachable pair (address + sequence number) * \return true on success */ bool RemoveUnDestination (std::pair & un); /// Clear header void Clear (); /// Return number of unreachable destinations in RERR message - uint8_t GetDestCount () const { return (uint8_t)m_unreachableDstSeqNo.size (); } + uint8_t GetDestCount () const + { + return (uint8_t)m_unreachableDstSeqNo.size (); + } + + /** + * \brief Comparison operator + * \param o RERR header to compare + * \return true if the RERR headers are equal + */ bool operator== (RerrHeader const & o) const; private: uint8_t m_flag; ///< No delete flag - uint8_t m_reserved; ///< Not used + uint8_t m_reserved; ///< Not used (must be 0) /// List of Unreachable destination: IP addresses and sequence numbers std::map m_unreachableDstSeqNo; }; +/** + * \brief Stream output operator + * \param os output stream + * \return updated stream + */ std::ostream & operator<< (std::ostream & os, RerrHeader const &); -} -} + +} // namespace aodv +} // namespace ns3 + #endif /* AODVPACKET_H */ diff --git a/src/aodv/model/aodv-routing-protocol.h b/src/aodv/model/aodv-routing-protocol.h index a379c0321..476eb66e1 100644 --- a/src/aodv/model/aodv-routing-protocol.h +++ b/src/aodv/model/aodv-routing-protocol.h @@ -15,10 +15,10 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * Based on + * Based on * NS-2 AODV model developed by the CMU/MONARCH group and optimized and * tuned by Samir Das and Mahesh Marina, University of Cincinnati; - * + * * AODV-UU implementation by Erik Nordström of Uppsala University * http://core.it.uu.se/core/index.php/AODV-UU * @@ -41,24 +41,26 @@ #include "ns3/ipv4-l3-protocol.h" #include -namespace ns3 -{ -namespace aodv -{ +namespace ns3 { +namespace aodv { /** * \ingroup aodv - * + * * \brief AODV routing protocol */ class RoutingProtocol : public Ipv4RoutingProtocol { public: + /** + * \brief Get the type ID. + * \return the object TypeId + */ static TypeId GetTypeId (void); static const uint32_t AODV_PORT; /// c-tor RoutingProtocol (); - virtual ~RoutingProtocol(); + virtual ~RoutingProtocol (); virtual void DoDispose (); // Inherited from Ipv4RoutingProtocol @@ -72,35 +74,112 @@ public: virtual void NotifyRemoveAddress (uint32_t interface, Ipv4InterfaceAddress address); virtual void SetIpv4 (Ptr ipv4); virtual void PrintRoutingTable (Ptr stream, Time::Unit unit = Time::S) const; - - // Handle protocol parameters - Time GetMaxQueueTime () const { return m_maxQueueTime; } - void SetMaxQueueTime (Time t); - uint32_t GetMaxQueueLen () const { return m_maxQueueLen; } - void SetMaxQueueLen (uint32_t len); - bool GetDesinationOnlyFlag () const { return m_destinationOnly; } - void SetDesinationOnlyFlag (bool f) { m_destinationOnly = f; } - bool GetGratuitousReplyFlag () const { return m_gratuitousReply; } - void SetGratuitousReplyFlag (bool f) { m_gratuitousReply = f; } - void SetHelloEnable (bool f) { m_enableHello = f; } - bool GetHelloEnable () const { return m_enableHello; } - void SetBroadcastEnable (bool f) { m_enableBroadcast = f; } - bool GetBroadcastEnable () const { return m_enableBroadcast; } - /** - * Assign a fixed random variable stream number to the random variables - * used by this model. Return the number of streams (possibly zero) that - * have been assigned. - * - * \param stream first stream index to use - * \return the number of stream indices assigned by this model - */ + // Handle protocol parameters + /** + * Get maximum queue time + * \returns the maximum queue time + */ + Time GetMaxQueueTime () const + { + return m_maxQueueTime; + } + /** + * Set the maximum queue time + * \param t the maximum queue time + */ + void SetMaxQueueTime (Time t); + /** + * Get the maximum queue length + * \returns the maximum queue length + */ + uint32_t GetMaxQueueLen () const + { + return m_maxQueueLen; + } + /** + * Set the maximum queue length + * \param len the maximum queue length + */ + void SetMaxQueueLen (uint32_t len); + /** + * Get destination only flag + * \returns the destination only flag + */ + bool GetDesinationOnlyFlag () const + { + return m_destinationOnly; + } + /** + * Set destination only flag + * \param f the destination only flag + */ + void SetDesinationOnlyFlag (bool f) + { + m_destinationOnly = f; + } + /** + * Get gratuitous reply flag + * \returns the gratuitous reply flag + */ + bool GetGratuitousReplyFlag () const + { + return m_gratuitousReply; + } + /** + * Set gratuitous reply flag + * \param f the gratuitous reply flag + */ + void SetGratuitousReplyFlag (bool f) + { + m_gratuitousReply = f; + } + /** + * Set hello enable + * \param f the hello enable flag + */ + void SetHelloEnable (bool f) + { + m_enableHello = f; + } + /** + * Get hello enable flag + * \returns the enable hello flag + */ + bool GetHelloEnable () const + { + return m_enableHello; + } + /** + * Set broadcast enable flag + * \param f enable broadcast flag + */ + void SetBroadcastEnable (bool f) + { + m_enableBroadcast = f; + } + /** + * Get broadcast enable flag + * \returns the broadcast enable flag + */ + bool GetBroadcastEnable () const + { + return m_enableBroadcast; + } + + /** + * Assign a fixed random variable stream number to the random variables + * used by this model. Return the number of streams (possibly zero) that + * have been assigned. + * + * \param stream first stream index to use + * \return the number of stream indices assigned by this model + */ int64_t AssignStreams (int64_t stream); protected: virtual void DoInitialize (void); private: - // Protocol parameters. uint32_t m_rreqRetries; ///< Maximum number of retransmissions of RREQ with TTL = NetDiameter to discover a route uint16_t m_ttlStart; ///< Initial TTL value for RREQ. @@ -147,7 +226,7 @@ private: /// Raw subnet directed broadcast socket per each IP interface, map socket -> iface address (IP + mask) std::map< Ptr, Ipv4InterfaceAddress > m_socketSubnetBroadcastAddresses; /// Loopback device used to defer RREQ until packet will be fully formed - Ptr m_lo; + Ptr m_lo; /// Routing table RoutingTable m_routingTable; @@ -249,6 +328,12 @@ private: void SendRerrWhenNoRouteToForward (Ipv4Address dst, uint32_t dstSeqNo, Ipv4Address origin); /// @} + /** + * Send packet to desitnation scoket + * \param socket - destination node socket + * \param packet - packet to send + * \param destination - destination node IP address + */ void SendTo (Ptr socket, Ptr packet, Ipv4Address destination); /// Hello timer @@ -271,11 +356,12 @@ private: void AckTimerExpire (Ipv4Address neighbor, Time blacklistTimeout); /// Provides uniform random variables. - Ptr m_uniformRandomVariable; + Ptr m_uniformRandomVariable; /// Keep track of the last bcast time Time m_lastBcastTime; }; -} -} +} //namespace aodv +} //namespace ns3 + #endif /* AODVROUTINGPROTOCOL_H */ diff --git a/src/aodv/model/aodv-rqueue.h b/src/aodv/model/aodv-rqueue.h index 3dc24346a..581624e01 100644 --- a/src/aodv/model/aodv-rqueue.h +++ b/src/aodv/model/aodv-rqueue.h @@ -15,10 +15,10 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * Based on + * Based on * NS-2 AODV model developed by the CMU/MONARCH group and optimized and * tuned by Samir Das and Mahesh Marina, University of Cincinnati; - * + * * AODV-UU implementation by Erik Nordström of Uppsala University * http://core.it.uu.se/core/index.php/AODV-UU * @@ -43,18 +43,25 @@ namespace aodv { class QueueEntry { public: + /// IPv4 routing unicast forward callback typedef typedef Ipv4RoutingProtocol::UnicastForwardCallback UnicastForwardCallback; + /// IPv4 routing error callback typedef typedef Ipv4RoutingProtocol::ErrorCallback ErrorCallback; /// c-tor QueueEntry (Ptr pa = 0, Ipv4Header const & h = Ipv4Header (), UnicastForwardCallback ucb = UnicastForwardCallback (), - ErrorCallback ecb = ErrorCallback (), Time exp = Simulator::Now ()) : - m_packet (pa), m_header (h), m_ucb (ucb), m_ecb (ecb), - m_expire (exp + Simulator::Now ()) - {} + ErrorCallback ecb = ErrorCallback (), Time exp = Simulator::Now ()) + : m_packet (pa), + m_header (h), + m_ucb (ucb), + m_ecb (ecb), + m_expire (exp + Simulator::Now ()) + { + } /** - * Compare queue entries + * \brief Compare queue entries + * \param o QueueEntry to compare * \return true if equal */ bool operator== (QueueEntry const & o) const @@ -63,19 +70,88 @@ public: } // Fields - UnicastForwardCallback GetUnicastForwardCallback () const { return m_ucb; } - void SetUnicastForwardCallback (UnicastForwardCallback ucb) { m_ucb = ucb; } - ErrorCallback GetErrorCallback () const { return m_ecb; } - void SetErrorCallback (ErrorCallback ecb) { m_ecb = ecb; } - Ptr GetPacket () const { return m_packet; } - void SetPacket (Ptr p) { m_packet = p; } - Ipv4Header GetIpv4Header () const { return m_header; } - void SetIpv4Header (Ipv4Header h) { m_header = h; } - void SetExpireTime (Time exp) { m_expire = exp + Simulator::Now (); } - Time GetExpireTime () const { return m_expire - Simulator::Now (); } + /** + * Get unicast forward callback + * \returns unicast callback + */ + UnicastForwardCallback GetUnicastForwardCallback () const + { + return m_ucb; + } + /** + * Set unicast forward callback + * \param ucb The unicast callback + */ + void SetUnicastForwardCallback (UnicastForwardCallback ucb) + { + m_ucb = ucb; + } + /** + * Get error callback + * \returns the error callback + */ + ErrorCallback GetErrorCallback () const + { + return m_ecb; + } + /** + * Set error callback + * \param ecb The error callback + */ + void SetErrorCallback (ErrorCallback ecb) + { + m_ecb = ecb; + } + /** + * Get packet from entry + * \returns the packet + */ + Ptr GetPacket () const + { + return m_packet; + } + /** + * Set packet in entry + * \param p The packet + */ + void SetPacket (Ptr p) + { + m_packet = p; + } + /** + * Get IPv4 header + * \returns the IPv4 header + */ + Ipv4Header GetIpv4Header () const + { + return m_header; + } + /** + * Set IPv4 header + * \param h the IPv4 header + */ + void SetIpv4Header (Ipv4Header h) + { + m_header = h; + } + /** + * Set expire time + * \param exp The expiration time + */ + void SetExpireTime (Time exp) + { + m_expire = exp + Simulator::Now (); + } + /** + * Get expire time + * \returns the expiration time + */ + Time GetExpireTime () const + { + return m_expire - Simulator::Now (); + } private: - /// Data packet Ptr m_packet; /// IP header @@ -90,15 +166,16 @@ private: /** * \ingroup aodv * \brief AODV route request queue - * + * * Since AODV is an on demand routing we queue requests while looking for route. */ class RequestQueue { public: /// Default c-tor - RequestQueue (uint32_t maxLen, Time routeToQueueTimeout) : - m_maxLen (maxLen), m_queueTimeout (routeToQueueTimeout) + RequestQueue (uint32_t maxLen, Time routeToQueueTimeout) + : m_maxLen (maxLen), + m_queueTimeout (routeToQueueTimeout) { } /// Push entry in queue, if there is no entry with the same packet and destination address in queue. @@ -111,15 +188,43 @@ public: bool Find (Ipv4Address dst); /// Number of entries uint32_t GetSize (); - + // Fields - uint32_t GetMaxQueueLen () const { return m_maxLen; } - void SetMaxQueueLen (uint32_t len) { m_maxLen = len; } - Time GetQueueTimeout () const { return m_queueTimeout; } - void SetQueueTimeout (Time t) { m_queueTimeout = t; } + /** + * Get maximum queue length + * \returns the maximum queue length + */ + uint32_t GetMaxQueueLen () const + { + return m_maxLen; + } + /** + * Set maximum queue length + * \param len The maximum queue length + */ + void SetMaxQueueLen (uint32_t len) + { + m_maxLen = len; + } + /** + * Get queue timeout + * \returns the queue timeout + */ + Time GetQueueTimeout () const + { + return m_queueTimeout; + } + /** + * Set queue timeout + * \param t The queue timeout + */ + void SetQueueTimeout (Time t) + { + m_queueTimeout = t; + } private: - + /// The queue std::vector m_queue; /// Remove all expired entries void Purge (); @@ -129,11 +234,20 @@ private: uint32_t m_maxLen; /// The maximum period of time that a routing protocol is allowed to buffer a packet for, seconds. Time m_queueTimeout; - static bool IsEqual (QueueEntry en, const Ipv4Address dst) { return (en.GetIpv4Header ().GetDestination () == dst); } + /** + * Determine if queue matches a destination address + * \param en The queue entry + * \param dst The destination IPv4 address + * \returns true if the queue entry matches the desination address + */ + static bool IsEqual (QueueEntry en, const Ipv4Address dst) + { + return (en.GetIpv4Header ().GetDestination () == dst); + } }; -} -} +} // namespace aodv +} // namespace ns3 #endif /* AODV_RQUEUE_H */ diff --git a/src/aodv/model/aodv-rtable.h b/src/aodv/model/aodv-rtable.h index 537238b2c..592180059 100644 --- a/src/aodv/model/aodv-rtable.h +++ b/src/aodv/model/aodv-rtable.h @@ -15,10 +15,10 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * Based on + * Based on * NS-2 AODV model developed by the CMU/MONARCH group and optimized and * tuned by Samir Das and Mahesh Marina, University of Cincinnati; - * + * * AODV-UU implementation by Erik Nordström of Uppsala University * http://core.it.uu.se/core/index.php/AODV-UU * @@ -89,57 +89,244 @@ public: /// Delete all precursors void DeleteAllPrecursors (); /** - * Check that precursor list empty - * \return true if precursor list empty + * Check that precursor list is empty + * \return true if precursor list is empty */ bool IsPrecursorListEmpty () const; /** - * Inserts precursors in vector prec if they does not yet exist in vector + * Inserts precursors in output parameter prec if they do not yet exist in vector + * \param prec vector of precursor addresses */ void GetPrecursors (std::vector & prec) const; //\} /// Mark entry as "down" (i.e. disable it) void Invalidate (Time badLinkLifetime); - + // Fields - Ipv4Address GetDestination () const { return m_ipv4Route->GetDestination (); } - Ptr GetRoute () const { return m_ipv4Route; } - void SetRoute (Ptr r) { m_ipv4Route = r; } - void SetNextHop (Ipv4Address nextHop) { m_ipv4Route->SetGateway (nextHop); } - Ipv4Address GetNextHop () const { return m_ipv4Route->GetGateway (); } - void SetOutputDevice (Ptr dev) { m_ipv4Route->SetOutputDevice (dev); } - Ptr GetOutputDevice () const { return m_ipv4Route->GetOutputDevice (); } - Ipv4InterfaceAddress GetInterface () const { return m_iface; } - void SetInterface (Ipv4InterfaceAddress iface) { m_iface = iface; } - void SetValidSeqNo (bool s) { m_validSeqNo = s; } - bool GetValidSeqNo () const { return m_validSeqNo; } - void SetSeqNo (uint32_t sn) { m_seqNo = sn; } - uint32_t GetSeqNo () const { return m_seqNo; } - void SetHop (uint16_t hop) { m_hops = hop; } - uint16_t GetHop () const { return m_hops; } - void SetLifeTime (Time lt) { m_lifeTime = lt + Simulator::Now (); } - Time GetLifeTime () const { return m_lifeTime - Simulator::Now (); } - void SetFlag (RouteFlags flag) { m_flag = flag; } - RouteFlags GetFlag () const { return m_flag; } - void SetRreqCnt (uint8_t n) { m_reqCount = n; } - uint8_t GetRreqCnt () const { return m_reqCount; } - void IncrementRreqCnt () { m_reqCount++; } - void SetUnidirectional (bool u) { m_blackListState = u; } - bool IsUnidirectional () const { return m_blackListState; } - void SetBlacklistTimeout (Time t) { m_blackListTimeout = t; } - Time GetBlacklistTimeout () const { return m_blackListTimeout; } + /** + * Get destination address function + * \returns the IPv4 destiantion address + */ + Ipv4Address GetDestination () const + { + return m_ipv4Route->GetDestination (); + } + /** + * Get route function + * \returns The IPv4 route + */ + Ptr GetRoute () const + { + return m_ipv4Route; + } + /** + * Set route function + * \param r the IPv4 route + */ + void SetRoute (Ptr r) + { + m_ipv4Route = r; + } + /** + * Set next hop address + * \param nextHop the next hop IPv4 address + */ + void SetNextHop (Ipv4Address nextHop) + { + m_ipv4Route->SetGateway (nextHop); + } + /** + * Get next hop address + * \returns the next hop address + */ + Ipv4Address GetNextHop () const + { + return m_ipv4Route->GetGateway (); + } + /** + * Set output device + * \param dev The output device + */ + void SetOutputDevice (Ptr dev) + { + m_ipv4Route->SetOutputDevice (dev); + } + /** + * Get output device + * \returns the output device + */ + Ptr GetOutputDevice () const + { + return m_ipv4Route->GetOutputDevice (); + } + /** + * Get the Ipv4InterfaceAddress + * \returns the Ipv4InterfaceAddress + */ + Ipv4InterfaceAddress GetInterface () const + { + return m_iface; + } + /** + * Set the Ipv4InterfaceAddress + * \param iface The Ipv4InterfaceAddress + */ + void SetInterface (Ipv4InterfaceAddress iface) + { + m_iface = iface; + } + /** + * Set the valid sequence number + * \param s the sequence number + */ + void SetValidSeqNo (bool s) + { + m_validSeqNo = s; + } + /** + * Get the valid sequence number + * \returns the valid sequence number + */ + bool GetValidSeqNo () const + { + return m_validSeqNo; + } + /** + * Set the sequence number + * \param sn the sequence number + */ + void SetSeqNo (uint32_t sn) + { + m_seqNo = sn; + } + /** + * Get the sequence number + * \returns the sequence number + */ + uint32_t GetSeqNo () const + { + return m_seqNo; + } + /** + * Set the number of hops + * \param hop the number of hops + */ + void SetHop (uint16_t hop) + { + m_hops = hop; + } + /** + * Get the number of hops + * \returns the number of hops + */ + uint16_t GetHop () const + { + return m_hops; + } + /** + * Set the lifetime + * \param lt The lifetime + */ + void SetLifeTime (Time lt) + { + m_lifeTime = lt + Simulator::Now (); + } + /** + * Get the lifetime + * \returns the lifetime + */ + Time GetLifeTime () const + { + return m_lifeTime - Simulator::Now (); + } + /** + * Set the route flags + * \param flag the route flags + */ + void SetFlag (RouteFlags flag) + { + m_flag = flag; + } + /** + * Get the route flags + * \returns the route flags + */ + RouteFlags GetFlag () const + { + return m_flag; + } + /** + * Set the RREQ count + * \param n the RREQ count + */ + void SetRreqCnt (uint8_t n) + { + m_reqCount = n; + } + /** + * Get the RREQ count + * \returns the RREQ count + */ + uint8_t GetRreqCnt () const + { + return m_reqCount; + } + /** + * Increment the RREQ count + */ + void IncrementRreqCnt () + { + m_reqCount++; + } + /** + * Set the unidirectional flag + * \param u the uni directional flag + */ + void SetUnidirectional (bool u) + { + m_blackListState = u; + } + /** + * Get the unidirectional flag + * \returns the unidirectional flag + */ + bool IsUnidirectional () const + { + return m_blackListState; + } + /** + * Set the blacklist timeout + * \param t the blacklist timeout value + */ + void SetBlacklistTimeout (Time t) + { + m_blackListTimeout = t; + } + /** + * Get the blacklist timeout value + * \returns the blacklist timeout value + */ + Time GetBlacklistTimeout () const + { + return m_blackListTimeout; + } /// RREP_ACK timer Timer m_ackTimer; /** * \brief Compare destination address + * \param dst IP address to compare * \return true if equal */ bool operator== (Ipv4Address const dst) const { return (m_ipv4Route->GetDestination () == dst); } + /** + * Print packet to trace file + * \param stream The output stream + */ void Print (Ptr stream) const; private: @@ -151,7 +338,7 @@ private: uint16_t m_hops; /** * \brief Expiration or deletion time of the route - * Lifetime field in the routing table plays dual role -- + * Lifetime field in the routing table plays dual role: * for an active route it is the expiration time, and for an invalid route * it is the deletion time. */ @@ -191,8 +378,14 @@ public: RoutingTable (Time t); ///\name Handle life time of invalid route //\{ - Time GetBadLinkLifetime () const { return m_badLinkLifetime; } - void SetBadLinkLifetime (Time t) { m_badLinkLifetime = t; } + Time GetBadLinkLifetime () const + { + return m_badLinkLifetime; + } + void SetBadLinkLifetime (Time t) + { + m_badLinkLifetime = t; + } //\} /** * Add routing table entry if it doesn't yet exist in routing table @@ -222,17 +415,21 @@ public: /// Lookup routing entries with next hop Address dst and not empty list of precursors. void GetListOfDestinationWithNextHop (Ipv4Address nextHop, std::map & unreachable); /** - * Update routing entries with this destinations as follows: + * Update routing entries with this destination as follows: * 1. The destination sequence number of this routing entry, if it * exists and is valid, is incremented. * 2. The entry is invalidated by marking the route entry as invalid * 3. The Lifetime field is updated to current time plus DELETE_PERIOD. + * \param unreachable routes to invalidate */ void InvalidateRoutesWithDst (std::map const & unreachable); /// Delete all route from interface with address iface void DeleteAllRoutesFromInterface (Ipv4InterfaceAddress iface); /// Delete all entries from routing table - void Clear () { m_ipv4AddressEntry.clear (); } + void Clear () + { + m_ipv4AddressEntry.clear (); + } /// Delete all outdated entries and invalidate valid entry if Lifetime is expired void Purge (); /** Mark entry as unidirectional (e.g. add this neighbor to "blacklist" for blacklistTimeout period) @@ -245,6 +442,7 @@ public: void Print (Ptr stream) const; private: + /// The routing table std::map m_ipv4AddressEntry; /// Deletion time for invalid routes Time m_badLinkLifetime; @@ -252,7 +450,7 @@ private: void Purge (std::map &table) const; }; -} -} +} // namespace aodv +} // namespace ns3 #endif /* AODV_RTABLE_H */