Mesh: fixed FLAME PATH_UPDATE procedure, fixed mesh.cc, valgrind errors in
authorKirill Andreev <andreev@iitp.ru>
Tue Oct 27 18:43:45 2009 +0300 (3 months ago)
changeset 5510050630fcf15e
parent 5509 f2f95faff5bb
child 5511 917f7367691e
Mesh: fixed FLAME PATH_UPDATE procedure, fixed mesh.cc, valgrind errors in
FLAME
examples/mesh/mesh.cc
src/devices/mesh/flame/flame-protocol-mac.cc
src/devices/mesh/flame/flame-protocol.cc
     1.1 --- a/examples/mesh/mesh.cc	Tue Oct 27 13:56:38 2009 +0300
     1.2 +++ b/examples/mesh/mesh.cc	Tue Oct 27 18:43:45 2009 +0300
     1.3 @@ -158,7 +158,16 @@
     1.4     * mesh point device
     1.5     */
     1.6    mesh = MeshHelper::Default ();
     1.7 -  mesh.SetStackInstaller (m_stack, "Root", Mac48AddressValue (Mac48Address (m_root.c_str ())));
     1.8 +  if (!Mac48Address (m_root.c_str ()).IsBroadcast ())
     1.9 +    {
    1.10 +      mesh.SetStackInstaller (m_stack, "Root", Mac48AddressValue (Mac48Address (m_root.c_str ())));
    1.11 +    }
    1.12 +  else
    1.13 +    {
    1.14 +      //If root is not set, we do not use "Root" attribute, because it
    1.15 +      //is specified only for 11s
    1.16 +      mesh.SetStackInstaller (m_stack);
    1.17 +    }
    1.18    if (m_chan)
    1.19      {
    1.20        mesh.SetSpreadInterfaceChannels (MeshHelper::SPREAD_CHANNELS);
     2.1 --- a/src/devices/mesh/flame/flame-protocol-mac.cc	Tue Oct 27 13:56:38 2009 +0300
     2.2 +++ b/src/devices/mesh/flame/flame-protocol-mac.cc	Tue Oct 27 18:43:45 2009 +0300
     2.3 @@ -31,6 +31,8 @@
     2.4  }
     2.5  FlameProtocolMac::~FlameProtocolMac ()
     2.6  {
     2.7 +  m_protocol = 0;
     2.8 +  m_parent = 0;
     2.9  }
    2.10  void
    2.11  FlameProtocolMac::SetParent (Ptr<MeshWifiInterfaceMac> parent)
     3.1 --- a/src/devices/mesh/flame/flame-protocol.cc	Tue Oct 27 13:56:38 2009 +0300
     3.2 +++ b/src/devices/mesh/flame/flame-protocol.cc	Tue Oct 27 18:43:45 2009 +0300
     3.3 @@ -127,7 +127,7 @@
     3.4    return tid;
     3.5  }
     3.6  FlameProtocol::FlameProtocol () :
     3.7 -  m_address (Mac48Address ()), m_broadcastInterval (Seconds (5)), m_lastBroadcast (Simulator::Now ()),
     3.8 +  m_address (Mac48Address ()), m_broadcastInterval (Seconds (5)), m_lastBroadcast (Seconds (0)),
     3.9        m_maxCost (32), m_myLastSeqno (1), m_rtable (CreateObject<FlameRtable> ())
    3.10  {
    3.11  }
    3.12 @@ -137,6 +137,9 @@
    3.13  void
    3.14  FlameProtocol::DoDispose ()
    3.15  {
    3.16 +  m_interfaces.clear ();
    3.17 +  m_rtable = 0;
    3.18 +  m_mp = 0;
    3.19  }
    3.20  bool
    3.21  FlameProtocol::RequestRoute (uint32_t sourceIface, const Mac48Address source, const Mac48Address destination,
    3.22 @@ -224,8 +227,12 @@
    3.23                    m_stats.totalDropped++;
    3.24                    return false;
    3.25                  }
    3.26 +              tag.receiver = result.retransmitter;
    3.27              }
    3.28 -          tag.receiver = result.retransmitter;
    3.29 +          else
    3.30 +            {
    3.31 +              tag.receiver = Mac48Address::GetBroadcast ();
    3.32 +            }
    3.33            if (result.retransmitter == Mac48Address::GetBroadcast ())
    3.34              {
    3.35                m_stats.txBroadcast++;
    3.36 @@ -262,19 +269,21 @@
    3.37      }
    3.38    FlameHeader flameHdr;
    3.39    packet->RemoveHeader (flameHdr);
    3.40 -  if ((destination == GetAddress ()) && (m_lastBroadcast + m_broadcastInterval < Simulator::Now ()))
    3.41 -      {
    3.42 -        Ptr<Packet> packet = Create<Packet> ();
    3.43 -        m_mp->Send(packet, Mac48Address::GetBroadcast (), 0);
    3.44 -        m_lastBroadcast = Simulator::Now ();
    3.45 -      }
    3.46 -  NS_ASSERT (protocolType == FLAME_PROTOCOL);
    3.47 -  protocolType = flameHdr.GetProtocol ();
    3.48 -  if ((HandleDataFrame (flameHdr.GetSeqno (), source, flameHdr, tag.transmitter, fromIface))
    3.49 -      || packet->GetSize () == 0)
    3.50 +  if (HandleDataFrame (flameHdr.GetSeqno (), source, flameHdr, tag.transmitter, fromIface))
    3.51      {
    3.52        return false;
    3.53      }
    3.54 +  // Start PATH_UPDATE procedure if destination is our own address and last broadcast was sent more
    3.55 +  // than broadcast interval ago or was not sent at all
    3.56 +  if ((destination == GetAddress ()) && ((m_lastBroadcast + m_broadcastInterval < Simulator::Now ())
    3.57 +      || (m_lastBroadcast == Seconds (0))))
    3.58 +    {
    3.59 +      Ptr<Packet> packet = Create<Packet> ();
    3.60 +      m_mp->Send (packet, Mac48Address::GetBroadcast (), 0);
    3.61 +      m_lastBroadcast = Simulator::Now ();
    3.62 +    }
    3.63 +  NS_ASSERT (protocolType == FLAME_PROTOCOL);
    3.64 +  protocolType = flameHdr.GetProtocol ();
    3.65    return true;
    3.66  }
    3.67  bool