Unicast chain instead of broadcast data frame added. Metric
calculation:unfinished
--- a/examples/mesh.cc Thu Apr 02 20:41:08 2009 +0400
+++ b/examples/mesh.cc Tue Apr 07 20:24:39 2009 +0400
@@ -59,7 +59,7 @@
cmd.Parse (argc, argv);
NS_LOG_DEBUG ("Grid:" << xSize << "*" << ySize);
-
+ SeedManager::SetSeed(1);
// Creating nodes
NodeContainer nodes;
nodes.Create (ySize*xSize);
@@ -101,8 +101,8 @@
serverApps.Start (Seconds (1.0));
serverApps.Stop (Seconds (10.0));
UdpEchoClientHelper echoClient (interfaces.GetAddress (0), 9);
- echoClient.SetAttribute ("MaxPackets", UintegerValue (1000));
- echoClient.SetAttribute ("Interval", TimeValue (Seconds (0.001)));
+ echoClient.SetAttribute ("MaxPackets", UintegerValue (10000));
+ echoClient.SetAttribute ("Interval", TimeValue (Seconds (0.01)));
echoClient.SetAttribute ("PacketSize", UintegerValue (1024));
ApplicationContainer clientApps = echoClient.Install (nodes.Get (1));
clientApps.Start (Seconds (2.0));
--- a/src/devices/mesh/dot11s/hwmp-mac-plugin.cc Thu Apr 02 20:41:08 2009 +0400
+++ b/src/devices/mesh/dot11s/hwmp-mac-plugin.cc Tue Apr 07 20:24:39 2009 +0400
@@ -102,7 +102,7 @@
if (preq.GetTtl () == 0)
return false;
preq.DecrementTtl ();
- m_protocol->ReceivePreq (preq, header.GetAddr2 (), m_ifIndex);
+ m_protocol->ReceivePreq (preq, header.GetAddr2 (), m_ifIndex, m_parent->GetLinkMetric(header.GetAddr2 ()));
return false;
}
case WifiMeshMultihopActionHeader::PATH_REPLY:
@@ -112,7 +112,7 @@
if(prep.GetTtl () == 0)
return false;
prep.DecrementTtl ();
- m_protocol->ReceivePrep (prep, header.GetAddr2 (), m_ifIndex);
+ m_protocol->ReceivePrep (prep, header.GetAddr2 (), m_ifIndex, m_parent->GetLinkMetric(header.GetAddr2 ()));
return false;
}
case WifiMeshMultihopActionHeader::PATH_ERROR:
@@ -309,5 +309,10 @@
}
SendOnePerr ();
}
+uint32_t
+HwmpMacPlugin::GetLinkMetric(Mac48Address peerAddress)
+{
+ return m_parent->GetLinkMetric(peerAddress);
+}
} //namespace dot11s
}//namespace ns3
--- a/src/devices/mesh/dot11s/hwmp-mac-plugin.h Thu Apr 02 20:41:08 2009 +0400
+++ b/src/devices/mesh/dot11s/hwmp-mac-plugin.h Tue Apr 07 20:24:39 2009 +0400
@@ -69,6 +69,9 @@
/// Sends one PREQ when PreqMinInterval after last PREQ expires (if any PREQ exists in rhe queue)
void SendOnePreq ();
void SendOnePerr ();
+ /// Returns metric to HWMP protocol, needed only by metrics to add
+ //peer as routing entry
+ uint32_t GetLinkMetric (Mac48Address peerAddress);
private:
Ptr<MeshWifiInterfaceMac> m_parent;
uint32_t m_ifIndex;
--- a/src/devices/mesh/dot11s/hwmp-protocol.cc Thu Apr 02 20:41:08 2009 +0400
+++ b/src/devices/mesh/dot11s/hwmp-protocol.cc Tue Apr 07 20:24:39 2009 +0400
@@ -114,9 +114,15 @@
)
.AddAttribute ("unicastPreqThreshold",
"Maximum number of PREQ receivers, when we send a PREQ as a chain of unicasts",
- UintegerValue (0),
+ UintegerValue (1),
MakeUintegerAccessor (&HwmpProtocol::m_unicastPreqThreshold),
- MakeUintegerChecker<uint8_t> (0)
+ MakeUintegerChecker<uint8_t> (1)
+ )
+ .AddAttribute ("unicastDataThreshold",
+ "Maximum number ofbroadcast receivers, when we send a broadcast as a chain of unicasts",
+ UintegerValue (32),
+ MakeUintegerAccessor (&HwmpProtocol::m_unicastDataThreshold),
+ MakeUintegerChecker<uint8_t> (1)
)
.AddAttribute ("isRoot",
"Root mesh point",
@@ -200,10 +206,23 @@
}
if (destination == Mac48Address::GetBroadcast ())
{
- packet->RemovePacketTag (tag);
+ NS_ASSERT(packet->RemovePacketTag (tag));
+ for(HwmpPluginMap::const_iterator plugin = m_interfaces.begin (); plugin != m_interfaces.end (); plugin ++)
+ {
+ std::vector<Mac48Address> receivers = GetBroadcastReceivers (plugin->first);
+ for (std::vector<Mac48Address>::const_iterator i = receivers.begin (); i != receivers.end(); i ++)
+ {
+ Ptr<Packet> packet_copy = packet->Copy();
+ tag.SetAddress (*i);
+ packet_copy->AddPacketTag (tag);
+ routeReply (true, packet_copy, source, destination, protocolType, plugin->first);
+ }
+ }
+#if 0
tag.SetAddress (Mac48Address::GetBroadcast ());
packet->AddPacketTag(tag);
routeReply (true, packet, source, destination, protocolType, HwmpRtable::INTERFACE_ANY);
+#endif
}
else
return ForwardUnicast(sourceIface, source, destination, packet, protocolType, routeReply);
@@ -269,7 +288,7 @@
return true;
}
void
-HwmpProtocol::ReceivePreq (IePreq preq, Mac48Address from, uint32_t interface)
+HwmpProtocol::ReceivePreq (IePreq preq, Mac48Address from, uint32_t interface, uint32_t metric)
{
preq.IncrementMetric (1);
//acceptance cretirea:
@@ -284,14 +303,13 @@
if (i->second > preq.GetOriginatorSeqNumber ())
return;
if (i->second == preq.GetOriginatorSeqNumber ())
- {
- //find metric
- std::map<Mac48Address, uint32_t>::iterator j =
- m_lastHwmpMetric.find (preq.GetOriginatorAddress());
- NS_ASSERT (j != m_lastHwmpSeqno.end());
- if (j->second <= preq.GetMetric ())
- return;
- }
+ {
+ //find metric
+ std::map<Mac48Address, uint32_t>::iterator j = m_lastHwmpMetric.find (preq.GetOriginatorAddress());
+ NS_ASSERT (j != m_lastHwmpSeqno.end());
+ if (j->second <= preq.GetMetric ())
+ return;
+ }
m_lastHwmpSeqno[preq.GetOriginatorAddress ()] = preq.GetOriginatorSeqNumber();
m_lastHwmpMetric[preq.GetOriginatorAddress ()] = preq.GetMetric();
}
@@ -389,9 +407,9 @@
i->second->SendPreq (preq);
}
void
-HwmpProtocol::ReceivePrep (IePrep prep, Mac48Address from, uint32_t interface)
+HwmpProtocol::ReceivePrep (IePrep prep, Mac48Address from, uint32_t interface, uint32_t metric)
{
- prep.IncrementMetric (1);
+ prep.IncrementMetric (metric);
//acceptance cretirea:
std::map<Mac48Address, uint32_t>::iterator i = m_lastHwmpSeqno.find (prep.GetOriginatorAddress());
if (i == m_lastHwmpSeqno.end ())
@@ -507,8 +525,10 @@
if(status)
{
HwmpRtable::LookupResult result = m_rtable->LookupReactive(meshPointAddress);
+ HwmpPluginMap::iterator i = m_interfaces.find(interface);
+ NS_ASSERT(i != m_interfaces.end ());
if(result.retransmitter == Mac48Address::GetBroadcast ())
- m_rtable->AddReactivePath(meshPointAddress, peerAddress, interface, 1, Seconds (0), 0);
+ m_rtable->AddReactivePath(meshPointAddress, peerAddress, interface, 1, Seconds (0), i->second->GetLinkMetric(peerAddress));
}
else
{
@@ -588,6 +608,19 @@
}
return retval;
}
+std::vector<Mac48Address>
+HwmpProtocol::GetBroadcastReceivers (uint32_t interface)
+{
+ std::vector<Mac48Address> retval;
+ if(!m_neighboursCallback.IsNull ()) retval = m_neighboursCallback (interface);
+ if (retval.size() >= m_unicastDataThreshold)
+ {
+ retval.clear ();
+ retval.push_back (Mac48Address::GetBroadcast ());
+ }
+ return retval;
+}
+
bool
HwmpProtocol::QueuePacket (QueuedPacket packet)
{
--- a/src/devices/mesh/dot11s/hwmp-protocol.h Thu Apr 02 20:41:08 2009 +0400
+++ b/src/devices/mesh/dot11s/hwmp-protocol.h Tue Apr 07 20:24:39 2009 +0400
@@ -77,8 +77,8 @@
///\name Interaction with HWMP MAC plugin
//\{
- void ReceivePreq(IePreq preq, Mac48Address from, uint32_t interface);
- void ReceivePrep(IePrep prep, Mac48Address from, uint32_t interface);
+ void ReceivePreq(IePreq preq, Mac48Address from, uint32_t interface, uint32_t metric);
+ void ReceivePrep(IePrep prep, Mac48Address from, uint32_t interface, uint32_t metric);
void ReceivePerr(IePerr perr, Mac48Address from, uint32_t interface);
void SendPrep (
Mac48Address src,
@@ -97,7 +97,9 @@
/// \return list of addresses where a PERR should be sent to
std::vector<Mac48Address> GetPreqReceivers (uint32_t interface);
-
+ /// \return list of addresses where a broadcast should be
+ //retransmitted
+ std::vector<Mac48Address> GetBroadcastReceivers (uint32_t interface);
/**
* \brief MAC-plugin asks wether the frame can be dropeed. Protocol automatically updates seqno.
*
@@ -188,6 +190,7 @@
uint8_t m_maxTtl;
uint8_t m_unicastPerrThreshold;
uint8_t m_unicastPreqThreshold;
+ uint8_t m_unicastDataThreshold;
bool m_doFlag;
bool m_rfFlag;
//\}
--- a/src/devices/mesh/dot11s/ie-dot11s-preq.cc Thu Apr 02 20:41:08 2009 +0400
+++ b/src/devices/mesh/dot11s/ie-dot11s-preq.cc Tue Apr 07 20:24:39 2009 +0400
@@ -337,6 +337,7 @@
os << " metric = " << m_metric << "\n";
os << " seqno = " << m_originatorSeqNumber << "\n";
os << " lifetime = " << m_lifetime << "\n";
+ os << " preq ID = " <<m_preqId << "\n";
os << " Destinations are:\n";
for (int j = 0; j < m_destCount; j++ )
os << " " << m_destinations[j]->GetDestinationAddress () << "\n";
--- a/src/devices/mesh/mesh-point-device.cc Thu Apr 02 20:41:08 2009 +0400
+++ b/src/devices/mesh/mesh-point-device.cc Tue Apr 07 20:24:39 2009 +0400
@@ -82,14 +82,13 @@
NS_LOG_DEBUG ("UID is " << packet->GetUid ());
const Mac48Address src48 = Mac48Address::ConvertFrom (src);
const Mac48Address dst48 = Mac48Address::ConvertFrom (dst);
- NS_LOG_UNCOND("SRC="<<src48<<", DST = "<<dst48<<", I am: "<<m_address);
+ NS_LOG_DEBUG("SRC="<<src48<<", DST = "<<dst48<<", I am: "<<m_address);
if (!m_promiscRxCallback.IsNull ())
m_promiscRxCallback (this, packet, protocol, src, dst, packetType);
switch (packetType)
{
case PACKET_HOST:
- if (dst48 == m_address)
- m_rxCallback (this, packet, protocol, src);
+ m_rxCallback (this, packet, protocol, src);
break;
case PACKET_BROADCAST:
case PACKET_MULTICAST:
@@ -226,6 +225,7 @@
MeshPointDevice::Send (Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber)
{
const Mac48Address dst48 = Mac48Address::ConvertFrom (dest);
+ NS_LOG_DEBUG("SEND:, DST = "<<dst48<<", I am: "<<m_address);
return m_requestRoute (m_ifIndex, m_address, dst48, packet, protocolNumber, m_myResponse);
}
--- a/src/devices/mesh/mesh-wifi-interface-mac.cc Thu Apr 02 20:41:08 2009 +0400
+++ b/src/devices/mesh/mesh-wifi-interface-mac.cc Tue Apr 07 20:24:39 2009 +0400
@@ -584,7 +584,6 @@
}
}
}
-
// Filter frame through all installed plugins
for (PluginList::iterator i = m_plugins.begin (); i != m_plugins.end(); ++i)
{
@@ -596,6 +595,10 @@
if (hdr->IsData ())
ForwardUp (packet, hdr->GetAddr4(), hdr->GetAddr3());
}
-
+uint32_t
+MeshWifiInterfaceMac::GetLinkMetric (Mac48Address peerAddress)
+{
+ return 1;
+}
} // namespace ns3
--- a/src/devices/mesh/mesh-wifi-interface-mac.h Thu Apr 02 20:41:08 2009 +0400
+++ b/src/devices/mesh/mesh-wifi-interface-mac.h Tue Apr 07 20:24:39 2009 +0400
@@ -146,7 +146,7 @@
bool CheckSupportedRates(SupportedRates rates) const;
/// \return list of supported bitrates
SupportedRates GetSupportedRates () const;
-
+ uint32_t GetLinkMetric(Mac48Address peerAddress);
private:
/// Frame receive handler
void Receive (Ptr<Packet> packet, WifiMacHeader const *hdr);