A Discrete-Event Network Simulator
API
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 namespace ns3 {
37 
38 NS_LOG_COMPONENT_DEFINE ("PeerManagementProtocol");
39 
40 namespace dot11s {
41 
42 /***************************************************
43  * PeerManager
44  ***************************************************/
45 NS_OBJECT_ENSURE_REGISTERED (PeerManagementProtocol);
46 
47 TypeId
49 {
50  static TypeId tid = TypeId ("ns3::dot11s::PeerManagementProtocol")
51  .SetParent<Object> ()
52  .AddConstructor<PeerManagementProtocol> ()
53  // maximum number of peer links. Now we calculate the total
54  // number of peer links on all interfaces
55  .AddAttribute ( "MaxNumberOfPeerLinks",
56  "Maximum number of peer links",
57  UintegerValue (32),
60  MakeUintegerChecker<uint8_t> ()
61  )
62  .AddAttribute ( "MaxBeaconShiftValue",
63  "Maximum number of TUs for beacon shifting",
64  UintegerValue (15),
67  MakeUintegerChecker<uint16_t> ()
68  )
69  .AddAttribute ( "EnableBeaconCollisionAvoidance",
70  "Enable/Disable Beacon collision avoidance.",
71  BooleanValue (true),
75  )
76  .AddTraceSource ("LinkOpen",
77  "New peer link opened",
79  "ns3::PeerManagementProtocol::LinkOpenCloseTracedCallback"
80  )
81  .AddTraceSource ("LinkClose",
82  "New peer link closed",
84  "ns3::PeerManagementProtocol::LinkOpenCloseTracedCallback"
85  )
86 
87  ;
88  return tid;
89 }
91  m_lastAssocId (0), m_lastLocalLinkId (1), m_enableBca (true), m_maxBeaconShift (15)
92 {
93  m_beaconShift = CreateObject<UniformRandomVariable> ();
94 }
96 {
97  m_meshId = 0;
98 }
99 void
101 {
102  //cancel cleanup event and go through the map of peer links,
103  //deleting each
104  for (PeerLinksMap::iterator j = m_peerLinks.begin (); j != m_peerLinks.end (); j++)
105  {
106  for (PeerLinksOnInterface::iterator i = j->second.begin (); i != j->second.end (); i++)
107  {
108  (*i) = 0;
109  }
110  j->second.clear ();
111  }
112  m_peerLinks.clear ();
113  m_plugins.clear ();
114 }
115 
116 bool
118 {
119  std::vector<Ptr<NetDevice> > interfaces = mp->GetInterfaces ();
120  for (std::vector<Ptr<NetDevice> >::iterator i = interfaces.begin (); i != interfaces.end (); i++)
121  {
122  Ptr<WifiNetDevice> wifiNetDev = (*i)->GetObject<WifiNetDevice> ();
123  if (wifiNetDev == 0)
124  {
125  return false;
126  }
127  Ptr<MeshWifiInterfaceMac> mac = wifiNetDev->GetMac ()->GetObject<MeshWifiInterfaceMac> ();
128  if (mac == 0)
129  {
130  return false;
131  }
132  Ptr<PeerManagementProtocolMac> plugin = Create<PeerManagementProtocolMac> ((*i)->GetIfIndex (), this);
133  mac->InstallPlugin (plugin);
134  m_plugins[(*i)->GetIfIndex ()] = plugin;
135  PeerLinksOnInterface newmap;
136  m_peerLinks[(*i)->GetIfIndex ()] = newmap;
137  }
138  // Mesh point aggregates all installed protocols
139  m_address = Mac48Address::ConvertFrom (mp->GetAddress ());
140  mp->AggregateObject (this);
141  return true;
142 }
143 
146 {
148  {
149  return 0;
150  }
151  Ptr<IeBeaconTiming> retval = Create<IeBeaconTiming> ();
152  PeerLinksMap::iterator iface = m_peerLinks.find (interface);
153  NS_ASSERT (iface != m_peerLinks.end ());
154  for (PeerLinksOnInterface::iterator i = iface->second.begin (); i != iface->second.end (); i++)
155  {
156  //If we do not know peer Assoc Id, we shall not add any info
157  //to a beacon timing element
158  if ((*i)->GetBeaconInterval () == Seconds (0))
159  {
160  //No beacon was received, do not include to the beacon timing element
161  continue;
162  }
163  retval->AddNeighboursTimingElementUnit ((*i)->GetLocalAid (), (*i)->GetLastBeacon (),
164  (*i)->GetBeaconInterval ());
165  }
166  return retval;
167 }
168 void
169 PeerManagementProtocol::ReceiveBeacon (uint32_t interface, Mac48Address peerAddress, Time beaconInterval, Ptr<IeBeaconTiming> timingElement)
170 {
171  //PM STATE Machine
172  //Check that a given beacon is not from our interface
173  for (PeerManagementProtocolMacMap::const_iterator i = m_plugins.begin (); i != m_plugins.end (); i++)
174  {
175  if (i->second->GetAddress () == peerAddress)
176  {
177  return;
178  }
179  }
180  Ptr<PeerLink> peerLink = FindPeerLink (interface, peerAddress);
181  if (peerLink == 0)
182  {
183  if (ShouldSendOpen (interface, peerAddress))
184  {
185  peerLink = InitiateLink (interface, peerAddress, Mac48Address::GetBroadcast ());
186  peerLink->MLMEActivePeerLinkOpen ();
187  }
188  else
189  {
190  return;
191  }
192  }
193  peerLink->SetBeaconInformation (Simulator::Now (), beaconInterval);
195  {
196  peerLink->SetBeaconTimingElement (*PeekPointer (timingElement));
197  }
198 }
199 
200 void
202  Mac48Address peerMeshPointAddress, uint16_t aid, IePeerManagement peerManagementElement,
203  IeConfiguration meshConfig)
204 {
205  Ptr<PeerLink> peerLink = FindPeerLink (interface, peerAddress);
206  if (peerManagementElement.SubtypeIsOpen ())
207  {
208  PmpReasonCode reasonCode (REASON11S_RESERVED);
209  bool reject = !(ShouldAcceptOpen (interface, peerAddress, reasonCode));
210  if (peerLink == 0)
211  {
212  peerLink = InitiateLink (interface, peerAddress, peerMeshPointAddress);
213  }
214  if (!reject)
215  {
216  peerLink->OpenAccept (peerManagementElement.GetLocalLinkId (), meshConfig, peerMeshPointAddress);
217  }
218  else
219  {
220  peerLink->OpenReject (peerManagementElement.GetLocalLinkId (), meshConfig, peerMeshPointAddress,
221  reasonCode);
222  }
223  }
224  if (peerLink == 0)
225  {
226  return;
227  }
228  if (peerManagementElement.SubtypeIsConfirm ())
229  {
230  peerLink->ConfirmAccept (peerManagementElement.GetLocalLinkId (),
231  peerManagementElement.GetPeerLinkId (), aid, meshConfig, peerMeshPointAddress);
232  }
233  if (peerManagementElement.SubtypeIsClose ())
234  {
235  peerLink->Close (peerManagementElement.GetLocalLinkId (), peerManagementElement.GetPeerLinkId (),
236  peerManagementElement.GetReasonCode ());
237  }
238 }
239 void
241 {
242  Ptr<PeerLink> peerLink = FindPeerLink (interface, peerAddress);
243  if (peerLink != 0)
244  {
245  peerLink->MLMECancelPeerLink (REASON11S_MESH_CAPABILITY_POLICY_VIOLATION);
246  }
247 }
248 void
250 {
251  NS_LOG_DEBUG ("transmission failed between "<<GetAddress () << " and " << peerAddress << " failed, link will be closed");
252  Ptr<PeerLink> peerLink = FindPeerLink (interface, peerAddress);
253  if (peerLink != 0)
254  {
255  peerLink->TransmissionFailure ();
256  }
257 }
258 void
260 {
261  NS_LOG_DEBUG ("transmission success "<< GetAddress () << " and " << peerAddress);
262  Ptr<PeerLink> peerLink = FindPeerLink (interface, peerAddress);
263  if (peerLink != 0)
264  {
265  peerLink->TransmissionSuccess ();
266  }
267 }
269 PeerManagementProtocol::InitiateLink (uint32_t interface, Mac48Address peerAddress,
270  Mac48Address peerMeshPointAddress)
271 {
272  Ptr<PeerLink> new_link = CreateObject<PeerLink> ();
273  //find a peer link - it must not exist
274  if (FindPeerLink (interface, peerAddress) != 0)
275  {
276  NS_FATAL_ERROR ("Peer link must not exist.");
277  }
278  // Plugin must exist
279  PeerManagementProtocolMacMap::iterator plugin = m_plugins.find (interface);
280  NS_ASSERT (plugin != m_plugins.end ());
281  PeerLinksMap::iterator iface = m_peerLinks.find (interface);
282  NS_ASSERT (iface != m_peerLinks.end ());
283  new_link->SetLocalAid (m_lastAssocId++);
284  new_link->SetInterface (interface);
285  new_link->SetLocalLinkId (m_lastLocalLinkId++);
286  new_link->SetPeerAddress (peerAddress);
287  new_link->SetPeerMeshPointAddress (peerMeshPointAddress);
288  new_link->SetMacPlugin (plugin->second);
289  new_link->MLMESetSignalStatusCallback (MakeCallback (&PeerManagementProtocol::PeerLinkStatus, this));
290  iface->second.push_back (new_link);
291  return new_link;
292 }
293 
295 PeerManagementProtocol::FindPeerLink (uint32_t interface, Mac48Address peerAddress)
296 {
297  PeerLinksMap::iterator iface = m_peerLinks.find (interface);
298  NS_ASSERT (iface != m_peerLinks.end ());
299  for (PeerLinksOnInterface::iterator i = iface->second.begin (); i != iface->second.end (); i++)
300  {
301  if ((*i)->GetPeerAddress () == peerAddress)
302  {
303  if ((*i)->LinkIsIdle ())
304  {
305  (*i) = 0;
306  (iface->second).erase (i);
307  return 0;
308  }
309  else
310  {
311  return (*i);
312  }
313  }
314  }
315  return 0;
316 }
317 void
320 {
322 }
323 
324 std::vector<Mac48Address>
325 PeerManagementProtocol::GetPeers (uint32_t interface) const
326 {
327  std::vector<Mac48Address> retval;
328  PeerLinksMap::const_iterator iface = m_peerLinks.find (interface);
329  NS_ASSERT (iface != m_peerLinks.end ());
330  for (PeerLinksOnInterface::const_iterator i = iface->second.begin (); i != iface->second.end (); i++)
331  {
332  if ((*i)->LinkIsEstab ())
333  {
334  retval.push_back ((*i)->GetPeerAddress ());
335  }
336  }
337  return retval;
338 }
339 
340 std::vector< Ptr<PeerLink> >
342 {
343  std::vector< Ptr<PeerLink> > links;
344 
345  for (PeerLinksMap::const_iterator iface = m_peerLinks.begin (); iface != m_peerLinks.end (); ++iface)
346  {
347  for (PeerLinksOnInterface::const_iterator i = iface->second.begin ();
348  i != iface->second.end (); i++)
349  if ((*i)->LinkIsEstab ())
350  links.push_back (*i);
351  }
352  return links;
353 }
354 bool
355 PeerManagementProtocol::IsActiveLink (uint32_t interface, Mac48Address peerAddress)
356 {
357  Ptr<PeerLink> peerLink = FindPeerLink (interface, peerAddress);
358  if (peerLink != 0)
359  {
360  return (peerLink->LinkIsEstab ());
361  }
362  return false;
363 }
364 bool
365 PeerManagementProtocol::ShouldSendOpen (uint32_t interface, Mac48Address peerAddress)
366 {
368 }
369 
370 bool
372  PmpReasonCode & reasonCode)
373 {
375  {
376  reasonCode = REASON11S_MESH_MAX_PEERS;
377  return false;
378  }
379  return true;
380 }
381 
382 void
384 {
386  {
387  return;
388  }
389  PeerLinksMap::iterator iface = m_peerLinks.find (interface);
390  NS_ASSERT (iface != m_peerLinks.end ());
391  NS_ASSERT (m_plugins.find (interface) != m_plugins.end ());
392 
393  std::map<uint32_t, Time>::const_iterator lastBeacon = m_lastBeacon.find (interface);
394  std::map<uint32_t, Time>::const_iterator beaconInterval = m_beaconInterval.find (interface);
395  if ((lastBeacon == m_lastBeacon.end ()) || (beaconInterval == m_beaconInterval.end ()))
396  {
397  return;
398  }
399  //my last beacon in 256 us units
400  uint16_t lastBeaconInTimeElement = (uint16_t) ((lastBeacon->second.GetMicroSeconds () >> 8) & 0xffff);
401 
402  NS_ASSERT_MSG (TuToTime (m_maxBeaconShift) <= m_beaconInterval[interface], "Wrong beacon shift parameters");
403 
404  if (iface->second.size () == 0)
405  {
406  //I have no peers - may be our beacons are in collision
407  ShiftOwnBeacon (interface);
408  return;
409  }
410  //check whether all my peers receive my beacon and I'am not in collision with other beacons
411 
412  for (PeerLinksOnInterface::iterator i = iface->second.begin (); i != iface->second.end (); i++)
413  {
414  bool myBeaconExists = false;
415  IeBeaconTiming::NeighboursTimingUnitsList neighbors = (*i)->GetBeaconTimingElement ().GetNeighboursTimingElementsList ();
416  for (IeBeaconTiming::NeighboursTimingUnitsList::const_iterator j = neighbors.begin (); j != neighbors.end (); j++)
417  {
418  if ((*i)->GetPeerAid () == (*j)->GetAid ())
419  {
420  // I am presented at neighbour's list of neighbors
421  myBeaconExists = true;
422  continue;
423  }
424  if (
425  ((int16_t) ((*j)->GetLastBeacon () - lastBeaconInTimeElement) >= 0) &&
426  (((*j)->GetLastBeacon () - lastBeaconInTimeElement) % (4 * TimeToTu (beaconInterval->second)) == 0)
427  )
428  {
429  ShiftOwnBeacon (interface);
430  return;
431  }
432  }
433  if (!myBeaconExists)
434  {
435  // If I am not present in neighbor's beacon timing element, this may be caused by collisions with
436  ShiftOwnBeacon (interface);
437  return;
438  }
439  }
440 }
441 
442 void
444 {
445  int shift = 0;
446  do
447  {
448  shift = (int) m_beaconShift->GetValue ();
449  }
450  while (shift == 0);
451  // Apply beacon shift parameters:
452  PeerManagementProtocolMacMap::iterator plugin = m_plugins.find (interface);
453  NS_ASSERT (plugin != m_plugins.end ());
454  plugin->second->SetBeaconShift (TuToTime (shift));
455 }
456 
457 Time
459 {
460  return MicroSeconds (x * 1024);
461 }
462 int
464 {
465  return (int)(x.GetMicroSeconds () / 1024);
466 }
467 
468 void
469 PeerManagementProtocol::NotifyLinkOpen (Mac48Address peerMp, Mac48Address peerIface, Mac48Address myIface, uint32_t interface)
470 {
471  NS_LOG_LOGIC ("link_open " << myIface << " " << peerIface);
474  if (!m_peerStatusCallback.IsNull ())
475  {
476  m_peerStatusCallback (peerMp, peerIface, interface, true);
477  }
478  m_linkOpenTraceSrc (myIface, peerIface);
479 }
480 
481 void
482 PeerManagementProtocol::NotifyLinkClose (Mac48Address peerMp, Mac48Address peerIface, Mac48Address myIface, uint32_t interface)
483 {
484  NS_LOG_LOGIC ("link_close " << myIface << " " << peerIface);
487  if (!m_peerStatusCallback.IsNull ())
488  {
489  m_peerStatusCallback (peerMp, peerIface, interface, false);
490  }
491  m_linkCloseTraceSrc (myIface, peerIface);
492 }
493 
494 void
495 PeerManagementProtocol::PeerLinkStatus (uint32_t interface, Mac48Address peerAddress,
496  Mac48Address peerMeshPointAddress, PeerLink::PeerState ostate, PeerLink::PeerState nstate)
497 {
498  PeerManagementProtocolMacMap::iterator plugin = m_plugins.find (interface);
499  NS_ASSERT (plugin != m_plugins.end ());
500  NS_LOG_DEBUG ("Link between me:" << m_address << " my interface:" << plugin->second->GetAddress ()
501  << " and peer mesh point:" << peerMeshPointAddress << " and its interface:" << peerAddress
502  << ", at my interface ID:" << interface << ". State movement:" << ostate << " -> " << nstate);
503  if ((nstate == PeerLink::ESTAB) && (ostate != PeerLink::ESTAB))
504  {
505  NotifyLinkOpen (peerMeshPointAddress, peerAddress, plugin->second->GetAddress (), interface);
506  }
507  if ((ostate == PeerLink::ESTAB) && (nstate != PeerLink::ESTAB))
508  {
509  NotifyLinkClose (peerMeshPointAddress, peerAddress, plugin->second->GetAddress (), interface);
510  }
511  if (nstate == PeerLink::IDLE)
512  {
513  Ptr<PeerLink> link = FindPeerLink (interface, peerAddress);
514  NS_ASSERT (link == 0);
515  }
516 }
517 uint8_t
519 {
520  return m_stats.linksTotal;
521 }
524 {
525  NS_ASSERT (m_meshId != 0);
526  return m_meshId;
527 }
528 void
530 {
531  m_meshId = Create<IeMeshId> (s);
532 }
535 {
536  return m_address;
537 }
538 void
539 PeerManagementProtocol::NotifyBeaconSent (uint32_t interface, Time beaconInterval)
540 {
541  m_lastBeacon[interface] = Simulator::Now ();
543  m_beaconInterval[interface] = beaconInterval;
544 }
546  linksTotal (t), linksOpened (0), linksClosed (0)
547 {
548 }
549 void
551 {
552  os << "<Statistics "
553  "linksTotal=\"" << linksTotal << "\" "
554  "linksOpened=\"" << linksOpened << "\" "
555  "linksClosed=\"" << linksClosed << "\"/>" << std::endl;
556 }
557 void
558 PeerManagementProtocol::Report (std::ostream & os) const
559 {
560  os << "<PeerManagementProtocol>" << std::endl;
561  m_stats.Print (os);
562  for (PeerManagementProtocolMacMap::const_iterator plugins = m_plugins.begin (); plugins != m_plugins.end (); plugins++)
563  {
564  //Take statistics from plugin:
565  plugins->second->Report (os);
566  //Print all active peer links:
567  PeerLinksMap::const_iterator iface = m_peerLinks.find (plugins->second->m_ifIndex);
568  NS_ASSERT (iface != m_peerLinks.end ());
569  for (PeerLinksOnInterface::const_iterator i = iface->second.begin (); i != iface->second.end (); i++)
570  {
571  (*i)->Report (os);
572  }
573  }
574  os << "</PeerManagementProtocol>" << std::endl;
575 }
576 void
578 {
579  m_stats = Statistics (m_stats.linksTotal); // don't reset number of links
580  for (PeerManagementProtocolMacMap::const_iterator plugins = m_plugins.begin (); plugins != m_plugins.end (); plugins++)
581  {
582  plugins->second->ResetStats ();
583  }
584 }
585 
586 int64_t
588 {
589  NS_LOG_FUNCTION (this << stream);
590  m_beaconShift->SetStream (stream);
591  return 1;
592 }
593 
594 void
596 {
597  // If beacon interval is equal to the neighbor's one and one o more beacons received
598  // by my neighbor coincide with my beacon - apply random uniformly distributed shift from
599  // [-m_maxBeaconShift, m_maxBeaconShift] except 0.
602 }
603 
604 void
606 {
607  m_enableBca = enable;
608 }
609 bool
611 {
612  return m_enableBca;
613 }
614 } // namespace dot11s
615 } // namespace ns3
616 
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:95
void NotifyLinkClose(Mac48Address peerMp, Mac48Address peerIface, Mac48Address myIface, uint32_t interface)
Aux. method to register closed links.
virtual void DoInitialize()
Initialize() implementation.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
void SetStream(int64_t stream)
Specifies the stream number for this RNG stream.
AttributeValue implementation for Boolean.
Definition: boolean.h:34
Callback template class.
Definition: callback.h:978
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:44
list plugins
Definition: base.py:77
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: boolean.h:81
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
Definition: assert.h:61
U * PeekPointer(const Ptr< U > &p)
Definition: ptr.h:562
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:201
void NotifyLinkOpen(Mac48Address peerMp, Mac48Address peerIface, Mac48Address myIface, uint32_t interface)
Aux. method to register open links.
#define NS_FATAL_ERROR(msg)
Fatal error handling.
Definition: fatal-error.h:100
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:819
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: ...
LinkEventCallback m_linkCloseTraceSrc
LinkClose trace source.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
PeerState
Peer Link state:
Definition: peer-link.h:54
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
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:335
Hold an unsigned integer type.
Definition: uinteger.h:44
void SetMeshId(std::string s)
Set peer link status change callback.
Ptr< SampleEmitter > s
tuple interfaces
Definition: first.py:41
void DoDispose()
Destructor implementation.
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:1290
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)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition: log.h:252
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.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeChecker > MakeBooleanChecker(void)
Definition: boolean.cc:121
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:43
LinkEventCallback m_linkOpenTraceSrc
LinkOpen trace source.
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:223
void ReceivePeerLinkFrame(uint32_t interface, Mac48Address peerAddress, Mac48Address peerMeshPointAddress, uint16_t aid, IePeerManagement peerManagementElement, IeConfiguration meshConfig)
Methods that handle Peer link management frames interaction:
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)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Definition: assert.h:84
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)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:236
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:859
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.
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:875
A base class which provides memory management and object aggregation.
Definition: object.h:87
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
This class can be used to hold variables of floating point type such as 'double' or 'float'...
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)
Set a single attribute, raising fatal errors if unsuccessful.
Definition: object-base.cc:190
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: uinteger.h:45
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:51
Ptr< PeerLink > InitiateLink(uint32_t interface, Mac48Address peerAddress, Mac48Address peerMeshPointAddress)
TypeId SetParent(TypeId tid)
Definition: type-id.cc:631
Basic MAC of mesh point Wi-Fi interface.
bool Install(Ptr< MeshPointDevice >)
Install PMP on given mesh point.
void TransmissionSuccess(uint32_t interface, const Mac48Address peerAddress)
resets transmission failure statistics