Unicast chain instead of broadcast data frame added. Metric

calculation:unfinished
This commit is contained in:
Kirill Andreev
2009-04-07 20:24:39 +04:00
parent 97b31efba4
commit 6900402c16
9 changed files with 77 additions and 29 deletions

View File

@@ -59,7 +59,7 @@ main (int argc, char *argv[])
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 @@ main (int argc, char *argv[])
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));

View File

@@ -102,7 +102,7 @@ HwmpMacPlugin::Receive (Ptr<Packet> packet, const WifiMacHeader & header)
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 @@ HwmpMacPlugin::Receive (Ptr<Packet> packet, const WifiMacHeader & header)
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 @@ HwmpMacPlugin::SendPerr(IePerr perr, std::vector<Mac48Address> receivers)
}
SendOnePerr ();
}
uint32_t
HwmpMacPlugin::GetLinkMetric(Mac48Address peerAddress)
{
return m_parent->GetLinkMetric(peerAddress);
}
} //namespace dot11s
}//namespace ns3

View File

@@ -69,6 +69,9 @@ private:
/// 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;

View File

@@ -114,9 +114,15 @@ HwmpProtocol::GetTypeId ()
)
.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 @@ HwmpProtocol::RequestRoute (
}
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 @@ HwmpProtocol::ForwardUnicast(uint32_t sourceIface, const Mac48Address source, c
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 @@ HwmpProtocol::ReceivePreq (IePreq preq, Mac48Address from, uint32_t interface)
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 @@ HwmpProtocol::ReceivePreq (IePreq preq, Mac48Address from, uint32_t interface)
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 @@ HwmpProtocol::PeerLinkStatus(Mac48Address meshPointAddress, Mac48Address peerAdd
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 @@ HwmpProtocol::GetPreqReceivers (uint32_t interface)
}
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)
{

View File

@@ -77,8 +77,8 @@ private:
///\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 @@ private:
/// \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 @@ private:
uint8_t m_maxTtl;
uint8_t m_unicastPerrThreshold;
uint8_t m_unicastPreqThreshold;
uint8_t m_unicastDataThreshold;
bool m_doFlag;
bool m_rfFlag;
//\}

View File

@@ -337,6 +337,7 @@ IePreq::PrintInformation (std::ostream &os) const
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";

View File

@@ -82,14 +82,13 @@ MeshPointDevice::ReceiveFromDevice (Ptr<NetDevice> incomingPort, Ptr<const Packe
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 @@ bool
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);
}

View File

@@ -584,7 +584,6 @@ MeshWifiInterfaceMac::Receive (Ptr<Packet> packet, WifiMacHeader const *hdr)
}
}
}
// Filter frame through all installed plugins
for (PluginList::iterator i = m_plugins.begin (); i != m_plugins.end(); ++i)
{
@@ -596,6 +595,10 @@ MeshWifiInterfaceMac::Receive (Ptr<Packet> packet, WifiMacHeader const *hdr)
if (hdr->IsData ())
ForwardUp (packet, hdr->GetAddr4(), hdr->GetAddr3());
}
uint32_t
MeshWifiInterfaceMac::GetLinkMetric (Mac48Address peerAddress)
{
return 1;
}
} // namespace ns3

View File

@@ -146,7 +146,7 @@ public:
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);