Added proper flags to HWMP PREQ, routing information is updated in accordance

with D3.0
This commit is contained in:
Kirill Andreev
2009-04-09 17:47:14 +04:00
parent 4cfcf907f1
commit bfb3f65003
5 changed files with 73 additions and 39 deletions

View File

@@ -155,7 +155,7 @@ HwmpMacPlugin::SendPreq(IePreq preq)
SendOnePreq ();
}
void
HwmpMacPlugin::RequestDestination (Mac48Address dst, uint32_t seqno)
HwmpMacPlugin::RequestDestination (Mac48Address dst, uint32_t originator_seqno, uint32_t dst_seqno)
{
if (m_preqQueue.end () == m_myPreq)
{
@@ -165,9 +165,9 @@ HwmpMacPlugin::RequestDestination (Mac48Address dst, uint32_t seqno)
preq.SetTTL (m_protocol->GetMaxTtl ());
preq.SetPreqID (m_protocol->GetNextPreqId ());
preq.SetOriginatorAddress (m_protocol->GetAddress ());
preq.SetOriginatorSeqNumber (seqno);
preq.SetOriginatorSeqNumber (originator_seqno);
preq.SetLifetime (m_protocol->GetActivePathLifetime ());
preq.AddDestinationAddressElement (false, false, dst, 0); //DO = 0, RF = 0
preq.AddDestinationAddressElement (false, false, dst, dst_seqno);
m_preqQueue.push_back (preq);
//set iterator position to my preq:
m_myPreq = m_preqQueue.end () - 1;
@@ -176,7 +176,7 @@ HwmpMacPlugin::RequestDestination (Mac48Address dst, uint32_t seqno)
else
{
NS_ASSERT (m_myPreq->GetOriginatorAddress() == m_protocol->GetAddress());
m_myPreq->AddDestinationAddressElement (m_protocol->GetDoFlag(), m_protocol->GetRfFlag(), dst, 0); //DO = 0, RF = 0
m_myPreq->AddDestinationAddressElement (m_protocol->GetDoFlag(), m_protocol->GetRfFlag(), dst, dst_seqno);
}
}
void

View File

@@ -63,7 +63,13 @@ private:
void SendPreq(IePreq preq);
void SendPrep(IePrep prep, Mac48Address receiver);
void SendPerr(IePerr perr, std::vector<Mac48Address> receivers);
void RequestDestination (Mac48Address dest, uint32_t seqno);
///\brief Request a destination. If can not send preq immediately -
//add a destination to exisying PREQ generated by me and stored in
//PREQ queue
///\param originator_seqno is a sequence number that shall be preq
//originator sequenece number
///\param dst_seqno is a sequence number taken from routing table
void RequestDestination (Mac48Address dest, uint32_t originator_seqno, uint32_t dst_seqno);
//\}
/// Sends one PREQ when PreqMinInterval after last PREQ expires (if any PREQ exists in rhe queue)

View File

@@ -276,11 +276,15 @@ HwmpProtocol::ForwardUnicast(uint32_t sourceIface, const Mac48Address source, c
return false;
}
//Request a destination:
result = m_rtable->LookupReactiveExpired (destination);
if(ShouldSendPreq(destination))
{
uint32_t seqno = GetNextHwmpSeqno ();
uint32_t originator_seqno = GetNextHwmpSeqno ();
uint32_t dst_seqno = 0;
if(result.retransmitter != Mac48Address::GetBroadcast ())
dst_seqno = result.seqnum;
for(HwmpPluginMap::const_iterator i = m_interfaces.begin (); i != m_interfaces.end (); i ++)
i->second->RequestDestination(destination, seqno);
i->second->RequestDestination(destination, originator_seqno, dst_seqno);
}
QueuedPacket pkt;
HwmpTag tag;
@@ -376,7 +380,7 @@ HwmpProtocol::ReceivePreq (IePreq preq, Mac48Address from, uint32_t interface, u
{
//have a valid information and acn answer
if ((*i)->IsRf ())
(*i)->SetFlags (true, false); //DO = 1, RF = 0 (as it was)
(*i)->SetFlags (true, false, (*i)->IsUsn ()); //DO = 1, RF = 0 (as it was)
else
{
//send a PREP and delete destination
@@ -432,21 +436,28 @@ HwmpProtocol::ReceivePrep (IePrep prep, Mac48Address from, uint32_t interface, u
NS_LOG_DEBUG("I am "<<m_address<<", received prep from "<<prep.GetOriginatorAddress ()<<", receiver was:"<<from);
//update routing info
//Now add a path to destination and add precursor to source
m_rtable->AddPrecursor (prep.GetDestinationAddress (), interface, from);
m_rtable->AddReactivePath (
prep.GetOriginatorAddress (),
from,
interface,
prep.GetMetric (),
MicroSeconds(prep.GetLifetime () * 1024),
prep.GetOriginatorSeqNumber ());
HwmpRtable::LookupResult result = m_rtable->LookupReactive(prep.GetDestinationAddress());
//Add a reactive path only if it is better than existing:
if (
(result.retransmitter == Mac48Address::GetBroadcast ()) ||
(result.retransmitter != Mac48Address::GetBroadcast ()) && (result.metric > prep.GetMetric ())
)
{
m_rtable->AddPrecursor (prep.GetDestinationAddress (), interface, from);
m_rtable->AddReactivePath (
prep.GetOriginatorAddress (),
from,
interface,
prep.GetMetric (),
MicroSeconds(prep.GetLifetime () * 1024),
prep.GetOriginatorSeqNumber ());
m_rtable->AddPrecursor (prep.GetOriginatorAddress (), interface, result.retransmitter);
}
if (result.retransmitter == Mac48Address::GetBroadcast ())
//try to look for default route
result = m_rtable->LookupProactive ();
if (result.retransmitter == Mac48Address::GetBroadcast ())
return;
m_rtable->AddPrecursor (prep.GetOriginatorAddress (), interface, result.retransmitter);
//Forward PREP
HwmpPluginMap::const_iterator prep_sender = m_interfaces.find (result.ifIndex);
NS_ASSERT(prep_sender != m_interfaces.end ());
@@ -539,8 +550,8 @@ HwmpProtocol::PeerLinkStatus(Mac48Address meshPointAddress, Mac48Address peerAdd
NS_ASSERT(i != m_interfaces.end ());
if(result.metric < i->second->GetLinkMetric(peerAddress))
{
m_rtable->AddReactivePath(meshPointAddress, peerAddress, interface, 1, Seconds (0), i->second->GetLinkMetric(peerAddress));
ReactivePathResolved (meshPointAddress);
m_rtable->AddReactivePath(meshPointAddress, peerAddress, interface, 1, Seconds (0), i->second->GetLinkMetric(peerAddress));
ReactivePathResolved (meshPointAddress);
}
}
else
@@ -756,9 +767,12 @@ HwmpProtocol::RetryPathDiscovery (Mac48Address dst, uint8_t numOfRetry)
m_preqTimeouts.erase (i);
return;
}
uint32_t seqno = GetNextHwmpSeqno ();
uint32_t originator_seqno = GetNextHwmpSeqno ();
uint32_t dst_seqno = 0;
if(result.retransmitter != Mac48Address::GetBroadcast ())
dst_seqno = result.seqnum;
for(HwmpPluginMap::const_iterator i = m_interfaces.begin (); i != m_interfaces.end (); i ++)
i->second->RequestDestination(dst, seqno);
i->second->RequestDestination(dst, originator_seqno, dst_seqno);
m_preqTimeouts[dst] = Simulator::Schedule (
MilliSeconds (2*(m_dot11MeshHWMPnetDiameterTraversalTime.GetMilliSeconds())),
&HwmpProtocol::RetryPathDiscovery, this, dst, numOfRetry);
@@ -831,7 +845,7 @@ HwmpProtocol::GetNextHwmpSeqno ()
{
m_hwmpSeqno ++;
if(m_hwmpSeqno == 0xffffffff)
m_hwmpSeqno = 0;
m_hwmpSeqno = 1;
return m_hwmpSeqno;
}
uint32_t

View File

@@ -31,29 +31,28 @@ namespace dot11s {
/*************************
* DestinationAddressUnit
************************/
DestinationAddressUnit::DestinationAddressUnit ()
DestinationAddressUnit::DestinationAddressUnit ():
m_do (false),
m_rf (false),
m_usn (false),
m_destinationAddress (Mac48Address ()),
m_destSeqNumber (0)
{
m_do = false;
m_rf = false;
m_destSeqNumber = 0;
uint8_t mac_buffer[6];
for (int j = 0; j < 6; j++)
{
mac_buffer[j] = 0;
}
m_destinationAddress.CopyFrom (mac_buffer);
}
void
DestinationAddressUnit::SetFlags (bool doFlag, bool rfFlag)
DestinationAddressUnit::SetFlags (bool doFlag, bool rfFlag, bool usnFlag)
{
m_do = doFlag;
m_rf = rfFlag;
m_usn = usnFlag;
}
void
DestinationAddressUnit::SetDestSeqNumber (uint32_t dest_seq_number)
{
m_destSeqNumber = dest_seq_number;
if(m_destSeqNumber != 0)
m_usn = true;
}
void
DestinationAddressUnit::SetDestinationAddress (Mac48Address dest_address)
@@ -71,7 +70,11 @@ DestinationAddressUnit::IsRf ()
{
return m_rf;
}
bool
DestinationAddressUnit::IsUsn ()
{
return m_usn;
}
uint32_t
DestinationAddressUnit::GetDestSeqNumber () const
{
@@ -261,9 +264,11 @@ IePreq::SerializeInformation (Buffer::Iterator i) const
{
uint8_t flags = 0;
if ((*j)->IsDo ())
flags +=128;
flags += 128;
if ((*j)->IsRf ())
flags +=64;
flags += 64;
if((*j)->IsUsn ())
flags += 32;
i.WriteU8 (flags);
WriteTo (i, (*j)->GetDestinationAddress());
i.WriteHtonU32 ((*j)->GetDestSeqNumber ());
@@ -291,6 +296,7 @@ IePreq::DeserializeInformation (Buffer::Iterator start, uint8_t length)
Ptr<DestinationAddressUnit> new_element = Create<DestinationAddressUnit> ();
bool doFlag = false;
bool rfFlag = false;
bool usnFlag = false;
uint8_t flags = i.ReadU8 ();
if (flags >= 128)
{
@@ -298,8 +304,13 @@ IePreq::DeserializeInformation (Buffer::Iterator start, uint8_t length)
flags -=128;
}
if (flags >=64)
{
rfFlag = true;
new_element->SetFlags (doFlag, rfFlag);
flags -= 64;
}
if (flags >= 32)
usnFlag = true;
new_element->SetFlags (doFlag, rfFlag, usnFlag);
Mac48Address addr;
ReadFrom (i,addr);
new_element->SetDestinationAddress (addr);
@@ -358,7 +369,7 @@ IePreq::AddDestinationAddressElement (
if ((*i)->GetDestinationAddress () == dest_address)
return;
Ptr<DestinationAddressUnit>new_element = Create<DestinationAddressUnit> ();
new_element->SetFlags (doFlag, rfFlag);
new_element->SetFlags (doFlag, rfFlag, false);
new_element->SetDestinationAddress (dest_address);
new_element->SetDestSeqNumber (dest_seq_number);
m_destinations.push_back (new_element);
@@ -392,6 +403,7 @@ bool operator== (const DestinationAddressUnit & a, const DestinationAddressUnit
{
return (a.m_do == b.m_do
&& a.m_rf == b.m_rf
&& a.m_usn == b.m_usn
&& a.m_destinationAddress == b.m_destinationAddress
&& a.m_destSeqNumber == b.m_destSeqNumber
);

View File

@@ -38,17 +38,19 @@ class DestinationAddressUnit : public RefCountBase
{
public:
DestinationAddressUnit ();
void SetFlags (bool doFlag, bool rfflag);
void SetFlags (bool doFlag, bool rfFlag, bool usnFlag);
void SetDestinationAddress (Mac48Address dest_address);
void SetDestSeqNumber (uint32_t dest_seq_number);
bool IsDo ();
bool IsRf ();
bool IsUsn ();
Mac48Address GetDestinationAddress () const;
uint32_t GetDestSeqNumber () const;
private:
bool m_do;
bool m_rf;
bool m_usn;
Mac48Address m_destinationAddress;
uint32_t m_destSeqNumber;