removed GetElementId from *.h files. Fixed spaces before '(' and added {} when needed.
This commit is contained in:
@@ -56,16 +56,20 @@ Dot11sStack::InstallStack (Ptr<MeshPointDevice> mp)
|
||||
Ptr<PeerManagementProtocol> pmp = CreateObject<PeerManagementProtocol> ();
|
||||
pmp->SetMeshId("mesh");
|
||||
bool install_ok = pmp->Install (mp);
|
||||
if(!install_ok)
|
||||
return false;
|
||||
if (!install_ok)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
//Install HWMP:
|
||||
Ptr<HwmpProtocol> hwmp = CreateObject<HwmpProtocol> ();
|
||||
install_ok = hwmp->Install (mp);
|
||||
if(!install_ok)
|
||||
return false;
|
||||
if (!install_ok)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
//Install interaction between HWMP and Peer management protocol:
|
||||
pmp->SetPeerLinkStatusCallback(MakeCallback(&HwmpProtocol::PeerLinkStatus, hwmp));
|
||||
hwmp->SetNeighboursCallback(MakeCallback(&PeerManagementProtocol::GetActiveLinks, pmp));
|
||||
pmp->SetPeerLinkStatusCallback (MakeCallback(&HwmpProtocol::PeerLinkStatus, hwmp));
|
||||
hwmp->SetNeighboursCallback (MakeCallback(&PeerManagementProtocol::GetActiveLinks, pmp));
|
||||
return true;
|
||||
}
|
||||
void
|
||||
@@ -74,18 +78,18 @@ Dot11sStack::Report (const Ptr<MeshPointDevice> mp, std::ostream& os)
|
||||
mp->Report (os);
|
||||
|
||||
std::vector<Ptr<NetDevice> > ifaces = mp->GetInterfaces ();
|
||||
for (std::vector<Ptr<NetDevice> >::const_iterator i = ifaces.begin(); i != ifaces.end(); ++i)
|
||||
for (std::vector<Ptr<NetDevice> >::const_iterator i = ifaces.begin (); i != ifaces.end (); ++i)
|
||||
{
|
||||
Ptr<WifiNetDevice> device = (*i)->GetObject<WifiNetDevice> ();
|
||||
NS_ASSERT (device != 0);
|
||||
MeshInterfaceHelper::Report(device, os);
|
||||
MeshInterfaceHelper::Report (device, os);
|
||||
}
|
||||
Ptr <HwmpProtocol> hwmp = mp->GetObject<HwmpProtocol> ();
|
||||
NS_ASSERT(hwmp != 0);
|
||||
NS_ASSERT (hwmp != 0);
|
||||
hwmp->Report (os);
|
||||
|
||||
Ptr <PeerManagementProtocol> pmp = mp->GetObject<PeerManagementProtocol> ();
|
||||
NS_ASSERT(pmp != 0);
|
||||
NS_ASSERT (pmp != 0);
|
||||
pmp->Report (os);
|
||||
}
|
||||
void
|
||||
@@ -94,7 +98,7 @@ Dot11sStack::ResetStats (const Ptr<MeshPointDevice> mp)
|
||||
mp->ResetStats ();
|
||||
|
||||
std::vector<Ptr<NetDevice> > ifaces = mp->GetInterfaces ();
|
||||
for (std::vector<Ptr<NetDevice> >::const_iterator i = ifaces.begin(); i != ifaces.end(); ++i)
|
||||
for (std::vector<Ptr<NetDevice> >::const_iterator i = ifaces.begin (); i != ifaces.end (); ++i)
|
||||
{
|
||||
Ptr<WifiNetDevice> device = (*i)->GetObject<WifiNetDevice> ();
|
||||
NS_ASSERT (device != 0);
|
||||
|
||||
@@ -132,11 +132,17 @@ MeshHeader::Serialize (Buffer::Iterator start) const
|
||||
uint8_t addresses_to_add = GetAddressExt ();
|
||||
//Writing Address extensions:
|
||||
if ((addresses_to_add == 1) || (addresses_to_add == 3))
|
||||
WriteTo (i, m_addr4);
|
||||
{
|
||||
WriteTo (i, m_addr4);
|
||||
}
|
||||
if (addresses_to_add > 1)
|
||||
WriteTo (i, m_addr5);
|
||||
{
|
||||
WriteTo (i, m_addr5);
|
||||
}
|
||||
if (addresses_to_add > 1)
|
||||
WriteTo (i, m_addr6);
|
||||
{
|
||||
WriteTo (i, m_addr6);
|
||||
}
|
||||
}
|
||||
uint32_t
|
||||
MeshHeader::Deserialize (Buffer::Iterator start)
|
||||
@@ -148,11 +154,17 @@ MeshHeader::Deserialize (Buffer::Iterator start)
|
||||
m_meshSeqno = i.ReadLsbtohU32 ();
|
||||
addresses_to_read = m_meshFlags & 0x03;
|
||||
if ((addresses_to_read == 1) || (addresses_to_read == 3))
|
||||
ReadFrom (i, m_addr4);
|
||||
{
|
||||
ReadFrom (i, m_addr4);
|
||||
}
|
||||
if (addresses_to_read > 1)
|
||||
ReadFrom (i, m_addr5);
|
||||
{
|
||||
ReadFrom (i, m_addr5);
|
||||
}
|
||||
if (addresses_to_read > 1)
|
||||
ReadFrom (i, m_addr6);
|
||||
{
|
||||
ReadFrom (i, m_addr6);
|
||||
}
|
||||
return i.GetDistanceFrom (start);
|
||||
}
|
||||
void
|
||||
@@ -319,7 +331,7 @@ WifiMeshActionHeader::Deserialize (Buffer::Iterator start)
|
||||
struct Dot11sMacHeaderBist : public Test
|
||||
{
|
||||
Dot11sMacHeaderBist () : Test ("Mesh/802.11s/MeshHeader") {}
|
||||
virtual bool RunTests();
|
||||
virtual bool RunTests ();
|
||||
};
|
||||
|
||||
/// Test instance
|
||||
@@ -330,10 +342,10 @@ bool Dot11sMacHeaderBist::RunTests ()
|
||||
bool result (true);
|
||||
{
|
||||
MeshHeader a;
|
||||
a.SetAddressExt(3);
|
||||
a.SetAddr4(Mac48Address ("11:22:33:44:55:66"));
|
||||
a.SetAddr5(Mac48Address ("11:00:33:00:55:00"));
|
||||
a.SetAddr6(Mac48Address ("00:22:00:44:00:66"));
|
||||
a.SetAddressExt (3);
|
||||
a.SetAddr4 (Mac48Address ("11:22:33:44:55:66"));
|
||||
a.SetAddr5 (Mac48Address ("11:00:33:00:55:00"));
|
||||
a.SetAddr6 (Mac48Address ("00:22:00:44:00:66"));
|
||||
a.SetMeshTtl (122);
|
||||
a.SetMeshSeqno (321);
|
||||
Ptr<Packet> packet = Create<Packet> ();
|
||||
@@ -344,9 +356,9 @@ bool Dot11sMacHeaderBist::RunTests ()
|
||||
}
|
||||
{
|
||||
MeshHeader a;
|
||||
a.SetAddressExt(2);
|
||||
a.SetAddr5(Mac48Address ("11:00:33:00:55:00"));
|
||||
a.SetAddr6(Mac48Address ("00:22:00:44:00:66"));
|
||||
a.SetAddressExt (2);
|
||||
a.SetAddr5 (Mac48Address ("11:00:33:00:55:00"));
|
||||
a.SetAddr6 (Mac48Address ("00:22:00:44:00:66"));
|
||||
a.SetMeshTtl (122);
|
||||
a.SetMeshSeqno (321);
|
||||
Ptr<Packet> packet = Create<Packet> ();
|
||||
@@ -357,8 +369,8 @@ bool Dot11sMacHeaderBist::RunTests ()
|
||||
}
|
||||
{
|
||||
MeshHeader a;
|
||||
a.SetAddressExt(1);
|
||||
a.SetAddr4(Mac48Address ("11:22:33:44:55:66"));
|
||||
a.SetAddressExt (1);
|
||||
a.SetAddr4 (Mac48Address ("11:22:33:44:55:66"));
|
||||
a.SetMeshTtl (122);
|
||||
a.SetMeshSeqno (321);
|
||||
Ptr<Packet> packet = Create<Packet> ();
|
||||
|
||||
@@ -204,18 +204,20 @@ HwmpProtocol::RequestRoute (
|
||||
if (sourceIface == GetMeshPoint ()->GetIfIndex())
|
||||
// packet from level 3
|
||||
{
|
||||
if(packet->PeekPacketTag(tag))
|
||||
if (packet->PeekPacketTag(tag))
|
||||
{
|
||||
NS_FATAL_ERROR ("HWMP tag has come with a packet from upper layer. This must not occur...");
|
||||
}
|
||||
//Filling TAG:
|
||||
if(destination == Mac48Address::GetBroadcast ())
|
||||
tag.SetSeqno (m_dataSeqno++);
|
||||
if (destination == Mac48Address::GetBroadcast ())
|
||||
{
|
||||
tag.SetSeqno (m_dataSeqno++);
|
||||
}
|
||||
tag.SetTtl (m_maxTtl);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!packet->RemovePacketTag(tag))
|
||||
if (!packet->RemovePacketTag(tag))
|
||||
{
|
||||
NS_FATAL_ERROR ("HWMP tag is supposed to be here at this point.");
|
||||
}
|
||||
@@ -232,14 +234,20 @@ HwmpProtocol::RequestRoute (
|
||||
m_stats.txBytes += packet->GetSize ();
|
||||
//channel IDs where we have already sent broadcast:
|
||||
std::vector<uint16_t> channels;
|
||||
for(HwmpProtocolMacMap::const_iterator plugin = m_interfaces.begin (); plugin != m_interfaces.end (); plugin ++)
|
||||
for (HwmpProtocolMacMap::const_iterator plugin = m_interfaces.begin (); plugin != m_interfaces.end (); plugin ++)
|
||||
{
|
||||
bool should_send = true;
|
||||
for(std::vector<uint16_t>::const_iterator chan = channels.begin(); chan != channels.end(); chan ++)
|
||||
if( (*chan) == plugin->second->GetChannelId ())
|
||||
should_send = false;
|
||||
if(!should_send)
|
||||
continue;
|
||||
for (std::vector<uint16_t>::const_iterator chan = channels.begin(); chan != channels.end(); chan ++)
|
||||
{
|
||||
if ((*chan) == plugin->second->GetChannelId ())
|
||||
{
|
||||
should_send = false;
|
||||
}
|
||||
}
|
||||
if (!should_send)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
channels.push_back(plugin->second->GetChannelId ());
|
||||
std::vector<Mac48Address> receivers = GetBroadcastReceivers (plugin->first);
|
||||
for (std::vector<Mac48Address>::const_iterator i = receivers.begin (); i != receivers.end(); i ++)
|
||||
@@ -252,7 +260,9 @@ HwmpProtocol::RequestRoute (
|
||||
}
|
||||
}
|
||||
else
|
||||
return ForwardUnicast(sourceIface, source, destination, packet, protocolType, routeReply, tag.GetTtl ());
|
||||
{
|
||||
return ForwardUnicast (sourceIface, source, destination, packet, protocolType, routeReply, tag.GetTtl ());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
bool
|
||||
@@ -260,27 +270,29 @@ HwmpProtocol::RemoveRoutingStuff (uint32_t fromIface, const Mac48Address source,
|
||||
const Mac48Address destination, Ptr<Packet> packet, uint16_t& protocolType)
|
||||
{
|
||||
HwmpTag tag;
|
||||
if(!packet->RemovePacketTag (tag))
|
||||
if (!packet->RemovePacketTag (tag))
|
||||
{
|
||||
NS_FATAL_ERROR ("HWMP tag must exist when packet received from the network");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
bool
|
||||
HwmpProtocol::ForwardUnicast(uint32_t sourceIface, const Mac48Address source, const Mac48Address destination,
|
||||
HwmpProtocol::ForwardUnicast (uint32_t sourceIface, const Mac48Address source, const Mac48Address destination,
|
||||
Ptr<Packet> packet, uint16_t protocolType, RouteReplyCallback routeReply, uint32_t ttl)
|
||||
{
|
||||
NS_ASSERT(destination != Mac48Address::GetBroadcast ());
|
||||
HwmpRtable::LookupResult result = m_rtable->LookupReactive(destination);
|
||||
NS_LOG_DEBUG("Requested src = "<<source<<", dst = "<<destination<<", I am "<<GetAddress ()<<", RA = "<<result.retransmitter);
|
||||
if(result.retransmitter == Mac48Address::GetBroadcast ())
|
||||
result = m_rtable->LookupProactive ();
|
||||
if (result.retransmitter == Mac48Address::GetBroadcast ())
|
||||
{
|
||||
result = m_rtable->LookupProactive ();
|
||||
}
|
||||
HwmpTag tag;
|
||||
tag.SetAddress (result.retransmitter);
|
||||
tag.SetTtl (ttl);
|
||||
//seqno and metric is not used;
|
||||
packet->AddPacketTag(tag);
|
||||
if(result.retransmitter != Mac48Address::GetBroadcast ())
|
||||
packet->AddPacketTag (tag);
|
||||
if (result.retransmitter != Mac48Address::GetBroadcast ())
|
||||
{
|
||||
//reply immediately:
|
||||
routeReply (true, packet, source, destination, protocolType, result.ifIndex);
|
||||
@@ -288,7 +300,7 @@ HwmpProtocol::ForwardUnicast(uint32_t sourceIface, const Mac48Address source, c
|
||||
m_stats.txBytes += packet->GetSize ();
|
||||
return true;
|
||||
}
|
||||
if (sourceIface != GetMeshPoint ()->GetIfIndex())
|
||||
if (sourceIface != GetMeshPoint ()->GetIfIndex ())
|
||||
{
|
||||
//Start path error procedure:
|
||||
NS_LOG_DEBUG ("Must Send PERR");
|
||||
@@ -298,27 +310,33 @@ HwmpProtocol::ForwardUnicast(uint32_t sourceIface, const Mac48Address source, c
|
||||
//2. If there was no reactive path, we lookup expired proactive
|
||||
// path. If exist - start path error procedure towards path to
|
||||
// root
|
||||
if(result.retransmitter == Mac48Address::GetBroadcast ())
|
||||
result = m_rtable->LookupProactiveExpired ();
|
||||
if(result.retransmitter != Mac48Address::GetBroadcast ())
|
||||
{
|
||||
std::vector<IePerr::FailedDestination> destinations = m_rtable->GetUnreachableDestinations (result.retransmitter);
|
||||
InitiatePathError (MakePathError (destinations));
|
||||
}
|
||||
if (result.retransmitter == Mac48Address::GetBroadcast ())
|
||||
{
|
||||
result = m_rtable->LookupProactiveExpired ();
|
||||
}
|
||||
if (result.retransmitter != Mac48Address::GetBroadcast ())
|
||||
{
|
||||
std::vector<IePerr::FailedDestination> destinations = m_rtable->GetUnreachableDestinations (result.retransmitter);
|
||||
InitiatePathError (MakePathError (destinations));
|
||||
}
|
||||
m_stats.totalDropped ++;
|
||||
return false;
|
||||
}
|
||||
//Request a destination:
|
||||
result = m_rtable->LookupReactiveExpired (destination);
|
||||
if(ShouldSendPreq(destination))
|
||||
if (ShouldSendPreq (destination))
|
||||
{
|
||||
uint32_t originator_seqno = GetNextHwmpSeqno ();
|
||||
uint32_t dst_seqno = 0;
|
||||
if(result.retransmitter != Mac48Address::GetBroadcast ())
|
||||
dst_seqno = result.seqnum;
|
||||
if (result.retransmitter != Mac48Address::GetBroadcast ())
|
||||
{
|
||||
dst_seqno = result.seqnum;
|
||||
}
|
||||
m_stats.initiatedPreq ++;
|
||||
for(HwmpProtocolMacMap::const_iterator i = m_interfaces.begin (); i != m_interfaces.end (); i ++)
|
||||
i->second->RequestDestination(destination, originator_seqno, dst_seqno);
|
||||
for (HwmpProtocolMacMap::const_iterator i = m_interfaces.begin (); i != m_interfaces.end (); i ++)
|
||||
{
|
||||
i->second->RequestDestination(destination, originator_seqno, dst_seqno);
|
||||
}
|
||||
}
|
||||
QueuedPacket pkt;
|
||||
pkt.pkt = packet;
|
||||
@@ -327,7 +345,7 @@ HwmpProtocol::ForwardUnicast(uint32_t sourceIface, const Mac48Address source, c
|
||||
pkt.protocol = protocolType;
|
||||
pkt.reply = routeReply;
|
||||
pkt.inInterface = sourceIface;
|
||||
if(QueuePacket (pkt))
|
||||
if (QueuePacket (pkt))
|
||||
{
|
||||
m_stats.totalQueued ++;
|
||||
return true;
|
||||
@@ -346,25 +364,29 @@ HwmpProtocol::ReceivePreq (IePreq preq, Mac48Address from, uint32_t interface, M
|
||||
std::map<Mac48Address, uint32_t>::const_iterator i = m_lastHwmpSeqno.find (preq.GetOriginatorAddress());
|
||||
if (i == m_lastHwmpSeqno.end ())
|
||||
{
|
||||
m_lastHwmpSeqno[preq.GetOriginatorAddress ()] = preq.GetOriginatorSeqNumber();
|
||||
m_lastHwmpMetric[preq.GetOriginatorAddress ()] = preq.GetMetric();
|
||||
m_lastHwmpSeqno[preq.GetOriginatorAddress ()] = preq.GetOriginatorSeqNumber ();
|
||||
m_lastHwmpMetric[preq.GetOriginatorAddress ()] = preq.GetMetric ();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (i->second > preq.GetOriginatorSeqNumber ())
|
||||
return;
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (i->second == preq.GetOriginatorSeqNumber ())
|
||||
{
|
||||
//find metric
|
||||
std::map<Mac48Address, uint32_t>::const_iterator j = m_lastHwmpMetric.find (preq.GetOriginatorAddress());
|
||||
NS_ASSERT (j != m_lastHwmpSeqno.end());
|
||||
if (j->second <= preq.GetMetric ())
|
||||
return;
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
m_lastHwmpSeqno[preq.GetOriginatorAddress ()] = preq.GetOriginatorSeqNumber();
|
||||
m_lastHwmpMetric[preq.GetOriginatorAddress ()] = preq.GetMetric();
|
||||
m_lastHwmpSeqno[preq.GetOriginatorAddress ()] = preq.GetOriginatorSeqNumber ();
|
||||
m_lastHwmpMetric[preq.GetOriginatorAddress ()] = preq.GetMetric ();
|
||||
}
|
||||
NS_LOG_DEBUG("I am "<<GetAddress ()<<"Accepted preq from address"<<from<<", preq:"<<preq);
|
||||
NS_LOG_DEBUG("I am " << GetAddress () << "Accepted preq from address" << from << ", preq:" << preq);
|
||||
std::vector<Ptr<DestinationAddressUnit> > destinations = preq.GetDestinationList ();
|
||||
//Add reactive path to originator:
|
||||
if (
|
||||
@@ -377,15 +399,15 @@ HwmpProtocol::ReceivePreq (IePreq preq, Mac48Address from, uint32_t interface, M
|
||||
from,
|
||||
interface,
|
||||
preq.GetMetric (),
|
||||
MicroSeconds (preq.GetLifetime () *1024),
|
||||
MicroSeconds (preq.GetLifetime () * 1024),
|
||||
preq.GetOriginatorSeqNumber ()
|
||||
);
|
||||
ReactivePathResolved (preq.GetOriginatorAddress ());
|
||||
}
|
||||
//Add reactive path for precursor:
|
||||
if (
|
||||
((m_rtable->LookupReactive(fromMp)).retransmitter == Mac48Address::GetBroadcast ()) ||
|
||||
((m_rtable->LookupReactive(fromMp)).metric > preq.GetMetric ())
|
||||
((m_rtable->LookupReactive (fromMp)).retransmitter == Mac48Address::GetBroadcast ()) ||
|
||||
((m_rtable->LookupReactive (fromMp)).metric > preq.GetMetric ())
|
||||
)
|
||||
{
|
||||
m_rtable->AddReactivePath (
|
||||
@@ -393,12 +415,12 @@ HwmpProtocol::ReceivePreq (IePreq preq, Mac48Address from, uint32_t interface, M
|
||||
from,
|
||||
interface,
|
||||
metric,
|
||||
MicroSeconds (preq.GetLifetime () *1024),
|
||||
MicroSeconds (preq.GetLifetime () * 1024),
|
||||
preq.GetOriginatorSeqNumber ()
|
||||
);
|
||||
ReactivePathResolved (fromMp);
|
||||
}
|
||||
for (std::vector<Ptr<DestinationAddressUnit> >::const_iterator i = destinations.begin (); i != destinations.end(); i++)
|
||||
for (std::vector<Ptr<DestinationAddressUnit> >::const_iterator i = destinations.begin (); i != destinations.end (); i++)
|
||||
{
|
||||
if ((*i)->GetDestinationAddress () == Mac48Address::GetBroadcast())
|
||||
{
|
||||
@@ -414,16 +436,19 @@ HwmpProtocol::ReceivePreq (IePreq preq, Mac48Address from, uint32_t interface, M
|
||||
((m_rtable->LookupProactive ()).retransmitter == Mac48Address::GetBroadcast ()) ||
|
||||
((m_rtable->LookupProactive ()).metric > preq.GetMetric ())
|
||||
)
|
||||
m_rtable->AddProactivePath (
|
||||
preq.GetMetric (),
|
||||
preq.GetOriginatorAddress (),
|
||||
from,
|
||||
interface,
|
||||
MicroSeconds (preq.GetLifetime () * 1024),
|
||||
preq.GetOriginatorSeqNumber ()
|
||||
);
|
||||
ProactivePathResolved ();
|
||||
{
|
||||
m_rtable->AddProactivePath (
|
||||
preq.GetMetric (),
|
||||
preq.GetOriginatorAddress (),
|
||||
from,
|
||||
interface,
|
||||
MicroSeconds (preq.GetLifetime () * 1024),
|
||||
preq.GetOriginatorSeqNumber ()
|
||||
);
|
||||
ProactivePathResolved ();
|
||||
}
|
||||
if (!preq.IsNeedNotPrep ())
|
||||
{
|
||||
SendPrep (
|
||||
GetAddress (),
|
||||
preq.GetOriginatorAddress (),
|
||||
@@ -434,6 +459,7 @@ HwmpProtocol::ReceivePreq (IePreq preq, Mac48Address from, uint32_t interface, M
|
||||
preq.GetLifetime (),
|
||||
interface
|
||||
);
|
||||
}
|
||||
break;
|
||||
}
|
||||
if ((*i)->GetDestinationAddress () == GetAddress ())
|
||||
@@ -449,12 +475,12 @@ HwmpProtocol::ReceivePreq (IePreq preq, Mac48Address from, uint32_t interface, M
|
||||
interface
|
||||
);
|
||||
NS_ASSERT(m_rtable->LookupReactive (preq.GetOriginatorAddress ()).retransmitter != Mac48Address::GetBroadcast ());
|
||||
preq.DelDestinationAddressElement ((*i)->GetDestinationAddress());
|
||||
preq.DelDestinationAddressElement ((*i)->GetDestinationAddress ());
|
||||
continue;
|
||||
}
|
||||
//check if can answer:
|
||||
HwmpRtable::LookupResult result = m_rtable->LookupReactive ((*i)->GetDestinationAddress());
|
||||
if ((! ((*i)->IsDo())) && (result.retransmitter != Mac48Address::GetBroadcast()))
|
||||
HwmpRtable::LookupResult result = m_rtable->LookupReactive ((*i)->GetDestinationAddress ());
|
||||
if ((! ((*i)->IsDo())) && (result.retransmitter != Mac48Address::GetBroadcast ()))
|
||||
{
|
||||
//have a valid information and can answer
|
||||
//!NB: If there is information from peer - set lifetime as
|
||||
@@ -462,58 +488,70 @@ HwmpProtocol::ReceivePreq (IePreq preq, Mac48Address from, uint32_t interface, M
|
||||
//route if the information is correct
|
||||
uint32_t lifetime = result.lifetime.GetMicroSeconds () / 1024;
|
||||
if(lifetime > 0)
|
||||
SendPrep (
|
||||
(*i)->GetDestinationAddress (),
|
||||
preq.GetOriginatorAddress (),
|
||||
from,
|
||||
result.metric,
|
||||
preq.GetOriginatorSeqNumber (),
|
||||
result.seqnum +1,
|
||||
lifetime,
|
||||
interface
|
||||
);
|
||||
{
|
||||
SendPrep (
|
||||
(*i)->GetDestinationAddress (),
|
||||
preq.GetOriginatorAddress (),
|
||||
from,
|
||||
result.metric,
|
||||
preq.GetOriginatorSeqNumber (),
|
||||
result.seqnum +1,
|
||||
lifetime,
|
||||
interface
|
||||
);
|
||||
}
|
||||
if ((*i)->IsRf ())
|
||||
(*i)->SetFlags (true, false, (*i)->IsUsn ()); //DO = 1, RF = 0
|
||||
{
|
||||
(*i)->SetFlags (true, false, (*i)->IsUsn ()); //DO = 1, RF = 0
|
||||
}
|
||||
else
|
||||
{
|
||||
preq.DelDestinationAddressElement ((*i)->GetDestinationAddress());
|
||||
preq.DelDestinationAddressElement ((*i)->GetDestinationAddress ());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
//check if must retransmit:
|
||||
if (preq.GetDestCount () == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
//Forward PREQ to all interfaces:
|
||||
NS_LOG_DEBUG("I am "<<GetAddress ()<<"retransmitting PREQ:"<<preq);
|
||||
for(HwmpProtocolMacMap::const_iterator i = m_interfaces.begin (); i != m_interfaces.end (); i ++)
|
||||
i->second->SendPreq (preq);
|
||||
NS_LOG_DEBUG("I am " << GetAddress () << "retransmitting PREQ:" << preq);
|
||||
for (HwmpProtocolMacMap::const_iterator i = m_interfaces.begin (); i != m_interfaces.end (); i ++)
|
||||
{
|
||||
i->second->SendPreq (preq);
|
||||
}
|
||||
}
|
||||
void
|
||||
HwmpProtocol::ReceivePrep (IePrep prep, Mac48Address from, uint32_t interface, Mac48Address fromMp, uint32_t metric)
|
||||
{
|
||||
prep.IncrementMetric (metric);
|
||||
//acceptance cretirea:
|
||||
std::map<Mac48Address, uint32_t>::const_iterator i = m_lastHwmpSeqno.find (prep.GetOriginatorAddress());
|
||||
std::map<Mac48Address, uint32_t>::const_iterator i = m_lastHwmpSeqno.find (prep.GetOriginatorAddress ());
|
||||
if (i == m_lastHwmpSeqno.end ())
|
||||
{
|
||||
m_lastHwmpSeqno[prep.GetOriginatorAddress ()] = prep.GetOriginatorSeqNumber();
|
||||
m_lastHwmpSeqno[prep.GetOriginatorAddress ()] = prep.GetOriginatorSeqNumber ();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (i->second > prep.GetOriginatorSeqNumber ())
|
||||
return;
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
m_lastHwmpSeqno[prep.GetOriginatorAddress ()] = prep.GetOriginatorSeqNumber();
|
||||
{
|
||||
m_lastHwmpSeqno[prep.GetOriginatorAddress ()] = prep.GetOriginatorSeqNumber ();
|
||||
}
|
||||
}
|
||||
//update routing info
|
||||
//Now add a path to destination and add precursor to source
|
||||
NS_LOG_DEBUG("I am "<<GetAddress ()<<", received prep from "<<prep.GetOriginatorAddress ()<<", receiver was:"<<from);
|
||||
HwmpRtable::LookupResult result = m_rtable->LookupReactive(prep.GetDestinationAddress());
|
||||
NS_LOG_DEBUG("I am " << GetAddress () << ", received prep from " << prep.GetOriginatorAddress () << ", receiver was:" << from);
|
||||
HwmpRtable::LookupResult result = m_rtable->LookupReactive(prep.GetDestinationAddress ());
|
||||
//Add a reactive path only if it is better than existing:
|
||||
if (
|
||||
((m_rtable->LookupReactive(prep.GetOriginatorAddress ())).retransmitter == Mac48Address::GetBroadcast ()) ||
|
||||
((m_rtable->LookupReactive(prep.GetOriginatorAddress ())).metric > prep.GetMetric ())
|
||||
((m_rtable->LookupReactive (prep.GetOriginatorAddress ())).retransmitter == Mac48Address::GetBroadcast ()) ||
|
||||
((m_rtable->LookupReactive (prep.GetOriginatorAddress ())).metric > prep.GetMetric ())
|
||||
)
|
||||
{
|
||||
m_rtable->AddReactivePath (
|
||||
@@ -524,13 +562,15 @@ HwmpProtocol::ReceivePrep (IePrep prep, Mac48Address from, uint32_t interface, M
|
||||
MicroSeconds(prep.GetLifetime () * 1024),
|
||||
prep.GetOriginatorSeqNumber ());
|
||||
m_rtable->AddPrecursor (prep.GetDestinationAddress (), interface, from);
|
||||
if(result.retransmitter != Mac48Address::GetBroadcast ())
|
||||
m_rtable->AddPrecursor (prep.GetOriginatorAddress (), interface, result.retransmitter);
|
||||
if (result.retransmitter != Mac48Address::GetBroadcast ())
|
||||
{
|
||||
m_rtable->AddPrecursor (prep.GetOriginatorAddress (), interface, result.retransmitter);
|
||||
}
|
||||
ReactivePathResolved (prep.GetOriginatorAddress ());
|
||||
}
|
||||
if (
|
||||
((m_rtable->LookupReactive(fromMp)).retransmitter == Mac48Address::GetBroadcast ()) ||
|
||||
((m_rtable->LookupReactive(fromMp)).metric > prep.GetMetric ())
|
||||
((m_rtable->LookupReactive (fromMp)).retransmitter == Mac48Address::GetBroadcast ()) ||
|
||||
((m_rtable->LookupReactive (fromMp)).metric > prep.GetMetric ())
|
||||
)
|
||||
{
|
||||
m_rtable->AddReactivePath (
|
||||
@@ -548,13 +588,17 @@ HwmpProtocol::ReceivePrep (IePrep prep, Mac48Address from, uint32_t interface, M
|
||||
return;
|
||||
}
|
||||
if (result.retransmitter == Mac48Address::GetBroadcast ())
|
||||
//try to look for default route
|
||||
result = m_rtable->LookupProactive ();
|
||||
{
|
||||
//try to look for default route
|
||||
result = m_rtable->LookupProactive ();
|
||||
}
|
||||
if (result.retransmitter == Mac48Address::GetBroadcast ())
|
||||
return;
|
||||
{
|
||||
return;
|
||||
}
|
||||
//Forward PREP
|
||||
HwmpProtocolMacMap::const_iterator prep_sender = m_interfaces.find (result.ifIndex);
|
||||
NS_ASSERT(prep_sender != m_interfaces.end ());
|
||||
NS_ASSERT (prep_sender != m_interfaces.end ());
|
||||
prep_sender->second->SendPrep (prep, result.retransmitter);
|
||||
}
|
||||
void
|
||||
@@ -572,10 +616,14 @@ HwmpProtocol::ReceivePerr (std::vector<IePerr::FailedDestination> destinations,
|
||||
(result.ifIndex != interface) ||
|
||||
(result.seqnum > destinations[i].seqnum)
|
||||
))
|
||||
{
|
||||
retval.push_back(destinations[i]);
|
||||
}
|
||||
}
|
||||
if(retval.size() == 0)
|
||||
return;
|
||||
if (retval.size() == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
ForwardPathError (MakePathError (retval));
|
||||
}
|
||||
void
|
||||
@@ -613,10 +661,14 @@ HwmpProtocol::Install (Ptr<MeshPointDevice> mp)
|
||||
// Checking for compatible net device
|
||||
Ptr<WifiNetDevice> wifiNetDev = (*i)->GetObject<WifiNetDevice> ();
|
||||
if (wifiNetDev == 0)
|
||||
return false;
|
||||
{
|
||||
return false;
|
||||
}
|
||||
Ptr<MeshWifiInterfaceMac> mac = wifiNetDev->GetMac ()->GetObject<MeshWifiInterfaceMac> ();
|
||||
if (mac == 0)
|
||||
return false;
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// Installing plugins:
|
||||
Ptr<HwmpProtocolMac> hwmpMac = Create<HwmpProtocolMac> (wifiNetDev->GetIfIndex (), this);
|
||||
m_interfaces[wifiNetDev->GetIfIndex ()] = hwmpMac;
|
||||
@@ -628,14 +680,16 @@ HwmpProtocol::Install (Ptr<MeshPointDevice> mp)
|
||||
mp->SetRoutingProtocol (this);
|
||||
// Mesh point aggregates all installed protocols
|
||||
mp->AggregateObject (this);
|
||||
m_address = Mac48Address::ConvertFrom (mp->GetAddress ());//* address;
|
||||
m_address = Mac48Address::ConvertFrom (mp->GetAddress ());// address;
|
||||
return true;
|
||||
}
|
||||
void
|
||||
HwmpProtocol::PeerLinkStatus(Mac48Address meshPointAddress, Mac48Address peerAddress, uint32_t interface, bool status)
|
||||
{
|
||||
if(status)
|
||||
return;
|
||||
if (status)
|
||||
{
|
||||
return;
|
||||
}
|
||||
std::vector<IePerr::FailedDestination> destinations = m_rtable->GetUnreachableDestinations (peerAddress);
|
||||
InitiatePathError (MakePathError (destinations));
|
||||
}
|
||||
@@ -647,15 +701,21 @@ HwmpProtocol::SetNeighboursCallback(Callback<std::vector<Mac48Address>, uint32_t
|
||||
bool
|
||||
HwmpProtocol::DropDataFrame(uint32_t seqno, Mac48Address source)
|
||||
{
|
||||
if(source == GetAddress ())
|
||||
return true;
|
||||
if (source == GetAddress ())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
std::map<Mac48Address, uint32_t,std::less<Mac48Address> >::const_iterator i = m_lastDataSeqno.find (source);
|
||||
if (i == m_lastDataSeqno.end ())
|
||||
m_lastDataSeqno[source] = seqno;
|
||||
{
|
||||
m_lastDataSeqno[source] = seqno;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (i->second >= seqno)
|
||||
return true;
|
||||
{
|
||||
return true;
|
||||
}
|
||||
m_lastDataSeqno[source] = seqno;
|
||||
}
|
||||
return false;
|
||||
@@ -666,10 +726,12 @@ HwmpProtocol::MakePathError (std::vector<IePerr::FailedDestination> destinations
|
||||
PathError retval;
|
||||
//HwmpRtable increments a sequence number as written in 11B.9.7.2
|
||||
retval.receivers = GetPerrReceivers (destinations);
|
||||
if(retval.receivers.size () == 0)
|
||||
return retval;
|
||||
if (retval.receivers.size () == 0)
|
||||
{
|
||||
return retval;
|
||||
}
|
||||
m_stats.initiatedPerr ++;
|
||||
for(unsigned int i = 0; i < destinations.size (); i ++)
|
||||
for (unsigned int i = 0; i < destinations.size (); i ++)
|
||||
{
|
||||
retval.destinations.push_back(destinations[i]);
|
||||
m_rtable->DeleteReactivePath(destinations[i].destination);
|
||||
@@ -679,24 +741,32 @@ HwmpProtocol::MakePathError (std::vector<IePerr::FailedDestination> destinations
|
||||
void
|
||||
HwmpProtocol::InitiatePathError(PathError perr)
|
||||
{
|
||||
for(HwmpProtocolMacMap::const_iterator i = m_interfaces.begin (); i != m_interfaces.end (); i ++)
|
||||
for (HwmpProtocolMacMap::const_iterator i = m_interfaces.begin (); i != m_interfaces.end (); i ++)
|
||||
{
|
||||
std::vector<Mac48Address> receivers_for_interface;
|
||||
for(unsigned int j = 0; j < perr.receivers.size(); j ++)
|
||||
if(i->first == perr.receivers[j].first)
|
||||
receivers_for_interface.push_back(perr.receivers[j].second);
|
||||
{
|
||||
if(i->first == perr.receivers[j].first)
|
||||
{
|
||||
receivers_for_interface.push_back (perr.receivers[j].second);
|
||||
}
|
||||
}
|
||||
i->second->InitiatePerr (perr.destinations, receivers_for_interface);
|
||||
}
|
||||
}
|
||||
void
|
||||
HwmpProtocol::ForwardPathError(PathError perr)
|
||||
{
|
||||
for(HwmpProtocolMacMap::const_iterator i = m_interfaces.begin (); i != m_interfaces.end (); i ++)
|
||||
for (HwmpProtocolMacMap::const_iterator i = m_interfaces.begin (); i != m_interfaces.end (); i ++)
|
||||
{
|
||||
std::vector<Mac48Address> receivers_for_interface;
|
||||
for(unsigned int j = 0; j < perr.receivers.size(); j ++)
|
||||
if(i->first == perr.receivers[j].first)
|
||||
receivers_for_interface.push_back(perr.receivers[j].second);
|
||||
for (unsigned int j = 0; j < perr.receivers.size(); j ++)
|
||||
{
|
||||
if (i->first == perr.receivers[j].first)
|
||||
{
|
||||
receivers_for_interface.push_back(perr.receivers[j].second);
|
||||
}
|
||||
}
|
||||
i->second->ForwardPerr (perr.destinations, receivers_for_interface);
|
||||
}
|
||||
}
|
||||
@@ -707,25 +777,35 @@ HwmpProtocol::GetPerrReceivers (std::vector<IePerr::FailedDestination> failedDes
|
||||
HwmpRtable::PrecursorList retval;
|
||||
for (unsigned int i = 0; i < failedDest.size (); i ++)
|
||||
{
|
||||
HwmpRtable::PrecursorList precursors = m_rtable->GetPrecursors(failedDest[i].destination);
|
||||
HwmpRtable::PrecursorList precursors = m_rtable->GetPrecursors (failedDest[i].destination);
|
||||
m_rtable->DeleteReactivePath (failedDest[i].destination);
|
||||
m_rtable->DeleteProactivePath(failedDest[i].destination);
|
||||
for (unsigned int j = 0; j < precursors.size (); j ++)
|
||||
retval.push_back(precursors[j]);
|
||||
{
|
||||
retval.push_back(precursors[j]);
|
||||
}
|
||||
}
|
||||
//Check if we have dublicates in retval and precursors:
|
||||
for (unsigned int i = 0; i < retval.size(); i ++)
|
||||
for (unsigned int j = i+1; j < retval.size(); j ++)
|
||||
if(retval[i].second == retval[j].second)
|
||||
retval.erase(retval.begin() + j);
|
||||
for (unsigned int i = 0; i < retval.size (); i ++)
|
||||
{
|
||||
for (unsigned int j = i+1; j < retval.size (); j ++)
|
||||
{
|
||||
if (retval[i].second == retval[j].second)
|
||||
{
|
||||
retval.erase(retval.begin() + j);
|
||||
}
|
||||
}
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
std::vector<Mac48Address>
|
||||
HwmpProtocol::GetPreqReceivers (uint32_t interface)
|
||||
{
|
||||
std::vector<Mac48Address> retval;
|
||||
if(!m_neighboursCallback.IsNull ())
|
||||
retval = m_neighboursCallback (interface);
|
||||
if (!m_neighboursCallback.IsNull ())
|
||||
{
|
||||
retval = m_neighboursCallback (interface);
|
||||
}
|
||||
if ((retval.size() >= m_unicastPreqThreshold) || (retval.size () == 0))
|
||||
{
|
||||
retval.clear ();
|
||||
@@ -737,8 +817,10 @@ std::vector<Mac48Address>
|
||||
HwmpProtocol::GetBroadcastReceivers (uint32_t interface)
|
||||
{
|
||||
std::vector<Mac48Address> retval;
|
||||
if(!m_neighboursCallback.IsNull ())
|
||||
retval = m_neighboursCallback (interface);
|
||||
if (!m_neighboursCallback.IsNull ())
|
||||
{
|
||||
retval = m_neighboursCallback (interface);
|
||||
}
|
||||
if ((retval.size() >= m_unicastDataThreshold) || (retval.size () == 0))
|
||||
{
|
||||
retval.clear ();
|
||||
@@ -751,7 +833,9 @@ bool
|
||||
HwmpProtocol::QueuePacket (QueuedPacket packet)
|
||||
{
|
||||
if (m_rqueue.size () > m_maxQueueSize)
|
||||
return false;
|
||||
{
|
||||
return false;
|
||||
}
|
||||
m_rqueue.push_back (packet);
|
||||
return true;
|
||||
}
|
||||
@@ -761,12 +845,14 @@ HwmpProtocol::DequeueFirstPacketByDst (Mac48Address dst)
|
||||
{
|
||||
QueuedPacket retval;
|
||||
retval.pkt = 0;
|
||||
for(std::vector<QueuedPacket>::iterator i = m_rqueue.begin (); i != m_rqueue.end (); i++)
|
||||
if((*i).dst == dst)
|
||||
for (std::vector<QueuedPacket>::iterator i = m_rqueue.begin (); i != m_rqueue.end (); i++)
|
||||
{
|
||||
retval = (*i);
|
||||
m_rqueue.erase (i);
|
||||
break;
|
||||
if ((*i).dst == dst)
|
||||
{
|
||||
retval = (*i);
|
||||
m_rqueue.erase (i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
@@ -776,7 +862,7 @@ HwmpProtocol::DequeueFirstPacket ()
|
||||
{
|
||||
QueuedPacket retval;
|
||||
retval.pkt = 0;
|
||||
if(m_rqueue.size () != 0)
|
||||
if (m_rqueue.size () != 0)
|
||||
{
|
||||
retval = m_rqueue[0];
|
||||
m_rqueue.erase (m_rqueue.begin ());
|
||||
@@ -795,7 +881,7 @@ HwmpProtocol::ReactivePathResolved (Mac48Address dst)
|
||||
{
|
||||
//set RA tag for retransmitter:
|
||||
HwmpTag tag;
|
||||
packet.pkt->RemovePacketTag(tag);
|
||||
packet.pkt->RemovePacketTag (tag);
|
||||
tag.SetAddress (result.retransmitter);
|
||||
packet.pkt->AddPacketTag (tag);
|
||||
m_stats.txUnicast ++;
|
||||
@@ -810,13 +896,13 @@ HwmpProtocol::ProactivePathResolved ()
|
||||
{
|
||||
//send all packets to root
|
||||
HwmpRtable::LookupResult result = m_rtable->LookupProactive ();
|
||||
NS_ASSERT(result.retransmitter != Mac48Address::GetBroadcast ());
|
||||
NS_ASSERT (result.retransmitter != Mac48Address::GetBroadcast ());
|
||||
QueuedPacket packet = DequeueFirstPacket ();
|
||||
while (packet.pkt != 0)
|
||||
{
|
||||
//set RA tag for retransmitter:
|
||||
HwmpTag tag;
|
||||
if(!packet.pkt->RemovePacketTag (tag))
|
||||
if (!packet.pkt->RemovePacketTag (tag))
|
||||
{
|
||||
NS_FATAL_ERROR ("HWMP tag must be present at this point");
|
||||
}
|
||||
@@ -847,8 +933,10 @@ void
|
||||
HwmpProtocol::RetryPathDiscovery (Mac48Address dst, uint8_t numOfRetry)
|
||||
{
|
||||
HwmpRtable::LookupResult result = m_rtable->LookupReactive (dst);
|
||||
if(result.retransmitter == Mac48Address::GetBroadcast ())
|
||||
result = m_rtable->LookupProactive ();
|
||||
if (result.retransmitter == Mac48Address::GetBroadcast ())
|
||||
{
|
||||
result = m_rtable->LookupProactive ();
|
||||
}
|
||||
if (result.retransmitter != Mac48Address::GetBroadcast ())
|
||||
{
|
||||
std::map<Mac48Address, EventId>::iterator i = m_preqTimeouts.find (dst);
|
||||
@@ -868,16 +956,20 @@ HwmpProtocol::RetryPathDiscovery (Mac48Address dst, uint8_t numOfRetry)
|
||||
packet = DequeueFirstPacketByDst (dst);
|
||||
}
|
||||
std::map<Mac48Address, EventId>::iterator i = m_preqTimeouts.find (dst);
|
||||
NS_ASSERT (i != m_preqTimeouts.end());
|
||||
NS_ASSERT (i != m_preqTimeouts.end ());
|
||||
m_preqTimeouts.erase (i);
|
||||
return;
|
||||
}
|
||||
uint32_t originator_seqno = GetNextHwmpSeqno ();
|
||||
uint32_t dst_seqno = 0;
|
||||
if(result.retransmitter != Mac48Address::GetBroadcast ())
|
||||
dst_seqno = result.seqnum;
|
||||
for(HwmpProtocolMacMap::const_iterator i = m_interfaces.begin (); i != m_interfaces.end (); i ++)
|
||||
i->second->RequestDestination(dst, originator_seqno, dst_seqno);
|
||||
if (result.retransmitter != Mac48Address::GetBroadcast ())
|
||||
{
|
||||
dst_seqno = result.seqnum;
|
||||
}
|
||||
for (HwmpProtocolMacMap::const_iterator i = m_interfaces.begin (); i != m_interfaces.end (); i ++)
|
||||
{
|
||||
i->second->RequestDestination(dst, originator_seqno, dst_seqno);
|
||||
}
|
||||
m_preqTimeouts[dst] = Simulator::Schedule (
|
||||
MilliSeconds (2*(m_dot11MeshHWMPnetDiameterTraversalTime.GetMilliSeconds())),
|
||||
&HwmpProtocol::RetryPathDiscovery, this, dst, numOfRetry);
|
||||
@@ -889,7 +981,7 @@ HwmpProtocol::SetRoot ()
|
||||
UniformVariable coefficient (0.0, m_randomStart.GetSeconds());
|
||||
Time randomStart = Seconds (coefficient.GetValue());
|
||||
m_proactivePreqTimer = Simulator::Schedule (randomStart, &HwmpProtocol::SendProactivePreq, this);
|
||||
NS_LOG_UNCOND("ROOT IS: "<<m_address);
|
||||
NS_LOG_DEBUG ("ROOT IS: " << m_address);
|
||||
SendProactivePreq ();
|
||||
m_isRoot = true;
|
||||
}
|
||||
@@ -909,11 +1001,13 @@ HwmpProtocol::SendProactivePreq ()
|
||||
//\attention: do not forget to set originator address, sequence
|
||||
//number and preq ID in HWMP-MAC plugin
|
||||
preq.AddDestinationAddressElement (true, true, Mac48Address::GetBroadcast (), 0);
|
||||
preq.SetOriginatorAddress(GetAddress ());
|
||||
preq.SetOriginatorAddress (GetAddress ());
|
||||
preq.SetPreqID (GetNextPreqId ());
|
||||
preq.SetOriginatorSeqNumber (GetNextHwmpSeqno ());
|
||||
for(HwmpProtocolMacMap::const_iterator i = m_interfaces.begin (); i != m_interfaces.end (); i ++)
|
||||
i->second->SendPreq(preq);
|
||||
for (HwmpProtocolMacMap::const_iterator i = m_interfaces.begin (); i != m_interfaces.end (); i ++)
|
||||
{
|
||||
i->second->SendPreq (preq);
|
||||
}
|
||||
m_proactivePreqTimer = Simulator::Schedule (m_dot11MeshHWMPpathToRootInterval, &HwmpProtocol::SendProactivePreq, this);
|
||||
}
|
||||
bool
|
||||
@@ -951,8 +1045,6 @@ uint32_t
|
||||
HwmpProtocol::GetNextHwmpSeqno ()
|
||||
{
|
||||
m_hwmpSeqno ++;
|
||||
if(m_hwmpSeqno == 0xffffffff)
|
||||
m_hwmpSeqno = 1;
|
||||
return m_hwmpSeqno;
|
||||
}
|
||||
uint32_t
|
||||
@@ -1006,9 +1098,9 @@ HwmpProtocol::Report (std::ostream & os) const
|
||||
"doFlag=\"" << m_doFlag << "\"\n"
|
||||
"rfFlag=\"" << m_rfFlag << "\">\n";
|
||||
m_stats.Print (os);
|
||||
for(HwmpProtocolMacMap::const_iterator plugin = m_interfaces.begin (); plugin != m_interfaces.end (); plugin ++)
|
||||
for (HwmpProtocolMacMap::const_iterator plugin = m_interfaces.begin (); plugin != m_interfaces.end (); plugin ++)
|
||||
{
|
||||
plugin->second->Report(os);
|
||||
plugin->second->Report (os);
|
||||
}
|
||||
os << "</Hwmp>\n";
|
||||
}
|
||||
@@ -1016,7 +1108,7 @@ void
|
||||
HwmpProtocol::ResetStats ()
|
||||
{
|
||||
m_stats = Statistics::Statistics ();
|
||||
for(HwmpProtocolMacMap::const_iterator plugin = m_interfaces.begin (); plugin != m_interfaces.end (); plugin ++)
|
||||
for (HwmpProtocolMacMap::const_iterator plugin = m_interfaces.begin (); plugin != m_interfaces.end (); plugin ++)
|
||||
plugin->second->ResetStats ();
|
||||
}
|
||||
|
||||
|
||||
@@ -37,37 +37,31 @@ IeBeaconTimingUnit::IeBeaconTimingUnit ():
|
||||
m_beaconInterval (0)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
IeBeaconTimingUnit::SetAid (uint8_t aid)
|
||||
{
|
||||
m_aid = aid;
|
||||
}
|
||||
|
||||
void
|
||||
IeBeaconTimingUnit::SetLastBeacon (uint16_t lastBeacon)
|
||||
{
|
||||
m_lastBeacon = lastBeacon;
|
||||
}
|
||||
|
||||
void
|
||||
IeBeaconTimingUnit::SetBeaconInterval (uint16_t beaconInterval)
|
||||
{
|
||||
m_beaconInterval = beaconInterval;
|
||||
}
|
||||
|
||||
uint8_t
|
||||
IeBeaconTimingUnit::GetAid () const
|
||||
{
|
||||
return m_aid;
|
||||
}
|
||||
|
||||
uint16_t
|
||||
IeBeaconTimingUnit::GetLastBeacon () const
|
||||
{
|
||||
return m_lastBeacon;
|
||||
}
|
||||
|
||||
uint16_t
|
||||
IeBeaconTimingUnit::GetBeaconInterval () const
|
||||
{
|
||||
@@ -76,17 +70,20 @@ IeBeaconTimingUnit::GetBeaconInterval () const
|
||||
/*******************************************
|
||||
* IeBeaconTiming
|
||||
*******************************************/
|
||||
WifiElementId
|
||||
IeBeaconTiming::ElementId () const
|
||||
{
|
||||
return IE11S_BEACON_TIMING;
|
||||
}
|
||||
IeBeaconTiming::IeBeaconTiming ():
|
||||
m_numOfUnits (0)
|
||||
{
|
||||
}
|
||||
|
||||
IeBeaconTiming::NeighboursTimingUnitsList
|
||||
IeBeaconTiming::GetNeighboursTimingElementsList ()
|
||||
{
|
||||
return m_neighbours;
|
||||
}
|
||||
|
||||
void
|
||||
IeBeaconTiming::AddNeighboursTimingElementUnit (
|
||||
uint16_t aid,
|
||||
@@ -101,15 +98,17 @@ IeBeaconTiming::AddNeighboursTimingElementUnit (
|
||||
}
|
||||
//First we lookup if this element already exists
|
||||
for (NeighboursTimingUnitsList::const_iterator i = m_neighbours.begin (); i != m_neighbours.end(); i++)
|
||||
if (
|
||||
((*i)->GetAid () == AidToU8(aid))
|
||||
&& ((*i)->GetLastBeacon () == TimestampToU16(last_beacon))
|
||||
&& ((*i)->GetBeaconInterval () == BeaconIntervalToU16(beacon_interval))
|
||||
)
|
||||
{
|
||||
NS_LOG_WARN ("Duplicated neighbor timing element is ignored.");
|
||||
return;
|
||||
}
|
||||
{
|
||||
if (
|
||||
((*i)->GetAid () == AidToU8(aid))
|
||||
&& ((*i)->GetLastBeacon () == TimestampToU16(last_beacon))
|
||||
&& ((*i)->GetBeaconInterval () == BeaconIntervalToU16(beacon_interval))
|
||||
)
|
||||
{
|
||||
NS_LOG_WARN ("Duplicated neighbor timing element is ignored.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
Ptr<IeBeaconTimingUnit>new_element = Create<IeBeaconTimingUnit> ();
|
||||
new_element->SetAid (AidToU8(aid));
|
||||
new_element->SetLastBeacon (TimestampToU16(last_beacon));
|
||||
@@ -117,7 +116,6 @@ IeBeaconTiming::AddNeighboursTimingElementUnit (
|
||||
m_neighbours.push_back (new_element);
|
||||
m_numOfUnits++;
|
||||
}
|
||||
|
||||
void
|
||||
IeBeaconTiming::DelNeighboursTimingElementUnit (
|
||||
uint16_t aid,
|
||||
@@ -126,18 +124,19 @@ IeBeaconTiming::DelNeighboursTimingElementUnit (
|
||||
)
|
||||
{
|
||||
for (NeighboursTimingUnitsList::iterator i = m_neighbours.begin (); i != m_neighbours.end(); i++)
|
||||
if (
|
||||
((*i)->GetAid () == AidToU8(aid))
|
||||
&& ((*i)->GetLastBeacon () == TimestampToU16(last_beacon))
|
||||
&& ((*i)->GetBeaconInterval () == BeaconIntervalToU16(beacon_interval))
|
||||
)
|
||||
{
|
||||
m_neighbours.erase (i);
|
||||
m_numOfUnits--;
|
||||
break;
|
||||
}
|
||||
{
|
||||
if (
|
||||
((*i)->GetAid () == AidToU8(aid))
|
||||
&& ((*i)->GetLastBeacon () == TimestampToU16(last_beacon))
|
||||
&& ((*i)->GetBeaconInterval () == BeaconIntervalToU16(beacon_interval))
|
||||
)
|
||||
{
|
||||
m_neighbours.erase (i);
|
||||
m_numOfUnits--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
IeBeaconTiming::ClearTimingElement ()
|
||||
{
|
||||
@@ -149,35 +148,36 @@ IeBeaconTiming::ClearTimingElement ()
|
||||
(*j) = 0;
|
||||
}
|
||||
for (i = 0; i < to_delete; i ++)
|
||||
m_neighbours.pop_back ();
|
||||
{
|
||||
m_neighbours.pop_back ();
|
||||
}
|
||||
m_neighbours.clear ();
|
||||
|
||||
}
|
||||
|
||||
uint8_t
|
||||
IeBeaconTiming::GetInformationSize () const
|
||||
{
|
||||
return (5*m_numOfUnits);
|
||||
}
|
||||
|
||||
void
|
||||
IeBeaconTiming::PrintInformation (std::ostream& os) const
|
||||
{
|
||||
os <<"Number of units: " << (uint16_t)m_numOfUnits << "\n";
|
||||
for (NeighboursTimingUnitsList::const_iterator j = m_neighbours.begin (); j != m_neighbours.end(); j++)
|
||||
os<< "AID=" << (uint16_t)(*j)->GetAid () << ", Last beacon was at "
|
||||
<< (*j)->GetLastBeacon ()<<", with beacon interval " << (*j)->GetBeaconInterval () << "\n";
|
||||
{
|
||||
os<< "AID=" << (uint16_t)(*j)->GetAid () << ", Last beacon was at "
|
||||
<< (*j)->GetLastBeacon ()<<", with beacon interval " << (*j)->GetBeaconInterval () << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
IeBeaconTiming::SerializeInformation (Buffer::Iterator i) const
|
||||
{
|
||||
for (NeighboursTimingUnitsList::const_iterator j = m_neighbours.begin (); j != m_neighbours.end(); j++)
|
||||
{
|
||||
i.WriteU8 ((*j)->GetAid ());
|
||||
i.WriteHtolsbU16 ((*j)->GetLastBeacon ());
|
||||
i.WriteHtolsbU16 ((*j)->GetBeaconInterval ());
|
||||
}
|
||||
{
|
||||
i.WriteU8 ((*j)->GetAid ());
|
||||
i.WriteHtolsbU16 ((*j)->GetLastBeacon ());
|
||||
i.WriteHtolsbU16 ((*j)->GetBeaconInterval ());
|
||||
}
|
||||
}
|
||||
uint8_t
|
||||
IeBeaconTiming::DeserializeInformation (Buffer::Iterator start, uint8_t length)
|
||||
@@ -194,7 +194,6 @@ IeBeaconTiming::DeserializeInformation (Buffer::Iterator start, uint8_t length)
|
||||
}
|
||||
return i.GetDistanceFrom (start);
|
||||
};
|
||||
|
||||
uint16_t
|
||||
IeBeaconTiming::TimestampToU16 (Time t)
|
||||
{
|
||||
@@ -205,8 +204,7 @@ uint16_t
|
||||
IeBeaconTiming::BeaconIntervalToU16 (Time t)
|
||||
{
|
||||
return ((uint16_t) (t.GetMicroSeconds() >>10)&0xffff);
|
||||
};
|
||||
|
||||
}
|
||||
uint8_t
|
||||
IeBeaconTiming::AidToU8 (uint16_t x)
|
||||
{
|
||||
@@ -224,10 +222,16 @@ bool operator== (const IeBeaconTimingUnit & a, const IeBeaconTimingUnit & b)
|
||||
bool operator== (const IeBeaconTiming & a, const IeBeaconTiming& b)
|
||||
{
|
||||
if(a.m_numOfUnits != b.m_numOfUnits)
|
||||
return false;
|
||||
for(unsigned int i = 0; i < a.m_neighbours.size (); i ++)
|
||||
if(!(*PeekPointer(a.m_neighbours[i]) == *PeekPointer(b.m_neighbours[i])))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
for(unsigned int i = 0; i < a.m_neighbours.size (); i ++)
|
||||
{
|
||||
if(!(*PeekPointer(a.m_neighbours[i]) == *PeekPointer(b.m_neighbours[i])))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -85,9 +85,7 @@ public:
|
||||
);
|
||||
void ClearTimingElement ();
|
||||
private:
|
||||
WifiElementId ElementId () const {
|
||||
return IE11S_BEACON_TIMING;
|
||||
}
|
||||
WifiElementId ElementId () const;
|
||||
uint8_t GetInformationSize () const;
|
||||
void SerializeInformation (Buffer::Iterator i) const;
|
||||
uint8_t DeserializeInformation (Buffer::Iterator i, uint8_t length);
|
||||
|
||||
@@ -43,19 +43,33 @@ uint16_t dot11sMeshCapability::GetUint16 () const
|
||||
{
|
||||
uint16_t result = 0;
|
||||
if (acceptPeerLinks)
|
||||
result |= 1 << 0;
|
||||
{
|
||||
result |= 1 << 0;
|
||||
}
|
||||
if (MCCASupported)
|
||||
result |= 1 << 1;
|
||||
{
|
||||
result |= 1 << 1;
|
||||
}
|
||||
if (MCCAEnabled)
|
||||
result |= 1 << 2;
|
||||
{
|
||||
result |= 1 << 2;
|
||||
}
|
||||
if (forwarding)
|
||||
result |= 1 << 3;
|
||||
{
|
||||
result |= 1 << 3;
|
||||
}
|
||||
if (beaconTimingReport)
|
||||
result |= 1 << 4;
|
||||
{
|
||||
result |= 1 << 4;
|
||||
}
|
||||
if (TBTTAdjustment)
|
||||
result |= 1 << 5;
|
||||
{
|
||||
result |= 1 << 5;
|
||||
}
|
||||
if (powerSaveLevel)
|
||||
result |= 1 << 6;
|
||||
{
|
||||
result |= 1 << 6;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
Buffer::Iterator dot11sMeshCapability::Serialize (Buffer::Iterator i) const
|
||||
@@ -80,6 +94,12 @@ bool dot11sMeshCapability::Is (uint16_t cap, uint8_t n) const
|
||||
uint16_t mask = 1 << n;
|
||||
return (cap & mask);
|
||||
}
|
||||
WifiElementId
|
||||
IeConfiguration::ElementId () const
|
||||
{
|
||||
return IE11S_MESH_CONFIGURATION;
|
||||
}
|
||||
|
||||
IeConfiguration::IeConfiguration ():
|
||||
m_APSPId (PROTOCOL_HWMP),
|
||||
m_APSMId (METRIC_AIRTIME),
|
||||
|
||||
@@ -111,10 +111,7 @@ public:
|
||||
|
||||
dot11sMeshCapability const& MeshCapability ();
|
||||
private:
|
||||
WifiElementId ElementId () const
|
||||
{
|
||||
return IE11S_MESH_CONFIGURATION;
|
||||
}
|
||||
WifiElementId ElementId () const;
|
||||
uint8_t GetInformationSize () const;
|
||||
void SerializeInformation (Buffer::Iterator i) const;
|
||||
uint8_t DeserializeInformation (Buffer::Iterator i, uint8_t length);
|
||||
|
||||
@@ -48,6 +48,11 @@ IeMeshId::IeMeshId (std::string s)
|
||||
len++;
|
||||
}
|
||||
}
|
||||
WifiElementId
|
||||
IeMeshId::ElementId () const
|
||||
{
|
||||
return IE11S_MESH_ID;
|
||||
}
|
||||
bool
|
||||
IeMeshId::IsEqual (IeMeshId const &o) const
|
||||
{
|
||||
@@ -83,9 +88,9 @@ IeMeshId::GetInformationSize (void) const
|
||||
{
|
||||
uint8_t size = 0;
|
||||
while (m_meshId[size] != 0 && size < 32)
|
||||
{
|
||||
size++;
|
||||
}
|
||||
{
|
||||
size++;
|
||||
}
|
||||
NS_ASSERT (size <= 32);
|
||||
return size;
|
||||
}
|
||||
@@ -94,10 +99,10 @@ IeMeshId::SerializeInformation (Buffer::Iterator i) const
|
||||
{
|
||||
uint8_t size = 0;
|
||||
while (m_meshId[size] != 0 && size < 32)
|
||||
{
|
||||
i.WriteU8 (m_meshId [size]);
|
||||
size ++;
|
||||
}
|
||||
{
|
||||
i.WriteU8 (m_meshId [size]);
|
||||
size ++;
|
||||
}
|
||||
}
|
||||
uint8_t
|
||||
IeMeshId::DeserializeInformation (Buffer::Iterator start, uint8_t length)
|
||||
|
||||
@@ -44,9 +44,7 @@ public:
|
||||
uint32_t GetLength (void) const;
|
||||
char *PeekString (void) const;
|
||||
private:
|
||||
WifiElementId ElementId () const{
|
||||
return IE11S_MESH_ID;
|
||||
};
|
||||
WifiElementId ElementId () const;
|
||||
void SerializeInformation (Buffer::Iterator i) const;
|
||||
uint8_t DeserializeInformation (Buffer::Iterator start, uint8_t length);
|
||||
void PrintInformation (std::ostream& os) const;
|
||||
|
||||
@@ -31,6 +31,11 @@ IeLinkMetricReport::IeLinkMetricReport (uint32_t metric)
|
||||
{
|
||||
m_metric = metric;
|
||||
}
|
||||
WifiElementId
|
||||
IeLinkMetricReport::ElementId () const
|
||||
{
|
||||
return IE11S_LINK_METRIC_REPORT;
|
||||
}
|
||||
uint8_t
|
||||
IeLinkMetricReport::GetInformationSize (void) const
|
||||
{
|
||||
|
||||
@@ -39,9 +39,7 @@ public:
|
||||
void SetMetric (uint32_t metric);
|
||||
uint32_t GetMetric ();
|
||||
private:
|
||||
WifiElementId ElementId () const{
|
||||
return IE11S_LINK_METRIC_REPORT;
|
||||
};
|
||||
WifiElementId ElementId () const;
|
||||
void SerializeInformation (Buffer::Iterator i) const;
|
||||
uint8_t DeserializeInformation (Buffer::Iterator start, uint8_t length);
|
||||
void PrintInformation (std::ostream& os) const;
|
||||
|
||||
@@ -35,8 +35,11 @@ IePeerManagement::IePeerManagement ():
|
||||
m_peerLinkId (0),
|
||||
m_reasonCode (REASON11S_RESERVED)
|
||||
{}
|
||||
|
||||
|
||||
WifiElementId
|
||||
IePeerManagement::ElementId () const
|
||||
{
|
||||
return IE11S_PEERING_MANAGEMENT;
|
||||
}
|
||||
void
|
||||
IePeerManagement::SetPeerOpen (uint16_t localLinkId)
|
||||
{
|
||||
@@ -109,9 +112,13 @@ IePeerManagement::SerializeInformation (Buffer::Iterator i) const
|
||||
i.WriteU8 (m_subtype);
|
||||
i.WriteHtolsbU16 (m_localLinkId);
|
||||
if (m_length > 3)
|
||||
i.WriteHtolsbU16 (m_peerLinkId);
|
||||
{
|
||||
i.WriteHtolsbU16 (m_peerLinkId);
|
||||
}
|
||||
if (m_length > 5)
|
||||
i.WriteHtolsbU16 (m_reasonCode);
|
||||
{
|
||||
i.WriteHtolsbU16 (m_reasonCode);
|
||||
}
|
||||
}
|
||||
uint8_t
|
||||
IePeerManagement::DeserializeInformation (Buffer::Iterator start, uint8_t length)
|
||||
@@ -120,22 +127,26 @@ IePeerManagement::DeserializeInformation (Buffer::Iterator start, uint8_t length
|
||||
m_subtype = i.ReadU8 ();
|
||||
m_length = length;
|
||||
if (m_subtype == PEER_OPEN)
|
||||
{
|
||||
NS_ASSERT (length == 3);
|
||||
}
|
||||
{
|
||||
NS_ASSERT (length == 3);
|
||||
}
|
||||
if (m_subtype == PEER_CONFIRM)
|
||||
{
|
||||
NS_ASSERT (length == 5);
|
||||
}
|
||||
{
|
||||
NS_ASSERT (length == 5);
|
||||
}
|
||||
if (m_subtype == PEER_CLOSE)
|
||||
{
|
||||
NS_ASSERT (length == 7);
|
||||
}
|
||||
{
|
||||
NS_ASSERT (length == 7);
|
||||
}
|
||||
m_localLinkId = i.ReadLsbtohU16 ();
|
||||
if (m_length > 3)
|
||||
m_peerLinkId = i.ReadLsbtohU16 ();
|
||||
{
|
||||
m_peerLinkId = i.ReadLsbtohU16 ();
|
||||
}
|
||||
if (m_length > 5)
|
||||
m_reasonCode = (PmpReasonCode)i.ReadLsbtohU16 ();
|
||||
{
|
||||
m_reasonCode = (PmpReasonCode)i.ReadLsbtohU16 ();
|
||||
}
|
||||
return i.GetDistanceFrom (start);
|
||||
}
|
||||
void
|
||||
|
||||
@@ -70,9 +70,7 @@ public:
|
||||
bool SubtypeIsConfirm () const ;
|
||||
uint8_t GetSubtype() const { return m_subtype;};
|
||||
private:
|
||||
WifiElementId ElementId () const{
|
||||
return IE11S_PEERING_MANAGEMENT;
|
||||
}
|
||||
WifiElementId ElementId () const;
|
||||
uint8_t GetInformationSize (void) const;
|
||||
void SerializeInformation (Buffer::Iterator i) const;
|
||||
uint8_t DeserializeInformation (Buffer::Iterator i, uint8_t length);
|
||||
|
||||
@@ -31,6 +31,11 @@ IePeeringProtocol::IePeeringProtocol ():
|
||||
m_protocol(0)
|
||||
{
|
||||
}
|
||||
WifiElementId
|
||||
IePeeringProtocol::ElementId () const
|
||||
{
|
||||
return IE11S_MESH_PEERING_PROTOCOL_VERSION;
|
||||
}
|
||||
void
|
||||
IePeeringProtocol::SerializeInformation (Buffer::Iterator i) const
|
||||
{
|
||||
|
||||
@@ -31,10 +31,7 @@ class IePeeringProtocol : public WifiInformationElement
|
||||
public:
|
||||
IePeeringProtocol ();
|
||||
private:
|
||||
WifiElementId ElementId () const
|
||||
{
|
||||
return IE11S_MESH_PEERING_PROTOCOL_VERSION;
|
||||
}
|
||||
WifiElementId ElementId () const;
|
||||
uint8_t GetInformationSize () const;
|
||||
void SerializeInformation (Buffer::Iterator i) const;
|
||||
uint8_t DeserializeInformation (Buffer::Iterator i, uint8_t length);
|
||||
|
||||
@@ -26,9 +26,17 @@
|
||||
#include "ns3/test.h"
|
||||
namespace ns3 {
|
||||
namespace dot11s {
|
||||
IePerr::IePerr ()
|
||||
{
|
||||
}
|
||||
IePerr::~IePerr ()
|
||||
{
|
||||
}
|
||||
WifiElementId
|
||||
IePerr::ElementId () const
|
||||
{
|
||||
return IE11S_PERR;
|
||||
}
|
||||
void
|
||||
IePerr::PrintInformation (std::ostream &os) const
|
||||
{
|
||||
@@ -39,10 +47,6 @@ IePerr::PrintInformation (std::ostream &os) const
|
||||
", sequence number = " << m_addressUnits[j].seqnum;
|
||||
}
|
||||
os << "\n";
|
||||
|
||||
}
|
||||
IePerr::IePerr ()
|
||||
{
|
||||
}
|
||||
uint8_t
|
||||
IePerr::GetNumOfDest ()
|
||||
@@ -92,10 +96,16 @@ void
|
||||
IePerr::AddAddressUnit (FailedDestination unit)
|
||||
{
|
||||
for (unsigned int i = 0; i < m_addressUnits.size (); i ++)
|
||||
if (m_addressUnits[i].destination == unit.destination)
|
||||
{
|
||||
if (m_addressUnits[i].destination == unit.destination)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
if ((m_addressUnits.size () + 1) * 10 + 2 > 255)
|
||||
{
|
||||
return;
|
||||
if((m_addressUnits.size () + 1) * 10 + 2 > 255)
|
||||
return;
|
||||
}
|
||||
m_addressUnits.push_back (unit);
|
||||
}
|
||||
bool
|
||||
@@ -112,11 +122,13 @@ void
|
||||
IePerr::DeleteAddressUnit (Mac48Address address)
|
||||
{
|
||||
for (std::vector<FailedDestination>::iterator i = m_addressUnits.begin (); i != m_addressUnits.end(); i ++)
|
||||
if (i->destination == address)
|
||||
{
|
||||
m_addressUnits.erase (i);
|
||||
break;
|
||||
}
|
||||
{
|
||||
if (i->destination == address)
|
||||
{
|
||||
m_addressUnits.erase (i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
void
|
||||
IePerr::ResetPerr ()
|
||||
@@ -125,14 +137,20 @@ IePerr::ResetPerr ()
|
||||
}
|
||||
bool operator== (const IePerr & a, const IePerr & b)
|
||||
{
|
||||
if(a.m_addressUnits.size () != b.m_addressUnits.size ())
|
||||
return false;
|
||||
for(unsigned int i = 0; i < a.m_addressUnits.size(); i ++)
|
||||
if (a.m_addressUnits.size () != b.m_addressUnits.size ())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
for (unsigned int i = 0; i < a.m_addressUnits.size(); i ++)
|
||||
{
|
||||
if(a.m_addressUnits[i].destination != b.m_addressUnits[i].destination)
|
||||
return false;
|
||||
if(a.m_addressUnits[i].seqnum != b.m_addressUnits[i].seqnum)
|
||||
return false;
|
||||
if (a.m_addressUnits[i].destination != b.m_addressUnits[i].destination)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (a.m_addressUnits[i].seqnum != b.m_addressUnits[i].seqnum)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -49,9 +49,7 @@ public:
|
||||
void DeleteAddressUnit (Mac48Address address);
|
||||
void ResetPerr ();
|
||||
private:
|
||||
WifiElementId ElementId () const{
|
||||
return IE11S_PERR;
|
||||
};
|
||||
WifiElementId ElementId () const;
|
||||
void SerializeInformation (Buffer::Iterator i) const;
|
||||
uint8_t DeserializeInformation (Buffer::Iterator start, uint8_t length);
|
||||
void PrintInformation (std::ostream& os) const;
|
||||
|
||||
@@ -45,6 +45,11 @@ IePrep::IePrep ():
|
||||
m_originatorSeqNumber (0)
|
||||
{
|
||||
}
|
||||
WifiElementId
|
||||
IePrep::ElementId () const
|
||||
{
|
||||
return IE11S_PREP;
|
||||
}
|
||||
void
|
||||
IePrep::SetFlags (uint8_t flags)
|
||||
{
|
||||
|
||||
@@ -60,9 +60,7 @@ public:
|
||||
void DecrementTtl ();
|
||||
void IncrementMetric (uint32_t metric);
|
||||
private:
|
||||
WifiElementId ElementId () const{
|
||||
return IE11S_PREP;
|
||||
}
|
||||
WifiElementId ElementId () const;
|
||||
void SerializeInformation (Buffer::Iterator i) const;
|
||||
uint8_t DeserializeInformation (Buffer::Iterator start, uint8_t length);
|
||||
uint8_t GetInformationSize () const;
|
||||
|
||||
@@ -104,6 +104,11 @@ IePreq::IePreq ():
|
||||
m_destCount (0)
|
||||
{
|
||||
}
|
||||
WifiElementId
|
||||
IePreq::ElementId () const
|
||||
{
|
||||
return IE11S_PREQ;
|
||||
}
|
||||
void
|
||||
IePreq::SetUnicastPreq ()
|
||||
{
|
||||
@@ -239,17 +244,25 @@ IePreq::SerializeInformation (Buffer::Iterator i) const
|
||||
{
|
||||
uint8_t flags = 0;
|
||||
if ((*j)->IsDo ())
|
||||
flags |= 1 << 0;
|
||||
{
|
||||
flags |= 1 << 0;
|
||||
}
|
||||
if ((*j)->IsRf ())
|
||||
flags |= 1 << 1;
|
||||
{
|
||||
flags |= 1 << 1;
|
||||
}
|
||||
if((*j)->IsUsn ())
|
||||
flags |= 1 << 2;
|
||||
{
|
||||
flags |= 1 << 2;
|
||||
}
|
||||
i.WriteU8 (flags);
|
||||
WriteTo (i, (*j)->GetDestinationAddress());
|
||||
i.WriteHtolsbU32 ((*j)->GetDestSeqNumber ());
|
||||
written++;
|
||||
if (written > m_maxSize)
|
||||
break;
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
uint8_t
|
||||
@@ -273,11 +286,17 @@ IePreq::DeserializeInformation (Buffer::Iterator start, uint8_t length)
|
||||
bool usnFlag = false;
|
||||
uint8_t flags = i.ReadU8 ();
|
||||
if (flags & (1 << 0))
|
||||
{
|
||||
doFlag = true;
|
||||
}
|
||||
if (flags & (1 << 1))
|
||||
rfFlag = true;
|
||||
{
|
||||
rfFlag = true;
|
||||
}
|
||||
if (flags & (1 << 2))
|
||||
usnFlag = true;
|
||||
{
|
||||
usnFlag = true;
|
||||
}
|
||||
new_element->SetFlags (doFlag, rfFlag, usnFlag);
|
||||
Mac48Address addr;
|
||||
ReadFrom (i,addr);
|
||||
@@ -302,9 +321,13 @@ IePreq::GetInformationSize () const
|
||||
+4 //metric
|
||||
+1; //destination count
|
||||
if (m_destCount > m_maxSize)
|
||||
retval += (m_maxSize*11);
|
||||
{
|
||||
retval += (m_maxSize*11);
|
||||
}
|
||||
else
|
||||
retval += (m_destCount*11);
|
||||
{
|
||||
retval += (m_destCount*11);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
void
|
||||
@@ -334,8 +357,12 @@ IePreq::AddDestinationAddressElement (
|
||||
)
|
||||
{
|
||||
for (std::vector<Ptr<DestinationAddressUnit> >::const_iterator i = m_destinations.begin (); i != m_destinations.end(); i++ )
|
||||
if ((*i)->GetDestinationAddress () == dest_address)
|
||||
return;
|
||||
{
|
||||
if ((*i)->GetDestinationAddress () == dest_address)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
//TODO: check overflow
|
||||
Ptr<DestinationAddressUnit>new_element = Create<DestinationAddressUnit> ();
|
||||
new_element->SetFlags (doFlag, rfFlag, false);
|
||||
@@ -348,21 +375,27 @@ void
|
||||
IePreq::DelDestinationAddressElement (Mac48Address dest_address)
|
||||
{
|
||||
for (std::vector<Ptr<DestinationAddressUnit> >::iterator i = m_destinations.begin (); i != m_destinations.end(); i++)
|
||||
if ((*i)->GetDestinationAddress () == dest_address)
|
||||
{
|
||||
m_destinations.erase (i);
|
||||
m_destCount--;
|
||||
break;
|
||||
}
|
||||
{
|
||||
if ((*i)->GetDestinationAddress () == dest_address)
|
||||
{
|
||||
m_destinations.erase (i);
|
||||
m_destCount--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
void
|
||||
IePreq::ClearDestinationAddressElements ()
|
||||
{
|
||||
int i;
|
||||
for (std::vector<Ptr<DestinationAddressUnit> >::iterator j = m_destinations.begin (); j != m_destinations.end(); j++)
|
||||
(*j) = 0;
|
||||
{
|
||||
(*j) = 0;
|
||||
}
|
||||
for (i = 0; i < m_destCount; i ++)
|
||||
m_destinations.pop_back ();
|
||||
{
|
||||
m_destinations.pop_back ();
|
||||
}
|
||||
m_destinations.clear ();
|
||||
m_destCount = 0;
|
||||
}
|
||||
@@ -388,30 +421,38 @@ bool operator== (const IePreq & a, const IePreq & b)
|
||||
&& a.m_destCount == b.m_destCount
|
||||
);
|
||||
|
||||
if (! ok)
|
||||
return false;
|
||||
|
||||
if (a.m_destinations.size() != b.m_destinations.size())
|
||||
return false;
|
||||
|
||||
for (size_t i = 0; i < a.m_destinations.size(); ++i)
|
||||
if (!( *(PeekPointer (a.m_destinations[i])) ==
|
||||
*(PeekPointer (b.m_destinations[i]))
|
||||
)
|
||||
)
|
||||
if (! ok)
|
||||
{
|
||||
return false;
|
||||
|
||||
}
|
||||
if (a.m_destinations.size() != b.m_destinations.size())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
for (size_t i = 0; i < a.m_destinations.size(); ++i)
|
||||
{
|
||||
if (!( *(PeekPointer (a.m_destinations[i])) == *(PeekPointer (b.m_destinations[i]))))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
bool
|
||||
IePreq::MayAddAddress (Mac48Address originator)
|
||||
{
|
||||
if (m_originatorAddress != originator)
|
||||
return false;
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if(m_destinations[0]->GetDestinationAddress () == Mac48Address::GetBroadcast ())
|
||||
return false;
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if((GetInformationSize () + 11) > 255)
|
||||
return false;
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
bool
|
||||
|
||||
@@ -120,9 +120,7 @@ public:
|
||||
bool MayAddAddress(Mac48Address originator);
|
||||
bool IsFull () const;
|
||||
private:
|
||||
WifiElementId ElementId () const{
|
||||
return IE11S_PREQ;
|
||||
}
|
||||
WifiElementId ElementId () const;
|
||||
void SerializeInformation (Buffer::Iterator i) const;
|
||||
uint8_t DeserializeInformation (Buffer::Iterator i, uint8_t length);
|
||||
uint8_t GetInformationSize () const;
|
||||
|
||||
Reference in New Issue
Block a user