--- a/src/devices/mesh/dot11s/hwmp-mac-plugin.cc Tue Mar 31 15:24:16 2009 +0400
+++ b/src/devices/mesh/dot11s/hwmp-mac-plugin.cc Tue Mar 31 18:04:54 2009 +0400
@@ -102,13 +102,16 @@
if (preq.GetTtl () == 0)
return false;
preq.DecrementTtl ();
- m_protocol->ReceivePreq (preq, header.GetAddr2 (), m_ifIndex, m_parent->GetAddress ());
+ m_protocol->ReceivePreq (preq, header.GetAddr2 (), m_ifIndex);
return false;
}
case WifiMeshMultihopActionHeader::PATH_REPLY:
{
IePrep prep;
packet->RemoveHeader (prep);
+ if(prep.GetTtl () == 0)
+ return false;
+ prep.DecrementTtl ();
m_protocol->ReceivePrep (prep, header.GetAddr2 (), m_ifIndex);
return false;
}
@@ -197,7 +200,7 @@
preq.SetHopcount (0);
preq.SetTTL (m_protocol->GetMaxTtl ());
preq.SetPreqID (m_protocol->GetNextPreqId ());
- preq.SetOriginatorAddress (m_parent->GetAddress ());
+ preq.SetOriginatorAddress (m_protocol->GetAddress ());
preq.SetOriginatorSeqNumber (m_protocol->GetNextHwmpSeqno());
preq.SetLifetime (m_protocol->GetActivePathLifetime ());
preq.AddDestinationAddressElement (false, false, dst, 0); //DO = 0, RF = 0
@@ -393,6 +396,7 @@
hdr.SetAddr2 (m_parent->GetAddress ());
hdr.SetAddr3 (Mac48Address::GetBroadcast ());
//Send Management frame
+ NS_LOG_UNCOND("Sending PREP");
m_parent->SendManagementFrame(packet, hdr);
}
#if 0
--- a/src/devices/mesh/dot11s/hwmp-protocol.cc Tue Mar 31 15:24:16 2009 +0400
+++ b/src/devices/mesh/dot11s/hwmp-protocol.cc Tue Mar 31 18:04:54 2009 +0400
@@ -232,7 +232,7 @@
return true;
}
void
-HwmpProtocol::ReceivePreq (IePreq preq, Mac48Address from, uint32_t interface, Mac48Address interfaceAddress)
+HwmpProtocol::ReceivePreq (IePreq preq, Mac48Address from, uint32_t interface)
{
preq.IncrementMetric (1);
//acceptance cretirea:
@@ -281,7 +281,7 @@
ProactivePathResolved ();
if (!preq.IsNeedNotPrep ())
SendPrep (
- interfaceAddress,
+ m_address,
preq.GetOriginatorAddress (),
from,
preq.GetMetric (),
@@ -292,11 +292,12 @@
);
break;
}
- if ((*i)->GetDestinationAddress () == interfaceAddress)
+ if ((*i)->GetDestinationAddress () == m_address)
{
+ NS_LOG_UNCOND("PREQ has reached destination:"<<m_address);
preq.DelDestinationAddressElement ((*i)->GetDestinationAddress());
SendPrep (
- interfaceAddress,
+ m_address,
preq.GetOriginatorAddress (),
from,
(uint32_t)0,
@@ -319,12 +320,12 @@
//send a PREP and delete destination
preq.DelDestinationAddressElement ((*i)->GetDestinationAddress());
SendPrep (
- interfaceAddress,
+ (*i)->GetDestinationAddress (),
preq.GetOriginatorAddress (),
from,
result.metric,
preq.GetOriginatorSeqNumber (),
- result.seqnum,
+ result.seqnum +1,
preq.GetLifetime (),
interface
);
@@ -346,55 +347,51 @@
if (preq.GetDestCount () == 0)
return;
//Forward PREQ to all interfaces:
- NS_LOG_UNCOND("I am "<<interfaceAddress<<"retransmitting PREQ:"<<preq);
+ NS_LOG_UNCOND("I am "<<m_address<<"retransmitting PREQ:"<<preq);
for(HwmpPluginMap::iterator i = m_interfaces.begin (); i != m_interfaces.end (); i ++)
i->second->SendPreq (preq);
}
void
HwmpProtocol::ReceivePrep (IePrep prep, Mac48Address from, uint32_t interface)
{
- prep.DecrementTtl ();
prep.IncrementMetric (1);
//acceptance cretirea:
- std::map<Mac48Address, uint32_t>::iterator i = m_lastHwmpSeqno.find (prep.GetDestinationAddress());
+ NS_LOG_UNCOND("I am "<<m_address<<", received prep");
+ std::map<Mac48Address, uint32_t>::iterator i = m_lastHwmpSeqno.find (prep.GetOriginatorAddress());
if (i == m_lastHwmpSeqno.end ())
{
- m_lastHwmpSeqno[prep.GetDestinationAddress ()] = prep.GetDestinationSeqNumber();
+ m_lastHwmpSeqno[prep.GetOriginatorAddress ()] = prep.GetOriginatorSeqNumber();
}
else
- if (i->second > prep.GetDestinationSeqNumber ())
+ if (i->second > prep.GetOriginatorSeqNumber ())
return;
//update routing info
- NS_LOG_UNCOND("try to llokup"<<prep.GetDestinationAddress());
+ //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 ());
+ if(prep.GetDestinationAddress() == m_address)
+ NS_LOG_UNCOND("Destination resolved:"<<prep.GetOriginatorAddress ());
HwmpRtable::LookupResult result = m_rtable->LookupReactive(prep.GetDestinationAddress());
if (result.retransmitter == Mac48Address::GetBroadcast ())
//try to look for default route
result = m_rtable->LookupProactive ();
if (result.retransmitter == Mac48Address::GetBroadcast ())
+ {
+ NS_LOG_UNCOND("I am "<<m_address<<", can not forward prep");
return;
-#if 0
- INFO newInfo;
- newInfo.me = m_address;
- newInfo.destination = prep.GetOriginatorAddress ();
- newInfo.source = prep.GetDestinationAddress ();
- newInfo.nextHop = from;
- newInfo.metric = prep.GetMetric ();
- newInfo.lifetime = TU_TO_TIME (prep.GetLifetime());
- newInfo.outPort = m_ifIndex;
- newInfo.dsn = prep.GetOriginatorSeqNumber ();
- newInfo.prevHop = result.retransmitter;
- newInfo.type = INFO_PREP;
- NS_LOG_DEBUG ("Path to "<<newInfo.source<<", i am "<<m_address<<", precursor is "<<from);
- NS_LOG_DEBUG ("Path to "<<newInfo.destination<<", i am "<<m_address<<", precursor is "<<result.retransmitter);
- m_routingInfoCallback (newInfo);
- if (prep.GetDestinationAddress () == m_address)
- {
- NS_LOG_DEBUG ("Destination resolved"<<newInfo.destination);
- return;
- }
- m_prepCallback (prep, result.retransmitter);
-#endif
- NS_ASSERT(false);
+ }
+ m_rtable->AddPrecursor (prep.GetOriginatorAddress (), interface, result.retransmitter);
+ //Forward PREP
+ HwmpPluginMap::iterator prep_sender = m_interfaces.find (result.ifIndex);
+ NS_ASSERT(prep_sender != m_interfaces.end ());
+ prep_sender->second->SendPrep(prep, result.retransmitter);
+
}
void
HwmpProtocol::ReceivePerr (IePerr perr, Mac48Address from, uint32_t interface)
@@ -411,9 +408,10 @@
uint32_t lifetime,
uint32_t interface)
{
+ NS_LOG_UNCOND("sending prep to "<<dst<<" through "<<retransmitter);
IePrep prep;
prep.SetHopcount (0);
- prep.SetTTL (m_maxTtl);
+ prep.SetTtl (m_maxTtl);
prep.SetDestinationAddress (dst);
prep.SetDestinationSeqNumber (destinationSN);
prep.SetLifetime (lifetime);
@@ -445,9 +443,14 @@
m_interfaces[wifiNetDev->GetIfIndex ()] = hwmpMac;
mac->InstallPlugin (hwmpMac);
}
- mp->SetRoutingProtocol(this);
+ mp->SetRoutingProtocol (this);
// Mesh point aggregates all installed protocols
- mp->AggregateObject(this);
+ mp->AggregateObject (this);
+ //Address tmp_addr = mp->GetAddress ();
+ //Mac48Address * address = dynamic_cast<Mac48Address *> (&tmp_addr);
+ //if (address == NULL)
+ // return false;
+ m_address = Mac48Address::ConvertFrom (mp->GetAddress ());//* address;
return true;
}
bool
@@ -704,7 +707,10 @@
return;
}
for(HwmpPluginMap::iterator i = m_interfaces.begin (); i != m_interfaces.end (); i ++)
+ {
i->second->RequestDestination(dst);
+ i->second->RequestDestination(Mac48Address("00:00:00:00:00:10"));
+ }
m_preqTimeouts[dst] = Simulator::Schedule (
MilliSeconds (2*(m_dot11MeshHWMPnetDiameterTraversalTime.GetMilliSeconds())),
&HwmpProtocol::RetryPathDiscovery, this, dst, numOfRetry);
@@ -785,5 +791,10 @@
{
return m_dot11MeshHWMPactivePathTimeout.GetMicroSeconds () / 1024;
}
+Mac48Address
+HwmpProtocol::GetAddress ()
+{
+ return m_address;
+}
} //namespace dot11s
} //namespace ns3
--- a/src/devices/mesh/dot11s/hwmp-protocol.h Tue Mar 31 15:24:16 2009 +0400
+++ b/src/devices/mesh/dot11s/hwmp-protocol.h Tue Mar 31 18:04:54 2009 +0400
@@ -74,7 +74,7 @@
///\name Interaction with HWMP MAC plugin
//\{
- void ReceivePreq(IePreq preq, Mac48Address from, uint32_t interface, Mac48Address interfaceAddress);
+ void ReceivePreq(IePreq preq, Mac48Address from, uint32_t interface);
void ReceivePrep(IePrep prep, Mac48Address from, uint32_t interface);
void ReceivePerr(IePerr perr, Mac48Address from, uint32_t interface);
void SendPrep (
@@ -113,7 +113,6 @@
private:
///\name Methods related to Queue/Dequeue procedures
//\{
- uint16_t m_maxQueueSize;
bool QueuePacket (MeshL2RoutingProtocol::QueuedPacket packet);
QueuedPacket DequeueFirstPacketByDst (Mac48Address dst);
QueuedPacket DequeueFirstPacket ();
@@ -145,10 +144,12 @@
void UnsetRoot ();
void SendProactivePreq ();
//\}
-
+ ///\return address of MeshPointDevice
+ Mac48Address GetAddress ();
private:
typedef std::map<uint32_t, Ptr<HwmpMacPlugin> > HwmpPluginMap;
HwmpPluginMap m_interfaces;
+ Mac48Address m_address;
uint32_t m_dataSeqno;
uint32_t m_hwmpSeqno;
uint32_t m_preqId;
@@ -177,6 +178,7 @@
private:
///\name HWMP-protocol parameters (attributes of GetTypeId)
//\{
+ uint16_t m_maxQueueSize;
uint8_t m_dot11MeshHWMPmaxPREQretries;
Time m_dot11MeshHWMPnetDiameterTraversalTime;
Time m_dot11MeshHWMPpreqMinInterval;
--- a/src/devices/mesh/dot11s/ie-dot11s-prep.cc Tue Mar 31 15:24:16 2009 +0400
+++ b/src/devices/mesh/dot11s/ie-dot11s-prep.cc Tue Mar 31 18:04:54 2009 +0400
@@ -67,7 +67,7 @@
m_hopcount = hopcount;
}
void
-IePrep::SetTTL (uint8_t ttl)
+IePrep::SetTtl (uint8_t ttl)
{
m_ttl = ttl;
}
@@ -112,7 +112,7 @@
return m_hopcount;
}
uint32_t
-IePrep::GetTTL () const
+IePrep::GetTtl () const
{
return m_ttl;
}
@@ -193,7 +193,7 @@
uint32_t retval =
1 //Flags
+1 //Hopcount
- +1 //TTL
+ +1 //Ttl
+6 //Dest address
+4 //Dest seqno
+4 //Lifetime
--- a/src/devices/mesh/dot11s/ie-dot11s-prep.h Tue Mar 31 15:24:16 2009 +0400
+++ b/src/devices/mesh/dot11s/ie-dot11s-prep.h Tue Mar 31 18:04:54 2009 +0400
@@ -41,7 +41,7 @@
virtual TypeId GetInstanceTypeId () const;
void SetFlags (uint8_t flags);
void SetHopcount (uint8_t hopcount);
- void SetTTL (uint8_t ttl);
+ void SetTtl (uint8_t ttl);
void SetDestinationAddress (Mac48Address dest_address);
void SetDestinationSeqNumber (uint32_t dest_seq_number);
void SetLifetime (uint32_t lifetime);
@@ -51,7 +51,7 @@
uint8_t GetFlags () const;
uint8_t GetHopcount () const;
- uint32_t GetTTL () const;
+ uint32_t GetTtl () const;
Mac48Address GetDestinationAddress () const;
uint32_t GetDestinationSeqNumber () const;
uint32_t GetLifetime () const;