Fixed broadcast propagation in FLAME
authorKirill Andreev <andreev@iitp.ru>
Wed, 12 Aug 2009 20:49:39 +0400
changeset 5151 56ac5af5f5c8
parent 5150 70e68391cf42
child 5152 f14eff131d13
Fixed broadcast propagation in FLAME
src/devices/mesh/dot11s/peer-management-protocol.cc
src/devices/mesh/flame/flame-protocol.cc
--- a/src/devices/mesh/dot11s/peer-management-protocol.cc	Thu Aug 06 13:11:15 2009 +0400
+++ b/src/devices/mesh/dot11s/peer-management-protocol.cc	Wed Aug 12 20:49:39 2009 +0400
@@ -136,7 +136,8 @@
   bool cleaned = false;
   while (!cleaned)
     {
-      for (BeaconsOnInterface::iterator j = i->second.begin (); j != i->second.end (); j++)
+      BeaconsOnInterface::iterator start = i->second.begin ();
+      for (BeaconsOnInterface::iterator j = start; j != i->second.end (); j++)
         {
           //check beacon loss and make a timing element
           //if last beacon was m_maxBeaconLostForBeaconTiming beacons ago - we do not put it to the
@@ -144,6 +145,7 @@
           if ((j->second.referenceTbtt + j->second.beaconInterval * Scalar (m_maxBeaconLostForBeaconTiming))
               < Simulator::Now ())
             {
+              start = j;
               i->second.erase (j);
               break;
             }
--- a/src/devices/mesh/flame/flame-protocol.cc	Thu Aug 06 13:11:15 2009 +0400
+++ b/src/devices/mesh/flame/flame-protocol.cc	Wed Aug 12 20:49:39 2009 +0400
@@ -126,7 +126,7 @@
 }
 FlameProtocol::FlameProtocol () :
   m_address (Mac48Address ()), m_broadcastInterval (Seconds (5)), m_lastBroadcast (Simulator::Now ()),
-      m_maxCost (32), m_myLastSeqno (0), m_rtable (CreateObject<FlameRtable> ())
+      m_maxCost (32), m_myLastSeqno (1), m_rtable (CreateObject<FlameRtable> ())
 {
 }
 FlameProtocol::~FlameProtocol ()
@@ -186,25 +186,11 @@
       FlameHeader flameHdr;
       packet->RemoveHeader (flameHdr);
       FlameTag tag;
-      
+
       if (!packet->RemovePacketTag (tag))
         {
           NS_FATAL_ERROR ("FLAME tag must exist here");
         }
-      if (HandleDataFrame (flameHdr.GetSeqno (), source, flameHdr, tag.transmitter, sourceIface))
-        {
-          return false;
-        }
-      if (source == GetAddress ())
-        {
-          if (tag.receiver != Mac48Address::GetBroadcast ())
-            {
-              NS_LOG_DEBUG ("received packet with SA = GetAddress (), RA = " << tag.receiver << ", TA = "
-                  << tag.transmitter << ", I am " << GetAddress ());
-            }
-          m_stats.totalDropped++;
-          return false;
-        }
       if (destination == Mac48Address::GetBroadcast ())
         {
           //Broadcast always is forwarded as broadcast!
@@ -220,7 +206,12 @@
         }
       else
         {
-          
+          // We check sequence only when forward unicast, because broadcast-checks were done
+          // inside remove routing stuff.
+          if (HandleDataFrame (flameHdr.GetSeqno (), source, flameHdr, tag.transmitter, sourceIface))
+            {
+              return false;
+            }
           FlameRtable::LookupResult result = m_rtable->Lookup (destination);
           if (tag.receiver != Mac48Address::GetBroadcast ())
             {
@@ -325,6 +316,7 @@
 {
   if (source == GetAddress ())
     {
+      m_stats.totalDropped++;
       return true;
     }
   FlameRtable::LookupResult result = m_rtable->Lookup (source);