OLSR: code cleanup, more extensive logging, many bug fixes. Should also handle multiple interfaces better, now.

This commit is contained in:
Gustavo J. A. M. Carneiro
2008-02-13 17:44:05 +00:00
parent 96451fdb37
commit c6f3793178
6 changed files with 662 additions and 307 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -77,8 +77,6 @@ private:
Time m_midInterval;
/// Willingness for forwarding packets on behalf of other nodes.
uint8_t m_willingness;
/// Determines if layer 2 notifications are enabled or not.
bool m_useL2Notifications;
/// Routing table.
Ptr<RoutingTable> m_routingTable;
@@ -124,6 +122,8 @@ protected:
void TopologyTupleTimerExpire (TopologyTuple tuple);
void IfaceAssocTupleTimerExpire (IfaceAssocTuple tuple);
void IncrementAnsn ();
/// A list of pending messages which are buffered awaiting for being sent.
olsr::MessageList m_queuedMessages;
Timer m_queuedMessagesTimer; // timer for throttling outgoing messages
@@ -141,7 +141,7 @@ protected:
void NeighborLoss (const LinkTuple &tuple);
void AddDuplicateTuple (const DuplicateTuple &tuple);
void RemoveDuplicateTuple (const DuplicateTuple &tuple);
LinkTuple & AddLinkTuple (const LinkTuple &tuple, uint8_t willingness);
void LinkTupleAdded (const LinkTuple &tuple, uint8_t willingness);
void RemoveLinkTuple (const LinkTuple &tuple);
void LinkTupleUpdated (const LinkTuple &tuple);
void AddNeighborTuple (const NeighborTuple &tuple);
@@ -177,8 +177,11 @@ protected:
int Degree (NeighborTuple const &tuple);
Ipv4Address m_mainAddress;
Ptr<Socket> m_receiveSocket; // UDP socket for receving OSLR packets
Ptr<Socket> m_sendSocket; // UDP socket for sending OSLR packets
// One socket per interface, each bound to that interface's address
// (reason: for OLSR Link Sensing we need to know on which interface
// HELLO messages arrive)
std::map< Ptr<Socket>, Ipv4Address > m_socketAddresses;
CallbackTraceSource <const PacketHeader &,
const MessageList &> m_rxPacketTrace;

View File

@@ -149,6 +149,16 @@ OlsrState::EraseNeighborTuple (const Ipv4Address &mainAddr)
void
OlsrState::InsertNeighborTuple (NeighborTuple const &tuple)
{
for (NeighborSet::iterator it = m_neighborSet.begin ();
it != m_neighborSet.end (); it++)
{
if (it->neighborMainAddr == tuple.neighborMainAddr)
{
// Update it
*it = tuple;
return;
}
}
m_neighborSet.push_back (tuple);
}

View File

@@ -63,6 +63,10 @@ public:
{
return m_neighborSet;
}
NeighborSet & GetNeighbors ()
{
return m_neighborSet;
}
NeighborTuple* FindNeighborTuple (const Ipv4Address &mainAddr);
const NeighborTuple* FindSymNeighborTuple (const Ipv4Address &mainAddr) const;
NeighborTuple* FindNeighborTuple (const Ipv4Address &mainAddr,
@@ -76,6 +80,10 @@ public:
{
return m_twoHopNeighborSet;
}
TwoHopNeighborSet & GetTwoHopNeighbors ()
{
return m_twoHopNeighborSet;
}
TwoHopNeighborTuple* FindTwoHopNeighborTuple (const Ipv4Address &neighbor,
const Ipv4Address &twoHopNeighbor);
void EraseTwoHopNeighborTuple (const TwoHopNeighborTuple &tuple);

View File

@@ -56,6 +56,15 @@ operator == (const IfaceAssocTuple &a, const IfaceAssocTuple &b)
&& a.mainAddr == b.mainAddr);
}
static inline std::ostream&
operator << (std::ostream &os, const IfaceAssocTuple &tuple)
{
os << "IfaceAssocTuple(ifaceAddr=" << tuple.ifaceAddr
<< ", mainAddr=" << tuple.mainAddr
<< ", time=" << tuple.time << ")";
return os;
}
/// A Link Tuple.
struct LinkTuple
{
@@ -67,8 +76,6 @@ struct LinkTuple
Time symTime;
/// The link is considered unidirectional until this time.
Time asymTime;
/// The link is considered lost until this time (used for link layer notification).
Time lostTime;
/// Time at which this tuple expires and must be removed.
Time time;
};
@@ -80,6 +87,17 @@ operator == (const LinkTuple &a, const LinkTuple &b)
&& a.neighborIfaceAddr == b.neighborIfaceAddr);
}
static inline std::ostream&
operator << (std::ostream &os, const LinkTuple &tuple)
{
os << "LinkTuple(localIfaceAddr=" << tuple.localIfaceAddr
<< ", neighborIfaceAddr=" << tuple.neighborIfaceAddr
<< ", symTime=" << tuple.symTime
<< ", asymTime=" << tuple.asymTime
<< ", expTime=" << tuple.time;
return os;
}
/// A Neighbor Tuple.
struct NeighborTuple
{
@@ -102,6 +120,15 @@ operator == (const NeighborTuple &a, const NeighborTuple &b)
&& a.willingness == b.willingness);
}
static inline std::ostream&
operator << (std::ostream &os, const NeighborTuple &tuple)
{
os << "NeighborTuple(neighborMainAddr=" << tuple.neighborMainAddr
<< ", status=" << (tuple.status == NeighborTuple::STATUS_SYM? "SYM" : "NOT_SYM")
<< ", willingness=" << (int) tuple.willingness << ")";
return os;
}
/// A 2-hop Tuple.
struct TwoHopNeighborTuple
{
@@ -113,6 +140,16 @@ struct TwoHopNeighborTuple
Time expirationTime; // previously called 'time_'
};
static inline std::ostream&
operator << (std::ostream &os, const TwoHopNeighborTuple &tuple)
{
os << "TwoHopNeighborTuple(neighborMainAddr=" << tuple.neighborMainAddr
<< ", twoHopNeighborAddr=" << tuple.twoHopNeighborAddr
<< ", expirationTime=" << tuple.expirationTime
<< ")";
return os;
}
static inline bool
operator == (const TwoHopNeighborTuple &a, const TwoHopNeighborTuple &b)
{
@@ -182,6 +219,17 @@ operator == (const TopologyTuple &a, const TopologyTuple &b)
&& a.sequenceNumber == b.sequenceNumber);
}
static inline std::ostream&
operator << (std::ostream &os, const TopologyTuple &tuple)
{
os << "TopologyTuple(destAddr=" << tuple.destAddr
<< ", lastAddr=" << tuple.lastAddr
<< ", sequenceNumber=" << (int) tuple.sequenceNumber
<< ", expirationTime=" << tuple.expirationTime
<< ")";
return os;
}
typedef std::set<Ipv4Address> MprSet; ///< MPR Set type.
typedef std::vector<MprSelectorTuple> MprSelectorSet; ///< MPR Selector Set type.

View File

@@ -122,7 +122,7 @@ RoutingTable::RequestRoute (uint32_t ifIndex,
NS_LOG_DEBUG ("Olsr node " << m_mainAddress
<< ": RouteRequest for dest=" << ipHeader.GetDestination ()
<< " --> destHop=" << entry2.nextAddr
<< " --> nestHop=" << entry2.nextAddr
<< " interface=" << entry2.interface);
routeReply (true, route, packet, ipHeader);
@@ -130,10 +130,10 @@ RoutingTable::RequestRoute (uint32_t ifIndex,
}
else
{
#ifdef NS3_LOG_ENABLE
NS_LOG_DEBUG ("Olsr node " << m_mainAddress
<< ": RouteRequest for dest=" << ipHeader.GetDestination ()
<< " --> NOT FOUND; ** Dumping routing table...");
#if 0
for (std::map<Ipv4Address, RoutingTableEntry>::const_iterator iter = m_table.begin ();
iter != m_table.end (); iter++)
{
@@ -191,6 +191,9 @@ RoutingTable::AddEntry (Ipv4Address const &dest,
NS_LOG_PARAM (distance);
NS_LOG_PARAM (m_mainAddress);
NS_LOG_PARAMS_END ();
NS_ASSERT (distance > 0);
// Creates a new rt entry with specified values
RoutingTableEntry &entry = m_table[dest];
@@ -214,8 +217,11 @@ RoutingTable::AddEntry (Ipv4Address const &dest,
NS_LOG_PARAM (distance);
NS_LOG_PARAM (m_mainAddress);
NS_LOG_PARAMS_END ();
RoutingTableEntry entry;
NS_ASSERT (distance > 0);
NS_ASSERT (m_ipv4);
RoutingTableEntry entry;
for (uint32_t i = 0; i < m_ipv4->GetNInterfaces (); i++)
{
if (m_ipv4->GetAddress (i) == interfaceAddress)