--- a/src/routing/aodv/aodv-packet.cc Thu Jul 16 14:58:10 2009 +0400
+++ b/src/routing/aodv/aodv-packet.cc Thu Jul 16 18:25:49 2009 +0400
@@ -33,9 +33,9 @@
namespace ns3 {
namespace aodv {
-TypeHeader::TypeHeader(uint8_t t) : type(t), valid(true)
+TypeHeader::TypeHeader(uint8_t t) : m_type(t), m_valid(true)
{
- switch (type)
+ switch (m_type)
{
case AODVTYPE_RREQ:
case AODVTYPE_RREP:
@@ -43,7 +43,7 @@
case AODVTYPE_RREP_ACK:
break;
default:
- valid = false;
+ m_valid = false;
}
}
@@ -62,16 +62,16 @@
void
TypeHeader::Serialize (Buffer::Iterator i) const
{
- i.WriteU8(type);
+ i.WriteU8(m_type);
}
uint32_t
TypeHeader::Deserialize (Buffer::Iterator start)
{
Buffer::Iterator i = start;
- type = i.ReadU8 ();
- valid = true;
- switch (type)
+ m_type = i.ReadU8 ();
+ m_valid = true;
+ switch (m_type)
{
case AODVTYPE_RREQ:
case AODVTYPE_RREP:
@@ -79,7 +79,7 @@
case AODVTYPE_RREP_ACK:
break;
default:
- valid = false;
+ m_valid = false;
}
uint32_t dist = i.GetDistanceFrom (start);
NS_ASSERT (dist == GetSerializedSize ());
@@ -89,7 +89,7 @@
void
TypeHeader::Print (std::ostream &os) const
{
- switch(type)
+ switch(m_type)
{
case AODVTYPE_RREQ:
{
@@ -119,7 +119,7 @@
bool
TypeHeader::operator==(TypeHeader const & o) const
{
- return ( type == o.type && valid == o.valid );
+ return ( m_type == o.m_type && m_valid == o.m_valid );
}
std::ostream & operator<<(std::ostream & os, TypeHeader const & h)
@@ -163,8 +163,8 @@
//-----------------------------------------------------------------------------
// RREQ
//-----------------------------------------------------------------------------
-RreqHeader::RreqHeader () : rq_flags(0), reserved(0), rq_hop_count(0), rq_bcast_id(0),
-rq_dst_seqno(0), rq_src_seqno(0)
+RreqHeader::RreqHeader () : m_flags(0), m_reserved(0), m_hopCount(0), m_broadcastID(0),
+m_dstSeqNo(0), m_srcSeqNo(0)
{
SetGratiousRrep (false);
SetDestinationOnly (false);
@@ -186,28 +186,28 @@
void
RreqHeader::Serialize (Buffer::Iterator i) const
{
- i.WriteU8 (rq_flags);
- i.WriteU8 (reserved);
- i.WriteU8 (rq_hop_count);
- i.WriteHtonU32 (rq_bcast_id);
- WriteTo (i, rq_dst);
- i.WriteHtonU32 (rq_dst_seqno);
- WriteTo (i, rq_src);
- i.WriteHtonU32 (rq_src_seqno);
+ i.WriteU8 (m_flags);
+ i.WriteU8 (m_reserved);
+ i.WriteU8 (m_hopCount);
+ i.WriteHtonU32 (m_broadcastID);
+ WriteTo (i, m_dst);
+ i.WriteHtonU32 (m_dstSeqNo);
+ WriteTo (i, m_src);
+ i.WriteHtonU32 (m_srcSeqNo);
}
uint32_t
RreqHeader::Deserialize (Buffer::Iterator start)
{
Buffer::Iterator i = start;
- rq_flags = i.ReadU8 ();
- reserved = i.ReadU8 ();
- rq_hop_count = i.ReadU8 ();
- rq_bcast_id = i.ReadNtohU32 ();
- ReadFrom (i, rq_dst);
- rq_dst_seqno = i.ReadNtohU32 ();
- ReadFrom (i, rq_src);
- rq_src_seqno = i.ReadNtohU32 ();
+ m_flags = i.ReadU8 ();
+ m_reserved = i.ReadU8 ();
+ m_hopCount = i.ReadU8 ();
+ m_broadcastID = i.ReadNtohU32 ();
+ ReadFrom (i, m_dst);
+ m_dstSeqNo = i.ReadNtohU32 ();
+ ReadFrom (i, m_src);
+ m_srcSeqNo = i.ReadNtohU32 ();
uint32_t dist = i.GetDistanceFrom (start);
NS_ASSERT (dist == GetSerializedSize ());
@@ -217,11 +217,11 @@
void
RreqHeader::Print (std::ostream &os) const
{
- os << "RREQ ID " << rq_bcast_id << "\n"
- << "destination: ipv4 " << rq_dst << " "
- << "sequence number " << rq_dst_seqno << "\n"
- << "source: ipv4 " << rq_src << " "
- << "sequence number " << rq_src_seqno << "\n"
+ os << "RREQ ID " << m_broadcastID << "\n"
+ << "destination: ipv4 " << m_dst << " "
+ << "sequence number " << m_dstSeqNo << "\n"
+ << "source: ipv4 " << m_src << " "
+ << "sequence number " << m_srcSeqNo << "\n"
<< "flags:\n"
<< "Gratuitous RREP " << (*this).GetGratiousRrep() << "\n"
<< "Destination only " << (*this).GetDestinationOnly() << "\n"
@@ -237,49 +237,49 @@
void
RreqHeader::SetGratiousRrep (bool f)
{
- if (f) rq_flags |= (1 << 5);
- else rq_flags &= ~(1 << 5);
+ if (f) m_flags |= (1 << 5);
+ else m_flags &= ~(1 << 5);
}
bool
RreqHeader::GetGratiousRrep () const
{
- return (rq_flags & (1 << 5));
+ return (m_flags & (1 << 5));
}
void
RreqHeader::SetDestinationOnly (bool f)
{
- if (f) rq_flags |= (1 << 4);
- else rq_flags &= ~(1 << 4);
+ if (f) m_flags |= (1 << 4);
+ else m_flags &= ~(1 << 4);
}
bool
RreqHeader::GetDestinationOnly () const
{
- return (rq_flags & (1 << 4));
+ return (m_flags & (1 << 4));
}
void
RreqHeader::SetUnknownSeqno (bool f)
{
- if (f) rq_flags |= (1 << 3);
- else rq_flags &= ~(1 << 3);
+ if (f) m_flags |= (1 << 3);
+ else m_flags &= ~(1 << 3);
}
bool
RreqHeader::GetUnknownSeqno () const
{
- return (rq_flags & (1 << 3));
+ return (m_flags & (1 << 3));
}
bool
RreqHeader::operator==(RreqHeader const & o) const
{
- return (rq_flags == o.rq_flags && reserved == o.reserved &&
- rq_hop_count == o.rq_hop_count && rq_bcast_id == o.rq_bcast_id &&
- rq_dst == o.rq_dst && rq_dst_seqno == o.rq_dst_seqno &&
- rq_src == o.rq_src && rq_src_seqno == o.rq_src_seqno);
+ return (m_flags == o.m_flags && m_reserved == o.m_reserved &&
+ m_hopCount == o.m_hopCount && m_broadcastID == o.m_broadcastID &&
+ m_dst == o.m_dst && m_dstSeqNo == o.m_dstSeqNo &&
+ m_src == o.m_src && m_srcSeqNo == o.m_srcSeqNo);
}
#ifdef RUN_SELF_TESTS
@@ -323,7 +323,7 @@
// RREP
//-----------------------------------------------------------------------------
-RrepHeader::RrepHeader() :rp_flags(0), prefixSize(0), rp_hop_count(0), rp_dst_seqno(0)
+RrepHeader::RrepHeader() :m_flags(0), m_prefixSize(0), m_hopCount(0), m_dstSeqNo(0)
{
SetAckRequired(false);
}
@@ -343,13 +343,13 @@
void
RrepHeader::Serialize (Buffer::Iterator i) const
{
- i.WriteU8(rp_flags);
- i.WriteU8(prefixSize);
- i.WriteU8 (rp_hop_count);
- WriteTo (i, rp_dst);
- i.WriteHtonU32 (rp_dst_seqno);
- WriteTo (i, rp_src);
- i.WriteHtonU32 (rp_lifetime);
+ i.WriteU8(m_flags);
+ i.WriteU8(m_prefixSize);
+ i.WriteU8 (m_hopCount);
+ WriteTo (i, m_dst);
+ i.WriteHtonU32 (m_dstSeqNo);
+ WriteTo (i, m_src);
+ i.WriteHtonU32 (m_lifeTime);
}
uint32_t
@@ -357,13 +357,13 @@
{
Buffer::Iterator i = start;
- rp_flags = i.ReadU8 ();
- prefixSize = i.ReadU8 ();
- rp_hop_count = i.ReadU8 ();
- ReadFrom (i, rp_dst);
- rp_dst_seqno = i.ReadNtohU32 ();
- ReadFrom (i, rp_src);
- rp_lifetime = i.ReadNtohU32 ();
+ m_flags = i.ReadU8 ();
+ m_prefixSize = i.ReadU8 ();
+ m_hopCount = i.ReadU8 ();
+ ReadFrom (i, m_dst);
+ m_dstSeqNo = i.ReadNtohU32 ();
+ ReadFrom (i, m_src);
+ m_lifeTime = i.ReadNtohU32 ();
uint32_t dist = i.GetDistanceFrom (start);
NS_ASSERT (dist == GetSerializedSize ());
@@ -373,73 +373,73 @@
void
RrepHeader::Print (std::ostream &os) const
{
- os << "destination: ipv4 " << rp_dst
- << "sequence number " << rp_dst_seqno;
- if(prefixSize != 0)
- os << "prefix size " << prefixSize << "\n";
+ os << "destination: ipv4 " << m_dst
+ << "sequence number " << m_dstSeqNo;
+ if(m_prefixSize != 0)
+ os << "prefix size " << m_prefixSize << "\n";
else os << "\n";
- os << "source ipv4 " << rp_src << "\n"
- << "life time " << rp_lifetime << "\n"
+ os << "source ipv4 " << m_src << "\n"
+ << "life time " << m_lifeTime << "\n"
<< "acknowledgment required flag " << (*this).GetAckRequired() << "\n";
}
void
RrepHeader::SetLifeTime (Time t)
{
- rp_lifetime = t.GetMilliSeconds();
+ m_lifeTime = t.GetMilliSeconds();
}
Time
RrepHeader::GetLifeTime () const
{
- Time t(MilliSeconds(rp_lifetime));
+ Time t(MilliSeconds(m_lifeTime));
return t;
}
void
RrepHeader::SetAckRequired (bool f)
{
- if (f) rp_flags |= (1 << 6);
- else rp_flags &= ~(1 << 6);
+ if (f) m_flags |= (1 << 6);
+ else m_flags &= ~(1 << 6);
}
bool
RrepHeader::GetAckRequired () const
{
- return (rp_flags & (1 << 6));
+ return (m_flags & (1 << 6));
}
void
RrepHeader::SetPrefixSize(uint8_t sz)
{
- prefixSize = sz;
+ m_prefixSize = sz;
}
uint8_t
RrepHeader::GetPrefixSize() const
{
- return prefixSize;
+ return m_prefixSize;
}
bool
RrepHeader::operator==(RrepHeader const & o) const
{
- return (rp_flags == o.rp_flags && prefixSize == o.prefixSize &&
- rp_hop_count == o.rp_hop_count && rp_dst == o.rp_dst &&
- rp_dst_seqno == o.rp_dst_seqno && rp_src == o.rp_src &&
- rp_lifetime == o.rp_lifetime);
+ return (m_flags == o.m_flags && m_prefixSize == o.m_prefixSize &&
+ m_hopCount == o.m_hopCount && m_dst == o.m_dst &&
+ m_dstSeqNo == o.m_dstSeqNo && m_src == o.m_src &&
+ m_lifeTime == o.m_lifeTime);
}
void
RrepHeader::SetHello(Ipv4Address src, uint32_t srcSeqNo, Time lifetime)
{
- rp_flags = 0;
- prefixSize = 0;
- rp_hop_count = 0;
- rp_dst = src;
- rp_dst_seqno = srcSeqNo;
- rp_src = src;
- rp_lifetime = lifetime.GetMilliSeconds ();
+ m_flags = 0;
+ m_prefixSize = 0;
+ m_hopCount = 0;
+ m_dst = src;
+ m_dstSeqNo = srcSeqNo;
+ m_src = src;
+ m_lifeTime = lifetime.GetMilliSeconds ();
}
std::ostream & operator<<(std::ostream & os, RrepHeader const & h)
@@ -490,7 +490,7 @@
// RREP-ACK
//-----------------------------------------------------------------------------
-RrepAckHeader::RrepAckHeader () : reserved(0)
+RrepAckHeader::RrepAckHeader () : m_reserved(0)
{
}
@@ -509,14 +509,14 @@
void
RrepAckHeader::Serialize (Buffer::Iterator i) const
{
- i.WriteU8(reserved);
+ i.WriteU8(m_reserved);
}
uint32_t
RrepAckHeader::Deserialize (Buffer::Iterator start)
{
Buffer::Iterator i = start;
- reserved = i.ReadU8 ();
+ m_reserved = i.ReadU8 ();
uint32_t dist = i.GetDistanceFrom (start);
NS_ASSERT (dist == GetSerializedSize ());
return dist;
@@ -530,7 +530,7 @@
bool
RrepAckHeader::operator==(RrepAckHeader const & o) const
{
- return reserved == o.reserved;
+ return m_reserved == o.m_reserved;
}
std::ostream & operator<<(std::ostream & os, RrepAckHeader const & h)
@@ -568,7 +568,7 @@
//-----------------------------------------------------------------------------
// RERR
//-----------------------------------------------------------------------------
-RerrHeader::RerrHeader() : er_flag(0), reserved(0)
+RerrHeader::RerrHeader() : m_flag(0), m_reserved(0)
{
}
@@ -587,11 +587,11 @@
void
RerrHeader::Serialize (Buffer::Iterator i) const
{
- i.WriteU8(er_flag);
- i.WriteU8(reserved);
+ i.WriteU8(m_flag);
+ i.WriteU8(m_reserved);
i.WriteU8(GetDestCount());
std::map<Ipv4Address, uint32_t>::const_iterator j;
- for(j = unreachable_dst.begin(); j != unreachable_dst.end(); ++j)
+ for(j = m_unreacheableDstSeqNo.begin(); j != m_unreacheableDstSeqNo.end(); ++j)
{
WriteTo (i, (*j).first);
i.WriteHtonU32 ((*j).second);
@@ -602,17 +602,17 @@
RerrHeader::Deserialize (Buffer::Iterator start)
{
Buffer::Iterator i = start;
- er_flag = i.ReadU8 ();
- reserved = i.ReadU8 ();
+ m_flag = i.ReadU8 ();
+ m_reserved = i.ReadU8 ();
uint8_t dest = i.ReadU8 ();
- unreachable_dst.clear();
+ m_unreacheableDstSeqNo.clear();
Ipv4Address address;
uint32_t seqNo;
for(uint8_t k = 0; k < dest; ++k)
{
ReadFrom (i, address);
seqNo = i.ReadNtohU32 ();
- unreachable_dst.insert(std::make_pair(address, seqNo));
+ m_unreacheableDstSeqNo.insert(std::make_pair(address, seqNo));
}
uint32_t dist = i.GetDistanceFrom (start);
@@ -625,7 +625,7 @@
{
os << "Unreachable destination (ipv4 address, seq. number):\n";
std::map<Ipv4Address, uint32_t>::const_iterator j;
- for(j = unreachable_dst.begin(); j != unreachable_dst.end(); ++j)
+ for(j = m_unreacheableDstSeqNo.begin(); j != m_unreacheableDstSeqNo.end(); ++j)
{
os << (*j).first << ", " << (*j).second << "\n";
}
@@ -635,35 +635,35 @@
void
RerrHeader::SetNoDelete(bool f)
{
- if (f) er_flag |= (1 << 0);
- else er_flag &= ~(1 << 0);
+ if (f) m_flag |= (1 << 0);
+ else m_flag &= ~(1 << 0);
}
bool
RerrHeader::GetNoDelete() const
{
- return (er_flag & (1 << 0));
+ return (m_flag & (1 << 0));
}
bool
RerrHeader::AddUnDestination(Ipv4Address dst, uint32_t seqNo)
{
- if(unreachable_dst.find(dst) != unreachable_dst.end())
+ if(m_unreacheableDstSeqNo.find(dst) != m_unreacheableDstSeqNo.end())
return false;
NS_ASSERT (GetDestCount() < 255); // can't support more than 255 destinations in single RERR
- unreachable_dst.insert(std::make_pair(dst, seqNo));
+ m_unreacheableDstSeqNo.insert(std::make_pair(dst, seqNo));
return true;
}
bool
RerrHeader::operator==(RerrHeader const & o) const
{
- if (er_flag != o.er_flag || reserved != o.reserved || GetDestCount() != o.GetDestCount())
+ if (m_flag != o.m_flag || m_reserved != o.m_reserved || GetDestCount() != o.GetDestCount())
return false;
- std::map<Ipv4Address, uint32_t>::const_iterator j = unreachable_dst.begin();
- std::map<Ipv4Address, uint32_t>::const_iterator k = o.unreachable_dst.begin();
+ std::map<Ipv4Address, uint32_t>::const_iterator j = m_unreacheableDstSeqNo.begin();
+ std::map<Ipv4Address, uint32_t>::const_iterator k = o.m_unreacheableDstSeqNo.begin();
for(uint8_t i = 0; i < GetDestCount(); ++i)
{
if ((j->first != k->first ) || (j->second != k->second))
--- a/src/routing/aodv/aodv-packet.h Thu Jul 16 14:58:10 2009 +0400
+++ b/src/routing/aodv/aodv-packet.h Thu Jul 16 18:25:49 2009 +0400
@@ -64,12 +64,12 @@
void Print (std::ostream &os) const;
//\}
- uint8_t Get() const { return type; }
- bool IsValid() const { return valid; }
+ uint8_t Get() const { return m_type; }
+ bool IsValid() const { return m_valid; }
bool operator==(TypeHeader const & o) const;
private:
- uint8_t type;
- bool valid;
+ uint8_t m_type;
+ bool m_valid;
};
std::ostream & operator<<(std::ostream & os, TypeHeader const & h);
@@ -111,18 +111,18 @@
///\name Fields
//\{
- void SetHopCount (uint8_t count) { rq_hop_count = count; }
- uint8_t GetHopCount () const { return rq_hop_count; }
- void SetId (uint32_t id) { rq_bcast_id = id; }
- uint8_t GetId () const { return rq_bcast_id; }
- void SetDst (Ipv4Address a) { rq_dst = a; }
- Ipv4Address GetDst () const { return rq_dst; }
- void SetDstSeqno (uint32_t s) { rq_dst_seqno = s; }
- uint32_t GetDstSeqno () const { return rq_dst_seqno; }
- void SetOrigin (Ipv4Address a) { rq_src = a; }
- Ipv4Address GetOrigin () const { return rq_src; }
- void SetOriginSeqno (uint32_t s) { rq_src_seqno = s; }
- uint32_t GetOriginSeqno () const { return rq_src_seqno; }
+ void SetHopCount (uint8_t count) { m_hopCount = count; }
+ uint8_t GetHopCount () const { return m_hopCount; }
+ void SetId (uint32_t id) { m_broadcastID = id; }
+ uint8_t GetId () const { return m_broadcastID; }
+ 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_src = a; }
+ Ipv4Address GetOrigin () const { return m_src; }
+ void SetOriginSeqno (uint32_t s) { m_srcSeqNo = s; }
+ uint32_t GetOriginSeqno () const { return m_srcSeqNo; }
//\}
///\name Flags
@@ -137,14 +137,14 @@
bool operator==(RreqHeader const & o) const;
private:
- uint8_t rq_flags; ///< |J|R|G|D|U| bit flags, see RFC
- uint8_t reserved; ///< Not used
- uint8_t rq_hop_count; ///< Hop Count
- uint32_t rq_bcast_id; ///< RREQ ID
- Ipv4Address rq_dst; ///< Destination IP Address
- uint32_t rq_dst_seqno; ///< Destination Sequence Number
- Ipv4Address rq_src; ///< Source IP Address
- uint32_t rq_src_seqno; ///< Source Sequence Number
+ uint8_t m_flags; ///< |J|R|G|D|U| bit flags, see RFC
+ uint8_t m_reserved; ///< Not used
+ uint8_t m_hopCount; ///< Hop Count
+ uint32_t m_broadcastID; ///< RREQ ID
+ Ipv4Address m_dst; ///< Destination IP Address
+ uint32_t m_dstSeqNo; ///< Destination Sequence Number
+ Ipv4Address m_src; ///< Source IP Address
+ uint32_t m_srcSeqNo; ///< Source Sequence Number
};
std::ostream & operator<<(std::ostream & os, RreqHeader const &);
@@ -183,14 +183,14 @@
///\name Fields
//\{
- void SetHopCount (uint8_t count) { rp_hop_count = count; }
- uint8_t GetHopCount () const { return rp_hop_count; }
- void SetDst (Ipv4Address a) { rp_dst = a; }
- Ipv4Address GetDst () const { return rp_dst; }
- void SetDstSeqno (uint32_t s) { rp_dst_seqno = s; }
- uint32_t GetDstSeqno () const { return rp_dst_seqno; }
- void SetOrigin (Ipv4Address a) { rp_src = a; }
- Ipv4Address GetOrigin () const { return rp_src; }
+ 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_src = a; }
+ Ipv4Address GetOrigin () const { return m_src; }
void SetLifeTime (Time t);
Time GetLifeTime () const;
//\}
@@ -208,13 +208,13 @@
bool operator==(RrepHeader const & o) const;
private:
- uint8_t rp_flags; ///< A - acknowledgment required flag
- uint8_t prefixSize; ///< Prefix Size
- uint8_t rp_hop_count; ///< Hop Count
- Ipv4Address rp_dst; ///< Destination IP Address
- uint32_t rp_dst_seqno; ///< Destination Sequence Number
- Ipv4Address rp_src; ///< Source IP Address
- uint32_t rp_lifetime; ///< Lifetime
+ uint8_t m_flags; ///< A - acknowledgment required flag
+ uint8_t m_prefixSize; ///< Prefix Size
+ uint8_t m_hopCount; ///< Hop Count
+ Ipv4Address m_dst; ///< Destination IP Address
+ uint32_t m_dstSeqNo; ///< Destination Sequence Number
+ Ipv4Address m_src; ///< Source IP Address
+ uint32_t m_lifeTime; ///< Lifetime
};
std::ostream & operator<<(std::ostream & os, RrepHeader const &);
@@ -246,7 +246,7 @@
bool operator==(RrepAckHeader const & o) const;
private:
- uint8_t reserved;
+ uint8_t m_reserved;
};
std::ostream & operator<<(std::ostream & os, RrepAckHeader const &);
@@ -291,14 +291,14 @@
//\}
bool AddUnDestination(Ipv4Address dst, uint32_t seqNo);
- uint8_t GetDestCount() const { return (uint8_t)unreachable_dst.size(); }
+ uint8_t GetDestCount() const { return (uint8_t)m_unreacheableDstSeqNo.size(); }
bool operator==(RerrHeader const & o) const;
private:
- uint8_t er_flag; ///< No delete flag
- uint8_t reserved; ///< Not used
+ uint8_t m_flag; ///< No delete flag
+ uint8_t m_reserved; ///< Not used
/// List of Unreachable destination IP addresses and sequence numbers
- std::map<Ipv4Address, uint32_t> unreachable_dst;
+ std::map<Ipv4Address, uint32_t> m_unreacheableDstSeqNo;
};
std::ostream & operator<<(std::ostream & os, RerrHeader const &);
--- a/src/routing/aodv/aodv-routing-protocol.cc Thu Jul 16 14:58:10 2009 +0400
+++ b/src/routing/aodv/aodv-routing-protocol.cc Thu Jul 16 18:25:49 2009 +0400
@@ -62,13 +62,13 @@
if(LookupBroadcastId(id, bid) )
return;
struct BroadcastId broadcastId = {id, bid,BCAST_ID_SAVE + Simulator::Now()};
- bi.push_back(broadcastId);
+ m_broadcastIdCache.push_back(broadcastId);
}
bool
RoutingProtocol::LookupBroadcastId (Ipv4Address id, uint32_t bid)
{
std::vector<BroadcastId>::const_iterator i;
- for(i = bi.begin(); i != bi.end(); ++i)
+ for(i = m_broadcastIdCache.begin(); i != m_broadcastIdCache.end(); ++i)
if(i->src == id && i->id == bid)
return true;
return false;
@@ -76,8 +76,8 @@
void
RoutingProtocol::PurgeBroadcastId ()
{
- std::vector<BroadcastId>::iterator i = remove_if(bi.begin(), bi.end(), IsExpired());
- bi.erase(i, bi.end());
+ std::vector<BroadcastId>::iterator i = remove_if(m_broadcastIdCache.begin(), m_broadcastIdCache.end(), IsExpired());
+ m_broadcastIdCache.erase(i, m_broadcastIdCache.end());
}
RoutingProtocol::RoutingProtocol() :
@@ -88,7 +88,7 @@
ALLOWED_HELLO_LOSS (2),
BAD_LINK_LIFETIME (Seconds (3)),
FREQUENCY (Seconds (0.5)),
- bid(1), seqno(2/*??*/),
+ m_broadcastID(1), m_seqNo(2/*??*/),
btimer(Timer::REMOVE_ON_DESTROY),
htimer(Timer::REMOVE_ON_DESTROY),
ntimer(Timer::REMOVE_ON_DESTROY),
@@ -162,13 +162,13 @@
// Add local broadcast record to the routing table
Ptr<NetDevice> dev = m_ipv4->GetNetDevice(m_ipv4->GetInterfaceForAddress (iface.GetLocal()));
- aodv_rt_entry rt(/*device=*/dev, /*dst=*/iface.GetBroadcast (),
+ RoutingTableEntry rt(/*device=*/dev, /*dst=*/iface.GetBroadcast (),
/*know seqno=*/true, /*seqno=*/0,
/*iface=*/iface.GetLocal (),
/*hops=*/1,
/*next hop=*/iface.GetBroadcast (),
/*lifetime=*/Seconds(1e9)); // TODO use infty
- rtable.rt_add (rt);
+ m_routingTable.AddRoute (rt);
}
}
@@ -179,8 +179,8 @@
Ptr<Ipv4Route> rtentry;
Ipv4Address dst = header.GetDestination();
Ptr<NetDevice> dev;
- aodv_rt_entry rt(dev);
- if (! rtable.rt_lookup(dst, rt))
+ RoutingTableEntry rt(dev);
+ if (! m_routingTable.LookupRoute(dst, rt))
{
SendRequest(dst, false, false);
sockerr = Socket::ERROR_NOROUTETOHOST;
@@ -245,8 +245,8 @@
// Forwarding
Ptr<NetDevice> dev;
- aodv_rt_entry rt(dev);
- if (rtable.rt_lookup(dst, rt))
+ RoutingTableEntry rt(dev);
+ if (m_routingTable.LookupRoute(dst, rt))
{
Ptr<Ipv4Route> rtentry = rt.GetRoute();
NS_LOG_LOGIC(rtentry->GetSource()<<" forwarding to " << dst);
@@ -254,7 +254,7 @@
return true;
}
NS_LOG_LOGIC("route not found to "<< header.GetDestination());
- rtable.Print(std::cout);
+ m_routingTable.Print(std::cout);
return false;
}
@@ -322,8 +322,8 @@
rreqHeader.SetDst (dst);
Ptr<NetDevice> dev;
- aodv_rt_entry rt(dev);
- if(rtable.rt_lookup (dst, rt))
+ RoutingTableEntry rt(dev);
+ if(m_routingTable.LookupRoute (dst, rt))
{
rreqHeader.SetHopCount (rt.GetLastValidHopCount());
rreqHeader.SetDstSeqno (rt.GetSeqNo());
@@ -336,10 +336,10 @@
if (G) rreqHeader.SetGratiousRrep(true);
if (D) rreqHeader.SetDestinationOnly(true);
- seqno++;
- rreqHeader.SetOriginSeqno(seqno);
- bid++;
- rreqHeader.SetId(bid);
+ m_seqNo++;
+ rreqHeader.SetOriginSeqno(m_seqNo);
+ m_broadcastID++;
+ rreqHeader.SetId(m_broadcastID);
rreqHeader.SetHopCount(0);
// Send RREQ as subnet directed broadcast from each (own) interface
@@ -350,7 +350,7 @@
Ipv4InterfaceAddress iface = j->second;
rreqHeader.SetOrigin (iface.GetLocal());
- InsertBroadcastId (iface.GetLocal(), bid);
+ InsertBroadcastId (iface.GetLocal(), m_broadcastID);
packet->AddHeader (rreqHeader);
@@ -415,16 +415,16 @@
{
NS_LOG_FUNCTION (this << "sender " << sender << " receiver " << receiver );
Ptr<NetDevice> dev;
- aodv_rt_entry toNeighbor(dev);
- if(!rtable.rt_lookup(sender, toNeighbor))
+ RoutingTableEntry toNeighbor(dev);
+ if(!m_routingTable.LookupRoute(sender, toNeighbor))
{
dev = m_ipv4->GetNetDevice(m_ipv4->GetInterfaceForAddress (receiver));
- aodv_rt_entry newEntry(/*device=*/dev, /*dst=*/sender,
+ RoutingTableEntry newEntry(/*device=*/dev, /*dst=*/sender,
/*know seqno=*/false, /*seqno=*/0,
/*iface=*/receiver,
/*hops=*/1, /*next hop=*/sender,
/*lifetime=*/Simulator::Now() + ACTIVE_ROUTE_TIMEOUT);
- rtable.rt_add(newEntry);
+ m_routingTable.AddRoute(newEntry);
}
else
{
@@ -432,7 +432,7 @@
Time t = toNeighbor.GetLifeTime();
if (t < Simulator::Now() + ACTIVE_ROUTE_TIMEOUT)
toNeighbor.SetLifeTime(Simulator::Now() + ACTIVE_ROUTE_TIMEOUT);
- rtable.Update(sender, toNeighbor);
+ m_routingTable.Update(sender, toNeighbor);
}
}
@@ -463,14 +463,14 @@
// Reverse route to the Originator IP Address is created, or updating
Ptr<NetDevice> dev;
- aodv_rt_entry toOrigin(dev);
- if(! rtable.rt_lookup(origin, toOrigin))
+ RoutingTableEntry toOrigin(dev);
+ if(! m_routingTable.LookupRoute(origin, toOrigin))
{
dev = m_ipv4->GetNetDevice(m_ipv4->GetInterfaceForAddress (receiver));
- aodv_rt_entry newEntry(/*device=*/dev, /*dst=*/origin, /*validSeno=*/true, /*seqNo=*/rreqHeader.GetOriginSeqno(),
+ RoutingTableEntry newEntry(/*device=*/dev, /*dst=*/origin, /*validSeno=*/true, /*seqNo=*/rreqHeader.GetOriginSeqno(),
/*iface=*/receiver, /*hops=*/hop, /*nextHop*/src,
/*timeLife=*/Simulator::Now() + Scalar(2)*NET_TRAVERSAL_TIME - Scalar(2*hop)*NODE_TRAVERSAL_TIME );
- rtable.rt_add (newEntry);
+ m_routingTable.AddRoute (newEntry);
}
else // TODO check logic
{
@@ -482,7 +482,7 @@
Time minimalLifetime = Simulator::Now() + Scalar(2)*NET_TRAVERSAL_TIME - Scalar(2*hop)*NODE_TRAVERSAL_TIME;
if (toOrigin.GetLifeTime() < minimalLifetime)
toOrigin.SetLifeTime(minimalLifetime);
- rtable.Update(origin, toOrigin);
+ m_routingTable.Update(origin, toOrigin);
}
// A node generates a RREP if either:
@@ -493,7 +493,7 @@
Ipv4Address addr = m_ipv4->GetAddress (k, 0).GetLocal ();
if (addr == rreqHeader.GetDst())
{
- rtable.rt_lookup(origin, toOrigin);
+ m_routingTable.LookupRoute(origin, toOrigin);
SendReply (rreqHeader, toOrigin, socket);
return;
}
@@ -505,9 +505,9 @@
// the Destination Sequence Number of the RREQ ,
// and the "destination only" ('D') flag is NOT set.
- aodv_rt_entry toDst(dev);
+ RoutingTableEntry toDst(dev);
Ipv4Address dst = rreqHeader.GetDst();
- if (rtable.rt_lookup(dst, toDst))
+ if (m_routingTable.LookupRoute(dst, toDst))
{
// The Destination Sequence number for the requested destination is set
// to the maximum of the corresponding value received in the RREQ message,
@@ -549,7 +549,7 @@
}
void
-RoutingProtocol::SendReply (RreqHeader const & rreqHeader, aodv_rt_entry const & toOrigin, Ptr<Socket> socket)
+RoutingProtocol::SendReply (RreqHeader const & rreqHeader, RoutingTableEntry const & toOrigin, Ptr<Socket> socket)
{
NS_LOG_FUNCTION (this << toOrigin.GetDestination ());
// Create RREP
@@ -560,9 +560,9 @@
// if the sequence number in the RREQ packet is equal to that incremented value.
// Otherwise, the destination does not change its sequence number before
// generating the RREP message.
- if(!rreqHeader.GetUnknownSeqno() && (rreqHeader.GetDstSeqno() == seqno + 1))
- seqno++;
- rrepHeader.SetDstSeqno(seqno);
+ if(!rreqHeader.GetUnknownSeqno() && (rreqHeader.GetDstSeqno() == m_seqNo + 1))
+ m_seqNo++;
+ rrepHeader.SetDstSeqno(m_seqNo);
rrepHeader.SetDst(rreqHeader.GetDst());
rrepHeader.SetLifeTime(MY_ROUTE_TIMEOUT);
@@ -585,7 +585,7 @@
uint8_t hop = rrepHeader.GetHopCount() + 1;
rrepHeader.SetHopCount(hop);
Ptr<NetDevice> dev;
- aodv_rt_entry toDst (dev);
+ RoutingTableEntry toDst (dev);
// If the route table entry to the destination is created or updated,
// then the following actions occur:
@@ -601,12 +601,12 @@
// Number in the RREP message.
// The forward route for this destination is created if it does not already exist.
- if(!rtable.rt_lookup(rrepHeader.GetDst(), toDst))
+ if(!m_routingTable.LookupRoute(rrepHeader.GetDst(), toDst))
{
dev = m_ipv4->GetNetDevice(m_ipv4->GetInterfaceForAddress (receiverIfaceAddr));
- aodv_rt_entry newEntry(/*device=*/dev, /*dst=*/rrepHeader.GetDst(), /*validSeqNo=*/true, /*seqno=*/rrepHeader.GetDstSeqno(), /*iface=*/receiverIfaceAddr,
+ RoutingTableEntry newEntry(/*device=*/dev, /*dst=*/rrepHeader.GetDst(), /*validSeqNo=*/true, /*seqno=*/rrepHeader.GetDstSeqno(), /*iface=*/receiverIfaceAddr,
/*hop=*/hop, /*nextHop=*/senderIfaceAddr, /*lifeTime=*/Simulator::Now() + rrepHeader.GetLifeTime());
- rtable.rt_add(newEntry);
+ m_routingTable.AddRoute(newEntry);
}
// The existing entry is updated only in the following circumstances:
else
@@ -620,7 +620,7 @@
toDst.SetHop(hop);
if(!toDst.GetValidSeqNo())
{
- rtable.Update(rrepHeader.GetDst(), toDst);
+ m_routingTable.Update(rrepHeader.GetDst(), toDst);
}
// (ii) the Destination Sequence Number in the RREP is greater than
// the node's copy of the destination sequence number and the
@@ -628,20 +628,20 @@
else if(rrepHeader.GetDstSeqno() > toDst.GetSeqNo())
{
toDst.SetSeqNo(rrepHeader.GetDstSeqno());
- rtable.Update(rrepHeader.GetDst(), toDst);
+ m_routingTable.Update(rrepHeader.GetDst(), toDst);
}
else
{
// (iii) the sequence numbers are the same, but the route is marked as inactive.
if( (rrepHeader.GetDstSeqno() == toDst.GetSeqNo()) && (toDst.GetFlag() != RTF_UP) )
{
- rtable.Update(rrepHeader.GetDst(), toDst);
+ m_routingTable.Update(rrepHeader.GetDst(), toDst);
}
// (iv) the sequence numbers are the same, and the New Hop Count is
// smaller than the hop count in route table entry.
else if( (rrepHeader.GetDstSeqno() == toDst.GetSeqNo()) && (hop < toDst.GetHop()) )
{
- rtable.Update(rrepHeader.GetDst(), toDst);
+ m_routingTable.Update(rrepHeader.GetDst(), toDst);
}
}
}
@@ -653,27 +653,27 @@
}
- aodv_rt_entry toOrigin(dev);
- if(!rtable.rt_lookup(rrepHeader.GetOrigin(), toOrigin))
+ RoutingTableEntry toOrigin(dev);
+ if(!m_routingTable.LookupRoute(rrepHeader.GetOrigin(), toOrigin))
{
// imposible!
// drop();
return;
}
- rtable.rt_lookup(rrepHeader.GetDst(), toDst);
- toDst.pc_insert(toOrigin.GetNextHop());
- rtable.Update(rrepHeader.GetDst(), toDst);
+ m_routingTable.LookupRoute(rrepHeader.GetDst(), toDst);
+ toDst.InsertPrecursor(toOrigin.GetNextHop());
+ m_routingTable.Update(rrepHeader.GetDst(), toDst);
if ( toOrigin.GetLifeTime() < (Simulator::Now() + ACTIVE_ROUTE_TIMEOUT) )
{
toOrigin.SetLifeTime(Simulator::Now() + ACTIVE_ROUTE_TIMEOUT);
- rtable.Update(toOrigin.GetDestination (), toOrigin);
+ m_routingTable.Update(toOrigin.GetDestination (), toOrigin);
}
- aodv_rt_entry toNextHopToDst(dev);
- rtable.rt_lookup(toDst.GetNextHop(), toNextHopToDst);
- toNextHopToDst.pc_insert(toOrigin.GetNextHop());
- rtable.Update(toDst.GetNextHop(), toNextHopToDst);
+ RoutingTableEntry toNextHopToDst(dev);
+ m_routingTable.LookupRoute(toDst.GetNextHop(), toNextHopToDst);
+ toNextHopToDst.InsertPrecursor(toOrigin.GetNextHop());
+ m_routingTable.Update(toDst.GetNextHop(), toNextHopToDst);
// TODO add operation over unidirctinal links
Ptr<Packet> packet = Create<Packet> ();
@@ -738,7 +738,7 @@
void
-RoutingProtocol::SendReplyByIntermediateNode(aodv_rt_entry & toDst, aodv_rt_entry & toOrigin, bool gratRep)
+RoutingProtocol::SendReplyByIntermediateNode(RoutingTableEntry & toDst, RoutingTableEntry & toOrigin, bool gratRep)
{
#if 0
RrepHeader rrepHeader;
@@ -750,8 +750,8 @@
rrepHeader.SetHopCount(toDst.GetHop());
rrepHeader.SetLifeTime(toDst.GetLifeTime() - Simulator::Now());
- toDst.pc_insert(toOrigin.GetNextHop());
- toOrigin.pc_insert(toDst.GetNextHop());
+ toDst.InsertPrecursor(toOrigin.GetNextHop());
+ toOrigin.InsertPrecursor(toDst.GetNextHop());
Ptr<Packet> packet = Create<Packet> ();
--- a/src/routing/aodv/aodv-routing-protocol.h Thu Jul 16 14:58:10 2009 +0400
+++ b/src/routing/aodv/aodv-routing-protocol.h Thu Jul 16 18:25:49 2009 +0400
@@ -47,25 +47,6 @@
{
namespace aodv
{
-/// List of neighbors TODO document & move inside protocol
-class NeighborList
-{
-public:
- /// The neighbor
- struct Neighbor
- {
- Ipv4Address nb_addr;
- Time nb_expire;
- };
-
- void Insert(Ipv4Address id);
- bool Lookup (Ipv4Address id, Neighbor & n);
- void Delete (Ipv4Address id);
- void Purge ();
-
-private:
- std::vector<Neighbor> nb;
-};
/**
* \ingroup aodv
@@ -129,7 +110,7 @@
return (b.expire < Simulator::Now());
}
};
- std::vector<BroadcastId> bi;
+ std::vector<BroadcastId> m_broadcastIdCache;
//\}
/// IP protocol
@@ -138,15 +119,13 @@
std::map< Ptr<Socket>, Ipv4InterfaceAddress > m_socketAddresses;
/// Routing table
- aodv_rtable rtable;
+ RoutingTable m_routingTable;
/// A "drop-front" queue used by the routing layer to buffer packets to which it does not have a route.
- aodv_rqueue rqueue;
- /// List of neighbors (aka neighbors cache). TODO: separate list for each interface???
- NeighborList nbhead;
+ AodvQueue m_queue;
/// Broadcast ID
- uint32_t bid;
+ uint32_t m_broadcastID;
/// Request sequence number
- uint32_t seqno;
+ uint32_t m_seqNo;
private:
/// Start protocol operation
@@ -155,7 +134,7 @@
void LocalRouteRepair (Ipv4Address dst, Ptr<Packet> p);
/// Process broken link
void HandleLinkFailure (Ipv4Address id);
- /// Purge all expired records from rtable
+ /// Purge all expired records from m_routingTable
void RtPurge ();
/// Update neighbor record. \param receiver is supposed to be my interface
void UpdateNeighbor (Ipv4Address sender, Ipv4Address receiver);
@@ -181,9 +160,9 @@
/// Send RREQ
void SendRequest (Ipv4Address dst, bool G, bool D);
/// Send RREP
- void SendReply (RreqHeader const & rreqHeader, aodv_rt_entry const & toOrigin, Ptr<Socket> socket);
+ void SendReply (RreqHeader const & rreqHeader, RoutingTableEntry const & toOrigin, Ptr<Socket> socket);
/// TODO
- void SendReplyByIntermediateNode(aodv_rt_entry & toDst, aodv_rt_entry & toOrigin, bool gratRep = false);
+ void SendReplyByIntermediateNode(RoutingTableEntry & toDst, RoutingTableEntry & toOrigin, bool gratRep = false);
/// Send RERR
void SendError (Ipv4Address failed);
//\}
--- a/src/routing/aodv/aodv-rqueue.cc Thu Jul 16 14:58:10 2009 +0400
+++ b/src/routing/aodv/aodv-rqueue.cc Thu Jul 16 18:25:49 2009 +0400
@@ -33,63 +33,63 @@
namespace ns3 {
namespace aodv {
-aodv_rqueue::aodv_rqueue() : limit_(AODV_RTQ_MAX_LEN), timeout_(Seconds(AODV_RTQ_TIMEOUT))
+AodvQueue::AodvQueue() : m_maxSize(AODV_RTQ_MAX_LEN), m_timeout(Seconds(AODV_RTQ_TIMEOUT))
{
}
uint32_t
-aodv_rqueue::size ()
+AodvQueue::GetSize ()
{
- purge();
- return queue.size();
+ Purge();
+ return m_queue.size();
}
void
-aodv_rqueue::enque(QueueEntry & entry)
+AodvQueue::Enqueue(QueueEntry & entry)
{
// Purge any packets that have timed out.
- purge();
- entry.enExpire = Simulator::Now() + timeout_;
+ Purge();
+ entry.m_expire = Simulator::Now() + m_timeout;
- if (queue.size() == limit_) drop(remove_head()); // drop the most aged packet
- queue.push_back(entry);
+ if (m_queue.size() == m_maxSize) Drop(RemoveHead()); // Drop the most aged packet
+ m_queue.push_back(entry);
}
QueueEntry
-aodv_rqueue::deque()
+AodvQueue::Dequeue()
{
- purge();
- return remove_head();
+ Purge();
+ return RemoveHead();
}
bool
-aodv_rqueue::deque(Ipv4Address dst, QueueEntry & entry)
+AodvQueue::Dequeue(Ipv4Address dst, QueueEntry & entry)
{
- purge();
- for(std::vector<QueueEntry>::iterator i = queue.begin(); i != queue.end(); ++i)
- if(i->header.GetDestination() == dst)
+ Purge();
+ for(std::vector<QueueEntry>::iterator i = m_queue.begin(); i != m_queue.end(); ++i)
+ if(i->m_header.GetDestination() == dst)
{
entry = *i;
- queue.erase(i);
+ m_queue.erase(i);
return true;
}
return false;
}
bool
-aodv_rqueue::find(Ipv4Address dst)
+AodvQueue::Find(Ipv4Address dst)
{
- for( std::vector<QueueEntry>::const_iterator i = queue.begin(); i != queue.end(); ++i)
- if(i->header.GetDestination() == dst)
+ for( std::vector<QueueEntry>::const_iterator i = m_queue.begin(); i != m_queue.end(); ++i)
+ if(i->m_header.GetDestination() == dst)
return true;
return false;
}
QueueEntry
-aodv_rqueue::remove_head()
+AodvQueue::RemoveHead()
{
- QueueEntry entry = queue.front();
- queue.erase(queue.begin());
+ QueueEntry entry = m_queue.front();
+ m_queue.erase(m_queue.begin());
return entry;
}
@@ -97,27 +97,27 @@
{
bool operator() (QueueEntry const & e) const
{
- return (e.enExpire < Simulator::Now());
+ return (e.m_expire < Simulator::Now());
}
};
void
-aodv_rqueue::purge()
+AodvQueue::Purge()
{
- std::vector<QueueEntry>::iterator i = std::remove_if(queue.begin(), queue.end(), IsExpired());
- for (std::vector<QueueEntry>::iterator j = i ; j < queue.end(); ++j)
- drop (*j);
- queue.erase(i, queue.end());
+ std::vector<QueueEntry>::iterator i = std::remove_if(m_queue.begin(), m_queue.end(), IsExpired());
+ for (std::vector<QueueEntry>::iterator j = i ; j < m_queue.end(); ++j)
+ Drop (*j);
+ m_queue.erase(i, m_queue.end());
}
void
-aodv_rqueue::drop(QueueEntry)
+AodvQueue::Drop(QueueEntry)
{
// TODO do nothing now.
}
#ifdef RUN_SELF_TESTS
-/// Unit test for aodv_rqueue
+/// Unit test for AodvQueue
struct AodvRqueueTest : public Test
{
AodvRqueueTest () : Test ("AODV/Rqueue"), result(true) {}
@@ -126,7 +126,7 @@
void CheckSizeLimit ();
void CheckTimeout ();
- aodv_rqueue q;
+ AodvQueue q;
bool result;
};
@@ -139,21 +139,21 @@
Ptr<Packet> packet = Create<Packet>();
Ipv4Header header;
QueueEntry e1 (packet, header);
- q.enque (e1);
- QueueEntry e2 = q.deque ();
+ q.Enqueue (e1);
+ QueueEntry e2 = q.Dequeue ();
NS_TEST_ASSERT (e1 == e2);
Ipv4Address dst("1.2.3.4");
header.SetDestination (dst);
e1 = QueueEntry (packet, header);
- q.enque (e1);
+ q.Enqueue (e1);
- bool ok = q.deque (dst, e2);
+ bool ok = q.Dequeue (dst, e2);
NS_TEST_ASSERT (ok);
NS_TEST_ASSERT (e1 == e2);
- NS_TEST_ASSERT (! q.find(dst));
- q.enque (e1);
- NS_TEST_ASSERT (q.find(dst));
+ NS_TEST_ASSERT (! q.Find(dst));
+ q.Enqueue (e1);
+ NS_TEST_ASSERT (q.Find(dst));
CheckSizeLimit ();
@@ -177,18 +177,18 @@
QueueEntry e1 (packet, header);
for (uint32_t i = 0; i < AODV_RTQ_MAX_LEN; ++i)
- q.enque (e1);
- NS_TEST_ASSERT (q.size() == AODV_RTQ_MAX_LEN);
+ q.Enqueue (e1);
+ NS_TEST_ASSERT (q.GetSize() == AODV_RTQ_MAX_LEN);
for (uint32_t i = 0; i < AODV_RTQ_MAX_LEN; ++i)
- q.enque (e1);
- NS_TEST_ASSERT (q.size() == AODV_RTQ_MAX_LEN);
+ q.Enqueue (e1);
+ NS_TEST_ASSERT (q.GetSize() == AODV_RTQ_MAX_LEN);
}
void
AodvRqueueTest::CheckTimeout ()
{
- NS_TEST_ASSERT (q.size() == 0);
+ NS_TEST_ASSERT (q.GetSize() == 0);
}
#endif
}}
--- a/src/routing/aodv/aodv-rqueue.h Thu Jul 16 14:58:10 2009 +0400
+++ b/src/routing/aodv/aodv-rqueue.h Thu Jul 16 18:25:49 2009 +0400
@@ -46,55 +46,53 @@
*/
struct QueueEntry
{
- Ptr<Packet> p;
- Ipv4Header header;
+ Ptr<Packet> m_packet;
+ Ipv4Header m_header;
/// Expire time for queue entry
- Time enExpire;
+ Time m_expire;
/// c-tor
- QueueEntry(Ptr<Packet> pa, Ipv4Header const & h, Time exp = Seconds(0)) : p(pa), header(h), enExpire(exp) {}
+ QueueEntry(Ptr<Packet> pa, Ipv4Header const & h, Time exp = Seconds(0)) : m_packet(pa), m_header(h), m_expire(exp) {}
/**
* Compare queue entries
* \return true if equal
*/
bool operator==(QueueEntry const & o) const
{
- return ((p == o.p)/*&& header == o.header*/ && (enExpire == o.enExpire));
+ return ((m_packet == o.m_packet)/*&& header == o.header*/ && (m_expire == o.m_expire));
}
};
/**
* \ingroup aodv
* \brief AODV Queue
*/
-class aodv_rqueue
+class AodvQueue
{
public:
/// Default c-tor
- aodv_rqueue();
+ AodvQueue ();
/// Push entry in queue.
- void enque(QueueEntry & entry);
+ void Enqueue (QueueEntry & entry);
/// Returns a entry from the head of the queue.
- QueueEntry deque();
+ QueueEntry Dequeue ();
/// Return first found (the earliest) entry for given destination
- bool deque(Ipv4Address dst, QueueEntry & entry);
+ bool Dequeue (Ipv4Address dst, QueueEntry & entry);
/// Finds whether a packet with destination dst exists in the queue
- bool find(Ipv4Address dst);
+ bool Find (Ipv4Address dst);
/// Number of entries
- uint32_t size();
+ uint32_t GetSize ();
private:
- std::vector<QueueEntry> queue;
+ std::vector<QueueEntry> m_queue;
/// Remove and return first entry from queue
- QueueEntry remove_head();
+ QueueEntry RemoveHead();
/// Remove all expired entries
- void purge();
- /// Find packet with destination address dst, return true on success
- bool findPacketWithDst(Ipv4Address dst, QueueEntry & entry);
+ void Purge();
/// Notify that packet is dropped from queue by timeout
- void drop (QueueEntry e);
+ void Drop (QueueEntry e);
/// Maximum number of entries in queue
- uint32_t limit_;
+ uint32_t m_maxSize;
/// Life time of queue entry in queue
- Time timeout_;
+ Time m_timeout;
};
}}
--- a/src/routing/aodv/aodv-rtable.cc Thu Jul 16 14:58:10 2009 +0400
+++ b/src/routing/aodv/aodv-rtable.cc Thu Jul 16 18:25:49 2009 +0400
@@ -37,16 +37,16 @@
*/
-aodv_rt_entry::aodv_rt_entry(Ptr<NetDevice> dev, Ipv4Address dst, bool vSeqNo, u_int32_t seqNo, Ipv4Address iface, u_int16_t hops,
+RoutingTableEntry::RoutingTableEntry(Ptr<NetDevice> dev, Ipv4Address dst, bool vSeqNo, u_int32_t seqNo, Ipv4Address iface, u_int16_t hops,
Ipv4Address nextHop, Time lifetime)
- : validSeqNo(vSeqNo), rt_seqno(seqNo), rt_hops(hops), rt_last_hop_count(hops), rt_lifetime(lifetime), rt_req_cnt(0)
+ : m_validSeqNo(vSeqNo), m_seqNo(seqNo), m_hops(hops), m_lastHopCount(hops), m_lifeTime(lifetime), m_reqCount(0)
{
m_ipv4Route = Create<Ipv4Route> ();
m_ipv4Route->SetDestination(dst);
m_ipv4Route->SetGateway(nextHop);
m_ipv4Route->SetSource(iface);
m_ipv4Route->SetOutputDevice(dev);
- rt_flags = RTF_UP;
+ m_flag = RTF_UP;
for(uint8_t i = 0; i < MAX_HISTORY; ++i)
{
rt_disc_latency[i] = 0;
@@ -54,68 +54,68 @@
hist_indx = 0;
}
-aodv_rt_entry::~aodv_rt_entry()
+RoutingTableEntry::~RoutingTableEntry()
{
}
bool
-aodv_rt_entry::pc_insert(Ipv4Address id)
+RoutingTableEntry::InsertPrecursor(Ipv4Address id)
{
- if (! pc_lookup(id))
+ if (! LookupPrecursor(id))
{
- rt_pclist.push_back(id);
+ m_precursorList.push_back(id);
return true;
}
else return false;
}
bool
-aodv_rt_entry::pc_lookup(Ipv4Address id)
+RoutingTableEntry::LookupPrecursor(Ipv4Address id)
{
- for(std::vector<Ipv4Address>::const_iterator i = rt_pclist.begin(); i != rt_pclist.end(); ++i)
+ for(std::vector<Ipv4Address>::const_iterator i = m_precursorList.begin(); i != m_precursorList.end(); ++i)
if (*i == id) return true;
return false;
}
bool
-aodv_rt_entry::pc_delete(Ipv4Address id)
+RoutingTableEntry::DeletePrecursor(Ipv4Address id)
{
- std::vector<Ipv4Address>::iterator i = std::remove(rt_pclist.begin(), rt_pclist.end(), id);
- if(i == rt_pclist.end())
+ std::vector<Ipv4Address>::iterator i = std::remove(m_precursorList.begin(), m_precursorList.end(), id);
+ if(i == m_precursorList.end())
return false;
else
- rt_pclist.erase (i, rt_pclist.end());
+ m_precursorList.erase (i, m_precursorList.end());
return true;
}
void
-aodv_rt_entry::pc_delete()
+RoutingTableEntry::DeleteAllPrecursors()
{
- rt_pclist.clear();
+ m_precursorList.clear();
}
bool
-aodv_rt_entry::pc_empty() const
+RoutingTableEntry::IsPrecursorListEmpty() const
{
- return rt_pclist.empty();
+ return m_precursorList.empty();
}
void
-aodv_rt_entry::Down ()
+RoutingTableEntry::Down ()
{
- if(rt_flags == RTF_DOWN) return;
+ if(m_flag == RTF_DOWN) return;
- rt_last_hop_count = rt_hops;
- rt_hops = INFINITY2;
- rt_flags = RTF_DOWN;
- rt_lifetime = Seconds (DELETE_PERIOD);
+ m_lastHopCount = m_hops;
+ m_hops = INFINITY2;
+ m_flag = RTF_DOWN;
+ m_lifeTime = Seconds (DELETE_PERIOD);
}
void
-aodv_rt_entry::Print(std::ostream & os) const
+RoutingTableEntry::Print(std::ostream & os) const
{
os << m_ipv4Route->GetDestination() << "\t" << m_ipv4Route->GetGateway() << "\t"
- << m_ipv4Route->GetSource() << "\t" << rt_lifetime << "\n";
+ << m_ipv4Route->GetSource() << "\t" << m_lifeTime << "\n";
}
/*
@@ -123,54 +123,54 @@
*/
bool
-aodv_rtable::rt_lookup(Ipv4Address id, aodv_rt_entry & rt) const
+RoutingTable::LookupRoute(Ipv4Address id, RoutingTableEntry & rt) const
{
- std::map<Ipv4Address, aodv_rt_entry>::const_iterator i = rthead.find(id);
- if (i == rthead.end()) return false;
+ std::map<Ipv4Address, RoutingTableEntry>::const_iterator i = m_ipv4AddressEntry.find(id);
+ if (i == m_ipv4AddressEntry.end()) return false;
rt = (*i).second;
return true;
}
bool
-aodv_rtable::rt_delete(Ipv4Address dst)
+RoutingTable::DeleteRoute(Ipv4Address dst)
{
- if(rthead.erase (dst) != 0) return true;
+ if(m_ipv4AddressEntry.erase (dst) != 0) return true;
return false;
}
bool
-aodv_rtable::rt_add(aodv_rt_entry const & rt)
+RoutingTable::AddRoute(RoutingTableEntry const & rt)
{
Ptr<NetDevice> dev;
- aodv_rt_entry dummy(dev);
- if(rt_lookup(rt.GetDestination(), dummy))
+ RoutingTableEntry dummy(dev);
+ if(LookupRoute(rt.GetDestination(), dummy))
return false;
- rthead.insert(std::make_pair(rt.GetDestination(), rt));
+ m_ipv4AddressEntry.insert(std::make_pair(rt.GetDestination(), rt));
return true;
}
bool
-aodv_rtable::Update(Ipv4Address dst, aodv_rt_entry & rt)
+RoutingTable::Update(Ipv4Address dst, RoutingTableEntry & rt)
{
- std::map<Ipv4Address, aodv_rt_entry>::iterator i = rthead.find(dst);
- if (i == rthead.end()) return false;
+ std::map<Ipv4Address, RoutingTableEntry>::iterator i = m_ipv4AddressEntry.find(dst);
+ if (i == m_ipv4AddressEntry.end()) return false;
i->second = rt;
return true;
}
void
-aodv_rtable::SetEntryState (Ipv4Address id, uint8_t state)
+RoutingTable::SetEntryState (Ipv4Address id, uint8_t state)
{
- std::map<Ipv4Address, aodv_rt_entry>::iterator i = rthead.find(id);
- if (i != rthead.end()) (*i).second.rt_flags = state;
+ std::map<Ipv4Address, RoutingTableEntry>::iterator i = m_ipv4AddressEntry.find(id);
+ if (i != m_ipv4AddressEntry.end()) (*i).second.SetFlag(state);
}
void
-aodv_rtable::Print(std::ostream &os) const
+RoutingTable::Print(std::ostream &os) const
{
os << "\nAODV Routing table\n"
<< "Destination\tGateway\t\tInterface\tExpire\n";
- for (std::map<Ipv4Address, aodv_rt_entry>::const_iterator i = rthead.begin(); i != rthead.end(); ++i)
+ for (std::map<Ipv4Address, RoutingTableEntry>::const_iterator i = m_ipv4AddressEntry.begin(); i != m_ipv4AddressEntry.end(); ++i)
{
i->second.Print(os);
}
@@ -195,36 +195,36 @@
bool
AodvRtableTest::RunTests ()
{
- aodv_rt_entry entry1;
+ RoutingTableEntry entry1;
Ipv4Address dst1("3.3.3.3");
Ipv4Address dst2("1.2.3.4");
- aodv_rt_entry entry2 = aodv_rt_entry(dst2, true, 34, Ipv4Address("2.3.4.5"), 1, Ipv4Address("5.5.5.5"), Seconds(5));
+ RoutingTableEntry entry2 = RoutingTableEntry(dst2, true, 34, Ipv4Address("2.3.4.5"), 1, Ipv4Address("5.5.5.5"), Seconds(5));
NS_TEST_ASSERT( !(entry1 == dst1) );
NS_TEST_ASSERT(entry2 == dst2);
- entry2.pc_insert(dst1);
- NS_TEST_ASSERT(entry2.pc_lookup(dst1));
- NS_TEST_ASSERT(!entry2.pc_delete(dst2));
- NS_TEST_ASSERT(entry2.pc_delete(dst1));
+ entry2.InsertPrecursor(dst1);
+ NS_TEST_ASSERT(entry2.LookupPrecursor(dst1));
+ NS_TEST_ASSERT(!entry2.DeletePrecursor(dst2));
+ NS_TEST_ASSERT(entry2.DeletePrecursor(dst1));
NS_TEST_ASSERT(entry2.pc_empty());
- entry2.pc_insert(dst2);
- NS_TEST_ASSERT(entry2.pc_insert(dst1));
- NS_TEST_ASSERT(!entry2.pc_insert(dst2));
- entry2.pc_delete();
+ entry2.InsertPrecursor(dst2);
+ NS_TEST_ASSERT(entry2.InsertPrecursor(dst1));
+ NS_TEST_ASSERT(!entry2.InsertPrecursor(dst2));
+ entry2.DeleteAllPrecursors();
NS_TEST_ASSERT(entry2.pc_empty());
- aodv_rtable rtable;
- rtable.rt_add(entry2);
+ RoutingTable rtable;
+ rtable.AddRoute(entry2);
rtable.Print(std::cout);
entry2.SetLifeTime(Seconds(10));
NS_TEST_ASSERT(rtable.Update(entry2.GetDst(), entry2));
- NS_TEST_ASSERT(rtable.rt_lookup(dst2, entry1));
+ NS_TEST_ASSERT(rtable.LookupRoute(dst2, entry1));
NS_TEST_ASSERT(entry1.GetLifeTime() == entry2.GetLifeTime());
NS_TEST_ASSERT(entry1 == dst2);
- NS_TEST_ASSERT(!rtable.rt_lookup(dst1, entry1));
- NS_TEST_ASSERT(rtable.rt_delete(dst2));
- NS_TEST_ASSERT(!rtable.rt_delete(dst2));
- NS_TEST_ASSERT(!rtable.rt_lookup(dst2, entry1));
+ NS_TEST_ASSERT(!rtable.LookupRoute(dst1, entry1));
+ NS_TEST_ASSERT(rtable.DeleteRoute(dst2));
+ NS_TEST_ASSERT(!rtable.DeleteRoute(dst2));
+ NS_TEST_ASSERT(!rtable.LookupRoute(dst2, entry1));
return result;
}
--- a/src/routing/aodv/aodv-rtable.h Thu Jul 16 14:58:10 2009 +0400
+++ b/src/routing/aodv/aodv-rtable.h Thu Jul 16 18:25:49 2009 +0400
@@ -55,13 +55,13 @@
* \ingroup aodv
* \brief Route Table Entry
*/
-class aodv_rt_entry
+class RoutingTableEntry
{
public:
- aodv_rt_entry(Ptr<NetDevice> dev,Ipv4Address dst = Ipv4Address(), bool vSeqNo = false, u_int32_t seqNo = 0, Ipv4Address iface = Ipv4Address(), u_int16_t hops = 0,
+ RoutingTableEntry(Ptr<NetDevice> dev,Ipv4Address dst = Ipv4Address(), bool vSeqNo = false, u_int32_t m_seqNo = 0, Ipv4Address iface = Ipv4Address(), u_int16_t hops = 0,
Ipv4Address nextHop = Ipv4Address(), Time lifetime = Seconds(0));
- ~aodv_rt_entry();
+ ~RoutingTableEntry();
///\name Precursors management
//\{
@@ -70,28 +70,28 @@
* \param id precursor address
* \return true on success
*/
- bool pc_insert(Ipv4Address id);
+ bool InsertPrecursor(Ipv4Address id);
/**
* Lookup precursor by address
* \param id precursor address
* \return true on success
*/
- bool pc_lookup(Ipv4Address id);
+ bool LookupPrecursor(Ipv4Address id);
/**
* \brief Delete precursor
* \param id precursor address
* \return true on success
*/
- bool pc_delete(Ipv4Address id);
+ bool DeletePrecursor(Ipv4Address id);
/// Delete all precursors
- void pc_delete();
+ void DeleteAllPrecursors();
/**
* \return true if precursor list empty
*/
- bool pc_empty() const;
+ bool IsPrecursorListEmpty() const;
//\}
/// Return last valid hop count
- uint16_t GetLastValidHopCount() { return rt_last_hop_count; }
+ uint16_t GetLastValidHopCount() { return m_lastHopCount; }
/// Mark entry as "down" (i.e. disable it)
void Down ();
///\name Fields
@@ -103,20 +103,20 @@
Ipv4Address GetNextHop () const { return m_ipv4Route->GetGateway(); }
void SetOutputDevice(Ptr<NetDevice> dev) { m_ipv4Route->SetOutputDevice(dev); }
Ptr<NetDevice> GetOutputDevice() const { return m_ipv4Route->GetOutputDevice(); }
- void SetValidSeqNo(bool s) { validSeqNo = s; }
- bool GetValidSeqNo() const { return validSeqNo; }
- void SetSeqNo(uint32_t sn) { rt_seqno = sn; }
- uint32_t GetSeqNo() const { return rt_seqno; }
- void SetHop(uint16_t hop) { rt_hops = hop; }
- uint16_t GetHop() const {return rt_hops; }
- void SetLifeTime(Time lt) { rt_lifetime = lt; }
- Time GetLifeTime() const { return rt_lifetime; }
- void SetFlag(uint8_t flag) { rt_flags = flag; }
- uint8_t GetFlag() const { return rt_flags; }
- void SetRreqCnt(uint8_t n) { rt_req_cnt = n; }
- uint8_t GetRreqCnt() const { return rt_req_cnt; }
- void SetRreqTimeout(Time t) {rt_req_timeout = t; }
- Time GetRreqTimeout() const { return rt_req_timeout; }
+ 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; }
+ Time GetLifeTime() const { return m_lifeTime; }
+ void SetFlag(uint8_t flag) { m_flag = flag; }
+ uint8_t GetFlag() const { return m_flag; }
+ void SetRreqCnt(uint8_t n) { m_reqCount = n; }
+ uint8_t GetRreqCnt() const { return m_reqCount; }
+ void SetRreqTimeout(Time t) {m_reqTimeout = t; }
+ Time GetRreqTimeout() const { return m_reqTimeout; }
//\}
/**
@@ -129,24 +129,21 @@
}
void Print(std::ostream & os) const;
private:
- friend class aodv_rtable;
/// Valid Destination Sequence Number flag
- bool validSeqNo;
- /// Destination Sequence Number, if validSeqNo = true
- uint32_t rt_seqno;
+ bool m_validSeqNo;
+ /// Destination Sequence Number, if m_validSeqNo = true
+ uint32_t m_seqNo;
/// Hop Count (number of hops needed to reach destination)
- uint16_t rt_hops;
+ uint16_t m_hops;
/// Last valid hop count
- uint16_t rt_last_hop_count;
-
+ uint16_t m_lastHopCount;
/**
* \brief Expiration or deletion time of the route
* 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.
*/
- Time rt_lifetime;
-
+ Time m_lifeTime;
/** Ip route, include
* - destination address
* - source address
@@ -154,20 +151,18 @@
* - output device
*/
Ptr<Ipv4Route> m_ipv4Route;
-
/// Routing flags: down, up or in repair
- uint8_t rt_flags; /*TODO use enum*/
-
-#define MAX_HISTORY 3
+ uint8_t m_flag;
/// List of precursors
- std::vector<Ipv4Address> rt_pclist;
+ std::vector<Ipv4Address> m_precursorList;
/// When I can send another request
- Time rt_req_timeout;
+ Time m_reqTimeout;
/// Number of route requests
- uint8_t rt_req_cnt;
+ uint8_t m_reqCount;
// TODO review and delete
+#define MAX_HISTORY 3
double rt_disc_latency[MAX_HISTORY];
char hist_indx;
};
@@ -176,40 +171,39 @@
* \ingroup aodv
* The Routing Table
*/
-class aodv_rtable
+class RoutingTable
{
public:
- aodv_rtable() {}
+ RoutingTable() {}
- // aodv_rt_entry * head() {TODO}
/**
* Add routing table entry if it doesn't yet exist in routing table
* \param r routing table entry
* \return true in success
*/
- bool rt_add(aodv_rt_entry const & r);
+ bool AddRoute(RoutingTableEntry const & r);
/**
* Delete routing table entry
* \param dst destination address
* \return true on success
*/
- bool rt_delete(Ipv4Address dst);
+ bool DeleteRoute(Ipv4Address dst);
/**
* Lookup routing table entry
* \param dst destination address
* \param rt entry with destination address dst, if exists
* \return true on success
*/
- bool rt_lookup(Ipv4Address dst, aodv_rt_entry & rt) const;
+ bool LookupRoute(Ipv4Address dst, RoutingTableEntry & rt) const;
/// Update routing table
- bool Update(Ipv4Address dst, aodv_rt_entry & rt);
+ bool Update(Ipv4Address dst, RoutingTableEntry & rt);
/// Set routing table entry flags
void SetEntryState (Ipv4Address dst, uint8_t state /*TODO use enum*/);
/// Print routing table
void Print(std::ostream &os) const;
private:
- std::map<Ipv4Address, aodv_rt_entry> rthead;
+ std::map<Ipv4Address, RoutingTableEntry> m_ipv4AddressEntry;
};
}}