OLSR optimization: avoid doing routing table computation if no local DB changed after receiving a OLSR packet.
This commit is contained in:
@@ -350,6 +350,8 @@ AgentImpl::RecvOlsr (Ptr<Socket> socket,
|
||||
|
||||
m_rxPacketTrace (olsrPacketHeader, messages);
|
||||
|
||||
m_state.SetModified (false);
|
||||
|
||||
for (MessageList::const_iterator messageIter = messages.begin ();
|
||||
messageIter != messages.end (); messageIter++)
|
||||
{
|
||||
@@ -446,7 +448,11 @@ AgentImpl::RecvOlsr (Ptr<Socket> socket,
|
||||
}
|
||||
|
||||
// After processing all OLSR messages, we must recompute the routing table
|
||||
RoutingTableComputation ();
|
||||
if (m_state.GetModified ())
|
||||
{
|
||||
RoutingTableComputation ();
|
||||
m_state.SetModified (false);
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
|
||||
@@ -127,6 +127,7 @@ OlsrState::EraseNeighborTuple (const NeighborTuple &tuple)
|
||||
if (*it == tuple)
|
||||
{
|
||||
m_neighborSet.erase (it);
|
||||
m_modified = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -141,6 +142,7 @@ OlsrState::EraseNeighborTuple (const Ipv4Address &mainAddr)
|
||||
if (it->neighborMainAddr == mainAddr)
|
||||
{
|
||||
it = m_neighborSet.erase (it);
|
||||
m_modified = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -156,6 +158,7 @@ OlsrState::InsertNeighborTuple (NeighborTuple const &tuple)
|
||||
{
|
||||
// Update it
|
||||
*it = tuple;
|
||||
m_modified = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -189,6 +192,7 @@ OlsrState::EraseTwoHopNeighborTuple (const TwoHopNeighborTuple &tuple)
|
||||
if (*it == tuple)
|
||||
{
|
||||
m_twoHopNeighborSet.erase(it);
|
||||
m_modified = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -206,6 +210,7 @@ OlsrState::EraseTwoHopNeighborTuples (const Ipv4Address &neighborMainAddr,
|
||||
{
|
||||
it = m_twoHopNeighborSet.erase (it);
|
||||
it--; // FIXME: is this correct in the case 'it' pointed to the first element?
|
||||
m_modified = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -219,13 +224,16 @@ OlsrState::EraseTwoHopNeighborTuples (const Ipv4Address &neighborMainAddr)
|
||||
if (it->neighborMainAddr == neighborMainAddr) {
|
||||
it = m_twoHopNeighborSet.erase (it);
|
||||
it--;
|
||||
m_modified = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
OlsrState::InsertTwoHopNeighborTuple (TwoHopNeighborTuple const &tuple){
|
||||
OlsrState::InsertTwoHopNeighborTuple (TwoHopNeighborTuple const &tuple)
|
||||
{
|
||||
m_twoHopNeighborSet.push_back (tuple);
|
||||
m_modified = true;
|
||||
}
|
||||
|
||||
/********** MPR Set Manipulation **********/
|
||||
@@ -323,6 +331,7 @@ OlsrState::EraseLinkTuple (const LinkTuple &tuple)
|
||||
if (*it == tuple)
|
||||
{
|
||||
m_linkSet.erase (it);
|
||||
m_modified = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -332,6 +341,7 @@ LinkTuple&
|
||||
OlsrState::InsertLinkTuple (LinkTuple const &tuple)
|
||||
{
|
||||
m_linkSet.push_back (tuple);
|
||||
m_modified = true;
|
||||
return m_linkSet.back ();
|
||||
}
|
||||
|
||||
@@ -371,6 +381,7 @@ OlsrState::EraseTopologyTuple(const TopologyTuple &tuple)
|
||||
if (*it == tuple)
|
||||
{
|
||||
m_topologySet.erase (it);
|
||||
m_modified = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -386,6 +397,7 @@ OlsrState::EraseOlderTopologyTuples (const Ipv4Address &lastAddr, uint16_t ansn)
|
||||
{
|
||||
it = m_topologySet.erase (it);
|
||||
it--;
|
||||
m_modified = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -394,6 +406,7 @@ void
|
||||
OlsrState::InsertTopologyTuple (TopologyTuple const &tuple)
|
||||
{
|
||||
m_topologySet.push_back (tuple);
|
||||
m_modified = true;
|
||||
}
|
||||
|
||||
/********** Interface Association Set Manipulation **********/
|
||||
@@ -431,6 +444,7 @@ OlsrState::EraseIfaceAssocTuple (const IfaceAssocTuple &tuple)
|
||||
if (*it == tuple)
|
||||
{
|
||||
m_ifaceAssocSet.erase (it);
|
||||
m_modified = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -440,6 +454,7 @@ void
|
||||
OlsrState::InsertIfaceAssocTuple (const IfaceAssocTuple &tuple)
|
||||
{
|
||||
m_ifaceAssocSet.push_back (tuple);
|
||||
m_modified = true;
|
||||
}
|
||||
|
||||
std::vector<Ipv4Address>
|
||||
|
||||
@@ -46,8 +46,29 @@ protected:
|
||||
DuplicateSet m_duplicateSet; ///< Duplicate Set (RFC 3626, section 3.4).
|
||||
IfaceAssocSet m_ifaceAssocSet; ///< Interface Association Set (RFC 3626, section 4.1).
|
||||
|
||||
// m_modified is set to true when any of the following databases is modified:
|
||||
// - the link set,
|
||||
// - the neighbor set,
|
||||
// - the 2-hop neighbor set,
|
||||
// - the topology set,
|
||||
// - the Multiple Interface Association Information Base,
|
||||
bool m_modified;
|
||||
|
||||
public:
|
||||
|
||||
OlsrState ()
|
||||
: m_modified (false)
|
||||
{}
|
||||
|
||||
bool GetModified () const
|
||||
{
|
||||
return m_modified;
|
||||
}
|
||||
void SetModified (bool modified)
|
||||
{
|
||||
m_modified = modified;
|
||||
}
|
||||
|
||||
// MPR selector
|
||||
const MprSelectorSet & GetMprSelectors () const
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user