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 TypeId
46 {
47  static TypeId tid = TypeId ("ns3::dot11s::PeerManagementProtocol")
48  .SetParent<Object> ()
49  .AddConstructor<PeerManagementProtocol> ()
50  // maximum number of peer links. Now we calculate the total
51  // number of peer links on all interfaces
52  .AddAttribute ( "MaxNumberOfPeerLinks",
53  "Maximum number of peer links",
54  UintegerValue (32),
55  MakeUintegerAccessor (
57  MakeUintegerChecker<uint8_t> ()
58  )
59  .AddAttribute ( "MaxBeaconShiftValue",
60  "Maximum number of TUs for beacon shifting",
61  UintegerValue (15),
62  MakeUintegerAccessor (
64  MakeUintegerChecker<uint16_t> ()
65  )
66  .AddAttribute ( "EnableBeaconCollisionAvoidance",
67  "Enable/Disable Beacon collision avoidance.",
68  BooleanValue (true),
69  MakeBooleanAccessor (
71  MakeBooleanChecker ()
72  )
73  .AddTraceSource ("LinkOpen",
74  "New peer link opened",
76  )
77  .AddTraceSource ("LinkClose",
78  "New peer link closed",
80  )
81 
82  ;
83  return tid;
84 }
86  m_lastAssocId (0), m_lastLocalLinkId (1), m_enableBca (true), m_maxBeaconShift (15)
87 {
88  m_beaconShift = CreateObject<UniformRandomVariable> ();
89 }
91 {
92  m_meshId = 0;
93 }
94 void
96 {
97  //cancel cleanup event and go through the map of peer links,
98  //deleting each
99  for (PeerLinksMap::iterator j = m_peerLinks.begin (); j != m_peerLinks.end (); j++)
100  {
101  for (PeerLinksOnInterface::iterator i = j->second.begin (); i != j->second.end (); i++)
102  {
103  (*i) = 0;
104  }
105  j->second.clear ();
106  }
107  m_peerLinks.clear ();
108  m_plugins.clear ();
109 }
110 
111 bool
113 {
114  std::vector<Ptr<NetDevice> > interfaces = mp->GetInterfaces ();
115  for (std::vector<Ptr<NetDevice> >::iterator i = interfaces.begin (); i != interfaces.end (); i++)
116  {
117  Ptr<WifiNetDevice> wifiNetDev = (*i)->GetObject<WifiNetDevice> ();
118  if (wifiNetDev == 0)
119  {
120  return false;
121  }
122  Ptr<MeshWifiInterfaceMac> mac = wifiNetDev->GetMac ()->GetObject<MeshWifiInterfaceMac> ();
123  if (mac == 0)
124  {
125  return false;
126  }
127  Ptr<PeerManagementProtocolMac> plugin = Create<PeerManagementProtocolMac> ((*i)->GetIfIndex (), this);
128  mac->InstallPlugin (plugin);
129  m_plugins[(*i)->GetIfIndex ()] = plugin;
130  PeerLinksOnInterface newmap;
131  m_peerLinks[(*i)->GetIfIndex ()] = newmap;
132  }
133  // Mesh point aggregates all installed protocols
134  m_address = Mac48Address::ConvertFrom (mp->GetAddress ());
135  mp->AggregateObject (this);
136  return true;
137 }
138 
141 {
143  {
144  return 0;
145  }
146  Ptr<IeBeaconTiming> retval = Create<IeBeaconTiming> ();
147  PeerLinksMap::iterator iface = m_peerLinks.find (interface);
148  NS_ASSERT (iface != m_peerLinks.end ());
149  for (PeerLinksOnInterface::iterator i = iface->second.begin (); i != iface->second.end (); i++)
150  {
151  //If we do not know peer Assoc Id, we shall not add any info
152  //to a beacon timing element
153  if ((*i)->GetBeaconInterval () == Seconds (0))
154  {
155  //No beacon was received, do not include to the beacon timing element
156  continue;
157  }
158  retval->AddNeighboursTimingElementUnit ((*i)->GetLocalAid (), (*i)->GetLastBeacon (),
159  (*i)->GetBeaconInterval ());
160  }
161  return retval;
162 }
163 void
164 PeerManagementProtocol::ReceiveBeacon (uint32_t interface, Mac48Address peerAddress, Time beaconInterval, Ptr<IeBeaconTiming> timingElement)
165 {
166  //PM STATE Machine
167  //Check that a given beacon is not from our interface
168  for (PeerManagementProtocolMacMap::const_iterator i = m_plugins.begin (); i != m_plugins.end (); i++)
169  {
170  if (i->second->GetAddress () == peerAddress)
171  {
172  return;
173  }
174  }
175  Ptr<PeerLink> peerLink = FindPeerLink (interface, peerAddress);
176  if (peerLink == 0)
177  {
178  if (ShouldSendOpen (interface, peerAddress))
179  {
180  peerLink = InitiateLink (interface, peerAddress, Mac48Address::GetBroadcast ());
181  peerLink->MLMEActivePeerLinkOpen ();
182  }
183  else
184  {
185  return;
186  }
187  }
188  peerLink->SetBeaconInformation (Simulator::Now (), beaconInterval);
190  {
191  peerLink->SetBeaconTimingElement (*PeekPointer (timingElement));
192  }
193 }
194 
195 void
197  Mac48Address peerMeshPointAddress, uint16_t aid, IePeerManagement peerManagementElement,
198  IeConfiguration meshConfig)
199 {
200  Ptr<PeerLink> peerLink = FindPeerLink (interface, peerAddress);
201  if (peerManagementElement.SubtypeIsOpen ())
202  {
203  PmpReasonCode reasonCode (REASON11S_RESERVED);
204  bool reject = !(ShouldAcceptOpen (interface, peerAddress, reasonCode));
205  if (peerLink == 0)
206  {
207  peerLink = InitiateLink (interface, peerAddress, peerMeshPointAddress);
208  }
209  if (!reject)
210  {
211  peerLink->OpenAccept (peerManagementElement.GetLocalLinkId (), meshConfig, peerMeshPointAddress);
212  }
213  else
214  {
215  peerLink->OpenReject (peerManagementElement.GetLocalLinkId (), meshConfig, peerMeshPointAddress,
216  reasonCode);
217  }
218  }
219  if (peerLink == 0)
220  {
221  return;
222  }
223  if (peerManagementElement.SubtypeIsConfirm ())
224  {
225  peerLink->ConfirmAccept (peerManagementElement.GetLocalLinkId (),
226  peerManagementElement.GetPeerLinkId (), aid, meshConfig, peerMeshPointAddress);
227  }
228  if (peerManagementElement.SubtypeIsClose ())
229  {
230  peerLink->Close (peerManagementElement.GetLocalLinkId (), peerManagementElement.GetPeerLinkId (),
231  peerManagementElement.GetReasonCode ());
232  }
233 }
234 void
236 {
237  Ptr<PeerLink> peerLink = FindPeerLink (interface, peerAddress);
238  if (peerLink != 0)
239  {
240  peerLink->MLMECancelPeerLink (REASON11S_MESH_CAPABILITY_POLICY_VIOLATION);
241  }
242 }
243 void
245 {
246  NS_LOG_DEBUG ("transmission failed between "<<GetAddress () << " and " << peerAddress << " failed, link will be closed");
247  Ptr<PeerLink> peerLink = FindPeerLink (interface, peerAddress);
248  if (peerLink != 0)
249  {
250  peerLink->TransmissionFailure ();
251  }
252 }
253 void
255 {
256  NS_LOG_DEBUG ("transmission success "<< GetAddress () << " and " << peerAddress);
257  Ptr<PeerLink> peerLink = FindPeerLink (interface, peerAddress);
258  if (peerLink != 0)
259  {
260  peerLink->TransmissionSuccess ();
261  }
262 }
264 PeerManagementProtocol::InitiateLink (uint32_t interface, Mac48Address peerAddress,
265  Mac48Address peerMeshPointAddress)
266 {
267  Ptr<PeerLink> new_link = CreateObject<PeerLink> ();
268  //find a peer link - it must not exist
269  if (FindPeerLink (interface, peerAddress) != 0)
270  {
271  NS_FATAL_ERROR ("Peer link must not exist.");
272  }
273  // Plugin must exist
274  PeerManagementProtocolMacMap::iterator plugin = m_plugins.find (interface);
275  NS_ASSERT (plugin != m_plugins.end ());
276  PeerLinksMap::iterator iface = m_peerLinks.find (interface);
277  NS_ASSERT (iface != m_peerLinks.end ());
278  new_link->SetLocalAid (m_lastAssocId++);
279  new_link->SetInterface (interface);
280  new_link->SetLocalLinkId (m_lastLocalLinkId++);
281  new_link->SetPeerAddress (peerAddress);
282  new_link->SetPeerMeshPointAddress (peerMeshPointAddress);
283  new_link->SetMacPlugin (plugin->second);
284  new_link->MLMESetSignalStatusCallback (MakeCallback (&PeerManagementProtocol::PeerLinkStatus, this));
285  iface->second.push_back (new_link);
286  return new_link;
287 }
288 
290 PeerManagementProtocol::FindPeerLink (uint32_t interface, Mac48Address peerAddress)
291 {
292  PeerLinksMap::iterator iface = m_peerLinks.find (interface);
293  NS_ASSERT (iface != m_peerLinks.end ());
294  for (PeerLinksOnInterface::iterator i = iface->second.begin (); i != iface->second.end (); i++)
295  {
296  if ((*i)->GetPeerAddress () == peerAddress)
297  {
298  if ((*i)->LinkIsIdle ())
299  {
300  (*i) = 0;
301  (iface->second).erase (i);
302  return 0;
303  }
304  else
305  {
306  return (*i);
307  }
308  }
309  }
310  return 0;
311 }
312 void
315 {
317 }
318 
319 std::vector<Mac48Address>
320 PeerManagementProtocol::GetPeers (uint32_t interface) const
321 {
322  std::vector<Mac48Address> retval;
323  PeerLinksMap::const_iterator iface = m_peerLinks.find (interface);
324  NS_ASSERT (iface != m_peerLinks.end ());
325  for (PeerLinksOnInterface::const_iterator i = iface->second.begin (); i != iface->second.end (); i++)
326  {
327  if ((*i)->LinkIsEstab ())
328  {
329  retval.push_back ((*i)->GetPeerAddress ());
330  }
331  }
332  return retval;
333 }
334 
335 std::vector< Ptr<PeerLink> >
337 {
338  std::vector< Ptr<PeerLink> > links;
339 
340  for (PeerLinksMap::const_iterator iface = m_peerLinks.begin (); iface != m_peerLinks.end (); ++iface)
341  {
342  for (PeerLinksOnInterface::const_iterator i = iface->second.begin ();
343  i != iface->second.end (); i++)
344  if ((*i)->LinkIsEstab ())
345  links.push_back (*i);
346  }
347  return links;
348 }
349 bool
350 PeerManagementProtocol::IsActiveLink (uint32_t interface, Mac48Address peerAddress)
351 {
352  Ptr<PeerLink> peerLink = FindPeerLink (interface, peerAddress);
353  if (peerLink != 0)
354  {
355  return (peerLink->LinkIsEstab ());
356  }
357  return false;
358 }
359 bool
360 PeerManagementProtocol::ShouldSendOpen (uint32_t interface, Mac48Address peerAddress)
361 {
363 }
364 
365 bool
367  PmpReasonCode & reasonCode)
368 {
370  {
371  reasonCode = REASON11S_MESH_MAX_PEERS;
372  return false;
373  }
374  return true;
375 }
376 
377 void
379 {
381  {
382  return;
383  }
384  PeerLinksMap::iterator iface = m_peerLinks.find (interface);
385  NS_ASSERT (iface != m_peerLinks.end ());
386  NS_ASSERT (m_plugins.find (interface) != m_plugins.end ());
387 
388  std::map<uint32_t, Time>::const_iterator lastBeacon = m_lastBeacon.find (interface);
389  std::map<uint32_t, Time>::const_iterator beaconInterval = m_beaconInterval.find (interface);
390  if ((lastBeacon == m_lastBeacon.end ()) || (beaconInterval == m_beaconInterval.end ()))
391  {
392  return;
393  }
394  //my last beacon in 256 us units
395  uint16_t lastBeaconInTimeElement = (uint16_t) ((lastBeacon->second.GetMicroSeconds () >> 8) & 0xffff);
396 
397  NS_ASSERT_MSG (TuToTime (m_maxBeaconShift) <= m_beaconInterval[interface], "Wrong beacon shift parameters");
398 
399  if (iface->second.size () == 0)
400  {
401  //I have no peers - may be our beacons are in collision
402  ShiftOwnBeacon (interface);
403  return;
404  }
405  //check whether all my peers receive my beacon and I'am not in collision with other beacons
406 
407  for (PeerLinksOnInterface::iterator i = iface->second.begin (); i != iface->second.end (); i++)
408  {
409  bool myBeaconExists = false;
410  IeBeaconTiming::NeighboursTimingUnitsList neighbors = (*i)->GetBeaconTimingElement ().GetNeighboursTimingElementsList ();
411  for (IeBeaconTiming::NeighboursTimingUnitsList::const_iterator j = neighbors.begin (); j != neighbors.end (); j++)
412  {
413  if ((*i)->GetPeerAid () == (*j)->GetAid ())
414  {
415  // I am presented at neighbour's list of neighbors
416  myBeaconExists = true;
417  continue;
418  }
419  if (
420  ((int16_t) ((*j)->GetLastBeacon () - lastBeaconInTimeElement) >= 0) &&
421  (((*j)->GetLastBeacon () - lastBeaconInTimeElement) % (4 * TimeToTu (beaconInterval->second)) == 0)
422  )
423  {
424  ShiftOwnBeacon (interface);
425  return;
426  }
427  }
428  if (!myBeaconExists)
429  {
430  // If I am not present in neighbor's beacon timing element, this may be caused by collisions with
431  ShiftOwnBeacon (interface);
432  return;
433  }
434  }
435 }
436 
437 void
439 {
440  int shift = 0;
441  do
442  {
443  shift = (int) m_beaconShift->GetValue ();
444  }
445  while (shift == 0);
446  // Apply beacon shift parameters:
447  PeerManagementProtocolMacMap::iterator plugin = m_plugins.find (interface);
448  NS_ASSERT (plugin != m_plugins.end ());
449  plugin->second->SetBeaconShift (TuToTime (shift));
450 }
451 
452 Time
454 {
455  return MicroSeconds (x * 1024);
456 }
457 int
459 {
460  return (int)(x.GetMicroSeconds () / 1024);
461 }
462 
463 void
464 PeerManagementProtocol::NotifyLinkOpen (Mac48Address peerMp, Mac48Address peerIface, Mac48Address myIface, uint32_t interface)
465 {
466  NS_LOG_LOGIC ("link_open " << myIface << " " << peerIface);
469  if (!m_peerStatusCallback.IsNull ())
470  {
471  m_peerStatusCallback (peerMp, peerIface, interface, true);
472  }
473  m_linkOpenTraceSrc (myIface, peerIface);
474 }
475 
476 void
477 PeerManagementProtocol::NotifyLinkClose (Mac48Address peerMp, Mac48Address peerIface, Mac48Address myIface, uint32_t interface)
478 {
479  NS_LOG_LOGIC ("link_close " << myIface << " " << peerIface);
482  if (!m_peerStatusCallback.IsNull ())
483  {
484  m_peerStatusCallback (peerMp, peerIface, interface, false);
485  }
486  m_linkCloseTraceSrc (myIface, peerIface);
487 }
488 
489 void
490 PeerManagementProtocol::PeerLinkStatus (uint32_t interface, Mac48Address peerAddress,
491  Mac48Address peerMeshPointAddress, PeerLink::PeerState ostate, PeerLink::PeerState nstate)
492 {
493  PeerManagementProtocolMacMap::iterator plugin = m_plugins.find (interface);
494  NS_ASSERT (plugin != m_plugins.end ());
495  NS_LOG_DEBUG ("Link between me:" << m_address << " my interface:" << plugin->second->GetAddress ()
496  << " and peer mesh point:" << peerMeshPointAddress << " and its interface:" << peerAddress
497  << ", at my interface ID:" << interface << ". State movement:" << ostate << " -> " << nstate);
498  if ((nstate == PeerLink::ESTAB) && (ostate != PeerLink::ESTAB))
499  {
500  NotifyLinkOpen (peerMeshPointAddress, peerAddress, plugin->second->GetAddress (), interface);
501  }
502  if ((ostate == PeerLink::ESTAB) && (nstate != PeerLink::ESTAB))
503  {
504  NotifyLinkClose (peerMeshPointAddress, peerAddress, plugin->second->GetAddress (), interface);
505  }
506  if (nstate == PeerLink::IDLE)
507  {
508  Ptr<PeerLink> link = FindPeerLink (interface, peerAddress);
509  NS_ASSERT (link == 0);
510  }
511 }
512 uint8_t
514 {
515  return m_stats.linksTotal;
516 }
519 {
520  NS_ASSERT (m_meshId != 0);
521  return m_meshId;
522 }
523 void
525 {
526  m_meshId = Create<IeMeshId> (s);
527 }
530 {
531  return m_address;
532 }
533 void
534 PeerManagementProtocol::NotifyBeaconSent (uint32_t interface, Time beaconInterval)
535 {
536  m_lastBeacon[interface] = Simulator::Now ();
538  m_beaconInterval[interface] = beaconInterval;
539 }
541  linksTotal (t), linksOpened (0), linksClosed (0)
542 {
543 }
544 void
546 {
547  os << "<Statistics "
548  "linksTotal=\"" << linksTotal << "\" "
549  "linksOpened=\"" << linksOpened << "\" "
550  "linksClosed=\"" << linksClosed << "\"/>" << std::endl;
551 }
552 void
553 PeerManagementProtocol::Report (std::ostream & os) const
554 {
555  os << "<PeerManagementProtocol>" << std::endl;
556  m_stats.Print (os);
557  for (PeerManagementProtocolMacMap::const_iterator plugins = m_plugins.begin (); plugins != m_plugins.end (); plugins++)
558  {
559  //Take statistics from plugin:
560  plugins->second->Report (os);
561  //Print all active peer links:
562  PeerLinksMap::const_iterator iface = m_peerLinks.find (plugins->second->m_ifIndex);
563  NS_ASSERT (iface != m_peerLinks.end ());
564  for (PeerLinksOnInterface::const_iterator i = iface->second.begin (); i != iface->second.end (); i++)
565  {
566  (*i)->Report (os);
567  }
568  }
569  os << "</PeerManagementProtocol>" << std::endl;
570 }
571 void
573 {
574  m_stats = Statistics (m_stats.linksTotal); // don't reset number of links
575  for (PeerManagementProtocolMacMap::const_iterator plugins = m_plugins.begin (); plugins != m_plugins.end (); plugins++)
576  {
577  plugins->second->ResetStats ();
578  }
579 }
580 
581 int64_t
583 {
584  NS_LOG_FUNCTION (this << stream);
585  m_beaconShift->SetStream (stream);
586  return 1;
587 }
588 
589 void
591 {
592  // If beacon interval is equal to the neighbor's one and one o more beacons received
593  // by my neighbor coincide with my beacon - apply random uniformly distributed shift from
594  // [-m_maxBeaconShift, m_maxBeaconShift] except 0.
597 }
598 
599 void
601 {
602  m_enableBca = enable;
603 }
604 bool
606 {
607  return m_enableBca;
608 }
609 } // namespace dot11s
610 } // namespace ns3
611 
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:79
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:60
#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.
Hold a bool native type.
Definition: boolean.h:38
Callback template class.
Definition: callback.h:924
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register the class in the ns-3 factory.
Definition: object-base.h:38
list plugins
Definition: base.py:77
#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
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:170
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:95
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:825
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.
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:289
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:280
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:1242
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:233
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)
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:213
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:64
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:176
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:610
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