Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1309)

Unified Diff: src/dsdv/model/dsdv-routing-protocol.cc

Issue 7304093: SMECN protocol and RNS algorithm
Patch Set: Created 11 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/dsdv/model/dsdv-routing-protocol.h ('k') | src/dsdv/wscript » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/dsdv/model/dsdv-routing-protocol.cc
===================================================================
--- a/src/dsdv/model/dsdv-routing-protocol.cc
+++ b/src/dsdv/model/dsdv-routing-protocol.cc
@@ -152,7 +152,11 @@
.AddAttribute ("RouteAggregationTime","Time to aggregate updates before sending them out (in seconds)",
TimeValue (Seconds (1)),
MakeTimeAccessor (&RoutingProtocol::m_routeAggregationTime),
- MakeTimeChecker ());
+ MakeTimeChecker ())
+ .AddAttribute ("EnableRns","Enables the Redundant Node Selection (RNS) module usage.",
+ BooleanValue (false),
+ MakeBooleanAccessor (&RoutingProtocol::EnableRns),
+ MakeBooleanChecker());
return tid;
}
@@ -240,6 +244,17 @@
m_ecb = MakeCallback (&RoutingProtocol::Drop,this);
m_periodicUpdateTimer.SetFunction (&RoutingProtocol::SendPeriodicUpdate,this);
m_periodicUpdateTimer.Schedule (MicroSeconds (m_uniformRandomVariable->GetInteger (0,1000)));
+
+ //Check if Rns is usable and configure it.
+ if (EnableRns)
+ {
+ Ptr<rns::Rns<Ipv4Address> > AggregatedRnsModule =
+ this->GetObject<rns::Rns<Ipv4Address> >();
+ NS_ASSERT(AggregatedRnsModule != NULL);
+ SetRns(AggregatedRnsModule);
+ AggregatedRnsModule->SetProtocolUpdateCallback(
+ MakeCallback(&RoutingProtocol::UpdateFromRns, this));
+ }
}
Ptr<Ipv4Route>
@@ -591,6 +606,10 @@
true);
newEntry.SetFlag (VALID);
m_routingTable.AddRoute (newEntry);
+ if (EnableRns)
+ {
+ UpdateRns(newEntry);
+ }
NS_LOG_DEBUG ("New Route added to both tables");
m_advRoutingTable.AddRoute (newEntry);
}
@@ -645,6 +664,8 @@
// if received changed metric, use it but adv it only after wst
m_routingTable.Update (advTableEntry);
m_advRoutingTable.Update (advTableEntry);
+ if (EnableRns)
+ UpdateRns(advTableEntry);
}
else
{
@@ -684,6 +705,8 @@
NS_LOG_DEBUG ("EventCreated EventUID: " << event.GetUid ());
// if received changed metric, use it but adv it only after wst
m_routingTable.Update (advTableEntry);
+ if (EnableRns)
+ UpdateRns(advTableEntry);
m_advRoutingTable.Update (advTableEntry);
}
else
@@ -700,6 +723,8 @@
{
advTableEntry.SetLifeTime (Simulator::Now ());
m_routingTable.Update (advTableEntry);
+ if (EnableRns)
+ UpdateRns(advTableEntry);
}
m_advRoutingTable.DeleteRoute (
dsdvHeader.GetDst ());
@@ -770,6 +795,10 @@
void
RoutingProtocol::SendTriggeredUpdate ()
{
+ if (EnableRns && m_rns->IsRedundant())
+ {
+ return;
+ }
NS_LOG_FUNCTION (m_mainAddress << " is sending a triggered update");
std::map<Ipv4Address, RoutingTableEntry> allRoutes;
m_advRoutingTable.GetListOfAllRoutes (allRoutes);
@@ -848,7 +877,7 @@
m_routingTable.Purge (removedAddresses);
MergeTriggerPeriodicUpdates ();
m_routingTable.GetListOfAllRoutes (allRoutes);
- if (allRoutes.empty ())
+ if (allRoutes.empty () || (EnableRns && m_rns->IsRedundant()))
{
return;
}
@@ -1207,5 +1236,26 @@
}
}
}
+
+void
+RoutingProtocol::UpdateRns (RoutingTableEntry rte)
+{
+ rns::Neighbor<Ipv4Address> n;
+ n.SetId(rte.GetDestination());
+ m_rns->UpdateNeighbor(n,false);
}
+
+void RoutingProtocol::UpdateFromRns(rns::Neighbor<Ipv4Address> n)
+{
+ if (m_ipv4->GetAddress(1, 0).GetLocal() == n.GetId())
+ {
+ // My redundancy status has changed.
+ }
+ else
+ {
+ // One of my neighbors became redundant.
+ }
}
+
+}
+}
« no previous file with comments | « src/dsdv/model/dsdv-routing-protocol.h ('k') | src/dsdv/wscript » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b