A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
peer-management-protocol.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2008,2009 IITP RAS
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Authors: Kirill Andreev <andreev@iitp.ru>
19  * Aleksey Kovalenko <kovalenko@iitp.ru>
20  */
21 
22 #include "ns3/peer-management-protocol.h"
25 #include "ie-dot11s-id.h"
26 #include "ns3/mesh-point-device.h"
27 #include "ns3/simulator.h"
28 #include "ns3/assert.h"
29 #include "ns3/log.h"
30 #include "ns3/random-variable-stream.h"
31 #include "ns3/mesh-wifi-interface-mac.h"
32 #include "ns3/mesh-wifi-interface-mac-plugin.h"
33 #include "ns3/wifi-net-device.h"
34 #include "ns3/trace-source-accessor.h"
35 
36 NS_LOG_COMPONENT_DEFINE ("PeerManagementProtocol");
37 namespace ns3 {
38 namespace dot11s {
39 /***************************************************
40  * PeerManager
41  ***************************************************/
42 NS_OBJECT_ENSURE_REGISTERED (PeerManagementProtocol)
43  ;
44 
45 TypeId
47 {
48  static TypeId tid = TypeId ("ns3::dot11s::PeerManagementProtocol")
49  .SetParent<Object> ()
50  .AddConstructor<PeerManagementProtocol> ()
51  // maximum number of peer links. Now we calculate the total
52  // number of peer links on all interfaces
53  .AddAttribute ( "MaxNumberOfPeerLinks",
54  "Maximum number of peer links",
55  UintegerValue (32),
56  MakeUintegerAccessor (
58  MakeUintegerChecker<uint8_t> ()
59  )
60  .AddAttribute ( "MaxBeaconShiftValue",
61  "Maximum number of TUs for beacon shifting",
62  UintegerValue (15),
63  MakeUintegerAccessor (
65  MakeUintegerChecker<uint16_t> ()
66  )
67  .AddAttribute ( "EnableBeaconCollisionAvoidance",
68  "Enable/Disable Beacon collision avoidance.",
69  BooleanValue (true),
70  MakeBooleanAccessor (
72  MakeBooleanChecker ()
73  )
74  .AddTraceSource ("LinkOpen",
75  "New peer link opened",
77  )
78  .AddTraceSource ("LinkClose",
79  "New peer link closed",
81  )
82 
83  ;
84  return tid;
85 }
87  m_lastAssocId (0), m_lastLocalLinkId (1), m_enableBca (true), m_maxBeaconShift (15)
88 {
89  m_beaconShift = CreateObject<UniformRandomVariable> ();
90 }
92 {
93  m_meshId = 0;
94 }
95 void
97 {
98  //cancel cleanup event and go through the map of peer links,
99  //deleting each
100  for (PeerLinksMap::iterator j = m_peerLinks.begin (); j != m_peerLinks.end (); j++)
101  {
102  for (PeerLinksOnInterface::iterator i = j->second.begin (); i != j->second.end (); i++)
103  {
104  (*i) = 0;
105  }
106  j->second.clear ();
107  }
108  m_peerLinks.clear ();
109  m_plugins.clear ();
110 }
111 
112 bool
114 {
115  std::vector<Ptr<NetDevice> > interfaces = mp->GetInterfaces ();
116  for (std::vector<Ptr<NetDevice> >::iterator i = interfaces.begin (); i != interfaces.end (); i++)
117  {
118  Ptr<WifiNetDevice> wifiNetDev = (*i)->GetObject<WifiNetDevice> ();
119  if (wifiNetDev == 0)
120  {
121  return false;
122  }
123  Ptr<MeshWifiInterfaceMac> mac = wifiNetDev->GetMac ()->GetObject<MeshWifiInterfaceMac> ();
124  if (mac == 0)
125  {
126  return false;
127  }
128  Ptr<PeerManagementProtocolMac> plugin = Create<PeerManagementProtocolMac> ((*i)->GetIfIndex (), this);
129  mac->InstallPlugin (plugin);
130  m_plugins[(*i)->GetIfIndex ()] = plugin;
131  PeerLinksOnInterface newmap;
132  m_peerLinks[(*i)->GetIfIndex ()] = newmap;
133  }
134  // Mesh point aggregates all installed protocols
135  m_address = Mac48Address::ConvertFrom (mp->GetAddress ());
136  mp->AggregateObject (this);
137  return true;
138 }
139 
142 {
144  {
145  return 0;
146  }
147  Ptr<IeBeaconTiming> retval = Create<IeBeaconTiming> ();
148  PeerLinksMap::iterator iface = m_peerLinks.find (interface);
149  NS_ASSERT (iface != m_peerLinks.end ());
150  for (PeerLinksOnInterface::iterator i = iface->second.begin (); i != iface->second.end (); i++)
151  {
152  //If we do not know peer Assoc Id, we shall not add any info
153  //to a beacon timing element
154  if ((*i)->GetBeaconInterval () == Seconds (0))
155  {
156  //No beacon was received, do not include to the beacon timing element
157  continue;
158  }
159  retval->AddNeighboursTimingElementUnit ((*i)->GetLocalAid (), (*i)->GetLastBeacon (),
160  (*i)->GetBeaconInterval ());
161  }
162  return retval;
163 }
164 void
165 PeerManagementProtocol::ReceiveBeacon (uint32_t interface, Mac48Address peerAddress, Time beaconInterval, Ptr<IeBeaconTiming> timingElement)
166 {
167  //PM STATE Machine
168  //Check that a given beacon is not from our interface
169  for (PeerManagementProtocolMacMap::const_iterator i = m_plugins.begin (); i != m_plugins.end (); i++)
170  {
171  if (i->second->GetAddress () == peerAddress)
172  {
173  return;
174  }
175  }
176  Ptr<PeerLink> peerLink = FindPeerLink (interface, peerAddress);
177  if (peerLink == 0)
178  {
179  if (ShouldSendOpen (interface, peerAddress))
180  {
181  peerLink = InitiateLink (interface, peerAddress, Mac48Address::GetBroadcast ());
182  peerLink->MLMEActivePeerLinkOpen ();
183  }
184  else
185  {
186  return;
187  }
188  }
189  peerLink->SetBeaconInformation (Simulator::Now (), beaconInterval);
191  {
192  peerLink->SetBeaconTimingElement (*PeekPointer (timingElement));
193  }
194 }
195 
196 void
198  Mac48Address peerMeshPointAddress, uint16_t aid, IePeerManagement peerManagementElement,
199  IeConfiguration meshConfig)
200 {
201  Ptr<PeerLink> peerLink = FindPeerLink (interface, peerAddress);
202  if (peerManagementElement.SubtypeIsOpen ())
203  {
204  PmpReasonCode reasonCode (REASON11S_RESERVED);
205  bool reject = !(ShouldAcceptOpen (interface, peerAddress, reasonCode));
206  if (peerLink == 0)
207  {
208  peerLink = InitiateLink (interface, peerAddress, peerMeshPointAddress);
209  }
210  if (!reject)
211  {
212  peerLink->OpenAccept (peerManagementElement.GetLocalLinkId (), meshConfig, peerMeshPointAddress);
213  }
214  else
215  {
216  peerLink->OpenReject (peerManagementElement.GetLocalLinkId (), meshConfig, peerMeshPointAddress,
217  reasonCode);
218  }
219  }
220  if (peerLink == 0)
221  {
222  return;
223  }
224  if (peerManagementElement.SubtypeIsConfirm ())
225  {
226  peerLink->ConfirmAccept (peerManagementElement.GetLocalLinkId (),
227  peerManagementElement.GetPeerLinkId (), aid, meshConfig, peerMeshPointAddress);
228  }
229  if (peerManagementElement.SubtypeIsClose ())
230  {
231  peerLink->Close (peerManagementElement.GetLocalLinkId (), peerManagementElement.GetPeerLinkId (),
232  peerManagementElement.GetReasonCode ());
233  }
234 }
235 void
237 {
238  Ptr<PeerLink> peerLink = FindPeerLink (interface, peerAddress);
239  if (peerLink != 0)
240  {
241  peerLink->MLMECancelPeerLink (REASON11S_MESH_CAPABILITY_POLICY_VIOLATION);
242  }
243 }
244 void
246 {
247  NS_LOG_DEBUG ("transmission failed between "<<GetAddress () << " and " << peerAddress << " failed, link will be closed");
248  Ptr<PeerLink> peerLink = FindPeerLink (interface, peerAddress);
249  if (peerLink != 0)
250  {
251  peerLink->TransmissionFailure ();
252  }
253 }
254 void
256 {
257  NS_LOG_DEBUG ("transmission success "<< GetAddress () << " and " << peerAddress);
258  Ptr<PeerLink> peerLink = FindPeerLink (interface, peerAddress);
259  if (peerLink != 0)
260  {
261  peerLink->TransmissionSuccess ();
262  }
263 }
265 PeerManagementProtocol::InitiateLink (uint32_t interface, Mac48Address peerAddress,
266  Mac48Address peerMeshPointAddress)
267 {
268  Ptr<PeerLink> new_link = CreateObject<PeerLink> ();
269  //find a peer link - it must not exist
270  if (FindPeerLink (interface, peerAddress) != 0)
271  {
272  NS_FATAL_ERROR ("Peer link must not exist.");
273  }
274  // Plugin must exist
275  PeerManagementProtocolMacMap::iterator plugin = m_plugins.find (interface);
276  NS_ASSERT (plugin != m_plugins.end ());
277  PeerLinksMap::iterator iface = m_peerLinks.find (interface);
278  NS_ASSERT (iface != m_peerLinks.end ());
279  new_link->SetLocalAid (m_lastAssocId++);
280  new_link->SetInterface (interface);
281  new_link->SetLocalLinkId (m_lastLocalLinkId++);
282  new_link->SetPeerAddress (peerAddress);
283  new_link->SetPeerMeshPointAddress (peerMeshPointAddress);
284  new_link->SetMacPlugin (plugin->second);
285  new_link->MLMESetSignalStatusCallback (MakeCallback (&PeerManagementProtocol::PeerLinkStatus, this));
286  iface->second.push_back (new_link);
287  return new_link;
288 }
289 
291 PeerManagementProtocol::FindPeerLink (uint32_t interface, Mac48Address peerAddress)
292 {
293  PeerLinksMap::iterator iface = m_peerLinks.find (interface);
294  NS_ASSERT (iface != m_peerLinks.end ());
295  for (PeerLinksOnInterface::iterator i = iface->second.begin (); i != iface->second.end (); i++)
296  {
297  if ((*i)->GetPeerAddress () == peerAddress)
298  {
299  if ((*i)->LinkIsIdle ())
300  {
301  (*i) = 0;
302  (iface->second).erase (i);
303  return 0;
304  }
305  else
306  {
307  return (*i);
308  }
309  }
310  }
311  return 0;
312 }
313 void
316 {
318 }
319 
320 std::vector<Mac48Address>
321 PeerManagementProtocol::GetPeers (uint32_t interface) const
322 {
323  std::vector<Mac48Address> retval;
324  PeerLinksMap::const_iterator iface = m_peerLinks.find (interface);
325  NS_ASSERT (iface != m_peerLinks.end ());
326  for (PeerLinksOnInterface::const_iterator i = iface->second.begin (); i != iface->second.end (); i++)
327  {
328  if ((*i)->LinkIsEstab ())
329  {
330  retval.push_back ((*i)->GetPeerAddress ());
331  }
332  }
333  return retval;
334 }
335 
336 std::vector< Ptr<PeerLink> >
338 {
339  std::vector< Ptr<PeerLink> > links;
340 
341  for (PeerLinksMap::const_iterator iface = m_peerLinks.begin (); iface != m_peerLinks.end (); ++iface)
342  {
343  for (PeerLinksOnInterface::const_iterator i = iface->second.begin ();
344  i != iface->second.end (); i++)
345  if ((*i)->LinkIsEstab ())
346  links.push_back (*i);
347  }
348  return links;
349 }
350 bool
351 PeerManagementProtocol::IsActiveLink (uint32_t interface, Mac48Address peerAddress)
352 {
353  Ptr<PeerLink> peerLink = FindPeerLink (interface, peerAddress);
354  if (peerLink != 0)
355  {
356  return (peerLink->LinkIsEstab ());
357  }
358  return false;
359 }
360 bool
361 PeerManagementProtocol::ShouldSendOpen (uint32_t interface, Mac48Address peerAddress)
362 {
364 }
365 
366 bool
368  PmpReasonCode & reasonCode)
369 {
371  {
372  reasonCode = REASON11S_MESH_MAX_PEERS;
373  return false;
374  }
375  return true;
376 }
377 
378 void
380 {
382  {
383  return;
384  }
385  PeerLinksMap::iterator iface = m_peerLinks.find (interface);
386  NS_ASSERT (iface != m_peerLinks.end ());
387  NS_ASSERT (m_plugins.find (interface) != m_plugins.end ());
388 
389  std::map<uint32_t, Time>::const_iterator lastBeacon = m_lastBeacon.find (interface);
390  std::map<uint32_t, Time>::const_iterator beaconInterval = m_beaconInterval.find (interface);
391  if ((lastBeacon == m_lastBeacon.end ()) || (beaconInterval == m_beaconInterval.end ()))
392  {
393  return;
394  }
395  //my last beacon in 256 us units
396  uint16_t lastBeaconInTimeElement = (uint16_t) ((lastBeacon->second.GetMicroSeconds () >> 8) & 0xffff);
397 
398  NS_ASSERT_MSG (TuToTime (m_maxBeaconShift) <= m_beaconInterval[interface], "Wrong beacon shift parameters");
399 
400  if (iface->second.size () == 0)
401  {
402  //I have no peers - may be our beacons are in collision
403  ShiftOwnBeacon (interface);
404  return;
405  }
406  //check whether all my peers receive my beacon and I'am not in collision with other beacons
407 
408  for (PeerLinksOnInterface::iterator i = iface->second.begin (); i != iface->second.end (); i++)
409  {
410  bool myBeaconExists = false;
411  IeBeaconTiming::NeighboursTimingUnitsList neighbors = (*i)->GetBeaconTimingElement ().GetNeighboursTimingElementsList ();
412  for (IeBeaconTiming::NeighboursTimingUnitsList::const_iterator j = neighbors.begin (); j != neighbors.end (); j++)
413  {
414  if ((*i)->GetPeerAid () == (*j)->GetAid ())
415  {
416  // I am presented at neighbour's list of neighbors
417  myBeaconExists = true;
418  continue;
419  }
420  if (
421  ((int16_t) ((*j)->GetLastBeacon () - lastBeaconInTimeElement) >= 0) &&
422  (((*j)->GetLastBeacon () - lastBeaconInTimeElement) % (4 * TimeToTu (beaconInterval->second)) == 0)
423  )
424  {
425  ShiftOwnBeacon (interface);
426  return;
427  }
428  }
429  if (!myBeaconExists)
430  {
431  // If I am not present in neighbor's beacon timing element, this may be caused by collisions with
432  ShiftOwnBeacon (interface);
433  return;
434  }
435  }
436 }
437 
438 void
440 {
441  int shift = 0;
442  do
443  {
444  shift = (int) m_beaconShift->GetValue ();
445  }
446  while (shift == 0);
447  // Apply beacon shift parameters:
448  PeerManagementProtocolMacMap::iterator plugin = m_plugins.find (interface);
449  NS_ASSERT (plugin != m_plugins.end ());
450  plugin->second->SetBeaconShift (TuToTime (shift));
451 }
452 
453 Time
455 {
456  return MicroSeconds (x * 1024);
457 }
458 int
460 {
461  return (int)(x.GetMicroSeconds () / 1024);
462 }
463 
464 void
465 PeerManagementProtocol::NotifyLinkOpen (Mac48Address peerMp, Mac48Address peerIface, Mac48Address myIface, uint32_t interface)
466 {
467  NS_LOG_LOGIC ("link_open " << myIface << " " << peerIface);
470  if (!m_peerStatusCallback.IsNull ())
471  {
472  m_peerStatusCallback (peerMp, peerIface, interface, true);
473  }
474  m_linkOpenTraceSrc (myIface, peerIface);
475 }
476 
477 void
478 PeerManagementProtocol::NotifyLinkClose (Mac48Address peerMp, Mac48Address peerIface, Mac48Address myIface, uint32_t interface)
479 {
480  NS_LOG_LOGIC ("link_close " << myIface << " " << peerIface);
483  if (!m_peerStatusCallback.IsNull ())
484  {
485  m_peerStatusCallback (peerMp, peerIface, interface, false);
486  }
487  m_linkCloseTraceSrc (myIface, peerIface);
488 }
489 
490 void
491 PeerManagementProtocol::PeerLinkStatus (uint32_t interface, Mac48Address peerAddress,
492  Mac48Address peerMeshPointAddress, PeerLink::PeerState ostate, PeerLink::PeerState nstate)
493 {
494  PeerManagementProtocolMacMap::iterator plugin = m_plugins.find (interface);
495  NS_ASSERT (plugin != m_plugins.end ());
496  NS_LOG_DEBUG ("Link between me:" << m_address << " my interface:" << plugin->second->GetAddress ()
497  << " and peer mesh point:" << peerMeshPointAddress << " and its interface:" << peerAddress
498  << ", at my interface ID:" << interface << ". State movement:" << ostate << " -> " << nstate);
499  if ((nstate == PeerLink::ESTAB) && (ostate != PeerLink::ESTAB))
500  {
501  NotifyLinkOpen (peerMeshPointAddress, peerAddress, plugin->second->GetAddress (), interface);
502  }
503  if ((ostate == PeerLink::ESTAB) && (nstate != PeerLink::ESTAB))
504  {
505  NotifyLinkClose (peerMeshPointAddress, peerAddress, plugin->second->GetAddress (), interface);
506  }
507  if (nstate == PeerLink::IDLE)
508  {
509  Ptr<PeerLink> link = FindPeerLink (interface, peerAddress);
510  NS_ASSERT (link == 0);
511  }
512 }
513 uint8_t
515 {
516  return m_stats.linksTotal;
517 }
520 {
521  NS_ASSERT (m_meshId != 0);
522  return m_meshId;
523 }
524 void
526 {
527  m_meshId = Create<IeMeshId> (s);
528 }
531 {
532  return m_address;
533 }
534 void
535 PeerManagementProtocol::NotifyBeaconSent (uint32_t interface, Time beaconInterval)
536 {
537  m_lastBeacon[interface] = Simulator::Now ();
539  m_beaconInterval[interface] = beaconInterval;
540 }
542  linksTotal (t), linksOpened (0), linksClosed (0)
543 {
544 }
545 void
547 {
548  os << "<Statistics "
549  "linksTotal=\"" << linksTotal << "\" "
550  "linksOpened=\"" << linksOpened << "\" "
551  "linksClosed=\"" << linksClosed << "\"/>" << std::endl;
552 }
553 void
554 PeerManagementProtocol::Report (std::ostream & os) const
555 {
556  os << "<PeerManagementProtocol>" << std::endl;
557  m_stats.Print (os);
558  for (PeerManagementProtocolMacMap::const_iterator plugins = m_plugins.begin (); plugins != m_plugins.end (); plugins++)
559  {
560  //Take statistics from plugin:
561  plugins->second->Report (os);
562  //Print all active peer links:
563  PeerLinksMap::const_iterator iface = m_peerLinks.find (plugins->second->m_ifIndex);
564  NS_ASSERT (iface != m_peerLinks.end ());
565  for (PeerLinksOnInterface::const_iterator i = iface->second.begin (); i != iface->second.end (); i++)
566  {
567  (*i)->Report (os);
568  }
569  }
570  os << "</PeerManagementProtocol>" << std::endl;
571 }
572 void
574 {
575  m_stats = Statistics (m_stats.linksTotal); // don't reset number of links
576  for (PeerManagementProtocolMacMap::const_iterator plugins = m_plugins.begin (); plugins != m_plugins.end (); plugins++)
577  {
578  plugins->second->ResetStats ();
579  }
580 }
581 
582 int64_t
584 {
585  NS_LOG_FUNCTION (this << stream);
586  m_beaconShift->SetStream (stream);
587  return 1;
588 }
589 
590 void
592 {
593  // If beacon interval is equal to the neighbor's one and one o more beacons received
594  // by my neighbor coincide with my beacon - apply random uniformly distributed shift from
595  // [-m_maxBeaconShift, m_maxBeaconShift] except 0.
598 }
599 
600 void
602 {
603  m_enableBca = enable;
604 }
605 bool
607 {
608  return m_enableBca;
609 }
610 } // namespace dot11s
611 } // namespace ns3
612 
keep track of time values and allow control of global simulation resolution
Definition: nstime.h:81
void NotifyLinkClose(Mac48Address peerMp, Mac48Address peerIface, Mac48Address myIface, uint32_t interface)
Aux. method to register closed links.
virtual void DoInitialize()
Set peer link status change callback.
smart pointer class similar to boost::intrusive_ptr
Definition: ptr.h:59
#define NS_LOG_FUNCTION(parameters)
Definition: log.h:345
void SetStream(int64_t stream)
Specifies the stream number for this RNG stream.
Hold a bool native type.
Definition: boolean.h:38
Callback template class.
Definition: callback.h:920
list plugins
Definition: base.py:77
#define NS_ASSERT(condition)
Definition: assert.h:64
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
void NotifyLinkOpen(Mac48Address peerMp, Mac48Address peerIface, Mac48Address myIface, uint32_t interface)
Aux. method to register open links.
Ptr< UniformRandomVariable > m_beaconShift
Add randomness to beacon shift.
void Report(std::ostream &) const
: Report statistics
static EventId Schedule(Time const &time, MEM mem_ptr, OBJ obj)
Schedule an event to expire at the relative time "time" is reached.
Definition: simulator.h:824
Ptr< PeerLink > FindPeerLink(uint32_t interface, Mac48Address peerAddress)
Find active peer link by my interface and peer interface MAC.
std::vector< Ptr< IeBeaconTimingUnit > > NeighboursTimingUnitsList
This type is a list of timing elements obtained from neighbours with their beacons: ...
#define NS_FATAL_ERROR(msg)
fatal error handling
Definition: fatal-error.h:72
LinkEventCallback m_linkCloseTraceSrc
LinkClose trace source.
bool IsActiveLink(uint32_t interface, Mac48Address peerAddress)
Checks if there is established link.
std::vector< Ptr< PeerLink > > PeerLinksOnInterface
We keep a vector of pointers to PeerLink class.
std::vector< Mac48Address > GetPeers(uint32_t interface) const
Get list of active peers of my given interface.
See 7.3.2.85 of draft 2.07.
int64_t GetMicroSeconds(void) const
Definition: nstime.h:291
Hold an unsigned integer type.
Definition: uinteger.h:46
void SetMeshId(std::string s)
Set peer link status change callback.
Ptr< SampleEmitter > s
tuple interfaces
Definition: first.py:40
T * PeekPointer(const Ptr< T > &p)
Definition: ptr.h:279
void DoDispose()
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
Hold together all Wifi-related objects.
static Mac48Address GetBroadcast(void)
void NotifyBeaconSent(uint32_t interface, Time beaconInterval)
Notify about beacon send event, needed to schedule BCA.
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
Definition: callback.h:1238
Mac48Address GetAddress()
Get mesh point address.
void SetPeerLinkStatusCallback(Callback< void, Mac48Address, Mac48Address, uint32_t, bool > cb)
Set peer link status change callback.
#define NS_LOG_LOGIC(msg)
Definition: log.h:368
std::vector< Ptr< PeerLink > > GetPeerLinks() const
Get list of all active peer links.
static Mac48Address ConvertFrom(const Address &address)
uint8_t GetNumberOfLinks()
Set peer link status change callback.
Ptr< IeMeshId > GetMeshId() const
Set peer link status change callback.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
double GetValue(double min, double max)
Returns a random double from the uniform distribution with the specified range.
an EUI-48 address
Definition: mac48-address.h:41
LinkEventCallback m_linkOpenTraceSrc
LinkOpen trace source.
static Time Now(void)
Return the "current simulation time".
Definition: simulator.cc:180
void ReceivePeerLinkFrame(uint32_t interface, Mac48Address peerAddress, Mac48Address peerMeshPointAddress, uint16_t aid, IePeerManagement peerManagementElement, IeConfiguration meshConfig)
Methods that handle Peer link management frames interaction:
void ResetStats()
Set peer link status change callback.
Ptr< IeBeaconTiming > GetBeaconTimingElement(uint32_t interface)
When we are sending a beacon - we fill beacon timing element.
void PeerLinkStatus(uint32_t interface, Mac48Address peerAddress, Mac48Address peerMeshPointAddres, PeerLink::PeerState ostate, PeerLink::PeerState nstate)
Indicates changes in peer links.
#define NS_ASSERT_MSG(condition, message)
Definition: assert.h:86
bool ShouldSendOpen(uint32_t interface, Mac48Address peerAddress)
void ConfigurationMismatch(uint32_t interface, Mac48Address peerAddress)
Cancels peer link due to broken configuration (Mesh ID or Supported rates)
void TransmissionFailure(uint32_t interface, const Mac48Address peerAddress)
Cancels peer link due to successive transmission failures.
void CheckBeaconCollisions(uint32_t interface)
BCA.
std::map< uint32_t, Time > m_lastBeacon
Last beacon at each interface.
bool GetBeaconCollisionAvoidance() const
Set peer link status change callback.
PmpReasonCode
Codes used by 802.11s Peer Management Protocol.
bool ShouldAcceptOpen(uint32_t interface, Mac48Address peerAddress, PmpReasonCode &reasonCode)
#define NS_LOG_DEBUG(msg)
Definition: log.h:289
bool m_enableBca
Flag which enables BCA.
void ReceiveBeacon(uint32_t interface, Mac48Address peerAddress, Time beaconInterval, Ptr< IeBeaconTiming > beaconTiming)
To initiate peer link we must notify about received beacon.
Describes Mesh Configuration Element see 7.3.2.86 of 802.11s draft 3.0.
std::map< uint32_t, Time > m_beaconInterval
Beacon interval at each interface.
void SetBeaconCollisionAvoidance(bool enable)
Enable or disable beacon collision avoidance.
a base class which provides memory management and object aggregation
Definition: object.h:63
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
Hold a floating point type.
Definition: double.h:41
uint16_t m_maxBeaconShift
Beacon can be shifted at [-m_maxBeaconShift; +m_maxBeaconShift] TUs.
void SetAttribute(std::string name, const AttributeValue &value)
Definition: object-base.cc:161
Callback< void, Mac48Address, Mac48Address, uint32_t, bool > m_peerStatusCallback
Callback to notify about peer link changes: Mac48Address is peer address of mesh point, Mac48Address is peer address of interface, uint32_t - interface ID, bool is status - true when new link has appeared, false - when link was closed,.
a unique identifier for an interface.
Definition: type-id.h:49
Ptr< PeerLink > InitiateLink(uint32_t interface, Mac48Address peerAddress, Mac48Address peerMeshPointAddress)
TypeId SetParent(TypeId tid)
Definition: type-id.cc:611
Basic MAC of mesh point Wi-Fi interface.
bool Install(Ptr< MeshPointDevice >)
Install PMP on given mesh point.
NS_LOG_COMPONENT_DEFINE("PeerManagementProtocol")
void TransmissionSuccess(uint32_t interface, const Mac48Address peerAddress)
resets transmission failure statistics