Preq queue bugfix. deleted m_myPreq
This commit is contained in:
@@ -35,10 +35,9 @@ namespace dot11s {
|
||||
|
||||
NS_LOG_COMPONENT_DEFINE ("HwmpMacPlugin");
|
||||
HwmpMacPlugin::HwmpMacPlugin (uint32_t ifIndex, Ptr<HwmpProtocol> protocol):
|
||||
m_myPreq (m_preqQueue.end())
|
||||
m_ifIndex (ifIndex),
|
||||
m_protocol (protocol)
|
||||
{
|
||||
m_ifIndex = ifIndex;
|
||||
m_protocol = protocol;
|
||||
}
|
||||
HwmpMacPlugin::~HwmpMacPlugin ()
|
||||
{
|
||||
@@ -154,39 +153,30 @@ HwmpMacPlugin::UpdateOutcomingFrame (Ptr<Packet> packet, WifiMacHeader & header,
|
||||
void
|
||||
HwmpMacPlugin::SendPreq(IePreq preq)
|
||||
{
|
||||
if(m_myPreq == m_preqQueue.end ())
|
||||
{
|
||||
m_preqQueue.push_back (preq);
|
||||
m_myPreq = m_preqQueue.end ();
|
||||
}
|
||||
else
|
||||
m_preqQueue.push_back (preq);
|
||||
SendOnePreq ();
|
||||
}
|
||||
void
|
||||
HwmpMacPlugin::RequestDestination (Mac48Address dst, uint32_t originator_seqno, uint32_t dst_seqno)
|
||||
{
|
||||
if (m_preqQueue.end () == m_myPreq)
|
||||
{
|
||||
IePreq preq;
|
||||
//fill PREQ:
|
||||
preq.SetHopcount (0);
|
||||
preq.SetTTL (m_protocol->GetMaxTtl ());
|
||||
preq.SetPreqID (m_protocol->GetNextPreqId ());
|
||||
preq.SetOriginatorAddress (m_protocol->GetAddress ());
|
||||
preq.SetOriginatorSeqNumber (originator_seqno);
|
||||
preq.SetLifetime (m_protocol->GetActivePathLifetime ());
|
||||
preq.AddDestinationAddressElement (false, false, dst, dst_seqno);
|
||||
m_preqQueue.push_back (preq);
|
||||
//set iterator position to my preq:
|
||||
m_myPreq = m_preqQueue.end () - 1;
|
||||
SendOnePreq ();
|
||||
}
|
||||
else
|
||||
{
|
||||
NS_ASSERT (m_myPreq->GetOriginatorAddress() == m_protocol->GetAddress());
|
||||
m_myPreq->AddDestinationAddressElement (m_protocol->GetDoFlag(), m_protocol->GetRfFlag(), dst, dst_seqno);
|
||||
}
|
||||
for(std::vector<IePreq>::iterator i = m_preqQueue.begin (); i != m_preqQueue.end (); i ++)
|
||||
if(i->MayAddAddress(m_protocol->GetAddress ()))
|
||||
{
|
||||
i->AddDestinationAddressElement (m_protocol->GetDoFlag(), m_protocol->GetRfFlag(), dst, dst_seqno);
|
||||
return;
|
||||
}
|
||||
IePreq preq;
|
||||
//fill PREQ:
|
||||
preq.SetHopcount (0);
|
||||
preq.SetTTL (m_protocol->GetMaxTtl ());
|
||||
preq.SetPreqID (m_protocol->GetNextPreqId ());
|
||||
preq.SetOriginatorAddress (m_protocol->GetAddress ());
|
||||
preq.SetOriginatorSeqNumber (originator_seqno);
|
||||
preq.SetLifetime (m_protocol->GetActivePathLifetime ());
|
||||
preq.AddDestinationAddressElement (false, false, dst, dst_seqno);
|
||||
m_preqQueue.push_back (preq);
|
||||
//set iterator position to my preq:
|
||||
SendOnePreq ();
|
||||
}
|
||||
void
|
||||
HwmpMacPlugin::SendOnePreq ()
|
||||
@@ -195,8 +185,6 @@ HwmpMacPlugin::SendOnePreq ()
|
||||
return;
|
||||
if (m_preqQueue.size () == 0)
|
||||
return;
|
||||
if (m_myPreq == m_preqQueue.begin ())
|
||||
m_myPreq == m_preqQueue.end ();
|
||||
//reschedule sending PREQ
|
||||
NS_ASSERT (!m_preqTimer.IsRunning());
|
||||
m_preqTimer = Simulator::Schedule (m_protocol->GetPreqMinInterval (), &HwmpMacPlugin::SendOnePreq, this);
|
||||
@@ -232,8 +220,6 @@ HwmpMacPlugin::SendOnePreq ()
|
||||
}
|
||||
//erase queue
|
||||
m_preqQueue.erase (m_preqQueue.begin());
|
||||
if(m_preqQueue.size () == 0)
|
||||
m_myPreq = m_preqQueue.end ();
|
||||
}
|
||||
void
|
||||
HwmpMacPlugin::SendOnePerr()
|
||||
|
||||
@@ -88,7 +88,6 @@ private:
|
||||
//\{
|
||||
EventId m_preqTimer;
|
||||
std::vector<IePreq> m_preqQueue;
|
||||
std::vector<IePreq>::iterator m_myPreq;
|
||||
//\}
|
||||
///\name PERR timer and stored path error
|
||||
//{
|
||||
|
||||
@@ -174,24 +174,16 @@ IePreq::SetDestCount (uint8_t dest_count)
|
||||
{
|
||||
m_destCount = dest_count;
|
||||
}
|
||||
|
||||
//uint8_t
|
||||
//IePreq::GetFlags () const
|
||||
//{
|
||||
// return m_flags;
|
||||
//}
|
||||
bool
|
||||
IePreq::IsUnicastPreq () const
|
||||
{
|
||||
return (m_flags & (1<<1));
|
||||
}
|
||||
|
||||
bool
|
||||
IePreq::IsNeedNotPrep () const
|
||||
{
|
||||
return (m_flags & (1<<2));
|
||||
}
|
||||
|
||||
uint8_t
|
||||
IePreq::GetHopCount () const
|
||||
{
|
||||
@@ -233,20 +225,17 @@ IePreq::GetDestCount () const
|
||||
{
|
||||
return m_destCount;
|
||||
}
|
||||
|
||||
void
|
||||
IePreq::DecrementTtl ()
|
||||
{
|
||||
m_ttl --;
|
||||
m_hopCount ++;
|
||||
}
|
||||
|
||||
void
|
||||
IePreq::IncrementMetric (uint32_t metric)
|
||||
{
|
||||
m_metric +=metric;
|
||||
}
|
||||
|
||||
void
|
||||
IePreq::SerializeInformation (Buffer::Iterator i) const
|
||||
{
|
||||
@@ -277,7 +266,6 @@ IePreq::SerializeInformation (Buffer::Iterator i) const
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t
|
||||
IePreq::DeserializeInformation (Buffer::Iterator start, uint8_t length)
|
||||
{
|
||||
@@ -375,7 +363,6 @@ IePreq::AddDestinationAddressElement (
|
||||
m_destinations.push_back (new_element);
|
||||
m_destCount++;
|
||||
}
|
||||
|
||||
void
|
||||
IePreq::DelDestinationAddressElement (Mac48Address dest_address)
|
||||
{
|
||||
@@ -387,7 +374,6 @@ IePreq::DelDestinationAddressElement (Mac48Address dest_address)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
IePreq::ClearDestinationAddressElement ()
|
||||
{
|
||||
@@ -397,8 +383,7 @@ IePreq::ClearDestinationAddressElement ()
|
||||
for (i = 0; i < m_destCount; i ++)
|
||||
m_destinations.pop_back ();
|
||||
m_destinations.clear ();
|
||||
};
|
||||
|
||||
}
|
||||
bool operator== (const DestinationAddressUnit & a, const DestinationAddressUnit & b)
|
||||
{
|
||||
return (a.m_do == b.m_do
|
||||
@@ -408,7 +393,6 @@ bool operator== (const DestinationAddressUnit & a, const DestinationAddressUnit
|
||||
&& a.m_destSeqNumber == b.m_destSeqNumber
|
||||
);
|
||||
}
|
||||
|
||||
bool operator== (const IePreq & a, const IePreq & b)
|
||||
{
|
||||
bool ok = ( a.m_flags == b.m_flags
|
||||
@@ -437,7 +421,15 @@ bool operator== (const IePreq & a, const IePreq & b)
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
IePreq::MayAddAddress (Mac48Address originator)
|
||||
{
|
||||
if (m_originatorAddress != originator)
|
||||
return false;
|
||||
if(m_destinations[0]->GetDestinationAddress () == Mac48Address::GetBroadcast ())
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
#ifdef RUN_SELF_TESTS
|
||||
|
||||
/// Built-in self test for IePreq
|
||||
|
||||
@@ -46,7 +46,6 @@ public:
|
||||
bool IsUsn ();
|
||||
Mac48Address GetDestinationAddress () const;
|
||||
uint32_t GetDestSeqNumber () const;
|
||||
|
||||
private:
|
||||
bool m_do;
|
||||
bool m_rf;
|
||||
@@ -102,6 +101,12 @@ public:
|
||||
uint8_t GetDestCount () const;
|
||||
void DecrementTtl ();
|
||||
void IncrementMetric (uint32_t metric);
|
||||
/*
|
||||
* \brief Checks that preq's originator address equals to originator, and
|
||||
* this preq is not proactive
|
||||
*/
|
||||
bool MayAddAddress(Mac48Address originator);
|
||||
|
||||
private:
|
||||
WifiElementId ElementId () const{
|
||||
return IE11S_PREQ;
|
||||
|
||||
Reference in New Issue
Block a user