Neighbours are attached

This commit is contained in:
Kirill Andreev
2009-03-20 13:46:50 +03:00
parent 8d29fe0b56
commit bd6dc43f03
6 changed files with 216 additions and 143 deletions

View File

@@ -152,7 +152,9 @@ IeDot11sBeaconTiming::GetInformationSize () const
void
IeDot11sBeaconTiming::PrintInformation (std::ostream& os) const
{
//TODO
for (NeighboursTimingUnitsList::const_iterator j = m_neighbours.begin (); j != m_neighbours.end(); j++)
os << "AID=" << (*j)->GetAid () << ", Last beacon was at "
<< (*j)->GetLastBeacon ()<<", with beacon interval " << (*j)->GetBeaconInterval () << "\n";
}
void

View File

@@ -22,12 +22,15 @@
#include "ie-dot11s-configuration.h"
#include "ie-dot11s-peer-management.h"
#include "peer-manager-plugin.h"
#include "ns3/simulator.h"
#include "ns3/log.h"
NS_LOG_COMPONENT_DEFINE("PeerManager");
namespace ns3 {
Dot11sPeerManagerMacPlugin::Dot11sPeerManagerMacPlugin ()
Dot11sPeerManagerMacPlugin::Dot11sPeerManagerMacPlugin (uint32_t interface, Ptr<Dot11sPeerManagerProtocol> protocol)
{
m_ifIndex = interface;
m_protocol = protocol;
}
Dot11sPeerManagerMacPlugin::~Dot11sPeerManagerMacPlugin ()
@@ -49,14 +52,22 @@ Dot11sPeerManagerMacPlugin::Receive (Ptr<Packet> packet, const WifiMacHeader & h
{
NS_LOG_UNCOND("Beacon recevied by PM from"<<header.GetAddr2 ());
IeDot11sBeaconTiming beaconTiming;
Mac48Address peerAddress = header.GetAddr2 ();
Ptr<Packet> myBeacon = packet->Copy();
MgtBeaconHeader beacon_hdr;
myBeacon->RemoveHeader(beacon_hdr);
if(myBeacon->GetSize () == 0)
NS_LOG_UNCOND("Empty");
bool meshBeacon = false;
if(beaconTiming.FindMyInformationElement(myBeacon))
NS_LOG_UNCOND("BEACON TIMING");
meshBeacon = true;
m_protocol->ReceiveBeacon(
m_ifIndex,
meshBeacon,
beaconTiming,
header.GetAddr2(),
Simulator::Now(),
MicroSeconds(beacon_hdr.GetBeaconIntervalUs())
);
#if 0
packet->RemoveHeader (beacon);
@@ -81,17 +92,15 @@ Dot11sPeerManagerMacPlugin::UpdateOutcomingFrame (Ptr<Packet> packet, WifiMacHea
void
Dot11sPeerManagerMacPlugin::UpdateBeacon (MeshWifiBeacon & beacon) const
{
#if 0
NS_LOG_UNCOND("I am sending a beacon");
Ptr<IeDot11sPreq> beaconTiming = Create<IeDot11sPreq> ();
beacon.AddInformationElement(beaconTiming);
Ptr<IeDot11sPrep> prep = Create<IeDot11sPrep> ();
beacon.AddInformationElement(prep);
#endif
Ptr<IeDot11sBeaconTiming> beaconTiming =
m_protocol->SendBeacon(
m_ifIndex,
Simulator::Now(),
MicroSeconds(beacon.BeaconHeader().GetBeaconIntervalUs()));
beacon.AddInformationElement(beaconTiming);
}
bool
Dot11sPeerManagerMacPlugin::BindWithProtocol(Ptr<Dot11sPeerManagerProtocol> protocol)
{
m_protocol = protocol;
return true;
}
}//namespace ns3

View File

@@ -29,6 +29,7 @@ class MeshWifiInterfaceMac;
class IeDot11sConfiguration;
class IeDot11sPeerManagement;
class Dot11sPeerManagerProtocol;
class Dot11sPeerManagerProtocol;
/**
* \ingroup dot11s
*
@@ -41,7 +42,7 @@ class Dot11sPeerManagerProtocol;
class Dot11sPeerManagerMacPlugin : public MeshWifiInterfaceMacPlugin
{
public:
Dot11sPeerManagerMacPlugin ();
Dot11sPeerManagerMacPlugin (uint32_t interface, Ptr<Dot11sPeerManagerProtocol> protocol);
~Dot11sPeerManagerMacPlugin ();
/**
* \brief Inherited from plugin abstract class
@@ -54,34 +55,25 @@ public:
/**
* \}
*/
bool BindWithProtocol(Ptr<Dot11sPeerManagerProtocol>);
void SetPeerManagerProtcol(Ptr<Dot11sPeerManagerProtocol> protocol);
/**
* Deliver Peer link management information to the protocol-part
* \param void is returning value - we pass a frame and forget
* about it
* \param uint32_t - is a port ID of a given MAC (portID rather
* than MAC address, beacause many ports may have the same MAC)
* \param Mac48Address is address of peer
* \param uint16_t is association ID, which peer has assigned to
* us
* \param IeDot11sConfiguration is mesh configuration element
* taken from the peer management frame
* \param IeDot11sPeerManagement is peer link management element
*/
void SetDeliverPeerLinkFrameCallbback (
Callback<void, uint32_t, Mac48Address, uint16_t, IeDot11sConfiguration, IeDot11sPeerManagement>
void SendPeerLinkManagementFrame(
Mac48Address peerAddress,
uint16_t aid,
IeDot11sPeerManagement peerElement,
IeDot11sConfiguration meshConfig
);
/**
* \brief Forms and sends peer link management frame.
*/
void SendPeerLinkManagementFrame(Mac48Address peerAddress, uint16_t aid, IeDot11sPeerManagement peerElement, IeDot11sConfiguration meshConfig);
IeDot11sConfiguration AskPeerLinkManagementElement();
private:
Callback<void, uint32_t, Mac48Address, uint16_t, IeDot11sConfiguration, IeDot11sPeerManagement> m_deliverPeerManFrame;
Callback<void> m_beaconCallback;
/**
* Information about MAC and protocol:
* \{
*/
Ptr<MeshWifiInterfaceMac> m_parent;
uint32_t m_ifIndex;
Ptr<Dot11sPeerManagerProtocol> m_protocol;
/**
* \}
*/
/**
* Create peer link management frames:
* \{

View File

@@ -580,9 +580,10 @@ Dot11sPeerManagerProtocol::GetTypeId (void)
return tid;
}
Dot11sPeerManagerProtocol::Dot11sPeerManagerProtocol ()
Dot11sPeerManagerProtocol::Dot11sPeerManagerProtocol ():
m_lastAssocId(0),
m_lastLocalLinkId(1)
{
// m_assocId = 0;
// m_numberOfActivePeers = 0;
// // firs peerLinkId is 1, because 0 means "unknown"
// m_localLinkId = 1;
@@ -616,45 +617,93 @@ Dot11sPeerManagerProtocol::~Dot11sPeerManagerProtocol ()
// UNFINISHED
//-----------------------------------------------------
bool
Dot11sPeerManagerProtocol::AttachPorts(std::vector<Ptr<WifiNetDevice> > ports)
Dot11sPeerManagerProtocol::AttachPorts(std::vector<Ptr<WifiNetDevice> > interfaces)
{
NS_LOG_UNCOND("Peer manager attach ports started!");
for(std::vector<Ptr<WifiNetDevice> >::iterator i = ports.begin(); i != ports.end(); i ++)
NS_LOG_UNCOND("Peer manager attach interfaces started!");
for(std::vector<Ptr<WifiNetDevice> >::iterator i = interfaces.begin(); i != interfaces.end(); i ++)
{
MeshWifiInterfaceMac * mac = dynamic_cast<MeshWifiInterfaceMac *> (PeekPointer ((*i)->GetMac ()));
if (mac == NULL)
return false;
Ptr<Dot11sPeerManagerMacPlugin> peerPlugin = Create<Dot11sPeerManagerMacPlugin>();
Ptr<Dot11sPeerManagerMacPlugin> peerPlugin = Create<Dot11sPeerManagerMacPlugin> ((*i)->GetIfIndex(), this);
mac->InstallPlugin(peerPlugin);
NS_ASSERT(peerPlugin->BindWithProtocol(this));
m_plugins[(*i)->GetIfIndex()] = peerPlugin;
}
return true;
}
IeDot11sBeaconTiming
Dot11sPeerManagerProtocol::SendBeacon(uint32_t port, Time currentTbtt, Time beaconInterval)
Ptr<IeDot11sBeaconTiming>
Dot11sPeerManagerProtocol::SendBeacon(uint32_t interface, Time currentTbtt, Time beaconInterval)
{
IeDot11sBeaconTiming retval;
Ptr<IeDot11sBeaconTiming> retval = Create<IeDot11sBeaconTiming> ();
NS_LOG_UNCOND("I am sending a beacon");
BeaconInfoMap::iterator i = m_neighbourBeacons.find(interface);
if(i == m_neighbourBeacons.end())
return retval;
for(BeaconInterfaceInfoMap::iterator j = i->second.begin(); j != i->second.end(); j++)
{
//check beacon loss and make a timing element
if(
(j->second.referenceTbtt.GetMicroSeconds() +
(j->second.beaconInterval.GetMicroSeconds()* m_maxBeaconLoss))
<
Simulator::Now().GetMicroSeconds()
)
continue;
retval->AddNeighboursTimingElementUnit(j->second.aid, j->second.referenceTbtt, j->second.beaconInterval);
}
return retval;
}
void
Dot11sPeerManagerProtocol::ReceiveBeacon(
uint32_t port,
uint32_t interface,
bool meshBeacon,
IeDot11sBeaconTiming timingElement,
Mac48Address peerAddress,
Time receivingTime,
Time beaconInterval)
{
NS_LOG_UNCOND("Beacon received from "<<peerAddress);
NS_LOG_UNCOND(timingElement);
//find beacon entry and write there a new one
BeaconInfoMap::iterator i = m_neighbourBeacons.find(interface);
if(i == m_neighbourBeacons.end())
{
NS_LOG_UNCOND("First beacon from this interface");
BeaconInterfaceInfoMap newMap;
m_neighbourBeacons[interface] = newMap;
}
i = m_neighbourBeacons.find(interface);
BeaconInterfaceInfoMap::iterator j = i->second.find(peerAddress);
if(j == i->second.end())
{
NS_LOG_UNCOND("first beacon from this station");
BeaconInfo newInfo;
newInfo.referenceTbtt = receivingTime;
newInfo.beaconInterval = beaconInterval;
newInfo.aid = m_lastAssocId++;
i->second[peerAddress] = newInfo;
}
else
{
NS_LOG_UNCOND("last beacon was at"<<j->second.referenceTbtt);
j->second.referenceTbtt = receivingTime;
NS_LOG_UNCOND("now beacon is at"<<j->second.referenceTbtt);
j->second.beaconInterval = beaconInterval;
}
if(!meshBeacon)
return;
//TODO: PM STATE Machine
}
void
Dot11sPeerManagerProtocol::ReceivePeerLinkFrame(
uint32_t port,
uint32_t interface,
Mac48Address peerAddress,
uint16_t aid,
IeDot11sConfiguration meshConfig,
IeDot11sPeerManagement peerManagementElement
IeDot11sPeerManagement peerManagementElement,
IeDot11sConfiguration meshConfig
)
{
}
@@ -662,12 +711,12 @@ Dot11sPeerManagerProtocol::ReceivePeerLinkFrame(
#if 0
void
Dot11sPeerManagerProtocol::SetSentBeaconTimers (
Mac48Address portAddress,
Mac48Address interfaceAddress,
Time ReferenceTbtt,
Time BeaconInterval
)
{
BeaconInfoMap::iterator myBeacon = m_myBeaconInfo.find (portAddress);
BeaconInfoMap::iterator myBeacon = m_myBeaconInfo.find (interfaceAddress);
NS_ASSERT (myBeacon != m_myBeaconInfo.end());
myBeacon->second.referenceTbtt = ReferenceTbtt;
myBeacon->second.beaconInterval = BeaconInterval;
@@ -676,16 +725,16 @@ Dot11sPeerManagerProtocol::SetSentBeaconTimers (
void
Dot11sPeerManagerProtocol::SetReceivedBeaconTimers (
Mac48Address portAddress,
Mac48Address interfaceAddress,
Mac48Address peerAddress,
Time lastBeacon,
Time beaconInterval,
IeDot11sBeaconTiming beaconTiming
)
{
PeerDescriptorsMap::iterator port = m_peerDescriptors.find (portAddress);
NS_ASSERT (port != m_peerDescriptors.end());
for (std::vector<Ptr<WifiPeerLinkDescriptor> >::iterator i = port->second.begin (); i != port->second.end(); i++)
PeerDescriptorsMap::iterator interface = m_peerDescriptors.find (interfaceAddress);
NS_ASSERT (interface != m_peerDescriptors.end());
for (std::vector<Ptr<WifiPeerLinkDescriptor> >::iterator i = interface->second.begin (); i != interface->second.end(); i++)
{
if ((*i)->GetPeerAddress () == peerAddress)
{
@@ -695,15 +744,15 @@ Dot11sPeerManagerProtocol::SetReceivedBeaconTimers (
}
}
Ptr<WifiPeerLinkDescriptor> new_descriptor =
AddDescriptor (portAddress, peerAddress, Simulator::Now(), beaconInterval);
AddDescriptor (interfaceAddress, peerAddress, Simulator::Now(), beaconInterval);
new_descriptor->SetBeaconTimingElement (beaconTiming);
}
bool
Dot11sPeerManagerProtocol::AttachPorts (std::vector<Ptr<WifiNetDevice> > ports)
Dot11sPeerManagerProtocol::AttachPorts (std::vector<Ptr<WifiNetDevice> > interfaces)
{
NS_ASSERT (ports.size() != 0);
for (std::vector<Ptr<WifiNetDevice> >::iterator i = ports.begin (); i != ports.end(); i++)
NS_ASSERT (interfaces.size() != 0);
for (std::vector<Ptr<WifiNetDevice> >::iterator i = interfaces.begin (); i != interfaces.end(); i++)
{
MeshWifiMac * meshWifiMac = dynamic_cast<MeshWifiMac *> (PeekPointer ((*i)->GetMac ()));
if (meshWifiMac == NULL)
@@ -721,14 +770,14 @@ Dot11sPeerManagerProtocol::AttachPorts (std::vector<Ptr<WifiNetDevice> > ports)
return true;
}
void
Dot11sPeerManagerProtocol::AskIfOpenNeeded (Mac48Address portAddress, Mac48Address peerAddress)
Dot11sPeerManagerProtocol::AskIfOpenNeeded (Mac48Address interfaceAddress, Mac48Address peerAddress)
{
PeerDescriptorsMap::iterator port = m_peerDescriptors.find (portAddress);
NS_ASSERT (port != m_peerDescriptors.end());
for (std::vector<Ptr<WifiPeerLinkDescriptor> >::iterator i = port->second.begin (); i != port->second.end(); i++)
PeerDescriptorsMap::iterator interface = m_peerDescriptors.find (interfaceAddress);
NS_ASSERT (interface != m_peerDescriptors.end());
for (std::vector<Ptr<WifiPeerLinkDescriptor> >::iterator i = interface->second.begin (); i != interface->second.end(); i++)
if ((*i)->GetPeerAddress () == peerAddress)
{
if (ShouldSendOpen (portAddress, peerAddress))
if (ShouldSendOpen (interfaceAddress, peerAddress))
(*i)->MLMEActivePeerLinkOpen ();
break;
}
@@ -736,27 +785,27 @@ Dot11sPeerManagerProtocol::AskIfOpenNeeded (Mac48Address portAddress, Mac48Addre
void
Dot11sPeerManagerProtocol::SetOpenReceived (
Mac48Address portAddress,
Mac48Address interfaceAddress,
Mac48Address peerAddress,
IeDot11sPeerManagement peerMan,
IeDot11sConfiguration conf
)
{
dot11sReasonCode reasonCode;
if (!ShouldAcceptOpen (portAddress, peerAddress,reasonCode))
if (!ShouldAcceptOpen (interfaceAddress, peerAddress,reasonCode))
return;
PeerDescriptorsMap::iterator port = m_peerDescriptors.find (portAddress);
NS_ASSERT (port != m_peerDescriptors.end());
for (std::vector<Ptr<WifiPeerLinkDescriptor> >::iterator i = port->second.begin (); i != port->second.end(); i++)
PeerDescriptorsMap::iterator interface = m_peerDescriptors.find (interfaceAddress);
NS_ASSERT (interface != m_peerDescriptors.end());
for (std::vector<Ptr<WifiPeerLinkDescriptor> >::iterator i = interface->second.begin (); i != interface->second.end(); i++)
if ((*i)->GetPeerAddress () == peerAddress)
{
(*i)->PeerLinkOpenAccept (peerMan.GetLocalLinkId(), conf);
return;
}
BeaconInfoMap::iterator myBeacon = m_myBeaconInfo.find (portAddress);
BeaconInfoMap::iterator myBeacon = m_myBeaconInfo.find (interfaceAddress);
NS_ASSERT (myBeacon != m_myBeaconInfo.end());
Ptr<WifiPeerLinkDescriptor>new_descriptor = AddDescriptor (
portAddress,
interfaceAddress,
peerAddress,
Simulator::Now (),
myBeacon->second.beaconInterval
@@ -765,30 +814,30 @@ Dot11sPeerManagerProtocol::SetOpenReceived (
}
void
Dot11sPeerManagerProtocol::SetConfirmReceived (
Mac48Address portAddress,
Mac48Address interfaceAddress,
Mac48Address peerAddress,
uint16_t peerAid,
IeDot11sPeerManagement peerMan,
IeDot11sConfiguration meshConfig
)
{
PeerDescriptorsMap::iterator port = m_peerDescriptors.find (portAddress);
NS_ASSERT (port != m_peerDescriptors.end());
for (std::vector<Ptr<WifiPeerLinkDescriptor> >::iterator i = port->second.begin (); i != port->second.end(); i++)
PeerDescriptorsMap::iterator interface = m_peerDescriptors.find (interfaceAddress);
NS_ASSERT (interface != m_peerDescriptors.end());
for (std::vector<Ptr<WifiPeerLinkDescriptor> >::iterator i = interface->second.begin (); i != interface->second.end(); i++)
if ((*i)->GetPeerAddress () == peerAddress)
(*i)->PeerLinkConfirmAccept (peerMan.GetLocalLinkId(), peerMan.GetPeerLinkId(), peerAid, meshConfig);
}
void
Dot11sPeerManagerProtocol::SetCloseReceived (
Mac48Address portAddress,
Mac48Address interfaceAddress,
Mac48Address peerAddress,
IeDot11sPeerManagement peerMan
)
{
PeerDescriptorsMap::iterator port = m_peerDescriptors.find (portAddress);
NS_ASSERT (port != m_peerDescriptors.end());
for (std::vector<Ptr<WifiPeerLinkDescriptor> >::iterator i = port->second.begin (); i != port->second.end(); i++)
PeerDescriptorsMap::iterator interface = m_peerDescriptors.find (interfaceAddress);
NS_ASSERT (interface != m_peerDescriptors.end());
for (std::vector<Ptr<WifiPeerLinkDescriptor> >::iterator i = interface->second.begin (); i != interface->second.end(); i++)
if ((*i)->GetPeerAddress () == peerAddress)
{
(*i)->PeerLinkClose (peerMan.GetLocalLinkId(), peerMan.GetPeerLinkId(), peerMan.GetReasonCode());
@@ -798,13 +847,13 @@ Dot11sPeerManagerProtocol::SetCloseReceived (
void
Dot11sPeerManagerProtocol::ConfigurationMismatch (
Mac48Address portAddress,
Mac48Address interfaceAddress,
Mac48Address peerAddress
)
{
PeerDescriptorsMap::iterator port = m_peerDescriptors.find (portAddress);
NS_ASSERT (port != m_peerDescriptors.end());
for (std::vector<Ptr<WifiPeerLinkDescriptor> >::iterator i = port->second.begin (); i != port->second.end(); i++)
PeerDescriptorsMap::iterator interface = m_peerDescriptors.find (interfaceAddress);
NS_ASSERT (interface != m_peerDescriptors.end());
for (std::vector<Ptr<WifiPeerLinkDescriptor> >::iterator i = interface->second.begin (); i != interface->second.end(); i++)
if ((*i)->GetPeerAddress () == peerAddress)
{
(*i)->MLMECancelPeerLink (REASON11S_MESH_CONFIGURATION_POLICY_VIOLATION);
@@ -814,12 +863,12 @@ Dot11sPeerManagerProtocol::ConfigurationMismatch (
}
IeDot11sBeaconTiming
Dot11sPeerManagerProtocol::GetIeDot11sBeaconTimingForMyBeacon (Mac48Address portAddress)
Dot11sPeerManagerProtocol::GetIeDot11sBeaconTimingForMyBeacon (Mac48Address interfaceAddress)
{
PeerDescriptorsMap::iterator port = m_peerDescriptors.find (portAddress);
NS_ASSERT (port != m_peerDescriptors.end());
PeerDescriptorsMap::iterator interface = m_peerDescriptors.find (interfaceAddress);
NS_ASSERT (interface != m_peerDescriptors.end());
IeDot11sBeaconTiming return_val;
for (std::vector<Ptr<WifiPeerLinkDescriptor> >::iterator i = port->second.begin (); i != port->second.end(); i++)
for (std::vector<Ptr<WifiPeerLinkDescriptor> >::iterator i = interface->second.begin (); i != interface->second.end(); i++)
{
//Just go through all neighbor entries and add it to timing element:
return_val.AddNeighboursTimingElementUnit (
@@ -833,20 +882,20 @@ Dot11sPeerManagerProtocol::GetIeDot11sBeaconTimingForMyBeacon (Mac48Address port
}
IeDot11sBeaconTiming
Dot11sPeerManagerProtocol::GetIeDot11sBeaconTimingForAddress (
Mac48Address portAddress,
Mac48Address interfaceAddress,
Mac48Address addr)
{
PeerDescriptorsMap::iterator port = m_peerDescriptors.find (portAddress);
NS_ASSERT (port != m_peerDescriptors.end());
PeerDescriptorsMap::iterator interface = m_peerDescriptors.find (interfaceAddress);
NS_ASSERT (interface != m_peerDescriptors.end());
IeDot11sBeaconTiming return_val;
for (std::vector<Ptr<WifiPeerLinkDescriptor> >::iterator i = port->second.begin (); i != port->second.end(); i++)
for (std::vector<Ptr<WifiPeerLinkDescriptor> >::iterator i = interface->second.begin (); i != interface->second.end(); i++)
if ((*i)->GetPeerAddress () == addr)
return_val = (*i)->GetBeaconTimingElement ();
return return_val;
}
Ptr<WifiPeerLinkDescriptor>
Dot11sPeerManagerProtocol::AddDescriptor (
Mac48Address portAddress,
Mac48Address interfaceAddress,
Mac48Address peerAddress,
Time lastBeacon,
Time beaconInterval)
@@ -861,18 +910,18 @@ Dot11sPeerManagerProtocol::AddDescriptor (
new_descriptor->SetPeerAddress (peerAddress);
new_descriptor->SetBeaconInformation (lastBeacon, beaconInterval);
//DEBUG ONLY:
new_descriptor->SetLocalAddress (portAddress);
//check if port address is wrong
MeshMacMap::iterator pos = m_macPointers.find (portAddress);
new_descriptor->SetLocalAddress (interfaceAddress);
//check if interface address is wrong
MeshMacMap::iterator pos = m_macPointers.find (interfaceAddress);
NS_ASSERT (pos != m_macPointers.end());
//check if descriptors array exist
PeerDescriptorsMap::iterator port = m_peerDescriptors.find (portAddress);
NS_ASSERT (port != m_peerDescriptors.end());
PeerDescriptorsMap::iterator interface = m_peerDescriptors.find (interfaceAddress);
NS_ASSERT (interface != m_peerDescriptors.end());
new_descriptor->SetMac (pos->second);
new_descriptor->SetMaxBeaconLoss (m_maxBeaconLoss);
new_descriptor->SetLinkStatusCallback (MakeCallback(&Dot11sPeerManagerProtocol::PeerLinkStatus, this));
NS_ASSERT (port != m_peerDescriptors.end());
m_peerDescriptors[portAddress].push_back (new_descriptor);
NS_ASSERT (interface != m_peerDescriptors.end());
m_peerDescriptors[interfaceAddress].push_back (new_descriptor);
return new_descriptor;
}
@@ -902,29 +951,29 @@ Dot11sPeerManagerProtocol::PeerCleanup ()
}
std::vector<Mac48Address>
Dot11sPeerManagerProtocol::GetNeighbourAddressList (Mac48Address portAddress, Mac48Address peerAddress)
Dot11sPeerManagerProtocol::GetNeighbourAddressList (Mac48Address interfaceAddress, Mac48Address peerAddress)
{
PeerDescriptorsMap::iterator port = m_peerDescriptors.find (portAddress);
NS_ASSERT (port != m_peerDescriptors.end());
PeerDescriptorsMap::iterator interface = m_peerDescriptors.find (interfaceAddress);
NS_ASSERT (interface != m_peerDescriptors.end());
std::vector<Mac48Address> return_value;
for (std::vector<Ptr<WifiPeerLinkDescriptor> >::iterator i = port->second.begin (); i != port->second.end(); i++)
for (std::vector<Ptr<WifiPeerLinkDescriptor> >::iterator i = interface->second.begin (); i != interface->second.end(); i++)
return_value.push_back ((*i)->GetPeerAddress());
return return_value;
}
bool
Dot11sPeerManagerProtocol::IsActiveLink (Mac48Address portAddress, Mac48Address peerAddress)
Dot11sPeerManagerProtocol::IsActiveLink (Mac48Address interfaceAddress, Mac48Address peerAddress)
{
PeerDescriptorsMap::iterator port = m_peerDescriptors.find (portAddress);
NS_ASSERT (port != m_peerDescriptors.end());
for (std::vector<Ptr<WifiPeerLinkDescriptor> >::iterator i = port->second.begin (); i != port->second.end(); i++)
PeerDescriptorsMap::iterator interface = m_peerDescriptors.find (interfaceAddress);
NS_ASSERT (interface != m_peerDescriptors.end());
for (std::vector<Ptr<WifiPeerLinkDescriptor> >::iterator i = interface->second.begin (); i != interface->second.end(); i++)
if ((*i)->GetPeerAddress () == peerAddress)
return ((*i)->LinkIsEstab ());
return false;
}
bool
Dot11sPeerManagerProtocol::ShouldSendOpen (Mac48Address portAddress, Mac48Address peerAddress)
Dot11sPeerManagerProtocol::ShouldSendOpen (Mac48Address interfaceAddress, Mac48Address peerAddress)
{
if (m_numberOfActivePeers > m_maxNumberOfPeerLinks)
return false;
@@ -932,7 +981,7 @@ Dot11sPeerManagerProtocol::ShouldSendOpen (Mac48Address portAddress, Mac48Addres
}
bool
Dot11sPeerManagerProtocol::ShouldAcceptOpen (Mac48Address portAddress, Mac48Address peerAddress,dot11sReasonCode & reasonCode)
Dot11sPeerManagerProtocol::ShouldAcceptOpen (Mac48Address interfaceAddress, Mac48Address peerAddress,dot11sReasonCode & reasonCode)
{
if (m_numberOfActivePeers > m_maxNumberOfPeerLinks)
{
@@ -944,7 +993,7 @@ Dot11sPeerManagerProtocol::ShouldAcceptOpen (Mac48Address portAddress, Mac48Addr
Time
Dot11sPeerManagerProtocol::GetNextBeaconShift (
Mac48Address portAddress,
Mac48Address interfaceAddress,
Time myNextTBTT
)
{
@@ -956,11 +1005,11 @@ Dot11sPeerManagerProtocol::GetNextBeaconShift (
uint32_t myNextTBTTInTimeUnits = 0;
uint32_t futureBeaconInTimeUnits = 0;
//Going through all my timing elements and detecting future beacon collisions
PeerDescriptorsMap::iterator port = m_peerDescriptors.find (portAddress);
NS_ASSERT (port != m_peerDescriptors.end());
BeaconInfoMap::iterator myBeacon = m_myBeaconInfo.find (portAddress);
PeerDescriptorsMap::iterator interface = m_peerDescriptors.find (interfaceAddress);
NS_ASSERT (interface != m_peerDescriptors.end());
BeaconInfoMap::iterator myBeacon = m_myBeaconInfo.find (interfaceAddress);
NS_ASSERT (myBeacon != m_myBeaconInfo.end());
for (std::vector<Ptr<WifiPeerLinkDescriptor> >::iterator i = port->second.begin (); i != port->second.end(); i++)
for (std::vector<Ptr<WifiPeerLinkDescriptor> >::iterator i = interface->second.begin (); i != interface->second.end(); i++)
{
IeDot11sBeaconTiming::NeighboursTimingUnitsList neighbours;
neighbours = (*i)->GetBeaconTimingElement ().GetNeighboursTimingElementsList();
@@ -1025,9 +1074,9 @@ Dot11sPeerManagerProtocol::GetNextBeaconShift (
}
void
Dot11sPeerManagerProtocol::PeerLinkStatus (Mac48Address portAddress, Mac48Address peerAddress, bool status)
Dot11sPeerManagerProtocol::PeerLinkStatus (Mac48Address interfaceAddress, Mac48Address peerAddress, bool status)
{
MeshMacMap::iterator pos = m_macPointers.find (portAddress);
MeshMacMap::iterator pos = m_macPointers.find (interfaceAddress);
NS_ASSERT (pos != m_macPointers.end());
pos->second->PeerLinkStatus (peerAddress, status);
}

View File

@@ -200,20 +200,27 @@ public:
* it and remember the time, when we sent a beacon (for BCA)
* \param IeDot11sBeaconTiming is a beacon timing element that
* should be present in beacon
* \param port is a port sending a beacon
* \param interface is a interface sending a beacon
* \param currentTbtt is a time of beacon sending
* \param beaconInterval is a beacon interval on this port
* \param beaconInterval is a beacon interval on this interface
*/
IeDot11sBeaconTiming SendBeacon(uint32_t port, Time currentTbtt, Time beaconInterval);
Ptr<IeDot11sBeaconTiming> SendBeacon(uint32_t interface, Time currentTbtt, Time beaconInterval);
/**
* \brief When we receive a beacon from peer-station, we remember
* its beacon timing element (needed for peer choosing mechanism),
* and remember beacon timers - last beacon and beacon interval to
* detect beacon loss and cancel links
* \param port is a port on which beacon was received
* \param interface is a interface on which beacon was received
* \param timingElement is a timing element of remote beacon
*/
void ReceiveBeacon(uint32_t port, IeDot11sBeaconTiming timingElement, Mac48Address peerAddress, Time receivingTime, Time beaconInterval);
void ReceiveBeacon(
uint32_t interface,
bool meshBeacon,
IeDot11sBeaconTiming timingElement,
Mac48Address peerAddress,
Time receivingTime,
Time beaconInterval
);
/**
* \}
*/
@@ -226,8 +233,8 @@ public:
* Deliver Peer link management information to the protocol-part
* \param void is returning value - we pass a frame and forget
* about it
* \param uint32_t - is a port ID of a given MAC (portID rather
* than MAC address, beacause many ports may have the same MAC)
* \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 uint16_t is association ID, which peer has assigned to
* us
@@ -236,11 +243,11 @@ public:
* \param IeDot11sPeerManagement is peer link management element
*/
void ReceivePeerLinkFrame(
uint32_t port,
uint32_t interface,
Mac48Address peerAddress,
uint16_t aid,
IeDot11sConfiguration meshConfig,
IeDot11sPeerManagement peerManagementElement
IeDot11sPeerManagement peerManagementElement,
IeDot11sConfiguration meshConfig
);
/**
* \}
@@ -253,18 +260,30 @@ private:
* * pointers to proper plugins
* \{
*/
// struct BeaconInfo
// {
// Time referenceTbtt; //When one of my station's beacons was put into a beacon queue;
// Time beaconInterval; //Beacon interval of my station;
// uint16_t aid; //Assoc ID
//};
struct BeaconInfo
{
uint16_t aid; //Assoc ID
Time referenceTbtt; //When one of my station's beacons was put into a beacon queue;
Time beaconInterval; //Beacon interval of my station;
};
typedef std::map<uint32_t, std::vector<Ptr<WifiPeerLinkDescriptor> > > PeerDescriptorsMap;
// typedef std::map<uint32_t, BeaconInfo> BeaconInfoMap;
typedef std::map<Mac48Address, BeaconInfo> BeaconInterfaceInfoMap;
typedef std::map<uint32_t, BeaconInterfaceInfoMap> BeaconInfoMap;
typedef std::map<uint32_t, Ptr<Dot11sPeerManagerMacPlugin> > PeerManagerPluginMap;
PeerManagerPluginMap m_plugins;
/**
* Information related to beacons:
* \{
*/
BeaconInfoMap m_neighbourBeacons;
static const uint8_t m_maxBeaconLoss = 3;
/**
* \}
* \}
*/
uint16_t m_lastAssocId;
uint16_t m_lastLocalLinkId;
#if 0
//Maximum peers that may be opened:
uint8_t m_maxNumberOfPeerLinks;
@@ -291,16 +310,16 @@ private:
Time m_peerLinkCleanupPeriod;
EventId m_cleanupEvent;
Ptr<WifiPeerLinkDescriptor> AddDescriptor (
Mac48Address portAddress,
Mac48Address interfaceAddress,
Mac48Address peerAddress,
Time lastBeacon,
Time beaconInterval
);
void PeerCleanup ();
//Mechanism of choosing PEERs:
bool ShouldSendOpen (Mac48Address portAddress, Mac48Address peerAddress);
bool ShouldSendOpen (Mac48Address interfaceAddress, Mac48Address peerAddress);
bool ShouldAcceptOpen (
Mac48Address portAddress,
Mac48Address interfaceAddress,
Mac48Address peerAddress,
dot11sReasonCode & reasonCode
);
@@ -315,7 +334,7 @@ private:
* \param status true - peer link opened, peer
* link closed otherwise
*/
void PeerLinkStatus (Mac48Address portAddress, Mac48Address peerAddress, bool status);
void PeerLinkStatus (Mac48Address interfaceAddress, Mac48Address peerAddress, bool status);
#endif
};
} //namespace ns3

View File

@@ -64,6 +64,7 @@ void WifiInformationElement::Print (std::ostream &os) const
PrintInformation (os);
os << "</information_element>\n";
}
bool WifiInformationElement::FindMyInformationElement(Ptr<Packet> packet)
{
const uint8_t * data = packet->PeekData();
@@ -72,15 +73,16 @@ bool WifiInformationElement::FindMyInformationElement(Ptr<Packet> packet)
{
if(data[position] == ElementId())
{
Ptr<Packet> myIe = packet->CreateFragment(position, data[position+1]+2);
NS_ASSERT(myIe->GetSize() == (uint32_t)(data[position+1]+2));
myIe->RemoveHeader(*this);
return true;
}
else
{
NS_LOG_UNCOND("not found"<<(uint16_t)data[position]);
if(data[position] > ElementId())
return false;
position +=data[position+1]+2;
//if(data[position + 1] == 0)
// return false;
}
}
return false;