Peer link restructured to support multi-interface

This commit is contained in:
Kirill Andreev
2009-04-02 13:38:38 +04:00
parent 143688ef05
commit d0a68752eb
11 changed files with 187 additions and 128 deletions

View File

@@ -39,8 +39,8 @@ int
main (int argc, char *argv[])
{
// Creating square topology with nNodes x nNodes grid
int xSize = 6;
int ySize = 6;
int xSize = 2;
int ySize = 2;
double step = 100.0; // Grid with one-hop edge
double randomStart = 0.1; // One beacon interval
uint32_t nIfaces = 1;

View File

@@ -74,7 +74,8 @@ HwmpMacPlugin::Receive (Ptr<Packet> packet, const WifiMacHeader & header)
return false;
tag.SetTtl (meshHdr.GetMeshTtl () - 1);
tag.SetAddress (header.GetAddr2 ());
packet->AddPacketTag(tag);
if(!m_protocol->RemoveTags(destination))
packet->AddPacketTag(tag);
if (destination == Mac48Address::GetBroadcast ())
if(m_protocol->DropDataFrame (meshHdr.GetMeshSeqno (), header.GetAddr4 ()) )
return false;
@@ -140,6 +141,7 @@ HwmpMacPlugin::UpdateOutcomingFrame (Ptr<Packet> packet, WifiMacHeader & header,
meshHdr.SetMeshTtl(tag.GetTtl());
packet->AddHeader(meshHdr);
header.SetAddr1(tag.GetAddress());
NS_LOG_UNCOND("Broadcast sent");
return true;
}
void

View File

@@ -183,7 +183,10 @@ HwmpProtocol::RequestRoute (
tag.DecrementTtl ();
}
if (destination == Mac48Address::GetBroadcast ())
{
NS_LOG_UNCOND("BROADCAS");
routeReply (true, packet, source, destination, protocolType, HwmpRtable::INTERFACE_ANY);
}
else
return ForwardUnicast(sourceIface, source, destination, packet, protocolType, routeReply);
return true;
@@ -248,13 +251,12 @@ HwmpProtocol::ForwardUnicast(uint32_t sourceIface, const Mac48Address source, c
return true;
}
bool
HwmpProtocol::HandleIncomingFrame (Ptr<Packet> packet, Mac48Address src, Mac48Address dst, uint16_t protocol)
HwmpProtocol::RemoveTags (Mac48Address dst)
{
//Handle only incoming frames:
NS_ASSERT(dst == m_address);
HwmpTag tag;
NS_ASSERT(packet->RemovePacketTag(tag));
return true;
//Check that dst is my address
if(dst == m_address)
return true;
return false;
}
void
HwmpProtocol::ReceivePreq (IePreq preq, Mac48Address from, uint32_t interface)
@@ -493,10 +495,17 @@ HwmpProtocol::Install (Ptr<MeshPointDevice> mp)
return true;
}
void
HwmpProtocol::PeerLinkStatus(Mac48Address peerAddress, uint32_t interface, bool status)
HwmpProtocol::PeerLinkStatus(Mac48Address meshPointAddress, Mac48Address peerAddress, uint32_t interface, bool status)
{
if(status)
m_rtable->AddReactivePath(peerAddress, peerAddress, interface, 1, Seconds (0), 0);
{
HwmpRtable::LookupResult result = m_rtable->LookupReactive(meshPointAddress);
if(result.retransmitter == Mac48Address::GetBroadcast ())
{
NS_LOG_UNCOND("I am"<<m_address<<" MP:"<<meshPointAddress<<"accessible through interface"<<interface<<", ra = "<<peerAddress);
m_rtable->AddReactivePath(meshPointAddress, peerAddress, interface, 1, Seconds (0), 0);
}
}
else
{
std::vector<IePerr::FailedDestination> destinations = m_rtable->GetUnreachableDestinations (peerAddress);
@@ -696,7 +705,10 @@ HwmpProtocol::RetryPathDiscovery (Mac48Address dst, uint8_t numOfRetry)
return;
}
for(HwmpPluginMap::iterator i = m_interfaces.begin (); i != m_interfaces.end (); i ++)
{
//i->second->RequestDestination(Mac48Address("00:00:00:00:00:04"));
i->second->RequestDestination(dst);
}
m_preqTimeouts[dst] = Simulator::Schedule (
MilliSeconds (2*(m_dot11MeshHWMPnetDiameterTraversalTime.GetMilliSeconds())),
&HwmpProtocol::RetryPathDiscovery, this, dst, numOfRetry);

View File

@@ -54,7 +54,6 @@ public:
/// Route request, inherited from MeshL2RoutingProtocol
bool RequestRoute (uint32_t sourceIface, const Mac48Address source, const Mac48Address destination,
Ptr<Packet> packet, uint16_t protocolType, RouteReplyCallback routeReply);
bool HandleIncomingFrame (Ptr<Packet> packet, Mac48Address src, Mac48Address dst, uint16_t protocol);
/**
* \brief Install HWMP on given mesh point.
*
@@ -64,7 +63,7 @@ public:
* via MeshPointDevice::GetObject<dot11s::HwmpProtocol>();
*/
bool Install (Ptr<MeshPointDevice>);
void PeerLinkStatus(Mac48Address peerAddress, uint32_t interface,bool status);
void PeerLinkStatus(Mac48Address meshPontAddress, Mac48Address peerAddress, uint32_t interface,bool status);
///\brief This callback is used to obtain active neighbours on a
//given interface
///\param interface is the interface ID
@@ -108,7 +107,8 @@ private:
*/
bool DropDataFrame(uint32_t, Mac48Address);
//\}
///\brief if the packet is ours - plugins should remove tag
bool RemoveTags (Mac48Address dst);
private:
///\name Methods related to Queue/Dequeue procedures
//\{

View File

@@ -70,19 +70,24 @@ PeerLink::GetTypeId()
// PeerLink public interface
//-----------------------------------------------------------------------------
PeerLink::PeerLink ():
m_localLinkId (0),
m_peerLinkId (0),
m_state (IDLE),
m_retryCounter (0)
m_peerAddress (Mac48Address::GetBroadcast ()),
m_peerMeshPointAddress (Mac48Address::GetBroadcast ()),
m_localLinkId (0),
m_peerLinkId (0),
m_state (IDLE),
m_retryCounter (0)
{
}
void
PeerLink::SetPeerAddress (Mac48Address macaddr)
{
m_peerAddress = macaddr;
}
void
PeerLink::SetPeerMeshPointAddress(Mac48Address macaddr)
{
m_peerMeshPointAddress = macaddr;
}
void
PeerLink::SetInterface (uint32_t interface)
{
@@ -93,13 +98,11 @@ PeerLink::SetLocalLinkId (uint16_t id)
{
m_localLinkId = id;
}
void
PeerLink::SetLocalAid (uint16_t aid)
{
m_assocId = aid;
}
void
PeerLink::SetBeaconInformation (Time lastBeacon, Time beaconInterval)
{
@@ -110,82 +113,73 @@ PeerLink::SetBeaconInformation (Time lastBeacon, Time beaconInterval)
NS_ASSERT (delay.GetMicroSeconds() != 0);
m_beaconLossTimer = Simulator::Schedule (delay, &PeerLink::BeaconLoss, this);
}
void
PeerLink::MLMESetSignalStatusCallback (PeerLink::SignalStatusCallback cb)
{
m_linkStatusCallback = cb;
}
void
PeerLink::BeaconLoss ()
{
StateMachine (CNCL);
}
void
PeerLink::SetBeaconTimingElement (IeBeaconTiming beaconTiming)
{
m_beaconTiming = beaconTiming;
}
Mac48Address
PeerLink::GetPeerAddress () const
{
return m_peerAddress;
}
uint16_t
PeerLink::GetLocalAid () const
{
return m_assocId;
}
Time
PeerLink::GetLastBeacon () const
{
return m_lastBeacon;
}
Time
PeerLink::GetBeaconInterval () const
{
return m_beaconInterval;
}
IeBeaconTiming
PeerLink::GetBeaconTimingElement () const
{
return m_beaconTiming;
}
void
PeerLink::ClearTimingElement ()
{
m_beaconTiming.ClearTimingElement ();
}
void PeerLink::MLMECancelPeerLink (PmpReasonCode reason)
void
PeerLink::MLMECancelPeerLink (PmpReasonCode reason)
{
StateMachine (CNCL,reason);
}
void PeerLink::MLMEPassivePeerLinkOpen ()
void
PeerLink::MLMEPassivePeerLinkOpen ()
{
StateMachine (PASOPN);
}
void PeerLink::MLMEActivePeerLinkOpen ()
void
PeerLink::MLMEActivePeerLinkOpen ()
{
StateMachine (ACTOPN);
}
void PeerLink::MLMEPeeringRequestReject ()
void
PeerLink::MLMEPeeringRequestReject ()
{
StateMachine (REQ_RJCT, REASON11S_PEER_LINK_CANCELLED);
}
void PeerLink::Close (uint16_t localLinkId, uint16_t peerLinkId, PmpReasonCode reason)
void
PeerLink::Close (uint16_t localLinkId, uint16_t peerLinkId, PmpReasonCode reason)
{
if (peerLinkId != 0 && m_localLinkId != peerLinkId)
return;
@@ -195,25 +189,32 @@ void PeerLink::Close (uint16_t localLinkId, uint16_t peerLinkId, PmpReasonCode r
return;
StateMachine (CLS_ACPT, reason);
}
void PeerLink::OpenAccept (uint16_t localLinkId, IeConfiguration conf)
void
PeerLink::OpenAccept (uint16_t localLinkId, IeConfiguration conf, Mac48Address peerMp)
{
if (m_peerLinkId == 0)
m_peerLinkId = localLinkId;
m_configuration = conf;
if(m_peerMeshPointAddress != Mac48Address::GetBroadcast ())
NS_ASSERT(m_peerMeshPointAddress == peerMp);
else
m_peerMeshPointAddress = peerMp;
StateMachine (OPN_ACPT);
}
void PeerLink::OpenReject (uint16_t localLinkId, IeConfiguration conf,PmpReasonCode reason)
void
PeerLink::OpenReject (uint16_t localLinkId, IeConfiguration conf, Mac48Address peerMp, PmpReasonCode reason)
{
if ( m_peerLinkId == 0)
m_peerLinkId = localLinkId;
m_configuration = conf;
if(m_peerMeshPointAddress != Mac48Address::GetBroadcast ())
NS_ASSERT(m_peerMeshPointAddress == peerMp);
else
m_peerMeshPointAddress = peerMp;
StateMachine (OPN_RJCT, reason);
}
void
PeerLink::ConfirmAccept (uint16_t localLinkId, uint16_t peerLinkId, uint16_t peerAid, IeConfiguration conf)
PeerLink::ConfirmAccept (uint16_t localLinkId, uint16_t peerLinkId, uint16_t peerAid, IeConfiguration conf, Mac48Address peerMp)
{
if ( m_localLinkId != peerLinkId)
return;
@@ -223,12 +224,15 @@ PeerLink::ConfirmAccept (uint16_t localLinkId, uint16_t peerLinkId, uint16_t pee
return;
m_configuration = conf;
m_peerAssocId = peerAid;
if(m_peerMeshPointAddress != Mac48Address::GetBroadcast ())
NS_ASSERT(m_peerMeshPointAddress == peerMp);
else
m_peerMeshPointAddress = peerMp;
StateMachine (CNF_ACPT);
}
void
PeerLink::ConfirmReject (uint16_t localLinkId, uint16_t peerLinkId,
IeConfiguration conf,PmpReasonCode reason)
IeConfiguration conf, Mac48Address peerMp, PmpReasonCode reason)
{
if (m_localLinkId != peerLinkId)
return;
@@ -237,15 +241,16 @@ PeerLink::ConfirmReject (uint16_t localLinkId, uint16_t peerLinkId,
else if (m_peerLinkId != localLinkId)
return;
m_configuration = conf;
if(m_peerMeshPointAddress != Mac48Address::GetBroadcast ())
NS_ASSERT(m_peerMeshPointAddress == peerMp);
m_peerMeshPointAddress = peerMp;
StateMachine (CNF_RJCT, reason);
}
bool
PeerLink::LinkIsEstab () const
{
return (m_state == ESTAB);
}
bool
PeerLink::LinkIsIdle () const
{
@@ -360,7 +365,8 @@ PeerLink::StateMachine (PeerEvent event,PmpReasonCode reasoncode)
m_state = ESTAB;
ClearConfirmTimer ();
SendPeerLinkConfirm ();
m_linkStatusCallback (m_interface, m_peerAddress, true);
NS_ASSERT(m_peerMeshPointAddress != Mac48Address::GetBroadcast ());
m_linkStatusCallback (m_interface, m_peerAddress, m_peerMeshPointAddress, true);
// TODO Callback MLME-SignalPeerLinkStatus
break;
case CLS_ACPT:
@@ -402,7 +408,8 @@ PeerLink::StateMachine (PeerEvent event,PmpReasonCode reasoncode)
case CNF_ACPT:
m_state = ESTAB;
ClearRetryTimer ();
m_linkStatusCallback (m_interface, m_peerAddress, true);
NS_ASSERT(m_peerMeshPointAddress != Mac48Address::GetBroadcast ());
m_linkStatusCallback (m_interface, m_peerAddress, m_peerMeshPointAddress, true);
// TODO Callback MLME-SignalPeerLinkStatus
break;
case CLS_ACPT:
@@ -444,7 +451,7 @@ PeerLink::StateMachine (PeerEvent event,PmpReasonCode reasoncode)
m_state = HOLDING;
SendPeerLinkClose (REASON11S_MESH_CLOSE_RCVD);
SetHoldingTimer ();
m_linkStatusCallback (m_interface, m_peerAddress, false);
m_linkStatusCallback (m_interface, m_peerAddress, m_peerMeshPointAddress, false);
break;
case OPN_RJCT:
case CNF_RJCT:
@@ -452,13 +459,13 @@ PeerLink::StateMachine (PeerEvent event,PmpReasonCode reasoncode)
ClearRetryTimer ();
SendPeerLinkClose (reasoncode);
SetHoldingTimer ();
m_linkStatusCallback (m_interface, m_peerAddress, false);
m_linkStatusCallback (m_interface, m_peerAddress, m_peerMeshPointAddress, false);
break;
case CNCL:
m_state = HOLDING;
SendPeerLinkClose (REASON11S_PEER_LINK_CANCELLED);
SetHoldingTimer ();
m_linkStatusCallback (m_interface, m_peerAddress, false);
m_linkStatusCallback (m_interface, m_peerAddress, m_peerMeshPointAddress, false);
break;
default:
{}
@@ -490,80 +497,79 @@ PeerLink::StateMachine (PeerEvent event,PmpReasonCode reasoncode)
break;
}
}
void PeerLink::ClearRetryTimer ()
void
PeerLink::ClearRetryTimer ()
{
m_retryTimer.Cancel ();
}
void PeerLink::ClearConfirmTimer ()
void
PeerLink::ClearConfirmTimer ()
{
m_confirmTimer.Cancel ();
}
void PeerLink::ClearHoldingTimer ()
void
PeerLink::ClearHoldingTimer ()
{
m_holdingTimer.Cancel ();
}
void PeerLink::SendPeerLinkClose (PmpReasonCode reasoncode)
void
PeerLink::SendPeerLinkClose (PmpReasonCode reasoncode)
{
IePeerManagement peerElement;
peerElement.SetPeerClose (m_localLinkId, m_peerLinkId, reasoncode);
m_macPlugin->SendPeerLinkManagementFrame (m_peerAddress, m_assocId, peerElement, m_configuration);
m_macPlugin->SendPeerLinkManagementFrame (m_peerAddress, m_peerMeshPointAddress, m_assocId, peerElement, m_configuration);
}
void PeerLink::SendPeerLinkOpen ()
void
PeerLink::SendPeerLinkOpen ()
{
IePeerManagement peerElement;
peerElement.SetPeerOpen (m_localLinkId);
NS_ASSERT (m_macPlugin != NULL);
m_macPlugin->SendPeerLinkManagementFrame (m_peerAddress, m_assocId, peerElement, m_configuration);
m_macPlugin->SendPeerLinkManagementFrame (m_peerAddress, m_peerMeshPointAddress, m_assocId, peerElement, m_configuration);
}
void PeerLink::SendPeerLinkConfirm ()
void
PeerLink::SendPeerLinkConfirm ()
{
IePeerManagement peerElement;
peerElement.SetPeerConfirm (m_localLinkId, m_peerLinkId);
m_macPlugin->SendPeerLinkManagementFrame (m_peerAddress, m_assocId, peerElement, m_configuration);
m_macPlugin->SendPeerLinkManagementFrame (m_peerAddress, m_peerMeshPointAddress, m_assocId, peerElement, m_configuration);
}
void PeerLink::SetHoldingTimer ()
void
PeerLink::SetHoldingTimer ()
{
NS_ASSERT(m_dot11MeshHoldingTimeout.GetMicroSeconds() !=0);
m_holdingTimer = Simulator::Schedule (m_dot11MeshHoldingTimeout, &PeerLink::HoldingTimeout, this);
}
void PeerLink::HoldingTimeout ()
void
PeerLink::HoldingTimeout ()
{
StateMachine (TOH);
}
void PeerLink::SetRetryTimer ()
void
PeerLink::SetRetryTimer ()
{
NS_ASSERT(m_dot11MeshRetryTimeout.GetMicroSeconds() !=0);
m_retryTimer = Simulator::Schedule (m_dot11MeshRetryTimeout, &PeerLink::RetryTimeout, this);
}
void PeerLink::RetryTimeout ()
void
PeerLink::RetryTimeout ()
{
if ( m_retryCounter < m_dot11MeshMaxRetries)
StateMachine (TOR1);
else
StateMachine (TOR2);
}
void PeerLink::SetConfirmTimer ()
void
PeerLink::SetConfirmTimer ()
{
NS_ASSERT(m_dot11MeshConfirmTimeout.GetMicroSeconds() !=0);
m_confirmTimer = Simulator::Schedule (m_dot11MeshConfirmTimeout, &PeerLink::ConfirmTimeout, this);
}
void PeerLink::ConfirmTimeout ()
void
PeerLink::ConfirmTimeout ()
{
StateMachine (TOC);
}
}
} // namespace dot11s
} //namespace ns3

View File

@@ -58,21 +58,22 @@ public:
* \name Peer link geeters/setters
* \{
*/
void SetPeerAddress (Mac48Address macaddr);
void SetInterface (uint32_t interface);
void SetLocalLinkId (uint16_t id);
void SetPeerLinkId (uint16_t id);
void SetLocalAid (uint16_t aid);
void SetPeerAid (uint16_t aid);
void SetBeaconTimingElement (IeBeaconTiming beaconTiming);
void SetPeerLinkDescriptorElement (IePeerManagement peerLinkElement);
void SetPeerAddress (Mac48Address macaddr);
void SetPeerMeshPointAddress (Mac48Address macaddr);
void SetInterface (uint32_t interface);
void SetLocalLinkId (uint16_t id);
void SetPeerLinkId (uint16_t id);
void SetLocalAid (uint16_t aid);
void SetPeerAid (uint16_t aid);
void SetBeaconTimingElement (IeBeaconTiming beaconTiming);
void SetPeerLinkDescriptorElement (IePeerManagement peerLinkElement);
Mac48Address GetPeerAddress () const;
uint16_t GetLocalAid () const;
Time GetLastBeacon () const;
Time GetBeaconInterval () const;
Time GetLastBeacon () const;
Time GetBeaconInterval () const;
IeBeaconTiming GetBeaconTimingElement ()const;
IePeerManagement GetPeerLinkDescriptorElement ()const;
void ClearTimingElement ();
void ClearTimingElement ();
//\}
/**
@@ -88,7 +89,7 @@ public:
/// MLME-PeeringRequestReject
void MLMEPeeringRequestReject ();
/// Callback type for MLME-SignalPeerLinkStatus event
typedef Callback<void, uint32_t, Mac48Address, bool> SignalStatusCallback;
typedef Callback<void, uint32_t, Mac48Address, Mac48Address, bool> SignalStatusCallback;
/// Set callback
void MLMESetSignalStatusCallback (SignalStatusCallback);
//\}
@@ -106,21 +107,23 @@ private:
/// Close link
void Close (uint16_t localLinkID, uint16_t peerLinkID, PmpReasonCode reason);
/// Accept open link
void OpenAccept (uint16_t localLinkId, IeConfiguration conf);
void OpenAccept (uint16_t localLinkId, IeConfiguration conf, Mac48Address peerMp);
/// Reject open link
void OpenReject (uint16_t localLinkId, IeConfiguration conf, PmpReasonCode reason);
void OpenReject (uint16_t localLinkId, IeConfiguration conf, Mac48Address peerMp, PmpReasonCode reason);
/// Confirm accept
void ConfirmAccept (
uint16_t localLinkId,
uint16_t peerLinkId,
uint16_t peerAid,
IeConfiguration conf
IeConfiguration conf,
Mac48Address peerMp
);
/// Confirm reject
void ConfirmReject (
uint16_t localLinkId,
uint16_t peerLinkId,
IeConfiguration conf,
Mac48Address peerMp,
PmpReasonCode reason
);
//\}
@@ -204,6 +207,9 @@ private:
Ptr<PeerManagerMacPlugin> m_macPlugin;
/// Peer address
Mac48Address m_peerAddress;
/// Mesh point address, equal to peer address in case of single
//interface mesh point
Mac48Address m_peerMeshPointAddress;
/// My ID of this link
uint16_t m_localLinkId;
/// Peer ID of this link

View File

@@ -88,8 +88,8 @@ PeerManagerMacPlugin::Receive (Ptr<Packet> const_packet, const WifiMacHeader & h
return true;
NS_ASSERT(meshHdr.GetMeshTtl () == 1);
NS_ASSERT(meshHdr.GetAddressExt () == 1);
NS_ASSERT(meshHdr.GetAddr4 () == header.GetAddr2 ());
Mac48Address peerAddress = header.GetAddr2 ();
Mac48Address peerMpAddress = meshHdr.GetAddr4 ();
PeerLinkFrameStart::PlinkFrameStartFields fields;
{
PeerLinkFrameStart peerFrame;
@@ -136,7 +136,7 @@ PeerManagerMacPlugin::Receive (Ptr<Packet> const_packet, const WifiMacHeader & h
return true;
}
//Deliver Peer link management frame to protocol:
m_protocol->ReceivePeerLinkFrame(m_ifIndex, peerAddress, fields.aid, peerElement, meshConfig);
m_protocol->ReceivePeerLinkFrame(m_ifIndex, peerAddress, peerMpAddress, fields.aid, peerElement, meshConfig);
// if we can handle a frame - drop it
return false;
}
@@ -159,6 +159,7 @@ PeerManagerMacPlugin::UpdateBeacon (MeshWifiBeacon & beacon) const
void
PeerManagerMacPlugin::SendPeerLinkManagementFrame(
Mac48Address peerAddress,
Mac48Address peerMpAddress,
uint16_t aid,
IePeerManagement peerElement,
IeConfiguration meshConfig
@@ -204,14 +205,14 @@ PeerManagerMacPlugin::SendPeerLinkManagementFrame(
meshHdr.SetMeshTtl (1);
meshHdr.SetMeshSeqno (0);
meshHdr.SetAddressExt(1);
meshHdr.SetAddr4(m_parent->GetAddress ());
meshHdr.SetAddr4(m_protocol->GetAddress ());
packet->AddHeader (meshHdr);
//Wifi Mac header:
WifiMacHeader hdr;
hdr.SetMultihopAction ();
hdr.SetAddr1 (peerAddress);
hdr.SetAddr2 (m_parent->GetAddress ());
hdr.SetAddr3 (peerAddress);
hdr.SetAddr3 (peerMpAddress);
hdr.SetDsNotFrom ();
hdr.SetDsNotTo ();
m_parent->SendManagementFrame(packet, hdr);

View File

@@ -66,6 +66,7 @@ private:
void SetPeerManagerProtcol(Ptr<PeerManagementProtocol> protocol);
void SendPeerLinkManagementFrame(
Mac48Address peerAddress,
Mac48Address peerMpAddress,
uint16_t aid,
IePeerManagement peerElement,
IeConfiguration meshConfig

View File

@@ -118,6 +118,8 @@ PeerManagementProtocol::Install(Ptr<MeshPointDevice> mp)
m_peerLinks[(*i)->GetIfIndex()] = newmap;
}
// Mesh point aggregates all installed protocols
m_address = Mac48Address::ConvertFrom(mp->GetAddress ());
NS_LOG_UNCOND("MP address:"<<m_address);
mp->AggregateObject(this);
return true;
}
@@ -200,6 +202,10 @@ PeerManagementProtocol::UpdatePeerBeaconTiming(
NS_ASSERT(plugin != m_plugins.end ());
plugin->second->SetBeaconShift(GetNextBeaconShift(interface));
//PM STATE Machine
//Check that a given beacon is not from our interface
for(PeerManagerPluginMap::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)
{
@@ -208,7 +214,7 @@ PeerManagementProtocol::UpdatePeerBeaconTiming(
}
else
{
peerLink = InitiateLink (interface, peerAddress, receivingTime, beaconInterval);
peerLink = InitiateLink (interface, peerAddress, Mac48Address::GetBroadcast (), receivingTime, beaconInterval);
peerLink->SetBeaconTimingElement (timingElement);
if (ShouldSendOpen (interface, peerAddress))
peerLink->MLMEActivePeerLinkOpen ();
@@ -219,6 +225,7 @@ void
PeerManagementProtocol::ReceivePeerLinkFrame (
uint32_t interface,
Mac48Address peerAddress,
Mac48Address peerMeshPointAddress,
uint16_t aid,
IePeerManagement peerManagementElement,
IeConfiguration meshConfig
@@ -230,19 +237,24 @@ PeerManagementProtocol::ReceivePeerLinkFrame (
PmpReasonCode reasonCode;
bool reject = ! (ShouldAcceptOpen (interface, peerAddress,reasonCode));
if (peerLink == 0)
peerLink = InitiateLink (interface, peerAddress, Simulator::Now (), Seconds(1.0));
peerLink = InitiateLink (interface, peerAddress, peerMeshPointAddress, Simulator::Now (), Seconds(1.0));
if(!reject)
{
peerLink->MLMEPassivePeerLinkOpen ();
peerLink->OpenAccept (peerManagementElement.GetLocalLinkId(), meshConfig);
peerLink->OpenAccept (peerManagementElement.GetLocalLinkId(), meshConfig, peerMeshPointAddress);
}
else
peerLink->OpenReject (peerManagementElement.GetLocalLinkId(), meshConfig, reasonCode);
peerLink->OpenReject (peerManagementElement.GetLocalLinkId(), meshConfig, peerMeshPointAddress, reasonCode);
}
if (peerLink == 0)
return;
if (peerManagementElement.SubtypeIsConfirm ())
peerLink->ConfirmAccept (peerManagementElement.GetLocalLinkId(), peerManagementElement.GetPeerLinkId(), aid, meshConfig);
peerLink->ConfirmAccept (
peerManagementElement.GetLocalLinkId(),
peerManagementElement.GetPeerLinkId(),
aid,
meshConfig,
peerMeshPointAddress);
if (peerManagementElement.SubtypeIsClose ())
peerLink->Close (
peerManagementElement.GetLocalLinkId(),
@@ -263,6 +275,7 @@ Ptr<PeerLink>
PeerManagementProtocol::InitiateLink (
uint32_t interface,
Mac48Address peerAddress,
Mac48Address peerMeshPointAddress,
Time lastBeacon,
Time beaconInterval)
{
@@ -289,6 +302,7 @@ PeerManagementProtocol::InitiateLink (
new_link->SetInterface (interface);
new_link->SetLocalLinkId (m_lastLocalLinkId++);
new_link->SetPeerAddress (peerAddress);
new_link->SetPeerMeshPointAddress (peerMeshPointAddress);
new_link->SetBeaconInformation (lastBeacon, beaconInterval);
new_link->SetMacPlugin (plugin->second);
new_link->MLMESetSignalStatusCallback (MakeCallback(&PeerManagementProtocol::PeerLinkStatus, this));
@@ -306,7 +320,7 @@ PeerManagementProtocol::FindPeerLink(uint32_t interface, Mac48Address peerAddres
return 0;
}
void
PeerManagementProtocol::SetPeerLinkStatusCallback(Callback <void, Mac48Address, uint32_t, bool> cb)
PeerManagementProtocol::SetPeerLinkStatusCallback(Callback <void, Mac48Address, Mac48Address, uint32_t, bool> cb)
{
m_peerStatusCallback = cb;
}
@@ -364,7 +378,10 @@ PeerManagementProtocol::ShouldSendOpen (uint32_t interface, Mac48Address peerAdd
return true;
}
bool
PeerManagementProtocol::ShouldAcceptOpen (uint32_t interface, Mac48Address peerAddress, PmpReasonCode & reasonCode)
PeerManagementProtocol::ShouldAcceptOpen (
uint32_t interface,
Mac48Address peerAddress,
PmpReasonCode & reasonCode)
{
if (m_numberOfActivePeers > m_maxNumberOfPeerLinks)
{
@@ -450,23 +467,29 @@ PeerManagementProtocol::GetNextBeaconShift (uint32_t interface)
return MicroSeconds (0);
}
void
PeerManagementProtocol::PeerLinkStatus (uint32_t interface, Mac48Address peerAddress, bool status)
PeerManagementProtocol::PeerLinkStatus (uint32_t interface, Mac48Address peerAddress, Mac48Address peerMeshPointAddress, bool status)
{
PeerManagerPluginMap::iterator plugin = m_plugins.find (interface);
NS_ASSERT(plugin != m_plugins.end());
NS_LOG_DEBUG(
"LINK between me:"<<plugin->second->GetAddress() <<
" and peer:"<<peerAddress<<
", at interface "<<interface<<
"Status(1 - opened, 0 - closed)"<<status);
"Link between me:" << m_address <<
" my interface:" << plugin->second->GetAddress() <<
" and peer mesh point:" << peerMeshPointAddress <<
" and its interface:" << peerAddress <<
", at my interface ID:" << interface <<
". Status:" << status);
if(status)
m_numberOfActivePeers ++;
else
m_numberOfActivePeers --;
if(!m_peerStatusCallback.IsNull ())
m_peerStatusCallback (peerAddress, interface, status);
m_peerStatusCallback (peerMeshPointAddress, peerAddress, interface, status);
}
Mac48Address
PeerManagementProtocol::GetAddress ()
{
return m_address;
}
} // namespace dot11s
} //namespace ns3

View File

@@ -101,6 +101,8 @@ public:
* \param uint32_t - is a interface ID of a given MAC (interfaceID rather
* than MAC address, beacause many interfaces may have the same MAC)
* \param Mac48Address is address of peer
* \param Mac48Address is address of peer mesh point device (equal
* to peer address when only one interface)
* \param uint16_t is association ID, which peer has assigned to
* us
* \param IeConfiguration is mesh configuration element
@@ -110,6 +112,7 @@ public:
void ReceivePeerLinkFrame(
uint32_t interface,
Mac48Address peerAddress,
Mac48Address peerMeshPointAddress,
uint16_t aid,
IePeerManagement peerManagementElement,
IeConfiguration meshConfig
@@ -126,8 +129,10 @@ public:
//\}
///\brief Needed by external module to do MLME
Ptr<PeerLink> FindPeerLink(uint32_t interface, Mac48Address peerAddress);
void SetPeerLinkStatusCallback (Callback<void, Mac48Address, uint32_t, bool> cb);
void SetPeerLinkStatusCallback (Callback<void, Mac48Address, Mac48Address, uint32_t, bool> cb);
std::vector<Mac48Address> GetActiveLinks(uint32_t interface);
///\brief needed by plugins to set global source address
Mac48Address GetAddress ();
private:
/** \name Private structures
* \{
@@ -158,7 +163,13 @@ private:
* Return a position in beacon-storage for a given remote station
*/
void FillBeaconInfo(uint32_t interface, Mac48Address peerAddress, Time receivingTime, Time beaconInterval);
Ptr<PeerLink> InitiateLink (uint32_t interface, Mac48Address peerAddress, Time lastBeacon, Time beaconInterval);
Ptr<PeerLink> InitiateLink (
uint32_t interface,
Mac48Address peerAddress,
Mac48Address peerMeshPointAddress,
Time lastBeacon,
Time beaconInterval
);
/**
* \name External peer-chooser
* \{
@@ -169,7 +180,7 @@ private:
* \}
* \brief Indicates changes in peer links
*/
void PeerLinkStatus (uint32_t interface, Mac48Address peerAddress, bool status);
void PeerLinkStatus (uint32_t interface, Mac48Address peerAddress, Mac48Address peerMeshPointAddres, bool status);
/**
* Removes all links which are idle
*/
@@ -178,6 +189,7 @@ private:
Time GetNextBeaconShift (uint32_t interface);
private:
PeerManagerPluginMap m_plugins;
Mac48Address m_address;
/**
* \name Information related to beacons:
* \{
@@ -205,11 +217,12 @@ private:
EventId m_cleanupEvent;
///\}
///\brief Callback to notify about peer link changes:
///\param Mac48Address is peer address
///\param Mac48Address is peer address of mesh point
///\param Mac48Address is peer address of interface
///\param uint32_t - interface ID
///\param bool is staus - true when new link has appeared, false -
//when link was closed
Callback <void, Mac48Address, uint32_t, bool> m_peerStatusCallback;
Callback <void, Mac48Address, Mac48Address, uint32_t, bool> m_peerStatusCallback;
};
} // namespace dot11s

View File

@@ -95,11 +95,6 @@ public:
*/
virtual bool RequestRoute (uint32_t sourceIface, const Mac48Address source, const Mac48Address destination,
Ptr<Packet> packet, uint16_t protocolType, RouteReplyCallback routeReply ) = 0;
///\return false if packet should be dropeed
///\details If incoming frame is our frame - we pass a packet
//through protocol, because protocol needs to remove all tags and
//check TTL
virtual bool HandleIncomingFrame (Ptr<Packet> packet, Mac48Address src, Mac48Address dst, uint16_t protocol) = 0;
/// Set host mesh point, analog of SetNode (...) methods for upper layer protocols.
void SetMeshPoint (Ptr<MeshPointDevice> mp);
/// Each mesh protocol must be installed on the mesh point to work.