Added max beacon loss to PeerManagementProtocol (for beacon timing), cosmetic

changes: added {} and spaces befor '('
This commit is contained in:
Kirill Andreev
2009-07-21 12:51:09 +04:00
parent a92d4f714d
commit 1fb5e143a7
9 changed files with 469 additions and 258 deletions

View File

@@ -56,12 +56,12 @@ HwmpProtocolMac::ReceiveData (Ptr<Packet> packet, const WifiMacHeader & header)
MeshHeader meshHdr;
HwmpTag tag;
if(packet->PeekPacketTag (tag))
if (packet->PeekPacketTag (tag))
{
NS_FATAL_ERROR ("HWMP tag is not supposed to be received by network");
}
packet->RemoveHeader(meshHdr);
packet->RemoveHeader (meshHdr);
m_stats.rxData ++;
m_stats.rxDataBytes += packet->GetSize ();
@@ -79,12 +79,12 @@ HwmpProtocolMac::ReceiveData (Ptr<Packet> packet, const WifiMacHeader & header)
};
tag.SetSeqno (meshHdr.GetMeshSeqno ());
tag.SetTtl (meshHdr.GetMeshTtl ());
packet->AddPacketTag(tag);
packet->AddPacketTag (tag);
if (destination == Mac48Address::GetBroadcast ())
if(m_protocol->DropDataFrame (meshHdr.GetMeshSeqno (), source))
if ((destination == Mac48Address::GetBroadcast ()) && (m_protocol->DropDataFrame (meshHdr.GetMeshSeqno (), source)))
{
return false;
}
return true;
}
@@ -96,8 +96,10 @@ HwmpProtocolMac::ReceiveAction (Ptr<Packet> packet, const WifiMacHeader & header
WifiMeshActionHeader actionHdr;
packet->RemoveHeader (actionHdr);
WifiMeshActionHeader::ActionValue actionValue = actionHdr.GetAction ();
if(actionHdr.GetCategory () != WifiMeshActionHeader::MESH_PATH_SELECTION)
return true;
if (actionHdr.GetCategory () != WifiMeshActionHeader::MESH_PATH_SELECTION)
{
return true;
}
IeRann rann;
IePreq preq;
IePrep prep;
@@ -110,9 +112,13 @@ HwmpProtocolMac::ReceiveAction (Ptr<Packet> packet, const WifiMacHeader & header
{
m_stats.rxPreq ++;
if (preq.GetOriginatorAddress () == m_protocol->GetAddress ())
continue;
{
continue;
}
if (preq.GetTtl () == 0)
continue;
{
continue;
}
preq.DecrementTtl ();
m_protocol->ReceivePreq (preq, header.GetAddr2 (), m_ifIndex, header.GetAddr3 (), m_parent->GetLinkMetric(header.GetAddr2 ()));
}
@@ -120,7 +126,9 @@ HwmpProtocolMac::ReceiveAction (Ptr<Packet> packet, const WifiMacHeader & header
{
m_stats.rxPrep ++;
if (prep.GetTtl () == 0)
continue;
{
continue;
}
prep.DecrementTtl ();
m_protocol->ReceivePrep (prep, header.GetAddr2 (), m_ifIndex, header.GetAddr3 (), m_parent->GetLinkMetric(header.GetAddr2 ()));
}
@@ -133,7 +141,9 @@ HwmpProtocolMac::ReceiveAction (Ptr<Packet> packet, const WifiMacHeader & header
failedDestinations.push_back (*i);
}
if (failedDestinations.size () > 0)
m_protocol->ReceivePerr (failedDestinations, header.GetAddr2 (), m_ifIndex, header.GetAddr3 ());
{
m_protocol->ReceivePerr (failedDestinations, header.GetAddr2 (), m_ifIndex, header.GetAddr3 ());
}
NS_ASSERT(packet->GetSize () == 0);
return false;
}
@@ -142,17 +152,28 @@ bool
HwmpProtocolMac::Receive (Ptr<Packet> packet, const WifiMacHeader & header)
{
if (header.IsData ())
return ReceiveData (packet, header);
else if (header.IsAction ())
return ReceiveAction (packet, header);
else
return true; // don't care
{
return ReceiveData (packet, header);
}
else
{
if (header.IsAction ())
{
return ReceiveAction (packet, header);
}
else
{
return true; // don't care
}
}
}
bool
HwmpProtocolMac::UpdateOutcomingFrame (Ptr<Packet> packet, WifiMacHeader & header, Mac48Address from, Mac48Address to)
{
if(!header.IsData ())
return true;
if (!header.IsData ())
{
return true;
}
HwmpTag tag;
bool tagExists = packet->RemovePacketTag(tag);
if (!tagExists)
@@ -162,7 +183,7 @@ HwmpProtocolMac::UpdateOutcomingFrame (Ptr<Packet> packet, WifiMacHeader & heade
m_stats.txData ++;
m_stats.txDataBytes += packet->GetSize ();
MeshHeader meshHdr;
meshHdr.SetMeshSeqno (tag.GetSeqno());
meshHdr.SetMeshSeqno (tag.GetSeqno ());
meshHdr.SetMeshTtl (tag.GetTtl());
packet->AddHeader (meshHdr);
header.SetAddr1 (tag.GetAddress());
@@ -178,7 +199,7 @@ HwmpProtocolMac::GetWifiMeshActionHeader ()
return actionHdr;
}
void
HwmpProtocolMac::SendPreq(IePreq preq)
HwmpProtocolMac::SendPreq (IePreq preq)
{
NS_LOG_FUNCTION_NOARGS ();
std::vector<IePreq> preq_vector;
@@ -203,23 +224,25 @@ HwmpProtocolMac::SendPreq(std::vector<IePreq> preq)
hdr.SetAddr3 (m_protocol->GetAddress ());
//Send Management frame
std::vector <Mac48Address> receivers = m_protocol->GetPreqReceivers (m_ifIndex);
for(std::vector<Mac48Address>::const_iterator i = receivers.begin (); i != receivers.end (); i ++)
for (std::vector<Mac48Address>::const_iterator i = receivers.begin (); i != receivers.end (); i ++)
{
hdr.SetAddr1 (*i);
m_stats.txPreq ++;
m_stats.txMgt ++;
m_stats.txMgtBytes += packet->GetSize ();
m_parent->SendManagementFrame(packet, hdr);
m_parent->SendManagementFrame (packet, hdr);
}
}
void
HwmpProtocolMac::RequestDestination (Mac48Address dst, uint32_t originator_seqno, uint32_t dst_seqno)
{
NS_LOG_FUNCTION_NOARGS ();
for(std::vector<IePreq>::iterator i = m_myPreq.begin (); i != m_myPreq.end(); i ++)
for (std::vector<IePreq>::iterator i = m_myPreq.begin (); i != m_myPreq.end(); i ++)
{
if(i->IsFull ())
continue;
if (i->IsFull ())
{
continue;
}
NS_ASSERT (i->GetDestCount () > 0);
i->AddDestinationAddressElement (m_protocol->GetDoFlag(), m_protocol->GetRfFlag(), dst, dst_seqno);
}
@@ -238,10 +261,14 @@ void
HwmpProtocolMac::SendMyPreq ()
{
NS_LOG_FUNCTION_NOARGS ();
if(m_preqTimer.IsRunning ())
return;
if(m_myPreq.size () == 0)
return;
if (m_preqTimer.IsRunning ())
{
return;
}
if (m_myPreq.size () == 0)
{
return;
}
//reschedule sending PREQ
NS_ASSERT (!m_preqTimer.IsRunning());
m_preqTimer = Simulator::Schedule (m_protocol->GetPreqMinInterval (), &HwmpProtocolMac::SendMyPreq, this);
@@ -276,18 +303,22 @@ HwmpProtocolMac::ForwardPerr(std::vector<IePerr::FailedDestination> failedDestin
NS_LOG_FUNCTION_NOARGS ();
Ptr<Packet> packet = Create<Packet> ();
IePerr perr;
for(std::vector<IePerr::FailedDestination>::const_iterator i = failedDestinations.begin (); i != failedDestinations.end (); i ++)
for (std::vector<IePerr::FailedDestination>::const_iterator i = failedDestinations.begin (); i != failedDestinations.end (); i ++)
{
if(!perr.IsFull ())
perr.AddAddressUnit (*i);
if (!perr.IsFull ())
{
perr.AddAddressUnit (*i);
}
else
{
packet->AddHeader (perr);
perr.ResetPerr ();
}
}
if (perr.GetNumOfDest () > 0)
{
packet->AddHeader (perr);
perr.ResetPerr ();
}
}
if(perr.GetNumOfDest () > 0)
packet->AddHeader (perr);
packet->AddHeader (GetWifiMeshActionHeader ());
//create 802.11 header:
WifiMacHeader hdr;
@@ -302,7 +333,7 @@ HwmpProtocolMac::ForwardPerr(std::vector<IePerr::FailedDestination> failedDestin
receivers.push_back (Mac48Address::GetBroadcast ());
}
//Send Management frame
for(std::vector<Mac48Address>::const_iterator i = m_myPerr.receivers.begin (); i != m_myPerr.receivers.end (); i ++)
for (std::vector<Mac48Address>::const_iterator i = m_myPerr.receivers.begin (); i != m_myPerr.receivers.end (); i ++)
{
hdr.SetAddr1 (*i);
m_stats.txPerr ++;
@@ -316,42 +347,52 @@ HwmpProtocolMac::InitiatePerr (std::vector<IePerr::FailedDestination> failedDest
{
//All duplicates in PERR are checked here, and there is no reason to
//check it at any athoer place
{
std::vector<Mac48Address>::const_iterator end = receivers.end();
for(std::vector<Mac48Address>::const_iterator i = receivers.begin (); i != end; i ++)
{
std::vector<Mac48Address>::const_iterator end = receivers.end();
for(std::vector<Mac48Address>::const_iterator i = receivers.begin (); i != end; i ++)
{
bool should_add = true;
for (std::vector<Mac48Address>::const_iterator j = m_myPerr.receivers.begin (); j != m_myPerr.receivers.end (); j ++)
{
if ((*i) == (*j))
{
should_add = false;
}
}
if (should_add)
{
m_myPerr.receivers.push_back(*i);
}
}
}
{
std::vector<IePerr::FailedDestination>::const_iterator end = failedDestinations.end ();
for(std::vector<IePerr::FailedDestination>::const_iterator i = failedDestinations.begin (); i != end; i ++)
}
{
std::vector<IePerr::FailedDestination>::const_iterator end = failedDestinations.end ();
for(std::vector<IePerr::FailedDestination>::const_iterator i = failedDestinations.begin (); i != end; i ++)
{
bool should_add = true;
for
(
std::vector<IePerr::FailedDestination>::const_iterator j = m_myPerr.destinations.begin ();
j != m_myPerr.destinations.end ();
j ++)
if ( ((*i).destination == (*j).destination) && ((*j).seqnum > (*i).seqnum) )
should_add = false;
for (std::vector<IePerr::FailedDestination>::const_iterator j = m_myPerr.destinations.begin (); j != m_myPerr.destinations.end (); j ++)
{
if ( ((*i).destination == (*j).destination) && ((*j).seqnum > (*i).seqnum) )
{
should_add = false;
}
}
if (should_add)
m_myPerr.destinations.push_back(*i);
{
m_myPerr.destinations.push_back(*i);
}
}
}
}
SendMyPerr ();
}
void
HwmpProtocolMac::SendMyPerr()
{
NS_LOG_FUNCTION_NOARGS ();
if(m_perrTimer.IsRunning ())
return;
if (m_perrTimer.IsRunning ())
{
return;
}
m_perrTimer = Simulator::Schedule (m_protocol->GetPerrMinInterval (), &HwmpProtocolMac::SendMyPerr, this);
ForwardPerr (m_myPerr.destinations, m_myPerr.receivers);
m_myPerr.destinations.clear ();
@@ -360,7 +401,7 @@ HwmpProtocolMac::SendMyPerr()
uint32_t
HwmpProtocolMac::GetLinkMetric(Mac48Address peerAddress) const
{
return m_parent->GetLinkMetric(peerAddress);
return m_parent->GetLinkMetric (peerAddress);
}
uint16_t
HwmpProtocolMac::GetChannelId () const

View File

@@ -41,6 +41,12 @@ IeRann::IeRann ():
m_metric (0)
{
}
WifiElementId
IeRann::ElementId () const
{
return IE11S_RANN;
}
void
IeRann::SetFlags (uint8_t flags)
{

View File

@@ -52,9 +52,7 @@ public:
void IncrementMetric (uint32_t metric);
private:
WifiElementId ElementId () const{
return IE11S_RANN;
}
WifiElementId ElementId () const;
void SerializeInformation (Buffer::Iterator i) const;
uint8_t DeserializeInformation (Buffer::Iterator start, uint8_t length);
uint8_t GetInformationSize () const;

View File

@@ -184,53 +184,79 @@ void
PeerLink::Close (uint16_t localLinkId, uint16_t peerLinkId, PmpReasonCode reason)
{
if (peerLinkId != 0 && m_localLinkId != peerLinkId)
return;
{
return;
}
if (m_peerLinkId == 0)
m_peerLinkId = localLinkId;
else if (m_peerLinkId != localLinkId)
return;
{
m_peerLinkId = localLinkId;
}
else
{
if (m_peerLinkId != localLinkId)
{
return;
}
}
StateMachine (CLS_ACPT, reason);
}
void
PeerLink::OpenAccept (uint16_t localLinkId, IeConfiguration conf, Mac48Address peerMp)
{
if (m_peerLinkId == 0)
m_peerLinkId = localLinkId;
{
m_peerLinkId = localLinkId;
}
m_configuration = conf;
if(m_peerMeshPointAddress != Mac48Address::GetBroadcast ())
{
NS_ASSERT(m_peerMeshPointAddress == peerMp);
}
if (m_peerMeshPointAddress != Mac48Address::GetBroadcast ())
{
NS_ASSERT(m_peerMeshPointAddress == peerMp);
}
else
m_peerMeshPointAddress = peerMp;
{
m_peerMeshPointAddress = peerMp;
}
StateMachine (OPN_ACPT);
}
void
PeerLink::OpenReject (uint16_t localLinkId, IeConfiguration conf, Mac48Address peerMp, PmpReasonCode reason)
{
if ( m_peerLinkId == 0)
m_peerLinkId = localLinkId;
{
m_peerLinkId = localLinkId;
}
m_configuration = conf;
if(m_peerMeshPointAddress != Mac48Address::GetBroadcast ())
{
NS_ASSERT(m_peerMeshPointAddress == peerMp);
}
if (m_peerMeshPointAddress != Mac48Address::GetBroadcast ())
{
NS_ASSERT(m_peerMeshPointAddress == peerMp);
}
else
m_peerMeshPointAddress = peerMp;
{
m_peerMeshPointAddress = peerMp;
}
StateMachine (OPN_RJCT, reason);
}
void
PeerLink::ConfirmAccept (uint16_t localLinkId, uint16_t peerLinkId, uint16_t peerAid, IeConfiguration conf, Mac48Address peerMp)
{
if ( m_localLinkId != peerLinkId)
return;
{
return;
}
if ( m_peerLinkId == 0)
m_peerLinkId = localLinkId;
else if ( m_peerLinkId != localLinkId )
return;
{
m_peerLinkId = localLinkId;
}
else
{
if ( m_peerLinkId != localLinkId )
{
return;
}
}
m_configuration = conf;
m_peerAssocId = peerAid;
if(m_peerMeshPointAddress != Mac48Address::GetBroadcast ())
if (m_peerMeshPointAddress != Mac48Address::GetBroadcast ())
{
NS_ASSERT(m_peerMeshPointAddress == peerMp);
}
@@ -243,13 +269,22 @@ PeerLink::ConfirmReject (uint16_t localLinkId, uint16_t peerLinkId,
IeConfiguration conf, Mac48Address peerMp, PmpReasonCode reason)
{
if (m_localLinkId != peerLinkId)
return;
{
return;
}
if (m_peerLinkId == 0)
m_peerLinkId = localLinkId;
else if (m_peerLinkId != localLinkId)
return;
{
m_peerLinkId = localLinkId;
}
else
{
if (m_peerLinkId != localLinkId)
{
return;
}
}
m_configuration = conf;
if(m_peerMeshPointAddress != Mac48Address::GetBroadcast ())
if (m_peerMeshPointAddress != Mac48Address::GetBroadcast ())
{
NS_ASSERT(m_peerMeshPointAddress == peerMp);
}
@@ -421,7 +456,7 @@ PeerLink::StateMachine (PeerEvent event,PmpReasonCode reasoncode)
m_state = ESTAB;
m_linkStatusCallback (m_interface, m_peerAddress, m_peerMeshPointAddress, OPN_RCVD, ESTAB);
ClearRetryTimer ();
NS_ASSERT(m_peerMeshPointAddress != Mac48Address::GetBroadcast ());
NS_ASSERT (m_peerMeshPointAddress != Mac48Address::GetBroadcast ());
break;
case CLS_ACPT:
m_state = HOLDING;
@@ -578,14 +613,18 @@ void
PeerLink::RetryTimeout ()
{
if ( m_retryCounter < m_dot11MeshMaxRetries)
StateMachine (TOR1);
{
StateMachine (TOR1);
}
else
StateMachine (TOR2);
{
StateMachine (TOR2);
}
}
void
PeerLink::SetConfirmTimer ()
{
NS_ASSERT(m_dot11MeshConfirmTimeout.GetMicroSeconds() !=0);
NS_ASSERT (m_dot11MeshConfirmTimeout.GetMicroSeconds() !=0);
m_confirmTimer = Simulator::Schedule (m_dot11MeshConfirmTimeout, &PeerLink::ConfirmTimeout, this);
}
void
@@ -596,8 +635,10 @@ PeerLink::ConfirmTimeout ()
void
PeerLink::Report (std::ostream & os) const
{
if(m_state != ESTAB)
if (m_state != ESTAB)
{
return;
}
os << "<PeerLink\n"
"localAddress=\"" << m_macPlugin->GetAddress () << "\"\n"
"peerInterfaceAddress=\"" << m_peerAddress << "\"\n"

View File

@@ -64,8 +64,10 @@ PeerManagementProtocolMac::Receive (Ptr<Packet> const_packet, const WifiMacHeade
(beaconTiming.FindFirst(myBeacon)) &&
(m_protocol->GetMeshId ()->IsEqual(meshId))
)
meshBeacon = true;
m_protocol->UpdatePeerBeaconTiming(
{
meshBeacon = true;
}
m_protocol->UpdatePeerBeaconTiming (
m_ifIndex,
meshBeacon,
beaconTiming,
@@ -76,7 +78,7 @@ PeerManagementProtocolMac::Receive (Ptr<Packet> const_packet, const WifiMacHeade
// Beacon shall not be dropeed. May be needed to another plugins
return true;
}
if(header.IsAction())
if (header.IsAction ())
{
WifiMeshActionHeader actionHdr;
packet->RemoveHeader (actionHdr);
@@ -91,14 +93,14 @@ PeerManagementProtocolMac::Receive (Ptr<Packet> const_packet, const WifiMacHeade
PeerLinkFrameStart::PlinkFrameStartFields fields;
{
PeerLinkFrameStart peerFrame;
peerFrame.SetPlinkFrameSubtype((uint8_t)actionValue.peerLink);
peerFrame.SetPlinkFrameSubtype ((uint8_t) actionValue.peerLink);
packet->RemoveHeader (peerFrame);
fields = peerFrame.GetFields();
NS_ASSERT(fields.subtype == actionValue.peerLink);
fields = peerFrame.GetFields ();
NS_ASSERT (fields.subtype == actionValue.peerLink);
}
if (
(actionValue.peerLink != WifiMeshActionHeader::PEER_LINK_CLOSE) &&
!(m_parent->CheckSupportedRates(fields.rates))
!(m_parent->CheckSupportedRates (fields.rates))
)
{
m_protocol->ConfigurationMismatch (m_ifIndex, peerAddress);
@@ -108,7 +110,7 @@ PeerManagementProtocolMac::Receive (Ptr<Packet> const_packet, const WifiMacHeade
}
if (
(actionValue.peerLink != WifiMeshActionHeader::PEER_LINK_CONFIRM) &&
!fields.meshId.IsEqual(*(m_protocol->GetMeshId()))
!fields.meshId.IsEqual (*(m_protocol->GetMeshId ()))
)
{
m_protocol->ConfigurationMismatch (m_ifIndex, peerAddress);
@@ -117,34 +119,34 @@ PeerManagementProtocolMac::Receive (Ptr<Packet> const_packet, const WifiMacHeade
return false;
}
IePeerManagement peerElement;
packet->RemoveHeader(peerElement);
packet->RemoveHeader (peerElement);
//Check taht frame subtype corresponds peer link subtype
if(peerElement.SubtypeIsOpen ())
if (peerElement.SubtypeIsOpen ())
{
m_stats.rxOpen ++;
NS_ASSERT(actionValue.peerLink == WifiMeshActionHeader::PEER_LINK_OPEN);
NS_ASSERT (actionValue.peerLink == WifiMeshActionHeader::PEER_LINK_OPEN);
}
if(peerElement.SubtypeIsConfirm ())
if (peerElement.SubtypeIsConfirm ())
{
m_stats.rxConfirm ++;
NS_ASSERT(actionValue.peerLink == WifiMeshActionHeader::PEER_LINK_CONFIRM);
NS_ASSERT (actionValue.peerLink == WifiMeshActionHeader::PEER_LINK_CONFIRM);
}
if(peerElement.SubtypeIsClose ())
if (peerElement.SubtypeIsClose ())
{
m_stats.rxClose ++;
NS_ASSERT(actionValue.peerLink == WifiMeshActionHeader::PEER_LINK_CLOSE);
NS_ASSERT (actionValue.peerLink == WifiMeshActionHeader::PEER_LINK_CLOSE);
}
//Deliver Peer link management frame to protocol:
m_protocol->ReceivePeerLinkFrame(m_ifIndex, peerAddress, peerMpAddress, fields.aid, peerElement, fields.config);
m_protocol->ReceivePeerLinkFrame (m_ifIndex, peerAddress, peerMpAddress, fields.aid, peerElement, fields.config);
// if we can handle a frame - drop it
return false;
}
return m_protocol->IsActiveLink(m_ifIndex,header.GetAddr2());
return m_protocol->IsActiveLink (m_ifIndex,header.GetAddr2());
}
bool
PeerManagementProtocolMac::UpdateOutcomingFrame (Ptr<Packet> packet, WifiMacHeader & header, Mac48Address from, Mac48Address to)
{
if(header.IsAction ())
if (header.IsAction ())
{
WifiMeshActionHeader actionHdr;
packet->PeekHeader (actionHdr);
@@ -152,12 +154,16 @@ PeerManagementProtocolMac::UpdateOutcomingFrame (Ptr<Packet> packet, WifiMacHead
if(actionHdr.GetCategory () == WifiMeshActionHeader::MESH_PEERING_MGT)
return true;
}
if(header.GetAddr1 ().IsGroup ())
if (header.GetAddr1 ().IsGroup ())
{
return true;
}
else
{
if(m_protocol->IsActiveLink(m_ifIndex,header.GetAddr1()))
if (m_protocol->IsActiveLink (m_ifIndex,header.GetAddr1()))
{
return true;
}
else
{
m_stats.dropped ++;
@@ -168,13 +174,13 @@ PeerManagementProtocolMac::UpdateOutcomingFrame (Ptr<Packet> packet, WifiMacHead
void
PeerManagementProtocolMac::UpdateBeacon (MeshWifiBeacon & beacon) const
{
Ptr<IeBeaconTiming> beaconTiming = m_protocol->GetBeaconTimingElement(m_ifIndex);
beacon.AddInformationElement(beaconTiming);
beacon.AddInformationElement(m_protocol->GetMeshId ());
Ptr<IeBeaconTiming> beaconTiming = m_protocol->GetBeaconTimingElement (m_ifIndex);
beacon.AddInformationElement (beaconTiming);
beacon.AddInformationElement (m_protocol->GetMeshId ());
}
void
PeerManagementProtocolMac::SendPeerLinkManagementFrame(
PeerManagementProtocolMac::SendPeerLinkManagementFrame (
Mac48Address peerAddress,
Mac48Address peerMpAddress,
uint16_t aid,
@@ -221,7 +227,7 @@ PeerManagementProtocolMac::SendPeerLinkManagementFrame(
fields.reasonCode = peerElement.GetReasonCode ();
actionHdr.SetAction (WifiMeshActionHeader::MESH_PEERING_MGT, action);
}
plinkFrame.SetPlinkFrameStart(fields);
plinkFrame.SetPlinkFrameStart (fields);
packet->AddHeader (plinkFrame);
packet->AddHeader (actionHdr);
m_stats.txMgt ++;
@@ -235,15 +241,20 @@ PeerManagementProtocolMac::SendPeerLinkManagementFrame(
hdr.SetAddr3 (m_protocol->GetAddress ());
hdr.SetDsNotFrom ();
hdr.SetDsNotTo ();
m_parent->SendManagementFrame(packet, hdr);
m_parent->SendManagementFrame (packet, hdr);
}
Mac48Address
PeerManagementProtocolMac::GetAddress () const
{
if(m_parent != 0)
return m_parent->GetAddress ();
else return Mac48Address::Mac48Address();
if (m_parent != 0)
{
return m_parent->GetAddress ();
}
else
{
return Mac48Address::Mac48Address ();
}
}
std::pair<Time, Time>
PeerManagementProtocolMac::GetBeaconInfo() const
@@ -256,8 +267,10 @@ PeerManagementProtocolMac::GetBeaconInfo() const
void
PeerManagementProtocolMac::SetBeaconShift(Time shift)
{
if(shift != Seconds (0))
m_stats.beaconShift ++;
if (shift != Seconds (0))
{
m_stats.beaconShift ++;
}
m_parent->ShiftTbtt (shift);
}
PeerManagementProtocolMac::Statistics::Statistics () :

View File

@@ -56,14 +56,21 @@ PeerManagementProtocol::GetTypeId (void)
UintegerValue (32),
MakeUintegerAccessor (&PeerManagementProtocol::m_maxNumberOfPeerLinks),
MakeUintegerChecker<uint8_t> ()
);
)
.AddAttribute ("MaxBeaconLossForBeaconTiming",
"If maximum number of beacons were lost, station will not included in beacon timing element",
UintegerValue (3),
MakeUintegerAccessor (&PeerManagementProtocol::m_maxBeaconLostForBeaconTiming),
MakeUintegerChecker<uint8_t> ()
)
;
return tid;
}
PeerManagementProtocol::PeerManagementProtocol ():
m_lastAssocId (0),
m_lastLocalLinkId (1)
{
}
m_lastLocalLinkId (1),
m_maxBeaconLostForBeaconTiming (3)
{}
PeerManagementProtocol::~PeerManagementProtocol ()
{
}
@@ -75,12 +82,14 @@ PeerManagementProtocol::DoDispose ()
for (PeerLinksMap::iterator j = m_peerLinks.begin (); j != m_peerLinks.end (); j++)
{
for (PeerLinksOnInterface::iterator i = j->second.begin (); i != j->second.end(); i++)
(*i) = 0;
{
(*i) = 0;
}
j->second.clear ();
}
m_peerLinks.clear ();
//cleaning beacon structures:
for(BeaconInfoMap::iterator i = m_neighbourBeacons.begin(); i != m_neighbourBeacons.end(); i ++)
for (BeaconInfoMap::iterator i = m_neighbourBeacons.begin (); i != m_neighbourBeacons.end (); i ++)
{
i->second.clear();
}
@@ -88,74 +97,77 @@ PeerManagementProtocol::DoDispose ()
}
bool
PeerManagementProtocol::Install(Ptr<MeshPointDevice> mp)
PeerManagementProtocol::Install (Ptr<MeshPointDevice> mp)
{
std::vector<Ptr<NetDevice> > interfaces = mp->GetInterfaces ();
for(std::vector<Ptr<NetDevice> >::iterator i = interfaces.begin(); i != interfaces.end(); i ++)
for (std::vector<Ptr<NetDevice> >::iterator i = interfaces.begin (); i != interfaces.end (); i ++)
{
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;
}
Ptr<PeerManagementProtocolMac> plugin = Create<PeerManagementProtocolMac> ((*i)->GetIfIndex(), this);
mac->InstallPlugin(plugin);
m_plugins[(*i)->GetIfIndex()] = plugin;
mac->InstallPlugin (plugin);
m_plugins[(*i)->GetIfIndex ()] = plugin;
PeerLinksOnInterface newmap;
m_peerLinks[(*i)->GetIfIndex()] = newmap;
m_peerLinks[(*i)->GetIfIndex ()] = newmap;
}
// Mesh point aggregates all installed protocols
m_address = Mac48Address::ConvertFrom(mp->GetAddress ());
mp->AggregateObject(this);
m_address = Mac48Address::ConvertFrom (mp->GetAddress ());
mp->AggregateObject (this);
return true;
}
Ptr<IeBeaconTiming>
PeerManagementProtocol::GetBeaconTimingElement(uint32_t interface)
PeerManagementProtocol::GetBeaconTimingElement (uint32_t interface)
{
Ptr<IeBeaconTiming> retval = Create<IeBeaconTiming> ();
BeaconInfoMap::iterator i = m_neighbourBeacons.find(interface);
if(i == m_neighbourBeacons.end())
return retval;
bool cleaned = false;
while(!cleaned)
BeaconInfoMap::iterator i = m_neighbourBeacons.find (interface);
if (i == m_neighbourBeacons.end ())
{
for(BeaconsOnInterface::iterator j = i->second.begin(); j != i->second.end(); j++)
return retval;
}
bool cleaned = false;
while (!cleaned)
{
for (BeaconsOnInterface::iterator j = i->second.begin (); j != i->second.end (); j++)
{
//check beacon loss and make a timing element
//if last beacon was 3 beacons ago - we do not put it to the
//if last beacon was m_maxBeaconLostForBeaconTiming beacons ago - we do not put it to the
//timing element
if(
(j->second.referenceTbtt.GetMicroSeconds() +
(j->second.beaconInterval.GetMicroSeconds()* 3))
<
Simulator::Now().GetMicroSeconds()
)
if ((j->second.referenceTbtt + j->second.beaconInterval * Scalar (m_maxBeaconLostForBeaconTiming)) < Simulator::Now ())
{
i->second.erase(j);
i->second.erase (j);
break;
}
}
cleaned = true;
}
for(BeaconsOnInterface::const_iterator j = i->second.begin(); j != i->second.end(); j++)
retval->AddNeighboursTimingElementUnit(j->second.aid, j->second.referenceTbtt, j->second.beaconInterval);
for (BeaconsOnInterface::const_iterator j = i->second.begin (); j != i->second.end (); j++)
{
retval->AddNeighboursTimingElementUnit (j->second.aid, j->second.referenceTbtt, j->second.beaconInterval);
}
return retval;
}
void
PeerManagementProtocol::FillBeaconInfo(uint32_t interface, Mac48Address peerAddress, Time receivingTime, Time beaconInterval)
PeerManagementProtocol::FillBeaconInfo (uint32_t interface, Mac48Address peerAddress, Time receivingTime, Time beaconInterval)
{
BeaconInfoMap::iterator i = m_neighbourBeacons.find(interface);
if(i == m_neighbourBeacons.end())
BeaconInfoMap::iterator i = m_neighbourBeacons.find (interface);
if (i == m_neighbourBeacons.end ())
{
BeaconsOnInterface newMap;
m_neighbourBeacons[interface] = newMap;
}
i = m_neighbourBeacons.find(interface);
BeaconsOnInterface::iterator j = i->second.find(peerAddress);
if(j == i->second.end())
i = m_neighbourBeacons.find (interface);
BeaconsOnInterface::iterator j = i->second.find (peerAddress);
if (j == i->second.end ())
{
BeaconInfo newInfo;
newInfo.referenceTbtt = receivingTime;
@@ -173,7 +185,7 @@ PeerManagementProtocol::FillBeaconInfo(uint32_t interface, Mac48Address peerAddr
}
void
PeerManagementProtocol::UpdatePeerBeaconTiming(
PeerManagementProtocol::UpdatePeerBeaconTiming (
uint32_t interface,
bool meshBeacon,
IeBeaconTiming timingElement,
@@ -181,33 +193,43 @@ PeerManagementProtocol::UpdatePeerBeaconTiming(
Time receivingTime,
Time beaconInterval)
{
FillBeaconInfo(interface, peerAddress, receivingTime, beaconInterval);
if(!meshBeacon)
return;
FillBeaconInfo (interface, peerAddress, receivingTime, beaconInterval);
if (!meshBeacon)
{
return;
}
//BCA:
PeerManagementProtocolMacMap::iterator plugin = m_plugins.find (interface);
NS_ASSERT(plugin != m_plugins.end ());
Time shift = GetNextBeaconShift(interface);
if(TimeToTu (shift) != 0)
plugin->second->SetBeaconShift(shift);
NS_ASSERT (plugin != m_plugins.end ());
Time shift = GetNextBeaconShift (interface);
if (TimeToTu (shift) != 0)
{
plugin->second->SetBeaconShift(shift);
}
//PM STATE Machine
//Check that a given beacon is not from our interface
for(PeerManagementProtocolMacMap::const_iterator i = m_plugins.begin (); i != m_plugins.end (); i ++)
if(i->second->GetAddress () == peerAddress)
return;
Ptr<PeerLink> peerLink = FindPeerLink(interface, peerAddress);
if(peerLink !=0)
for (PeerManagementProtocolMacMap::const_iterator i = m_plugins.begin (); i != m_plugins.end (); i ++)
{
if (i->second->GetAddress () == peerAddress)
{
return;
}
}
Ptr<PeerLink> peerLink = FindPeerLink (interface, peerAddress);
if (peerLink !=0)
{
peerLink->SetBeaconTimingElement (timingElement);
peerLink->SetBeaconInformation (receivingTime, beaconInterval);
}
else
{
if (ShouldSendOpen (interface, peerAddress))
{
peerLink = InitiateLink (interface, peerAddress, Mac48Address::GetBroadcast (), receivingTime, beaconInterval);
peerLink->SetBeaconTimingElement (timingElement);
peerLink->MLMEActivePeerLinkOpen ();
}
}
}
void
@@ -226,35 +248,48 @@ PeerManagementProtocol::ReceivePeerLinkFrame (
PmpReasonCode reasonCode;
bool reject = ! (ShouldAcceptOpen (interface, peerAddress,reasonCode));
if (peerLink == 0)
peerLink = InitiateLink (interface, peerAddress, peerMeshPointAddress, Simulator::Now (), Seconds(1.0));
if(!reject)
peerLink->OpenAccept (peerManagementElement.GetLocalLinkId(), meshConfig, peerMeshPointAddress);
{
peerLink = InitiateLink (interface, peerAddress, peerMeshPointAddress, Simulator::Now (), Seconds(1.0));
}
if (!reject)
{
peerLink->OpenAccept (peerManagementElement.GetLocalLinkId(), meshConfig, peerMeshPointAddress);
}
else
peerLink->OpenReject (peerManagementElement.GetLocalLinkId(), meshConfig, peerMeshPointAddress, reasonCode);
{
peerLink->OpenReject (peerManagementElement.GetLocalLinkId(), meshConfig, peerMeshPointAddress, reasonCode);
}
}
if (peerLink == 0)
return;
{
return;
}
if (peerManagementElement.SubtypeIsConfirm ())
peerLink->ConfirmAccept (
peerManagementElement.GetLocalLinkId(),
peerManagementElement.GetPeerLinkId(),
aid,
meshConfig,
peerMeshPointAddress);
{
peerLink->ConfirmAccept (
peerManagementElement.GetLocalLinkId(),
peerManagementElement.GetPeerLinkId(),
aid,
meshConfig,
peerMeshPointAddress);
}
if (peerManagementElement.SubtypeIsClose ())
peerLink->Close (
peerManagementElement.GetLocalLinkId(),
peerManagementElement.GetPeerLinkId(),
peerManagementElement.GetReasonCode()
);
{
peerLink->Close (
peerManagementElement.GetLocalLinkId(),
peerManagementElement.GetPeerLinkId(),
peerManagementElement.GetReasonCode()
);
}
}
void
PeerManagementProtocol::ConfigurationMismatch (uint32_t interface, Mac48Address peerAddress)
{
Ptr<PeerLink> peerLink = FindPeerLink(interface, peerAddress);
if(peerLink != 0)
peerLink->MLMECancelPeerLink (REASON11S_MESH_CAPABILITY_POLICY_VIOLATION);
Ptr<PeerLink> peerLink = FindPeerLink (interface, peerAddress);
if (peerLink != 0)
{
peerLink->MLMECancelPeerLink (REASON11S_MESH_CAPABILITY_POLICY_VIOLATION);
}
}
Ptr<PeerLink>
@@ -267,18 +302,24 @@ PeerManagementProtocol::InitiateLink (
{
Ptr<PeerLink> new_link = CreateObject<PeerLink> ();
if (m_lastLocalLinkId == 0xff)
m_lastLocalLinkId = 0;
{
m_lastLocalLinkId = 0;
}
//find a beacon entry
BeaconInfoMap::iterator beaconsOnInterface = m_neighbourBeacons.find (interface);
if(beaconsOnInterface == m_neighbourBeacons.end())
FillBeaconInfo(interface, peerAddress, lastBeacon, beaconInterval);
if (beaconsOnInterface == m_neighbourBeacons.end())
{
FillBeaconInfo(interface, peerAddress, lastBeacon, beaconInterval);
}
beaconsOnInterface = m_neighbourBeacons.find (interface);
BeaconsOnInterface::iterator beacon = beaconsOnInterface->second.find (peerAddress);
if(beacon == beaconsOnInterface->second.end ())
FillBeaconInfo(interface, peerAddress, lastBeacon, beaconInterval);
if (beacon == beaconsOnInterface->second.end ())
{
FillBeaconInfo(interface, peerAddress, lastBeacon, beaconInterval);
}
beacon = beaconsOnInterface->second.find (peerAddress);
//find a peer link - it must not exist
if(FindPeerLink(interface, peerAddress) != 0)
if (FindPeerLink(interface, peerAddress) != 0)
{
NS_FATAL_ERROR ("Peer link must not exist.");
}
@@ -304,6 +345,7 @@ PeerManagementProtocol::FindPeerLink(uint32_t interface, Mac48Address peerAddres
PeerLinksMap::iterator iface = m_peerLinks.find (interface);
NS_ASSERT (iface != m_peerLinks.end());
for (PeerLinksOnInterface::iterator i = iface->second.begin (); i != iface->second.end(); i++)
{
if ((*i)->GetPeerAddress () == peerAddress)
{
if((*i)->LinkIsIdle ())
@@ -313,8 +355,11 @@ PeerManagementProtocol::FindPeerLink(uint32_t interface, Mac48Address peerAddres
return 0;
}
else
{
return (*i);
}
}
}
return 0;
}
void
@@ -323,22 +368,28 @@ PeerManagementProtocol::SetPeerLinkStatusCallback(Callback <void, Mac48Address,
m_peerStatusCallback = cb;
}
std::vector<Mac48Address>
PeerManagementProtocol::GetActiveLinks(uint32_t interface)
PeerManagementProtocol::GetActiveLinks (uint32_t interface)
{
std::vector<Mac48Address> retval;
PeerLinksMap::iterator iface = m_peerLinks.find (interface);
NS_ASSERT (iface != m_peerLinks.end());
for (PeerLinksOnInterface::iterator i = iface->second.begin (); i != iface->second.end(); i++)
if((*i)->LinkIsEstab ())
{
if ((*i)->LinkIsEstab ())
{
retval.push_back((*i)->GetPeerAddress ());
}
}
return retval;
}
bool
PeerManagementProtocol::IsActiveLink (uint32_t interface, Mac48Address peerAddress)
{
Ptr<PeerLink> peerLink = FindPeerLink(interface, peerAddress);
if(peerLink != 0)
return (peerLink->LinkIsEstab ());
if (peerLink != 0)
{
return (peerLink->LinkIsEstab ());
}
return false;
}
bool
@@ -373,16 +424,20 @@ PeerManagementProtocol::GetNextBeaconShift (uint32_t interface)
PeerManagementProtocolMacMap::iterator plugin = m_plugins.find (interface);
NS_ASSERT (plugin != m_plugins.end());
std::pair<Time, Time> myBeacon = plugin->second->GetBeaconInfo ();
if(Simulator::Now () + TuToTime (maxShift) > myBeacon.first + myBeacon.second)
return MicroSeconds (0);
if (Simulator::Now () + TuToTime (maxShift) > myBeacon.first + myBeacon.second)
{
return MicroSeconds (0);
}
for (PeerLinksOnInterface::iterator i = iface->second.begin (); i != iface->second.end (); i++)
{
IeBeaconTiming::NeighboursTimingUnitsList neighbours;
if((*i)->LinkIsIdle ())
continue;
if ((*i)->LinkIsIdle ())
{
continue;
}
neighbours = (*i)->GetBeaconTimingElement ().GetNeighboursTimingElementsList();
//Going through all my timing elements and detecting future beacon collisions
for (IeBeaconTiming::NeighboursTimingUnitsList::const_iterator j = neighbours.begin (); j != neighbours.end(); j++)
for (IeBeaconTiming::NeighboursTimingUnitsList::const_iterator j = neighbours.begin (); j != neighbours.end (); j++)
//We apply MBAC only if beacon Intervals are equal
if ((*j)->GetBeaconInterval () == TimeToTu (myBeacon.second))
{
@@ -394,7 +449,7 @@ PeerManagementProtocol::GetNextBeaconShift (uint32_t interface)
int beaconShift = randomShift.GetInteger (minShift,maxShift) * ((randomSign.GetValue () >= 0) ? 1 : -1);
NS_LOG_DEBUG ("Apply MBCA: Shift value = " << beaconShift << " beacon TUs");
//Do not shift to the past!
return (TuToTime (beaconShift) + Simulator::Now() < myBeacon.first) ? TuToTime (beaconShift) : TuToTime (0);
return (TuToTime (beaconShift) + Simulator::Now () < myBeacon.first) ? TuToTime (beaconShift) : TuToTime (0);
}
}
}
@@ -408,33 +463,37 @@ PeerManagementProtocol::TuToTime (uint32_t x)
uint32_t
PeerManagementProtocol::TimeToTu (Time x)
{
return (uint32_t) (x.GetMicroSeconds ()/1024);
return (uint32_t) (x.GetMicroSeconds () / 1024);
}
void
PeerManagementProtocol::PeerLinkStatus (uint32_t interface, Mac48Address peerAddress, Mac48Address peerMeshPointAddress, PeerLink::PeerState ostate, PeerLink::PeerState nstate)
{
PeerManagementProtocolMacMap::iterator plugin = m_plugins.find (interface);
NS_ASSERT(plugin != m_plugins.end());
NS_LOG_DEBUG(
NS_ASSERT (plugin != m_plugins.end());
NS_LOG_DEBUG (
"Link between me:" << m_address <<
" my interface:" << plugin->second->GetAddress() <<
" and peer mesh point:" << peerMeshPointAddress <<
" and its interface:" << peerAddress <<
", at my interface ID:" << interface <<
". State movement:" << ostate << " -> " << nstate);
if((nstate == PeerLink::ESTAB) && (ostate != PeerLink::ESTAB))
if ((nstate == PeerLink::ESTAB) && (ostate != PeerLink::ESTAB))
{
m_stats.linksOpened ++;
m_stats.linksTotal++;
if(!m_peerStatusCallback.IsNull ())
m_peerStatusCallback (peerMeshPointAddress, peerAddress, interface, true);
if (!m_peerStatusCallback.IsNull ())
{
m_peerStatusCallback (peerMeshPointAddress, peerAddress, interface, true);
}
}
if((ostate == PeerLink::ESTAB) && (nstate != PeerLink::ESTAB))
if ((ostate == PeerLink::ESTAB) && (nstate != PeerLink::ESTAB))
{
m_stats.linksClosed ++;
m_stats.linksTotal--;
if(!m_peerStatusCallback.IsNull ())
m_peerStatusCallback (peerMeshPointAddress, peerAddress, interface, false);
if (!m_peerStatusCallback.IsNull ())
{
m_peerStatusCallback (peerMeshPointAddress, peerAddress, interface, false);
}
}
if (nstate == PeerLink::IDLE)
{
@@ -476,7 +535,7 @@ PeerManagementProtocol::Report (std::ostream & os) const
{
os << "<PeerManagementProtocol>\n";
m_stats.Print (os);
for(PeerManagementProtocolMacMap::const_iterator plugins = m_plugins.begin (); plugins != m_plugins.end (); plugins ++)
for (PeerManagementProtocolMacMap::const_iterator plugins = m_plugins.begin (); plugins != m_plugins.end (); plugins ++)
{
//Take statistics from plugin:
plugins->second->Report (os);
@@ -484,7 +543,9 @@ PeerManagementProtocol::Report (std::ostream & os) const
PeerLinksMap::const_iterator iface = m_peerLinks.find (plugins->second->m_ifIndex);
NS_ASSERT (iface != m_peerLinks.end());
for (PeerLinksOnInterface::const_iterator i = iface->second.begin (); i != iface->second.end(); i++)
(*i)->Report (os);
{
(*i)->Report (os);
}
}
os << "</PeerManagementProtocol>\n";
}
@@ -492,8 +553,10 @@ void
PeerManagementProtocol::ResetStats ()
{
m_stats = Statistics::Statistics (m_stats.linksTotal); // don't reset number of links
for(PeerManagementProtocolMacMap::const_iterator plugins = m_plugins.begin (); plugins != m_plugins.end (); plugins ++)
plugins->second->ResetStats ();
for (PeerManagementProtocolMacMap::const_iterator plugins = m_plugins.begin (); plugins != m_plugins.end (); plugins ++)
{
plugins->second->ResetStats ();
}
}
} // namespace dot11s

View File

@@ -213,6 +213,7 @@ private:
uint16_t m_lastAssocId;
uint16_t m_lastLocalLinkId;
uint8_t m_maxNumberOfPeerLinks;
uint8_t m_maxBeaconLostForBeaconTiming;
/**
* Peer Links
* \{

View File

@@ -38,14 +38,14 @@ TypeId
MeshPointDevice::GetTypeId ()
{
static TypeId tid = TypeId ("ns3::MeshPointDevice")
.SetParent<NetDevice> ()
.AddConstructor<MeshPointDevice> ()
.AddAttribute ("RoutingProtocol", "The mesh routing protocol used by this mesh point.",
PointerValue (),
MakePointerAccessor (&MeshPointDevice::GetRoutingProtocol,
&MeshPointDevice::SetRoutingProtocol),
MakePointerChecker<MeshL2RoutingProtocol> ())
;
.SetParent<NetDevice> ()
.AddConstructor<MeshPointDevice> ()
.AddAttribute ("RoutingProtocol", "The mesh routing protocol used by this mesh point.",
PointerValue (),
MakePointerAccessor (&MeshPointDevice::GetRoutingProtocol,
&MeshPointDevice::SetRoutingProtocol),
MakePointerChecker<MeshL2RoutingProtocol> ())
;
return tid;
}
@@ -65,7 +65,9 @@ MeshPointDevice::DoDispose ()
{
NS_LOG_FUNCTION_NOARGS ();
for (std::vector< Ptr<NetDevice> >::iterator iter = m_ifaces.begin (); iter != m_ifaces.end (); iter++)
*iter = 0;
{
*iter = 0;
}
m_ifaces.clear ();
m_node = 0;
NetDevice::DoDispose ();
@@ -87,7 +89,9 @@ MeshPointDevice::ReceiveFromDevice (Ptr<NetDevice> incomingPort, Ptr<const Packe
uint16_t& realProtocol = protocol;
NS_LOG_DEBUG ("SRC="<<src48<<", DST = "<<dst48<<", I am: "<<m_address);
if (!m_promiscRxCallback.IsNull ())
{
m_promiscRxCallback (this, packet, protocol, src, dst, packetType);
}
if(dst48.IsGroup ())
{
Ptr<Packet> packet_copy = packet->Copy ();
@@ -323,10 +327,13 @@ MeshPointDevice::GetNInterfaces () const
Ptr<NetDevice>
MeshPointDevice::GetInterface (uint32_t n) const
{
for(std::vector< Ptr<NetDevice> >::const_iterator i = m_ifaces.begin (); i != m_ifaces.end (); i ++)
if((*i)->GetIfIndex() == n)
for (std::vector< Ptr<NetDevice> >::const_iterator i = m_ifaces.begin (); i != m_ifaces.end (); i ++)
{
if ((*i)->GetIfIndex() == n)
{
return (*i);
}
}
NS_FATAL_ERROR ("Mesh point interface is not found by index");
return 0;
}
@@ -351,17 +358,20 @@ MeshPointDevice::AddInterface (Ptr<NetDevice> iface)
}
// Mesh point has MAC address of it's first interface
if (m_ifaces.empty())
if (m_ifaces.empty ())
{
m_address = Mac48Address::ConvertFrom (iface->GetAddress ());
}
const WifiNetDevice * wifiNetDev = dynamic_cast<const WifiNetDevice *> (PeekPointer (iface));
if (wifiNetDev == 0)
{
NS_FATAL_ERROR ("Device is not a WiFi NIC: cannot be used as a mesh point interface.");
}
MeshWifiInterfaceMac * ifaceMac = dynamic_cast<MeshWifiInterfaceMac *> (PeekPointer (wifiNetDev->GetMac ()));
if (ifaceMac == 0)
{
NS_FATAL_ERROR ("WiFi device doesn't have correct MAC installed: cannot be used as a mesh point interface.");
}
ifaceMac->SetMeshPointAddress (m_address);
// Receive frames from this interface
@@ -420,10 +430,16 @@ MeshPointDevice::DoSend (bool success, Ptr<Packet> packet, Mac48Address src, Mac
// Send
if (outIface != 0xffffffff)
{
GetInterface (outIface)->SendFrom(packet, src, dst, protocol);
}
else
{
for (std::vector<Ptr<NetDevice> >::iterator i = m_ifaces.begin (); i != m_ifaces.end(); i++)
{
(*i) -> SendFrom (packet->Copy (), src, dst, protocol);
}
}
}
void

View File

@@ -190,7 +190,9 @@ MeshWifiInterfaceMac::SetWifiRemoteStationManager (Ptr<WifiRemoteStationManager>
NS_LOG_FUNCTION (this << stationManager);
m_stationManager = stationManager;
for (Queues::const_iterator i = m_queues.begin (); i != m_queues.end (); i ++)
{
i->second->SetWifiRemoteStationManager (stationManager);
}
m_beaconDca->SetWifiRemoteStationManager (stationManager);
m_low->SetWifiRemoteStationManager (stationManager);
}
@@ -310,9 +312,13 @@ uint16_t MeshWifiInterfaceMac::GetFrequencyChannel () const
Ptr<YansWifiPhy> phy = m_phy->GetObject<YansWifiPhy> ();
if (phy != 0)
return phy->GetChannelNumber ();
{
return phy->GetChannelNumber ();
}
else
return 0;
{
return 0;
}
}
void MeshWifiInterfaceMac::SwitchFrequencyChannel (uint16_t new_id)
@@ -371,7 +377,10 @@ MeshWifiInterfaceMac::ForwardDown (Ptr<const Packet> const_packet, Mac48Address
for (PluginList::const_iterator i = m_plugins.end()-1; i != m_plugins.begin()-1; i--)
{
bool drop = ! ((*i)->UpdateOutcomingFrame(packet, hdr, from, to));
if (drop) return; // plugin drops frame
if (drop)
{
return; // plugin drops frame
}
}
// Assert that address1 is set. Assert will fail e.g. if there is no installed routing plugin.
@@ -394,8 +403,10 @@ MeshWifiInterfaceMac::ForwardDown (Ptr<const Packet> const_packet, Mac48Address
// Get Qos tag:
AccessClass ac = AC_BE;
QosTag tag;
if(packet->RemovePacketTag (tag))
ac = QosUtilsMapTidToAc (tag.Get ());
if (packet->RemovePacketTag (tag))
{
ac = QosUtilsMapTidToAc (tag.Get ());
}
m_stats.sentFrames ++;
m_stats.sentBytes += packet->GetSize ();
NS_ASSERT(m_queues.find(ac) != m_queues.end ());
@@ -410,7 +421,10 @@ MeshWifiInterfaceMac::SendManagementFrame (Ptr<Packet> packet, const WifiMacHead
for (PluginList::const_iterator i = m_plugins.end()-1; i != m_plugins.begin()-1; i--)
{
bool drop = ! ((*i)->UpdateOutcomingFrame(packet, header, Mac48Address (), Mac48Address ()));
if (drop) return; // plugin drops frame
if (drop)
{
return; // plugin drops frame
}
}
m_stats.sentFrames ++;
m_stats.sentBytes += packet->GetSize ();
@@ -448,7 +462,9 @@ MeshWifiInterfaceMac::CheckSupportedRates(SupportedRates rates) const
{
WifiMode mode = m_stationManager->GetBasicMode (i);
if (!rates.IsSupportedRate (mode.GetDataRate ()))
return false;
{
return false;
}
}
return true;
}
@@ -490,8 +506,10 @@ MeshWifiInterfaceMac::SetBeaconGeneration (bool enable)
m_tbtt = Simulator::Now() + randomStart;
}
else
// stop sending beacons
m_beaconSendEvent.Cancel ();
{
// stop sending beacons
m_beaconSendEvent.Cancel ();
}
}
bool
@@ -538,8 +556,9 @@ MeshWifiInterfaceMac::SendBeacon ()
// Ask all plugins to add their specific information elements to beacon
for (PluginList::const_iterator i = m_plugins.begin(); i != m_plugins.end(); ++i)
(*i)->UpdateBeacon (beacon);
{
(*i)->UpdateBeacon (beacon);
}
m_beaconDca->Queue (beacon.CreatePacket(), beacon.CreateHeader(GetAddress (), GetMeshPointAddress ()));
ScheduleNextBeacon ();
@@ -549,8 +568,10 @@ void
MeshWifiInterfaceMac::Receive (Ptr<Packet> packet, WifiMacHeader const *hdr)
{
// Process beacon
if((hdr->GetAddr1() != GetAddress()) && (hdr->GetAddr1() != Mac48Address::GetBroadcast()))
return;
if ((hdr->GetAddr1() != GetAddress()) && (hdr->GetAddr1() != Mac48Address::GetBroadcast()))
{
return;
}
if (hdr->IsBeacon ())
{
m_stats.recvBeacons ++;
@@ -577,7 +598,9 @@ MeshWifiInterfaceMac::Receive (Ptr<Packet> packet, WifiMacHeader const *hdr)
{
peerSta->AddSupportedMode (mode);
if (rates.IsBasicRate (mode.GetDataRate ()))
m_stationManager->AddBasicMode (mode);
{
m_stationManager->AddBasicMode (mode);
}
}
}
}
@@ -591,23 +614,32 @@ MeshWifiInterfaceMac::Receive (Ptr<Packet> packet, WifiMacHeader const *hdr)
for (PluginList::iterator i = m_plugins.begin (); i != m_plugins.end(); ++i)
{
bool drop = ! ((*i)->Receive(packet, *hdr));
if (drop) return; // plugin drops frame
if (drop)
{
return; // plugin drops frame
}
}
// Check if QoS tag exists and add it:
if (hdr->IsQosData ())
packet->AddPacketTag (QosTag (hdr->GetQosTid ()));
{
packet->AddPacketTag (QosTag (hdr->GetQosTid ()));
}
// Forward data up
if (hdr->IsData ())
{
ForwardUp (packet, hdr->GetAddr4(), hdr->GetAddr3());
}
}
uint32_t
MeshWifiInterfaceMac::GetLinkMetric (Mac48Address peerAddress)
{
uint32_t metric = 1;
if(!m_linkMetricCallback.IsNull ())
metric = m_linkMetricCallback(peerAddress, this);
if (!m_linkMetricCallback.IsNull ())
{
metric = m_linkMetricCallback(peerAddress, this);
}
return metric;
}
@@ -665,7 +697,7 @@ void
MeshWifiInterfaceMac::SetQueue (Ptr<DcaTxop> queue, AccessClass ac)
{
Queues::iterator i = m_queues.find(ac);
if(i != m_queues.end ())
if (i != m_queues.end ())
{
NS_LOG_WARN("Queue is already set!");
return;
@@ -677,7 +709,7 @@ MeshWifiInterfaceMac::SetQueue (Ptr<DcaTxop> queue, AccessClass ac)
Ptr<DcaTxop>
MeshWifiInterfaceMac::GetQueue (AccessClass ac)
{
Queues::iterator i = m_queues.find(ac);
Queues::iterator i = m_queues.find (ac);
if(i != m_queues.end ())
{
NS_LOG_WARN("Queue is not found! Check access class!");