[doxygen] dsr module (fix only trivial warnings)

This commit is contained in:
Daniel Lertpratchya
2013-12-13 10:28:25 -05:00
parent 013f400365
commit ef51173b0f
13 changed files with 621 additions and 474 deletions

View File

@@ -45,7 +45,16 @@ namespace dsr {
class ErrorBuffEntry
{
public:
// / c-tor
/**
* Create an ErrorBuffEntry with the given parameters.
*
* \param pa packet
* \param d IPv4 address of the destination
* \param s IPv4 address of the source
* \param n IPv4 address of the next hop
* \param exp expiration time
* \param p protocol number
*/
ErrorBuffEntry (Ptr<const Packet> pa = 0, Ipv4Address d = Ipv4Address (), Ipv4Address s = Ipv4Address (),
Ipv4Address n = Ipv4Address (), Time exp = Simulator::Now (), uint8_t p = 0)
: m_packet (pa),
@@ -58,13 +67,14 @@ public:
}
/**
* Compare send buffer entries
* \param o another ErrorBuffEntry
* \return true if equal
*/
bool operator== (ErrorBuffEntry const & o) const
{
return ((m_packet == o.m_packet) && (m_source == o.m_source) && (m_nextHop == o.m_nextHop) && (m_dst == o.m_dst) && (m_expire == o.m_expire));
}
// /\name Fields
///\name Fields
// \{
Ptr<const Packet> GetPacket () const
{
@@ -116,17 +126,17 @@ public:
}
// \}
private:
// / Data packet
/// Data packet
Ptr<const Packet> m_packet;
// / Destination address
/// Destination address
Ipv4Address m_dst;
// / Source address
/// Source address
Ipv4Address m_source;
// / Nexthop address
/// Nexthop address
Ipv4Address m_nextHop;
// / Expire time for queue entry
/// Expire time for queue entry
Time m_expire;
// / The protocol number
/// The protocol number
uint8_t m_protocol;
};
@@ -138,21 +148,23 @@ private:
class ErrorBuffer
{
public:
// / Default c-tor
/**
* Default constructor
*/
ErrorBuffer ()
{
}
// / Push entry in queue, if there is no entry with the same packet and destination address in queue.
/// Push entry in queue, if there is no entry with the same packet and destination address in queue.
bool Enqueue (ErrorBuffEntry & entry);
// / Return first found (the earliest) entry for given destination
/// Return first found (the earliest) entry for given destination
bool Dequeue (Ipv4Address dst, ErrorBuffEntry & entry);
// / Remove all packets with the error link
/// Remove all packets with the error link
void DropPacketForErrLink (Ipv4Address source, Ipv4Address nextHop);
// / Finds whether a packet with destination dst exists in the queue
/// Finds whether a packet with destination dst exists in the queue
bool Find (Ipv4Address dst);
// / Number of entries
/// Number of entries
uint32_t GetSize ();
// /\name Fields
///\name Fields
// \{
uint32_t GetMaxQueueLen () const
{
@@ -178,19 +190,19 @@ public:
}
private:
// / The send buffer to cache unsent packet
/// The send buffer to cache unsent packet
std::vector<ErrorBuffEntry> m_errorBuffer;
// / Remove all expired entries
/// Remove all expired entries
void Purge ();
// / Notify that packet is dropped from queue by timeout
/// Notify that packet is dropped from queue by timeout
void Drop (ErrorBuffEntry en, std::string reason);
// / Notify that packet is dropped from queue by timeout
/// Notify that packet is dropped from queue by timeout
void DropLink (ErrorBuffEntry en, std::string reason);
// / The maximum number of packets that we allow a routing protocol to buffer.
/// The maximum number of packets that we allow a routing protocol to buffer.
uint32_t m_maxLen;
// / The maximum period of time that a routing protocol is allowed to buffer a packet for, seconds.
/// The maximum period of time that a routing protocol is allowed to buffer a packet for, seconds.
Time m_errorBufferTimeout;
// / Check if the send buffer entry is the same or not
/// Check if the send buffer entry is the same or not
static bool LinkEqual (ErrorBuffEntry en, const std::vector<Ipv4Address> link)
{
return ((en.GetSource () == link[0]) && (en.GetNextHop () == link[1]));

View File

@@ -99,7 +99,7 @@ public:
virtual ~DsrFsHeader ();
/**
* \brief Set the "Next header" field.
* \param nextHeader the next header number
* \param protocol the next header number
*/
void SetNextHeader (uint8_t protocol);
/**
@@ -109,7 +109,7 @@ public:
uint8_t GetNextHeader () const;
/**
* brief Set the message type of the header.
* \param message type the message type of the header
* \param messageType the message type of the header
*/
void SetMessageType (uint8_t messageType);
/**
@@ -118,23 +118,23 @@ public:
*/
uint8_t GetMessageType () const;
/**
* brief Set the source id of the header.
* \param source id the source id of the header
* brief Set the source ID of the header.
* \param sourceId the source ID of the header
*/
void SetSourceId (uint16_t sourceId);
/**
* brief Get the source id of the header.
* \return source id the source id of the header
* brief Get the source ID of the header.
* \return source ID the source ID of the header
*/
uint16_t GetSourceId () const;
/**
* brief Set the dest id of the header.
* \param dest id the dest id of the header
* brief Set the dest ID of the header.
* \param destId the destination ID of the header
*/
void SetDestId (uint16_t destId);
/**
* brief Get the dest id of the header.
* \return dest id the dest id of the header
* brief Get the dest ID of the header.
* \return dest ID the dest ID of the header
*/
uint16_t GetDestId () const;
/**
@@ -257,6 +257,7 @@ private:
/**
* \brief Calculate padding.
* \param alignment alignment
* \return the number of bytes required to pad
*/
uint32_t CalculatePad (DsrOptionHeader::Alignment alignment) const;
/**

View File

@@ -65,49 +65,41 @@ struct GraReplyEntry
class GraReply : public Object
{
public:
// / c-tor
/**
* \brief Get the type identificator.
* \return type identificator
*/
static TypeId GetTypeId ();
/**
* \brief Constructor.
*/
GraReply ();
/**
* \brief Destructor.
*/
virtual ~GraReply ();
// / Set the gratuitous reply table size
/// Set the gratuitous reply table size
void SetGraTableSize (uint32_t g)
{
GraReplyTableSize = g;
}
// / Get the gratuitous reply table size
/// Get the gratuitous reply table size
uint32_t GetGraTableSize () const
{
return GraReplyTableSize;
}
// / Add a new gratuitous reply entry
/// Add a new gratuitous reply entry
bool AddEntry (GraReplyEntry & graTableEntry);
// / Update the route entry if found, create a new one if not
/// Update the route entry if found, create a new one if not
bool FindAndUpdate (Ipv4Address replyTo, Ipv4Address replyFrom, Time gratReplyHoldoff);
// / Remove all expired entries
/// Remove all expired entries
void Purge ();
// / Remove all entries
/// Remove all entries
void Clear ()
{
m_graReply.clear ();
}
private:
// / Vector of entries
/// Vector of entries
std::vector<GraReplyEntry> m_graReply;
// / The max # of gratuitous reply entries to hold
/// The max # of gratuitous reply entries to hold
uint32_t GraReplyTableSize;
// / Check if the entry is expired or not
/// Check if the entry is expired or not
struct IsExpired
{
bool operator() (const struct GraReplyEntry & b) const

View File

@@ -53,6 +53,7 @@ struct LinkKey
/**
* Compare maintain Buffer entries
* \param o
* \return true if equal
*/
bool operator < (LinkKey const & o) const
@@ -73,6 +74,7 @@ struct NetworkKey
/**
* Compare maintain Buffer entries
* \param o
* \return true if equal
*/
bool operator < (NetworkKey const & o) const
@@ -92,6 +94,7 @@ struct PassiveKey
/**
* Compare maintain Buffer entries
* \param o
* \return true if equal
*/
bool operator < (PassiveKey const & o) const
@@ -109,7 +112,18 @@ struct PassiveKey
class MaintainBuffEntry
{
public:
// / c-tor
/**
* Construct a MaintainBuffEntry with the given parameters
*
* \param pa packet
* \param us our IPv4 address
* \param n next hop IPv4 address
* \param s IPv4 address of the source
* \param dst IPv4 address of the destination
* \param ackId ACK ID
* \param segs number of segments left
* \param exp expiration time
*/
MaintainBuffEntry (Ptr<const Packet> pa = 0, Ipv4Address us = Ipv4Address (),
Ipv4Address n = Ipv4Address (), Ipv4Address s = Ipv4Address (), Ipv4Address dst = Ipv4Address (),
uint16_t ackId = 0, uint8_t segs = 0, Time exp = Simulator::Now ())
@@ -124,7 +138,7 @@ public:
{
}
// /\name Fields
///\name Fields
// \{
Ptr<const Packet> GetPacket () const
{
@@ -192,21 +206,21 @@ public:
}
// \}
private:
// / Data packet
/// Data packet
Ptr<const Packet> m_packet;
// / Our own ip address
/// Our own ip address
Ipv4Address m_ourAdd;
// / Next hop Ip address
/// Next hop Ip address
Ipv4Address m_nextHop;
// / The source address
/// The source address
Ipv4Address m_src;
// / The destination address
/// The destination address
Ipv4Address m_dst;
// / The data ack id
/// The data ack id
uint16_t m_ackId;
// / The segments left field
/// The segments left field
uint8_t m_segsLeft;
// / Expire time for queue entry
/// Expire time for queue entry
Time m_expire;
};
/**
@@ -217,21 +231,23 @@ private:
class MaintainBuffer
{
public:
// / Default c-tor
/**
* Default constructor
*/
MaintainBuffer ()
{
}
// / Push entry in queue, if there is no entry with the same packet and destination address in queue.
/// Push entry in queue, if there is no entry with the same packet and destination address in queue.
bool Enqueue (MaintainBuffEntry & entry);
// / Return first found (the earliest) entry for given destination
/// Return first found (the earliest) entry for given destination
bool Dequeue (Ipv4Address dst, MaintainBuffEntry & entry);
// / Remove all packets with destination IP address dst
/// Remove all packets with destination IP address dst
void DropPacketWithNextHop (Ipv4Address nextHop);
// / Finds whether a packet with destination dst exists in the queue
/// Finds whether a packet with destination dst exists in the queue
bool Find (Ipv4Address nextHop);
// / Number of entries
/// Number of entries
uint32_t GetSize ();
// /\name Fields
///\name Fields
// \{
uint32_t GetMaxQueueLen () const
{
@@ -249,27 +265,27 @@ public:
{
m_maintainBufferTimeout = t;
}
// / Verify if all the elements in the maintainence buffer entry is the same
/// Verify if all the elements in the maintainence buffer entry is the same
bool AllEqual (MaintainBuffEntry & entry);
// / Verify if the maintain buffer entry is the same in every field for link ack
/// Verify if the maintain buffer entry is the same in every field for link ack
bool LinkEqual (MaintainBuffEntry & entry);
// / Verify if the maintain buffer entry is the same in every field for network ack
/// Verify if the maintain buffer entry is the same in every field for network ack
bool NetworkEqual (MaintainBuffEntry & entry);
// / Verify if the maintain buffer entry is the same in every field for promiscuous ack
/// Verify if the maintain buffer entry is the same in every field for promiscuous ack
bool PromiscEqual (MaintainBuffEntry & entry);
// \}
private:
// / The vector of maintain buffer entries
/// The vector of maintain buffer entries
std::vector<MaintainBuffEntry> m_maintainBuffer;
std::vector<NetworkKey> m_allNetworkKey;
// / Remove all expired entries
/// Remove all expired entries
void Purge ();
// / The maximum number of packets that we allow a routing protocol to buffer.
/// The maximum number of packets that we allow a routing protocol to buffer.
uint32_t m_maxLen;
// / The maximum period of time that a routing protocol is allowed to buffer a packet for, seconds.
/// The maximum period of time that a routing protocol is allowed to buffer a packet for, seconds.
Time m_maintainBufferTimeout;
// / Verify if the maintain buffer is equal or not
/// Verify if the maintain buffer is equal or not
static bool IsEqual (MaintainBuffEntry en, const Ipv4Address nextHop)
{
return (en.GetNextHop () == nextHop);

View File

@@ -53,7 +53,15 @@ enum DsrMessageType
class DsrNetworkQueueEntry
{
public:
/// c-tor
/**
* Construct a DsrNetworkQueueEntry with the given parameters
*
* \param pa packet
* \param s IPv4 address of the source
* \param n IPv4 address of the next hop node
* \param exp expiration time
* \param r Route
*/
DsrNetworkQueueEntry (Ptr<const Packet> pa = 0, Ipv4Address s = Ipv4Address (), Ipv4Address n = Ipv4Address (),
Time exp = Simulator::Now (), Ptr<Ipv4Route> r = 0)
: m_packet (pa),
@@ -65,6 +73,7 @@ public:
}
/**
* Compare send buffer entries
* \param o
* \return true if equal
*/
bool operator== (DsrNetworkQueueEntry const & o) const
@@ -130,21 +139,69 @@ class DsrNetworkQueue : public Object
{
public:
static TypeId GetTypeId (void);
/// Default c-tor
DsrNetworkQueue ();
/**
* Construct a DsrNetworkQueue with the given
* maximum length and maximum delay.
*
* \param maxLen Maximum queue size
* \param maxDelay Maximum entry lifetime in the queue
*/
DsrNetworkQueue (uint32_t maxLen, Time maxDelay);
~DsrNetworkQueue ();
/// Push entry in queue, if there is no entry with the same packet and destination address in queue.
/**
* Push entry in queue, if there is no entry with the same
* packet and destination address in queue.
*
* \param entry packet entry
* \return true if the given entry was put in the queue,
* false otherwise
*/
bool Enqueue (DsrNetworkQueueEntry & entry);
/// Return first found (the earliest) entry for given destination
/**
* Return first found (the earliest) entry for given destination
*
* \param entry pointer to the return entry
* \return true if an entry is returned,
* false otherwise
*/
bool Dequeue (DsrNetworkQueueEntry & entry);
/// Number of entries
/**
* Number of entries
*
* \return the current queue size/length
*/
uint32_t GetSize ();
/**
* Set the maximum queue size
*
* \param maxSize the maximum queue size
*/
void SetMaxNetworkSize (uint32_t maxSize);
/**
* Set the maximum entry lifetime in the queue
*
* \param delay the maximum entry lifetime
*/
void SetMaxNetworkDelay (Time delay);
/**
* Return the maximum queue size
*
* \return the maximum queue size
*/
uint32_t GetMaxNetworkSize (void) const;
/**
* Return the maximum entry lifetime for this queue
*
* \return the maximum entry lifetime for this queue
*/
Time GetMaxNetworkDelay (void) const;
/**
* Clear the queue
*/
void Flush (void);
std::vector<DsrNetworkQueueEntry> & GetQueue ()
@@ -153,11 +210,14 @@ public:
}
private:
/**
* Clean the queue by removing entries that exceeded lifetime.
*/
void Cleanup (void);
std::vector<DsrNetworkQueueEntry> m_dsrNetworkQueue;
uint32_t m_size;
uint32_t m_maxSize;
Time m_maxDelay;
std::vector<DsrNetworkQueueEntry> m_dsrNetworkQueue; //!< Queue (vector) of entries
uint32_t m_size; //!< Current queue size
uint32_t m_maxSize; //!< Maximum queue size
Time m_maxDelay; //!< Maximum entry lifetime
};
} // namespace dsr

View File

@@ -339,7 +339,7 @@ public:
Ipv4Address GetNodeAddress (uint8_t index) const;
/**
* \brief Set the request id number.
* \param the identification number
* \param identification the identification number
*/
void SetId (uint16_t identification);
/**
@@ -589,7 +589,7 @@ public:
virtual ~DsrOptionSRHeader ();
/*
* \brief Set the number of segments left to send
* \param The segments left
* \param segmentsLeft The segments left
*/
void SetSegmentsLeft (uint8_t segmentsLeft);
/*
@@ -631,7 +631,7 @@ public:
Ipv4Address GetNodeAddress (uint8_t index) const;
/*
* \brief Set the salvage value for a packet
* \param The salvage value of the packet
* \param salvage The salvage value of the packet
*/
void SetSalvage (uint8_t salvage);
/*
@@ -715,7 +715,7 @@ private:
\endverbatim
*/
// / Error type
/// Error type
enum ErrorType
{
NODE_UNREACHABLE = 1, // !< NODE_UNREACHABLE
@@ -746,7 +746,7 @@ public:
virtual ~DsrOptionRerrHeader ();
/**
* \brief Set the route error type
* \param The error type
* \param errorType The error type
*/
void SetErrorType (uint8_t errorType);
/**
@@ -756,7 +756,7 @@ public:
uint8_t GetErrorType () const;
/**
* \brief Set the route error source address
* \param The error source address
* \param errorSrcAddress The error source address
*/
virtual void SetErrorSrc (Ipv4Address errorSrcAddress);
/**
@@ -770,12 +770,12 @@ public:
virtual void SetSalvage (uint8_t salvage);
/**
* \brief Get the salvage value of the packet
* \param The salvage value of the packet
* \return The salvage value of the packet
*/
virtual uint8_t GetSalvage () const;
/**
* \brief Set the error destination ip address
* \param The error destination address
* \param errorDstAddress The error destination address
*/
virtual void SetErrorDst (Ipv4Address errorDstAddress);
/**
@@ -891,7 +891,7 @@ public:
virtual ~DsrOptionRerrUnreachHeader ();
/**
* \brief Set the route error source address
* \param The error source address
* \param errorSrcAddress The error source address
*/
virtual void SetErrorSrc (Ipv4Address errorSrcAddress);
/**
@@ -905,12 +905,12 @@ public:
virtual void SetSalvage (uint8_t salvage);
/**
* \brief Get the salvage value of the packet
* \param The salvage value of the packet
* \return The salvage value of the packet
*/
virtual uint8_t GetSalvage () const;
/**
* \brief Set the error destination ip address
* \param The error destination address
* \param errorDstAddress The error destination address
*/
virtual void SetErrorDst (Ipv4Address errorDstAddress);
/**
@@ -920,7 +920,7 @@ public:
virtual Ipv4Address GetErrorDst () const;
/**
* \brief Set the unreachable node ip address
* \param The unreachable ip address
* \param unreachNode The unreachable ip address
*/
void SetUnreachNode (Ipv4Address unreachNode);
/**
@@ -930,7 +930,7 @@ public:
Ipv4Address GetUnreachNode () const;
/**
* \brief Set the unreachable node ip address
* \param The unreachable ip address
* \param originalDst The unreachable ip address
*/
void SetOriginalDst (Ipv4Address originalDst);
/**
@@ -1047,7 +1047,7 @@ public:
virtual ~DsrOptionRerrUnsupportHeader ();
/**
* \brief Set the route error source address
* \param The error source address
* \param errorSrcAddress The error source address
*/
virtual void SetErrorSrc (Ipv4Address errorSrcAddress);
/**
@@ -1057,16 +1057,17 @@ public:
virtual Ipv4Address GetErrorSrc () const;
/**
* \brief Set the salvage value of the packet
* \param salvage the salvage value
*/
virtual void SetSalvage (uint8_t salvage);
/**
* \brief Get the salvage value of the packet
* \param The salvage value of the packet
* \return The salvage value of the packet
*/
virtual uint8_t GetSalvage () const;
/**
* \brief Set the error destination ip address
* \param The error destination address
* \param errorDstAddress The error destination address
*/
virtual void SetErrorDst (Ipv4Address errorDstAddress);
/**
@@ -1076,7 +1077,7 @@ public:
virtual Ipv4Address GetErrorDst () const;
/**
* \brief Set the unsupported option type value
* \param The unsupported option type value
* \param optionType The unsupported option type value
*/
void SetUnsupported (uint16_t optionType);
/**
@@ -1175,7 +1176,7 @@ public:
virtual ~DsrOptionAckReqHeader ();
/**
* \brief Set the Ack request id number.
* \param the identification number
* \param identification the identification number
*/
void SetAckId (uint16_t identification);
/**
@@ -1212,7 +1213,7 @@ public:
virtual Alignment GetAlignment () const;
private:
/*
/**
* The identification field
*/
uint16_t m_identification;
@@ -1262,7 +1263,7 @@ public:
virtual ~DsrOptionAckHeader ();
/**
* \brief Set the Ack id number.
* \param the identification number
* \param identification the identification number
*/
void SetAckId (uint16_t identification);
/**
@@ -1272,7 +1273,7 @@ public:
uint16_t GetAckId () const;
/**
* \brief Set Error source ip address.
* \param The real source address
* \param realSrcAddress The real source address
*/
void SetRealSrc (Ipv4Address realSrcAddress);
/**
@@ -1282,7 +1283,7 @@ public:
Ipv4Address GetRealSrc () const;
/**
* \brief Set Error source ip address.
* \param The real dst address
* \param realDstAddress The real dst address
*/
void SetRealDst (Ipv4Address realDstAddress);
/**

View File

@@ -1562,7 +1562,7 @@ uint8_t DsrOptionRerr::DoSendError (Ptr<Packet> p, DsrOptionRerrUnreachHeader &r
newSourceRoute.SetNodesAddress (nodeList);
nextAddress = newSourceRoute.GetNodeAddress (nextAddressIndex);
// / to test if the next address is multicast or not
/// to test if the next address is multicast or not
if (nextAddress.IsMulticast () || targetAddress.IsMulticast ())
{
m_dropTrace (p);

View File

@@ -104,37 +104,58 @@ public:
Ptr<Node> GetNode () const;
/**
* \brief Search for the ipv4 address in the node list.
*
* \param ipv4Address IPv4 address to search for
* \param destAddress IPv4 address in the list that we begin the search
* \param nodeList List of IPv4 addresses
* \return true if contain ip address
*/
bool ContainAddressAfter (Ipv4Address ipv4Address, Ipv4Address destAddress, std::vector<Ipv4Address> &nodeList);
/**
* \brief Cut the route from ipv4Address to the end of the route vector
*
* \param ipv4Address the address to begin cutting
* \param nodeList List of IPv4 addresses
* \return the vector after the route cut
*/
std::vector<Ipv4Address> CutRoute (Ipv4Address ipv4Address, std::vector<Ipv4Address> &nodeList);
/**
* \brief Set the route to use for data packets
* \brief Set the route to use for data packets,
* used by the option headers when sending data/control packets
*
* \param nextHop IPv4 address of the next hop
* \param srcAddress IPv4 address of the source
* \return the route
* \used by the option headers when sending data/control packets
*/
virtual Ptr<Ipv4Route> SetRoute (Ipv4Address nextHop, Ipv4Address srcAddress);
/**
* \brief Reverse the routes.
*
* \param vec List of IPv4 addresses
* \return true if successfully reversed
*/
bool ReverseRoutes (std::vector<Ipv4Address>& vec);
/**
* \brief Search for the next hop in the route
*
* \param ipv4Address the IPv4 address of the node we are looking for its next hop address
* \param vec List of IPv4 addresses
* \return the next hop address if found
*/
Ipv4Address SearchNextHop (Ipv4Address ipv4Address, std::vector<Ipv4Address>& vec);
/**
* \brief Reverse search for the next hop in the route
*
* \param ipv4Address the IPv4 address of the node we are looking for its next hop address
* \param vec List of IPv4 addresses
* \return the previous next hop address if found
*/
Ipv4Address ReverseSearchNextHop (Ipv4Address ipv4Address, std::vector<Ipv4Address>& vec);
/**
* \brief Reverse search for the next two hop in the route
*
* \param ipv4Address the IPv4 address of the node we are looking for its next two hop address
* \param vec List of IPv4 addresses
* \return the previous next two hop address if found
*/
Ipv4Address ReverseSearchNextTwoHop (Ipv4Address ipv4Address, std::vector<Ipv4Address>& vec);
@@ -144,34 +165,46 @@ public:
void PrintVector (std::vector<Ipv4Address>& vec);
/**
* \brief Check if the two vectors contain duplicate or not
*
* \param vec the first list of IPv4 addresses
* \param vec2 the second list of IPv4 addresses
* \return true if contains duplicate
*/
bool IfDuplicates (std::vector<Ipv4Address>& vec, std::vector<Ipv4Address>& vec2);
/**
* \brief Check if the route already contains the node ip address
*
* \param ipv4Address the IPv4 address that we are looking for
* \param vec List of IPv4 addresses
* \return true if it already exists
*/
bool CheckDuplicates (Ipv4Address ipv4Address, std::vector<Ipv4Address>& vec);
/*
/**
* \brief Remove the duplicates from the route
*
* \param vec List of IPv4 addresses to be clean
* \return the route after route shorten
*/
void RemoveDuplicates (std::vector<Ipv4Address>& vec);
/**
* \brief Schedule the intermediate node route request broadcast
* \param the original packet
* \param rrepHeader The rrep header
* \param packet the original packet
* \param nodeList The list of IPv4 addresses
* \param source address
* \param destination address
*/
void ScheduleReply (Ptr<Packet> &packet, std::vector<Ipv4Address> &nodeList, Ipv4Address &source, Ipv4Address &destination);
/**
* \brief Get the node id with Ipv4Address
*
* \param address IPv4 address to look for ID
* \return the id of the node
*/
uint32_t GetIDfromIP (Ipv4Address address);
/**
* \brief Get the node object with Ipv4Address
*
* \param ipv4Address IPv4 address of the node
* \return the object of the node
*/
Ptr<Node> GetNodeWithAddress (Ipv4Address ipv4Address);
@@ -181,9 +214,12 @@ public:
* Called from DsrRouting::Receive.
* \param packet the packet
* \param dsrP the clean packet with payload
* \param ipv4Address the IPv4 address
* \param source IPv4 address of the source
* \param ipv4Header the IPv4 header of packet received
* \param protocol the protocol number of the up layer
* \param isPromisc if the packet must be dropped
* \param promiscSource IPv4 address
* \return the processed size
*/
virtual uint8_t Process (Ptr<Packet> packet, Ptr<Packet> dsrP, Ipv4Address ipv4Address, Ipv4Address source, Ipv4Header const& ipv4Header, uint8_t protocol, bool& isPromisc, Ipv4Address promiscSource) = 0;
@@ -245,35 +281,13 @@ public:
* \brief Pad1 option number.
*/
static const uint8_t OPT_NUMBER = 224;
/**
* \brief Get the type identificator.
* \return type identificator
*/
static TypeId GetTypeId ();
/**
* \brief Constructor.
*/
DsrOptionPad1 ();
/**
* \brief Destructor.
*/
virtual ~DsrOptionPad1 ();
/**
* \brief Get the option number.
* \return option number
*/
virtual uint8_t GetOptionNumber () const;
/**
* \brief Process method
*
* Called from DsrRouting::Receive.
* \param packet the packet
* \param dsrP the clean packet with payload
* \param ipv4Header the IPv4 header of packet received
* \param protocol the protocol number of the up layer
* \param isPromisc if the packet must be dropped
* \return the processed size
*/
virtual uint8_t Process (Ptr<Packet> packet, Ptr<Packet> dsrP, Ipv4Address ipv4Address, Ipv4Address source, Ipv4Header const& ipv4Header, uint8_t protocol, bool& isPromisc, Ipv4Address promiscSource);
};
@@ -288,35 +302,13 @@ public:
* \brief PadN option number.
*/
static const uint8_t OPT_NUMBER = 0;
/**
* \brief Get the type identificator.
* \return type identificator
*/
static TypeId GetTypeId ();
/**
* \brief Constructor.
*/
DsrOptionPadn ();
/**
* \brief Destructor.
*/
virtual ~DsrOptionPadn ();
/**
* \brief Get the option number.
* \return option number
*/
virtual uint8_t GetOptionNumber () const;
/**
* \brief Process method
*
* Called from DsrRouting::Receive.
* \param packet the packet
* \param dsrP the clean packet with payload
* \param ipv4Header the IPv4 header of packet received
* \param protocol the protocol number of the up layer
* \param isPromisc if the packet must be dropped
* \return the processed size
*/
virtual uint8_t Process (Ptr<Packet> packet, Ptr<Packet> dsrP, Ipv4Address ipv4Address, Ipv4Address source, Ipv4Header const& ipv4Header, uint8_t protocol, bool& isPromisc, Ipv4Address promiscSource);
};
@@ -331,10 +323,7 @@ public:
* \brief Rreq option number.
*/
static const uint8_t OPT_NUMBER = 1;
/**
* \brief Get the type identificator.
* \return type identificator
*/
static TypeId GetTypeId ();
/**
* \brief Get the instance type ID.
@@ -349,22 +338,8 @@ public:
* \brief Destructor.
*/
virtual ~DsrOptionRreq ();
/**
* \brief Get the option number.
* \return option number
*/
virtual uint8_t GetOptionNumber () const;
/**
* \brief Process method
*
* Called from DsrRouting::Receive.
* \param packet the packet
* \param dsrP the clean packet with payload
* \param ipv4Header the IPv4 header of packet received
* \param protocol the protocol number of the up layer
* \param isPromisc if the packet must be dropped
* \return the processed size
*/
virtual uint8_t Process (Ptr<Packet> packet, Ptr<Packet> dsrP, Ipv4Address ipv4Address, Ipv4Address source, Ipv4Header const& ipv4Header, uint8_t protocol, bool& isPromisc, Ipv4Address promiscSource);
private:
@@ -389,40 +364,18 @@ public:
* \brief Router alert option number.
*/
static const uint8_t OPT_NUMBER = 2;
/**
* \brief Get the type identificator.
* \return type identificator
*/
static TypeId GetTypeId ();
/**
* \brief Get the instance type ID.
* \return instance type ID
*/
virtual TypeId GetInstanceTypeId () const;
/**
* \brief Constructor.
*/
DsrOptionRrep ();
/**
* \brief Destructor.
*/
virtual ~DsrOptionRrep ();
/**
* \brief Get the option number.
* \return option number
*/
virtual uint8_t GetOptionNumber () const;
/**
* \brief Process method
*
* Called from DsrRouting::Receive.
* \param packet the packet
* \param dsrP the clean packet with payload
* \param ipv4Header the IPv4 header of packet received
* \param protocol the protocol number of the up layer
* \param isPromisc if the packet must be dropped
* \return the processed size
*/
virtual uint8_t Process (Ptr<Packet> packet, Ptr<Packet> dsrP, Ipv4Address ipv4Address, Ipv4Address source, Ipv4Header const& ipv4Header, uint8_t protocol, bool& isPromisc, Ipv4Address promiscSource);
private:
@@ -447,40 +400,18 @@ public:
* \brief Source Route option number.
*/
static const uint8_t OPT_NUMBER = 96;
/**
* \brief Get the type identificator.
* \return type identificator
*/
static TypeId GetTypeId ();
/**
* \brief Get the instance type ID.
* \return instance type ID
*/
virtual TypeId GetInstanceTypeId () const;
/**
* \brief Constructor.
*/
DsrOptionSR ();
/**
* \brief Destructor.
*/
virtual ~DsrOptionSR ();
/**
* \brief Get the option number.
* \return option number
*/
virtual uint8_t GetOptionNumber () const;
/**
* \brief Process method
*
* Called from DsrRouting::Receive.
* \param packet the packet
* \param dsrP the clean packet with payload
* \param ipv4Header the IPv4 header of packet received
* \param protocol the protocol number of the up layer
* \param isPromisc if the packet must be dropped
* \return the processed size
*/
virtual uint8_t Process (Ptr<Packet> packet, Ptr<Packet> dsrP, Ipv4Address ipv4Address, Ipv4Address source, Ipv4Header const& ipv4Header, uint8_t protocol, bool& isPromisc, Ipv4Address promiscSource);
private:
@@ -501,40 +432,18 @@ public:
* \brief Dsr Route Error option number.
*/
static const uint8_t OPT_NUMBER = 3;
/**
* \brief Get the type identificator.
* \return type identificator
*/
static TypeId GetTypeId ();
/**
* \brief Get the instance type ID.
* \return instance type ID
*/
virtual TypeId GetInstanceTypeId () const;
/**
* \brief Constructor.
*/
DsrOptionRerr ();
/**
* \brief Destructor.
*/
virtual ~DsrOptionRerr ();
/**
* \brief Get the option number.
* \return option number
*/
virtual uint8_t GetOptionNumber () const;
/**
* \brief Process method
*
* Called from DsrRouting::Receive.
* \param packet the packet
* \param dsrP the clean packet with payload
* \param ipv4Header the IPv4 header of packet received
* \param protocol the protocol number of the up layer
* \param isPromisc if the packet must be dropped
* \return the processed size
*/
virtual uint8_t Process (Ptr<Packet> packet, Ptr<Packet> dsrP, Ipv4Address ipv4Address, Ipv4Address source, Ipv4Header const& ipv4Header, uint8_t protocol, bool& isPromisc, Ipv4Address promiscSource);
/**
* \brief Do Send error message
@@ -570,40 +479,18 @@ public:
* \brief Dsr ack request option number.
*/
static const uint8_t OPT_NUMBER = 160;
/**
* \brief Get the type identificator.
* \return type identificator
*/
static TypeId GetTypeId ();
/**
* \brief Get the instance type ID.
* \return instance type ID
*/
virtual TypeId GetInstanceTypeId () const;
/**
* \brief Constructor.
*/
DsrOptionAckReq ();
/**
* \brief Destructor.
*/
virtual ~DsrOptionAckReq ();
/**
* \brief Get the option number.
* \return option number
*/
virtual uint8_t GetOptionNumber () const;
/**
* \brief Process method
*
* Called from DsrRouting::Receive.
* \param packet the packet
* \param dsrP the clean packet with payload
* \param ipv4Header the IPv4 header of packet received
* \param protocol the protocol number of the up layer
* \param isPromisc if the packet must be dropped
* \return the processed size
*/
virtual uint8_t Process (Ptr<Packet> packet, Ptr<Packet> dsrP, Ipv4Address ipv4Address, Ipv4Address source, Ipv4Header const& ipv4Header, uint8_t protocol, bool& isPromisc, Ipv4Address promiscSource);
private:
@@ -628,40 +515,18 @@ public:
* \brief The Dsr Ack option number.
*/
static const uint8_t OPT_NUMBER = 32;
/**
* \brief Get the type identificator.
* \return type identificator
*/
static TypeId GetTypeId ();
/**
* \brief Get the instance type ID.
* \return instance type ID
*/
virtual TypeId GetInstanceTypeId () const;
/**
* \brief Constructor.
*/
DsrOptionAck ();
/**
* \brief Destructor.
*/
virtual ~DsrOptionAck ();
/**
* \brief Get the option number.
* \return option number
*/
virtual uint8_t GetOptionNumber () const;
/**
* \brief Process method
*
* Called from DsrRouting::Receive.
* \param packet the packet
* \param dsrP the clean packet with payload
* \param ipv4Header the IPv4 header of packet received
* \param protocol the protocol number of the up layer
* \param isPromisc if the packet must be dropped
* \return the processed size
*/
virtual uint8_t Process (Ptr<Packet> packet, Ptr<Packet> dsrP, Ipv4Address ipv4Address, Ipv4Address source, Ipv4Header const& ipv4Header, uint8_t protocol, bool& isPromisc, Ipv4Address promiscSource);
private:

View File

@@ -45,7 +45,19 @@ namespace dsr {
class PassiveBuffEntry
{
public:
// / c-tor
/**
* Construct a PassiveBuffEntry with the given parameters
*
* \param pa packet
* \param d IPv4 address of the destination
* \param s IPv4 address of the source
* \param n IPv4 address of the next hop node
* \param i ID
* \param f fragment offset
* \param seg number of segments left
* \param exp expiration time
* \param p protocol number
*/
PassiveBuffEntry (Ptr<const Packet> pa = 0, Ipv4Address d = Ipv4Address (), Ipv4Address s = Ipv4Address (),
Ipv4Address n = Ipv4Address (), uint16_t i = 0, uint16_t f = 0, uint8_t seg = 0, Time exp = Simulator::Now (),
uint8_t p = 0)
@@ -68,7 +80,7 @@ public:
{
return ((m_packet == o.m_packet) && (m_source == o.m_source) && (m_nextHop == o.m_nextHop) && (m_dst == o.m_dst) && (m_expire == o.m_expire));
}
// /\name Fields
///\name Fields
// \{
Ptr<const Packet> GetPacket () const
{
@@ -144,21 +156,21 @@ public:
}
// \}
private:
// / Data packet
/// Data packet
Ptr<const Packet> m_packet;
// / Destination address
/// Destination address
Ipv4Address m_dst;
// / Source address
/// Source address
Ipv4Address m_source;
// / Nexthop address
/// Nexthop address
Ipv4Address m_nextHop;
// /
///
uint16_t m_identification;
uint16_t m_fragmentOffset;
uint8_t m_segsLeft;
// / Expire time for queue entry
/// Expire time for queue entry
Time m_expire;
// / The protocol number
/// The protocol number
uint8_t m_protocol;
};
@@ -170,31 +182,23 @@ private:
class PassiveBuffer : public Object
{
public:
// / c-tor
/**
* \brief Get the type identificator.
* \return type identificator
*/
static TypeId GetTypeId ();
/**
* \brief Constructor.
*/
PassiveBuffer ();
/**
* \brief Destructor.
*/
virtual ~PassiveBuffer ();
// / Push entry in queue, if there is no entry with the same packet and destination address in queue.
/// Push entry in queue, if there is no entry with the same packet and destination address in queue.
bool Enqueue (PassiveBuffEntry & entry);
// / Return first found (the earliest) entry for given destination
/// Return first found (the earliest) entry for given destination
bool Dequeue (Ipv4Address dst, PassiveBuffEntry & entry);
// / Finds whether a packet with destination dst exists in the queue
/// Finds whether a packet with destination dst exists in the queue
bool Find (Ipv4Address dst);
// / Check if all the entries in passive buffer entry is all equal or not
/// Check if all the entries in passive buffer entry is all equal or not
bool AllEqual (PassiveBuffEntry & entry);
// / Number of entries
/// Number of entries
uint32_t GetSize ();
// /\name Fields
///\name Fields
// \{
uint32_t GetMaxQueueLen () const
{
@@ -215,19 +219,19 @@ public:
// \}
private:
// / The send buffer to cache unsent packet
/// The send buffer to cache unsent packet
std::vector<PassiveBuffEntry> m_passiveBuffer;
// / Remove all expired entries
/// Remove all expired entries
void Purge ();
// / Notify that packet is dropped from queue by timeout
/// Notify that packet is dropped from queue by timeout
void Drop (PassiveBuffEntry en, std::string reason);
// / Notify that packet is dropped from queue by timeout
/// Notify that packet is dropped from queue by timeout
void DropLink (PassiveBuffEntry en, std::string reason);
// / The maximum number of packets that we allow a routing protocol to buffer.
/// The maximum number of packets that we allow a routing protocol to buffer.
uint32_t m_maxLen;
// / The maximum period of time that a routing protocol is allowed to buffer a packet for, seconds.
/// The maximum period of time that a routing protocol is allowed to buffer a packet for, seconds.
Time m_passiveBufferTimeout;
// / Check if the send buffer entry is the same or not
/// Check if the send buffer entry is the same or not
static bool LinkEqual (PassiveBuffEntry en, const std::vector<Ipv4Address> link)
{
return ((en.GetSource () == link[0]) && (en.GetNextHop () == link[1]));

View File

@@ -155,14 +155,8 @@ private:
class NodeStab
{
public:
/**
* \brief Constructor
*/
// NodeStab ();
NodeStab (Time nodeStab = Simulator::Now ());
/**
* \brief Destructor
*/
virtual ~NodeStab ();
void SetNodeStability (Time nodeStab)
@@ -182,18 +176,13 @@ class RouteCacheEntry
public:
typedef std::vector<Ipv4Address> IP_VECTOR; ///< Define the vector to hold Ip address
typedef std::vector<Ipv4Address>::iterator Iterator; ///< Define the iterator
// / c-tor
/**
* \brief Constructor
*/
RouteCacheEntry (IP_VECTOR const & ip = IP_VECTOR (), Ipv4Address dst = Ipv4Address (), Time exp = Simulator::Now ());
/**
* \brief Destructor
*/
virtual ~RouteCacheEntry ();
// / Mark entry as "down" (i.e. disable it)
/// Mark entry as "down" (i.e. disable it)
void Invalidate (Time badLinkLifetime);
// /\name Fields
///\name Fields
// \{
void SetUnidirectional (bool u)
{
@@ -278,23 +267,14 @@ public:
private:
Timer m_ackTimer; ///< RREP_ACK timer
Ipv4Address m_dst; ///< The destination Ip address
IP_VECTOR m_path; ///< brief The IP address constructed route
Time m_expire; ///< Expire time for queue entry
Ipv4InterfaceAddress m_iface; ///< Output interface address
uint8_t m_reqCount; ///< Number of route requests
bool m_blackListState; ///< Indicate if this entry is in "blacklist"
Time m_blackListTimeout; ///< Time for which the node is put into the blacklist
Ptr<Ipv4Route> m_ipv4Route; ///< The Ipv4 route
Ptr<Ipv4> m_ipv4; ///< The Ipv4 layer 3
};
/**
@@ -305,20 +285,12 @@ private:
class RouteCache : public Object
{
public:
// / Default c-tor
/**
* \ingroup dsr
* \brief The Route Cache used by DSR
*/
static TypeId GetTypeId ();
/**
* \brief Constructor.
*/
RouteCache ();
/**
* \brief Destructor.
*/
virtual ~RouteCache ();
/**
* \brief Remove the aged route cache entries when the route cache is full
*/
@@ -327,7 +299,7 @@ public:
* \brief Define the vector of route entries.
*/
typedef std::list<RouteCacheEntry::IP_VECTOR> routeVector;
// /\name Fields
///\name Fields
// \{
bool GetSubRoute () const
{
@@ -413,7 +385,6 @@ public:
/**
* \brief Update route cache entry if it has been recently used and successfully delivered the data packet
* \param dst destination address of the route
* \param vec the route vector
* \return true in success
*/
bool UpdateRouteEntry (Ipv4Address dst);
@@ -425,8 +396,8 @@ public:
bool AddRoute (RouteCacheEntry & rt);
/**
* \brief Lookup route cache entry with destination address dst
* \param dst destination address
* \param rt entry with destination address dst, if exists
* \param id destination address
* \param rt entry with destination address id, if exists
* \return true on success
*/
bool LookupRoute (Ipv4Address id, RouteCacheEntry & rt);
@@ -460,14 +431,14 @@ public:
* \param node This node's ip address
*/
void DeleteAllRoutesIncludeLink (Ipv4Address errorSrc, Ipv4Address unreachNode, Ipv4Address node);
// / Delete all entries from routing table
/// Delete all entries from routing table
void Clear ()
{
m_routeEntryVector.erase (m_routeEntryVector.begin (), m_routeEntryVector.end ());
}
// / Delete all outdated entries and invalidate valid entry if Lifetime is expired
/// Delete all outdated entries and invalidate valid entry if Lifetime is expired
void Purge ();
// / Print route cache
/// Print route cache
void Print (std::ostream &os);
//------------------------------------------------------------------------------------------
@@ -484,7 +455,7 @@ public:
/**
* The following code handles link-layer acks
*/
// / Neighbor description
/// Neighbor description
struct Neighbor
{
Ipv4Address m_neighborAddress;
@@ -549,7 +520,7 @@ public:
{
return m_txErrorCallback;
}
// /\name Handle link failure callback
///\name Handle link failure callback
// \{
void SetCallback (Callback<void, Ipv4Address, uint8_t > cb)
{
@@ -627,14 +598,14 @@ public:
/**
* \brief Dijsktra algorithm to get the best route from m_netGraph and update the m_bestRoutesTable_link
* when current graph information has changed
* \param The type of the cache
* \param type The type of the cache
*/
void SetCacheType (std::string type);
bool IsLinkCache ();
bool AddRoute_Link (RouteCacheEntry::IP_VECTOR nodelist, Ipv4Address node);
/**
* \brief USE MAXWEIGHT TO REPRESENT MAX; USE BROADCAST ADDRESS TO REPRESENT NULL PRECEEDING ADDRESS
* \param The source address the routes based on
* \param source The source address the routes based on
*/
void RebuildBestRouteTable (Ipv4Address source);
void PurgeLinkNode ();

View File

@@ -124,7 +124,7 @@ public:
void SetNode (Ptr<Node> node);
/**
* \brief Set the route cache.
* \param the route cache to set
* \param r the route cache to set
*/
void SetRouteCache (Ptr<dsr::RouteCache> r);
/**
@@ -134,7 +134,7 @@ public:
Ptr<dsr::RouteCache> GetRouteCache () const;
/**
* \brief Set the node.
* \param the request table to set
* \param r the request table to set
*/
void SetRequestTable (Ptr<dsr::RreqTable> r);
/**
@@ -144,7 +144,7 @@ public:
Ptr<dsr::RreqTable> GetRequestTable () const;
/**
* \brief Set the node.
* \param the passive buffer to set
* \param r the passive buffer to set
*/
void SetPassiveBuffer (Ptr<dsr::PassiveBuffer> r);
/**
@@ -172,31 +172,37 @@ public:
void ConnectCallbacks ();
/**
* \brief Get the netdevice from the context.
* \param context context
* \return the netdevice we are looking for
*/
Ptr<NetDevice> GetNetDeviceFromContext (std::string context);
/**
* \brief Get the elements from the tracing context.
* \param context context
* \return the elements we are looking for
*/
std::vector<std::string> GetElementsFromContext (std::string context);
/**
* \brief Get the node id from ip address.
* \param address IPv4 address
* \return the node id
*/
uint16_t GetIDfromIP (Ipv4Address address);
/**
* \brief Get the ip address from id.
* \param id unique ID
* \return the ip address for the id
*/
Ipv4Address GetIPfromID (uint16_t id);
/**
* \brief Get the Ip address from mac address.
* \param address Mac48Address
* \return the ip address
*/
Ipv4Address GetIPfromMAC (Mac48Address address);
/**
* \brief Get the node with give ip address.
* \param ipv4Address IPv4 address
* \return the node associated with the ip address
*/
Ptr<Node> GetNodeWithAddress (Ipv4Address ipv4Address);
@@ -206,6 +212,8 @@ public:
void PrintVector (std::vector<Ipv4Address>& vec);
/**
* \brief Get the next hop of the route.
* \param ipv4Address
* \param vec Route
* \return the next hop address of the route
*/
Ipv4Address SearchNextHop (Ipv4Address ipv4Address, std::vector<Ipv4Address>& vec);
@@ -230,13 +238,16 @@ public:
Ipv4Address destination,
uint8_t protocol);
/**
* \brief Set the route to use for data packets
* \brief Set the route to use for data packets,
* used by the option headers when sending data/control packets
* \param nextHop next hop IPv4 address
* \param srcAddress IPv4 address of the source
* \return the route
* \used by the option headers when sending data/control packets
*/
Ptr<Ipv4Route> SetRoute (Ipv4Address nextHop, Ipv4Address srcAddress);
/**
* \brief Set the priority of the packet in network queue
* \param messageType Message type
* \return the priority value
*/
uint32_t GetPriority (DsrMessageType messageType);
@@ -378,28 +389,28 @@ public:
uint8_t protocol);
/**
* \brief Send the error request packet
* \param the route error header
* \param the protocol number
* \param rerr the route error header
* \param protocol the protocol number
*/
void SendErrorRequest (DsrOptionRerrUnreachHeader &rerr, uint8_t protocol);
/**
* \brief Forward the route request if the node is not the destination
* \param the original packet
* \param packet the original packet
* \param source address
*/
void SendRequest (Ptr<Packet> packet,
Ipv4Address source);
/**
* \brief Schedule the intermediate route request
* \param the original packet
* \param source The source address
* \param destination The destination address
* \param packet the original packet
*/
void ScheduleInterRequest (Ptr<Packet> packet);
/**
* \brief Send the gratuitous reply
* \param replyTo The destination address to send the reply to
* \param replyFrom The source address sending the reply
* \param nodeList Route
* \param protocol the protocol number
*/
void SendGratuitousReply (Ipv4Address replyTo,
Ipv4Address replyFrom,
@@ -407,6 +418,11 @@ public:
uint8_t protocol);
/**
* Send the route reply back to the request originator with the cumulated route
*
* \param packet the original packet
* \param source IPv4 address of the source (i.e. request originator)
* \param nextHop IPv4 address of the next hop
* \param route Route
*/
void SendReply (Ptr<Packet> packet,
Ipv4Address source,
@@ -415,6 +431,11 @@ public:
/**
* this is a generating the initial route reply from the destination address, a random delay time
* [0, m_broadcastJitter] is used before unicasting back the route reply packet
*
* \param packet the original packet
* \param source IPv4 address of the source (i.e. request originator)
* \param nextHop IPv4 address of the next hop
* \param route Route
*/
void ScheduleInitialReply (Ptr<Packet> packet,
Ipv4Address source,
@@ -422,6 +443,11 @@ public:
Ptr<Ipv4Route> route);
/**
* Schedule the cached reply to a random start time to avoid possible route reply storm
*
* \param packet the original packet
* \param source IPv4 address of the source (i.e. request originator)
* \param destination IPv4 address of the destination
* \param route Route
*/
void ScheduleCachedReply (Ptr<Packet> packet,
Ipv4Address source,
@@ -430,6 +456,13 @@ public:
double hops);
/**
* Send network layer acknowledgment back to the earlier hop to notify the receipt of data packet
*
* \param ackId ACK ID
* \param destination IPv4 address of the immediate ACK receiver
* \param realSrc IPv4 address of the real source
* \param realDst IPv4 address of the real destination
* \param protocol the protocol number
* \param route Route
*/
void SendAck (uint16_t ackId,
Ipv4Address destination,
@@ -441,6 +474,7 @@ public:
* \param p packet to forward up
* \param header IPv4 Header information
* \param incomingInterface the Ipv4Interface on which the packet arrived
* \return receive status
*
* Called from lower-level layers to send the packet up
* in the stack.
@@ -453,6 +487,7 @@ public:
* \param p packet to forward up
* \param header IPv6 Header information
* \param incomingInterface the Ipv6Interface on which the packet arrived
* \return receive status
*
* Called from lower-level layers to send the packet up
* in the stack. Not implemented (IPv6).
@@ -470,9 +505,10 @@ public:
* Called from Ipv4L3Protocol::Receive.
*
* \param packet the packet
* \param offset the offset of the extension to process
* \param ipv4Header IPv4 header of the packet
* \param dst destination address of the packet received (i.e. us)
* \param nextHeader the next header
* \param protocol the protocol number
* \param isDropped if the packet must be dropped
* \return the size processed
*/
@@ -496,10 +532,21 @@ public:
void CancelRreqTimer (Ipv4Address dst, bool isRemove);
/**
* \brief Schedule the route request retry.
* \param dst The dst address of the route request
* \param packet the original packet
* \param address List of IPv4 addresses
* \param nonProp flag if RREQ is non-propagating
* \param requestId Unique request ID
* \param protocol the protocol number
*/
void ScheduleRreqRetry (Ptr<Packet> packet, std::vector<Ipv4Address> address, bool nonProp, uint32_t requestId, uint8_t protocol);
// / Handle route discovery timer
/**
* Handle route discovery timer
*
* \param packet the original packet
* \param address List of IPv4 addresses
* \param requestId Unique request ID
* \param protocol the protocol number
*/
void RouteRequestTimerExpire (Ptr<Packet> packet, std::vector<Ipv4Address> address, uint32_t requestId, uint8_t protocol);
/**
@@ -548,6 +595,7 @@ private:
* \param from The from address we received the packet
* \param to The address this packet is destined for
* \param packetType The dsr packet type, 0 is for control packet, 1 for data packet
* \return true if the packet was processed, false otherwise
*/
bool PromiscReceive (Ptr<NetDevice> device, Ptr<const Packet> packet, uint16_t protocol, const Address &from,
const Address &to, NetDevice::PacketType packetType);

View File

@@ -43,18 +43,27 @@
namespace ns3 {
namespace dsr {
/**
* State of link
*/
enum LinkStates
{
PROBABLE = 0, // !< PROBABLE
QUESTIONABLE = 1, // !< QUESTIONABLE
PROBABLE = 0, //!< PROBABLE
QUESTIONABLE = 1, //!< QUESTIONABLE
};
// / BlackList description
/// BlackList description
struct BlackList
{
Ipv4Address m_neighborAddress;
Time m_expireTime;
LinkStates m_linkStates;
Ipv4Address m_neighborAddress; //!< IPv4 address of the black-listed neighbor
Time m_expireTime; //!< Expire time in the black list
LinkStates m_linkStates; //!< State of the link
/**
* Construct a BlackList with the given parameters
*
* \param ip IPv4 address of the neighbor
* \param t expire time for the black list entry
*/
BlackList (Ipv4Address ip, Time t)
: m_neighborAddress (ip),
m_expireTime (t),
@@ -67,8 +76,8 @@ struct BlackList
*/
struct RreqTableEntry
{
uint32_t m_reqNo;
Time m_expire;
uint32_t m_reqNo; //!< Route request number
Time m_expire; //!< Expire time
};
/**
* The request entry for intermediate nodes to check if they have received this request or not
@@ -77,14 +86,20 @@ struct RreqTableEntry
class ReceivedRreqEntry
{
public:
// / c-tor
/**
* Construct a ReceivedRreqEntry with the given parameters
*
* \param d IPv4 address of the destination
* \param i identification
*/
ReceivedRreqEntry (Ipv4Address d = Ipv4Address (), uint16_t i = 0)
: m_destination (d),
m_identification (i)
{
}
/**
* \brief Compare send buffer entries
* \brief Compare send buffer entries (destination address and identification)
* \param o another ReceivedRreqEntry
* \return true if equal
*/
bool operator== (ReceivedRreqEntry const & o) const
@@ -92,46 +107,89 @@ public:
return ((m_destination == o.m_destination) && (m_identification == o.m_identification)
);
}
// /\name Fields
// \{
/**
* Return IPv4 address of the destination
*
* \return IPv4 address of the destination
*/
Ipv4Address GetDestination () const
{
return m_destination;
}
/**
* Set IPv4 address of the destination
*
* \param d IPv4 address of the destination
*/
void SetDestination (Ipv4Address d)
{
m_destination = d;
}
/**
* Return IPv4 address of the source
*
* \return IPv4 address of the source
*/
Ipv4Address GetSource () const
{
return m_source;
}
/**
* Set IPv4 address of the source
*
* \param s IPv4 address of the source
*/
void SetSource (Ipv4Address s)
{
m_source = s;
}
/**
* Return identification
*
* \return identification
*/
uint16_t GetIdentification () const
{
return m_identification;
}
/**
* Set identification
*
* \param i identification
*/
void SetIdentification (uint16_t i)
{
m_identification = i;
}
/**
* Set expire time for the RREQ entry.
* Note that the parameter is duration but
* the stored value is the absolute time.
*
* \param exp duration before expire
*/
void SetExpireTime (Time exp)
{
m_expire = exp + Simulator::Now ();
}
/**
* Return the remaining time before the RREQ entry expires.
* Note that we return the remaining time but the stored
* value is the absolute time.
*
* \return the remaining time before the RREQ entry expires
*/
Time GetExpireTime () const
{
return m_expire - Simulator::Now ();
}
// \}
private:
Ipv4Address m_destination;
Ipv4Address m_source;
uint16_t m_identification;
Time m_expire;
Ipv4Address m_destination; //!< IPv4 address of the destinaton
Ipv4Address m_source; //!< IPv4 address of the source
uint16_t m_identification; //!< Route request identification
Time m_expire; //!< Route request expire time
};
/**
@@ -141,81 +199,122 @@ private:
class RreqTable : public Object
{
public:
// / c-tor
/**
* \brief Get the type identificator.
* \return type identificator
*/
static TypeId GetTypeId ();
/**
* \brief Constructor.
*/
RreqTable ();
/**
* \brief Destructor.
*/
virtual ~RreqTable ();
// /\name Fields
// \{
/**
* Set the initial discovert hop limit
*
* \param hl the initial discovert hop limit
*/
void SetInitHopLimit (uint32_t hl)
{
m_initHopLimit = hl;
}
/**
* Return the initial discovert hop limit
*
* \return the initial discovert hop limit
*/
uint32_t GetInitHopLimit () const
{
return m_initHopLimit;
}
/**
* Set the maximum number of request entries in
* the request table.
*
* \param rt the maximum number of request entries
*/
void SetRreqTableSize (uint32_t rt)
{
m_requestTableSize = rt;
}
/**
* Return the maximum number of request entries in
* the request table.
*
* \return the maximum number of request entries
*/
uint32_t GetRreqTableSize () const
{
return m_requestTableSize;
}
/**
* Set the maximum number of request source Ids in
* the request table
*
* \param id the maximum number of request source Ids
*/
void SetRreqIdSize (uint32_t id)
{
m_requestIdSize = id;
}
/**
* Return the maximum number of request source Ids in
* the request table
*
* \return the maximum number of request source Ids
*/
uint32_t GetRreqIdSize () const
{
return m_requestIdSize;
}
/**
* Set the maximum number of request Ids in
* the request table for a single destination.
*
* \param uid the maximum number of request Ids
*/
void SetUniqueRreqIdSize (uint32_t uid)
{
m_maxRreqId = uid;
}
/**
* Return the maximum number of request Ids in
* the request table for a single destination.
*
* \return the maximum number of request Ids
*/
uint32_t GetUniqueRreqIdSize () const
{
return m_maxRreqId;
}
// \}
// / Remove the least used entry
/// Remove the least used entry
void RemoveLeastExpire (std::map<Ipv4Address, RreqTableEntry > & rreqDstMap);
// / Find the entry in the route request queue to see if already exists
/// Find the entry in the route request queue to see if already exists
void FindAndUpdate (Ipv4Address dst);
// / Remove route request entry for dst
/// Remove route request entry for dst
void RemoveRreqEntry (Ipv4Address dst);
// / Get the request count number for one destination address
/// Get the request count number for one destination address
uint32_t GetRreqCnt (Ipv4Address dst);
//----------------------------------------------------------------------------------------------------------
/**
* The following code generates new request id for each destination
* The following code generates new request id for each destination.
* Check for duplicate ids and save new entries if the id is not present in the table.
*
* \param dst IPv4 address of the destination
* \return id
*/
// / Check for duplicate ids and save new entries if the id is not present in the table
uint32_t CheckUniqueRreqId (Ipv4Address dst);
// / Get the request id size
/**
* Get the request id size
*
* \return the request id size
*/
uint32_t GetRreqSize ();
// ---------------------------------------------------------------------------------------------------------
/**
* set the unidirectional entry as QUESTIONABLE state
*/
void Invalidate ();
/**
* \brief Verify if entry is unidirectional or not(e.g. add this neighbor to "blacklist" for blacklistTimeout period)
* \param neighbor - neighbor address link to which assumed to be unidirectional
* \param neighbor neighbor address link to which assumed to be unidirectional
* \return true on success
*/
BlackList* FindUnidirectional (Ipv4Address neighbor);
@@ -226,50 +325,59 @@ public:
* \return true on success
*/
bool MarkLinkAsUnidirectional (Ipv4Address neighbor, Time blacklistTimeout);
///< Remove all expired black list entries
/**
* Remove all expired black list entries
*/
void PurgeNeighbor ();
// ----------------------------------------------------------------------------------------------------------
/**
* Find the source request entry in the route request queue, return false if not found
* \param src the source address we just received the source request
* \param dst the destination address the request is targeted at
* \param id the identification number for this request
* \return true if found, false otherwise
*/
bool FindSourceEntry (Ipv4Address src, Ipv4Address dst, uint16_t id);
private:
// / The max request period among requests
/// The max request period among requests
Time MaxRequestPeriod;
// / The original request period
/// The original request period
Time RequestPeriod;
// / The non-propagaton request timeout
/// The non-propagaton request timeout
Time NonpropRequestTimeout;
// / The source route entry expire time
/// The source route entry expire time
Time m_rreqEntryExpire;
// / The initial hop limit
/// The initial hop limit
uint32_t m_initHopLimit;
// / The request table size
/// The request table size
uint32_t m_requestTableSize;
// / The request source id size
/// The request source id size
uint32_t m_requestIdSize;
// / The unique request id for any destination
/// The unique request id for any destination
uint32_t m_maxRreqId;
// / The state of the unidirectional link
/// The state of the unidirectional link
LinkStates m_linkStates;
// / Map of entries
/// Map of entries
std::list<ReceivedRreqEntry> m_sourceRequests;
// / The id cache to ensure all the ids are unique, it is used when sending out route request
/// The id cache to ensure all the ids are unique, it is used when sending out route request
std::map<Ipv4Address, uint32_t> m_rreqIdCache;
// / The cache to save route request table entries indexed with destination address
/// The cache to save route request table entries indexed with destination address
std::map<Ipv4Address, RreqTableEntry > m_rreqDstMap;
// / The cache to ensure all the route request from unique source
/// The cache to ensure all the route request from unique source
std::map<Ipv4Address, std::list<ReceivedRreqEntry> > m_sourceRreqMap;
// / The Black list
/// The Black list
std::vector<BlackList> m_blackList;
// / Check if the entry is expired or not
/// Check if the entry is expired or not
struct IsExpired
{
/**
* Check if the entry is expired
*
* \param b BlackList entry
* \return true if expired, false otherwise
*/
bool operator() (const struct BlackList & b) const
{
return (b.m_expireTime < Simulator::Now ());

View File

@@ -45,7 +45,14 @@ namespace dsr {
class SendBuffEntry
{
public:
// / c-tor
/**
* Construct SendBuffEntry with the given parameters.
*
* \param pa packet
* \param d destination address
* \param exp expiration time
* \param p protocol number
*/
SendBuffEntry (Ptr<const Packet> pa = 0, Ipv4Address d = Ipv4Address (),
Time exp = Simulator::Now (), uint8_t p = 0)
: m_packet (pa),
@@ -56,6 +63,7 @@ public:
}
/**
* Compare send buffer entries
* \param o another SendBuffEntry
* \return true if equal
*/
bool operator== (SendBuffEntry const & o) const
@@ -98,13 +106,13 @@ public:
}
// \}
private:
// / Data packet
/// Data packet
Ptr<const Packet> m_packet;
// / Destination address
/// Destination address
Ipv4Address m_dst;
// / Expire time for queue entry
/// Expire time for queue entry
Time m_expire;
// / The protocol number
/// The protocol number
uint8_t m_protocol;
};
@@ -116,40 +124,93 @@ private:
class SendBuffer
{
public:
// / Default c-tor
/**
* Default constructor
*/
SendBuffer ()
{
}
// / Push entry in queue, if there is no entry with the same packet and destination address in queue.
/**
* Push entry in queue, if there is no entry with
* the same packet and destination address in queue.
*
* \param entry SendBuffEntry to put in the queue
* \return true if successfully enqueued,
* false otherwise
*/
bool Enqueue (SendBuffEntry & entry);
// / Return first found (the earliest) entry for given destination
/**
* Return first found (the earliest) entry for
* the given destination.
*
* \param dst IPv4 address of the destination
* \param entry pointer to entry to return
* \return true if successfully dequeued,
* false otherwise
*/
bool Dequeue (Ipv4Address dst, SendBuffEntry & entry);
// / Remove all packets with destination IP address dst
/**
* Remove all packets with destination IP address dst
*
* \param dst IPv4 address of the destination
*/
void DropPacketWithDst (Ipv4Address dst);
// / Finds whether a packet with destination dst exists in the queue
/**
* Check if a packet with destination dst exists in the queue
*
* \param dst IPv4 address of the destination
* \return true if found, false otherwise
*/
bool Find (Ipv4Address dst);
// / Number of entries
/**
* Number of entries
*
* \return the number of entries in the queue
*/
uint32_t GetSize ();
// /\name Fields
// \{
/**
* Return the maximum queue length
*
* \return the maximum queue length
*/
uint32_t GetMaxQueueLen () const
{
return m_maxLen;
}
/**
* Set the maximum queue length
*
* \param len the maximum queue length
*/
void SetMaxQueueLen (uint32_t len)
{
m_maxLen = len;
}
/**
* Return the entry lifetime in the queue
*
* \return the entry lifetime in the queue
*/
Time GetSendBufferTimeout () const
{
return m_sendBufferTimeout;
}
/**
* Set the entry lifetime in the queue
*
* \param t the entry lifetime in the queue
*/
void SetSendBufferTimeout (Time t)
{
m_sendBufferTimeout = t;
}
// \}
/**
* Return a pointer to the internal queue
*
* \return a pointer to the internal queue
*/
std::vector<SendBuffEntry> & GetBuffer ()
{
return m_sendBuffer;
@@ -162,7 +223,15 @@ private:
void Drop (SendBuffEntry en, std::string reason); ///< Notify that packet is dropped from queue by timeout
uint32_t m_maxLen; ///< The maximum number of packets that we allow a routing protocol to buffer.
Time m_sendBufferTimeout; ///< The maximum period of time that a routing protocol is allowed to buffer a packet for, seconds.
static bool IsEqual (SendBuffEntry en, const Ipv4Address dst) ///< Check if the send buffer entry is the same or not
/**
* Check if the send buffer entry is the same or not
*
* \param en SendBufferEntry
* \param dst IPv4 address to check
* \return true if the SendBufferEntry destination is the same,
* false otherwise
*/
static bool IsEqual (SendBuffEntry en, const Ipv4Address dst)
{
return (en.GetDestination () == dst);
}