A Discrete-Event Network Simulator
API
peer-management-protocol.h
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 #ifndef DOT11S_PEER_MAN_H
23 #define DOT11S_PEER_MAN_H
24 
25 #include "ns3/mac48-address.h"
26 #include "ns3/net-device.h"
27 #include "ns3/event-id.h"
28 #include "ns3/nstime.h"
29 #include "ns3/traced-value.h"
32 #include "peer-link.h"
33 
34 #include <map>
35 namespace ns3 {
36 class MeshPointDevice;
37 class UniformRandomVariable;
38 namespace dot11s {
39 class PeerManagementProtocolMac;
40 class PeerLink;
41 class IeMeshId;
42 class IePeerManagement;
43 class IeConfiguration;
50 {
51 public:
58  static TypeId GetTypeId ();
59  void DoDispose ();
70  bool Install (Ptr<MeshPointDevice> mp);
76 
83  Ptr<IeBeaconTiming> GetBeaconTimingElement (uint32_t interface);
91  void ReceiveBeacon (uint32_t interface, Mac48Address peerAddress, Time beaconInterval, Ptr<IeBeaconTiming> beaconTiming);
93 
97 
107  void ReceivePeerLinkFrame (
108  uint32_t interface,
109  Mac48Address peerAddress,
110  Mac48Address peerMeshPointAddress,
111  uint16_t aid,
112  IePeerManagement peerManagementElement,
113  IeConfiguration meshConfig
114  );
121  void ConfigurationMismatch (uint32_t interface, Mac48Address peerAddress);
127  void TransmissionFailure (uint32_t interface, const Mac48Address peerAddress);
133  void TransmissionSuccess (uint32_t interface, const Mac48Address peerAddress);
140  bool IsActiveLink (uint32_t interface, Mac48Address peerAddress);
142 
145 
156  Ptr<PeerLink> FindPeerLink (uint32_t interface, Mac48Address peerAddress);
161  std::vector < Ptr<PeerLink> > GetPeerLinks () const;
167  std::vector<Mac48Address> GetPeers (uint32_t interface) const;
178  uint8_t GetNumberOfLinks ();
183  void SetMeshId (std::string s);
188  Ptr<IeMeshId> GetMeshId () const;
193  void SetBeaconCollisionAvoidance (bool enable);
198  bool GetBeaconCollisionAvoidance () const;
204  void NotifyBeaconSent (uint32_t interface, Time beaconInterval);
206 
211  void Report (std::ostream & os) const;
213  void ResetStats ();
222  int64_t AssignStreams (int64_t stream);
223 
231  (Mac48Address src, const Mac48Address dst);
232 
233 
234 private:
235  virtual void DoInitialize ();
236 
237  // Private structures
239  struct BeaconInfo
240  {
241  uint16_t aid;
244  };
247  typedef std::vector<Ptr<PeerLink> > PeerLinksOnInterface;
249  typedef std::map<uint32_t, PeerLinksOnInterface> PeerLinksMap;
251  typedef std::map<Mac48Address, BeaconInfo> BeaconsOnInterface;
253  typedef std::map<uint32_t, BeaconsOnInterface> BeaconInfoMap;
255  typedef std::map<uint32_t, Ptr<PeerManagementProtocolMac> > PeerManagementProtocolMacMap;
256 
257 private:
267 
277  uint32_t interface,
278  Mac48Address peerAddress,
279  Mac48Address peerMeshPointAddress
280  );
287  bool ShouldSendOpen (uint32_t interface, Mac48Address peerAddress);
295  bool ShouldAcceptOpen (uint32_t interface, Mac48Address peerAddress, PmpReasonCode & reasonCode);
304  void PeerLinkStatus (uint32_t interface, Mac48Address peerAddress, Mac48Address peerMeshPointAddres, PeerLink::PeerState ostate, PeerLink::PeerState nstate);
309  void CheckBeaconCollisions (uint32_t interface);
314  void ShiftOwnBeacon (uint32_t interface);
320  Time TuToTime (int x);
326  int TimeToTu (Time x);
327 
335  void NotifyLinkOpen (Mac48Address peerMp, Mac48Address peerIface, Mac48Address myIface, uint32_t interface);
343  void NotifyLinkClose (Mac48Address peerMp, Mac48Address peerIface, Mac48Address myIface, uint32_t interface);
344 private:
348 
349  uint16_t m_lastAssocId;
350  uint16_t m_lastLocalLinkId;
352  bool m_enableBca;
357  std::map<uint32_t, Time> m_lastBeacon;
359  std::map<uint32_t, Time> m_beaconInterval;
360 
373 
380 
382  struct Statistics {
383  uint16_t linksTotal;
384  uint16_t linksOpened;
385  uint16_t linksClosed;
386 
392  Statistics (uint16_t t = 0);
397  void Print (std::ostream & os) const;
398  };
399  struct Statistics m_stats;
400 
403 };
404 
405 } // namespace dot11s
406 } // namespace ns3
407 #endif
ns3::dot11s::PeerManagementProtocol::m_peerStatusCallback
Callback< void, Mac48Address, Mac48Address, uint32_t, bool > m_peerStatusCallback
Callback to notify about peer link changes: Mac48Address is peer address of mesh point,...
Definition: peer-management-protocol.h:372
ns3::TypeId
a unique identifier for an interface.
Definition: type-id.h:59
ns3::dot11s::PeerManagementProtocol::GetPeers
std::vector< Mac48Address > GetPeers(uint32_t interface) const
Get list of active peers of my given interface.
Definition: peer-management-protocol.cc:326
ns3::dot11s::PeerManagementProtocol::BeaconInfo::aid
uint16_t aid
Assoc ID.
Definition: peer-management-protocol.h:241
ns3::dot11s::PeerManagementProtocol::SetPeerLinkStatusCallback
void SetPeerLinkStatusCallback(Callback< void, Mac48Address, Mac48Address, uint32_t, bool > cb)
Set peer link status change callback.
Definition: peer-management-protocol.cc:319
ns3::dot11s::PeerManagementProtocol::PeerManagementProtocolMacMap
std::map< uint32_t, Ptr< PeerManagementProtocolMac > > PeerManagementProtocolMacMap
this vector keeps pointers to MAC-plugins
Definition: peer-management-protocol.h:255
ns3::dot11s::PeerManagementProtocol::m_maxBeaconShift
uint16_t m_maxBeaconShift
Beacon can be shifted at [-m_maxBeaconShift; +m_maxBeaconShift] TUs.
Definition: peer-management-protocol.h:355
ns3::dot11s::PeerManagementProtocol::m_maxNumberOfPeerLinks
uint8_t m_maxNumberOfPeerLinks
maimum number of peer links
Definition: peer-management-protocol.h:351
ns3::dot11s::PeerManagementProtocol::ReceivePeerLinkFrame
void ReceivePeerLinkFrame(uint32_t interface, Mac48Address peerAddress, Mac48Address peerMeshPointAddress, uint16_t aid, IePeerManagement peerManagementElement, IeConfiguration meshConfig)
Deliver Peer link management information to the protocol-part.
Definition: peer-management-protocol.cc:202
ns3::dot11s::PeerManagementProtocol::m_stats
struct Statistics m_stats
statistics
Definition: peer-management-protocol.h:399
ns3::dot11s::PeerManagementProtocol::NotifyLinkClose
void NotifyLinkClose(Mac48Address peerMp, Mac48Address peerIface, Mac48Address myIface, uint32_t interface)
Aux.
Definition: peer-management-protocol.cc:483
ns3::dot11s::PeerManagementProtocol::NotifyLinkOpen
void NotifyLinkOpen(Mac48Address peerMp, Mac48Address peerIface, Mac48Address myIface, uint32_t interface)
Aux.
Definition: peer-management-protocol.cc:470
ns3::dot11s::PeerManagementProtocol::m_peerLinks
PeerLinksMap m_peerLinks
Simple link open/close trace source type. Addresses are: src interface, dst interface.
Definition: peer-management-protocol.h:364
ns3::Callback
Callback template class.
Definition: callback.h:1279
ns3::dot11s::PeerManagementProtocol::SetMeshId
void SetMeshId(std::string s)
Set mesh ID to a string value.
Definition: peer-management-protocol.cc:532
ns3::dot11s::PeerManagementProtocol::ReceiveBeacon
void ReceiveBeacon(uint32_t interface, Mac48Address peerAddress, Time beaconInterval, Ptr< IeBeaconTiming > beaconTiming)
To initiate peer link we must notify about received beacon.
Definition: peer-management-protocol.cc:170
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::dot11s::PeerManagementProtocol::GetAddress
Mac48Address GetAddress()
Get mesh point address.
Definition: peer-management-protocol.cc:537
ns3::dot11s::PeerManagementProtocol::m_linkCloseTraceSrc
LinkEventCallback m_linkCloseTraceSrc
LinkClose trace source.
Definition: peer-management-protocol.h:379
ns3::dot11s::IeConfiguration
Describes Mesh Configuration Element see 7.3.2.86 of 802.11s draft 3.0.
Definition: ie-dot11s-configuration.h:128
ns3::dot11s::PeerManagementProtocol::Statistics::Statistics
Statistics(uint16_t t=0)
Constructor.
Definition: peer-management-protocol.cc:548
ns3::dot11s::PeerManagementProtocol::BeaconInfo::beaconInterval
Time beaconInterval
Beacon interval of my station;.
Definition: peer-management-protocol.h:243
ns3::dot11s::PmpReasonCode
PmpReasonCode
Codes used by 802.11s Peer Management Protocol.
Definition: ie-dot11s-peer-management.h:35
ie-dot11s-peer-management.h
ns3::Mac48Address
an EUI-48 address
Definition: mac48-address.h:44
ns3::dot11s::PeerManagementProtocol::m_enableBca
bool m_enableBca
Flag which enables BCA.
Definition: peer-management-protocol.h:353
ns3::dot11s::PeerManagementProtocol::GetBeaconCollisionAvoidance
bool GetBeaconCollisionAvoidance() const
Get beacon collision avoidance.
Definition: peer-management-protocol.cc:613
ns3::dot11s::PeerManagementProtocol::InitiateLink
Ptr< PeerLink > InitiateLink(uint32_t interface, Mac48Address peerAddress, Mac48Address peerMeshPointAddress)
Initiate link function.
Definition: peer-management-protocol.cc:270
ns3::dot11s::PeerManagementProtocol::DoInitialize
virtual void DoInitialize()
Initialize() implementation.
Definition: peer-management-protocol.cc:598
ns3::dot11s::PeerManagementProtocol::TransmissionSuccess
void TransmissionSuccess(uint32_t interface, const Mac48Address peerAddress)
resets transmission failure statistics
Definition: peer-management-protocol.cc:260
ns3::dot11s::PeerManagementProtocol::Statistics::linksOpened
uint16_t linksOpened
opened links
Definition: peer-management-protocol.h:384
ns3::dot11s::PeerManagementProtocol::DoDispose
void DoDispose()
Destructor implementation.
Definition: peer-management-protocol.cc:101
ns3::dot11s::PeerManagementProtocol::m_beaconInterval
std::map< uint32_t, Time > m_beaconInterval
Beacon interval at each interface.
Definition: peer-management-protocol.h:359
ns3::dot11s::PeerManagementProtocol::GetPeerLinks
std::vector< Ptr< PeerLink > > GetPeerLinks() const
Get list of all active peer links.
Definition: peer-management-protocol.cc:342
ns3::dot11s::PeerManagementProtocol::m_linkOpenTraceSrc
LinkEventCallback m_linkOpenTraceSrc
LinkOpen trace source.
Definition: peer-management-protocol.h:377
ns3::dot11s::PeerManagementProtocol::BeaconInfo::referenceTbtt
Time referenceTbtt
When one of my station's beacons was put into a beacon queue;.
Definition: peer-management-protocol.h:242
ns3::dot11s::PeerManagementProtocol::GetBeaconTimingElement
Ptr< IeBeaconTiming > GetBeaconTimingElement(uint32_t interface)
When we are sending a beacon - we fill beacon timing element.
Definition: peer-management-protocol.cc:146
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:74
ns3::dot11s::PeerManagementProtocol::Statistics::Print
void Print(std::ostream &os) const
Print function.
Definition: peer-management-protocol.cc:553
ns3::dot11s::PeerManagementProtocol::GetMeshId
Ptr< IeMeshId > GetMeshId() const
Get mesh ID information element.
Definition: peer-management-protocol.cc:526
ns3::dot11s::PeerManagementProtocol::IsActiveLink
bool IsActiveLink(uint32_t interface, Mac48Address peerAddress)
Checks if there is established link.
Definition: peer-management-protocol.cc:356
ns3::dot11s::PeerManagementProtocol::ConfigurationMismatch
void ConfigurationMismatch(uint32_t interface, Mac48Address peerAddress)
Cancels peer link due to broken configuration (Mesh ID or Supported rates)
Definition: peer-management-protocol.cc:241
ns3::Object
A base class which provides memory management and object aggregation.
Definition: object.h:88
ns3::dot11s::PeerManagementProtocol::m_meshId
Ptr< IeMeshId > m_meshId
mesh ID
Definition: peer-management-protocol.h:347
ns3::dot11s::PeerManagementProtocol::LinkEventCallback
TracedCallback< Mac48Address, Mac48Address > LinkEventCallback
Simple link open/close trace source type. Addresses are: src interface, dst interface.
Definition: peer-management-protocol.h:375
ns3::dot11s::PeerManagementProtocol::PeerManagementProtocol
PeerManagementProtocol()
Definition: peer-management-protocol.cc:91
ns3::dot11s::PeerManagementProtocol::PeerManagementProtocol
PeerManagementProtocol(const PeerManagementProtocol &)
type conversion operator
ns3::dot11s::PeerManagementProtocol::Statistics
Statistics structure.
Definition: peer-management-protocol.h:382
ns3::dot11s::PeerManagementProtocol::Report
void Report(std::ostream &os) const
Report statistics.
Definition: peer-management-protocol.cc:561
ns3::dot11s::PeerManagementProtocol::m_address
Mac48Address m_address
address
Definition: peer-management-protocol.h:346
ns3::dot11s::PeerManagementProtocol::ShouldAcceptOpen
bool ShouldAcceptOpen(uint32_t interface, Mac48Address peerAddress, PmpReasonCode &reasonCode)
External peer-chooser.
Definition: peer-management-protocol.cc:372
ns3::dot11s::PeerManagementProtocol
802.11s Peer Management Protocol model
Definition: peer-management-protocol.h:50
ns3::dot11s::PeerManagementProtocol::PeerLinksMap
std::map< uint32_t, PeerLinksOnInterface > PeerLinksMap
This map keeps all peer links.
Definition: peer-management-protocol.h:249
ns3::dot11s::PeerManagementProtocol::m_lastAssocId
uint16_t m_lastAssocId
last associated ID
Definition: peer-management-protocol.h:349
ns3::dot11s::PeerManagementProtocol::m_plugins
PeerManagementProtocolMacMap m_plugins
plugins
Definition: peer-management-protocol.h:345
ns3::dot11s::PeerManagementProtocol::FindPeerLink
Ptr< PeerLink > FindPeerLink(uint32_t interface, Mac48Address peerAddress)
Find active peer link by my interface and peer interface MAC.
Definition: peer-management-protocol.cc:296
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:104
ns3::dot11s::PeerManagementProtocol::~PeerManagementProtocol
~PeerManagementProtocol()
Definition: peer-management-protocol.cc:96
ns3::dot11s::PeerManagementProtocol::LinkOpenCloseTracedCallback
void(* LinkOpenCloseTracedCallback)(Mac48Address src, const Mac48Address dst)
TracedCallback signature for link open/close events.
Definition: peer-management-protocol.h:231
ns3::dot11s::PeerManagementProtocol::Statistics::linksTotal
uint16_t linksTotal
total links
Definition: peer-management-protocol.h:383
ns3::dot11s::PeerManagementProtocol::ShouldSendOpen
bool ShouldSendOpen(uint32_t interface, Mac48Address peerAddress)
External peer-chooser.
Definition: peer-management-protocol.cc:366
ns3::dot11s::PeerManagementProtocol::m_beaconShift
Ptr< UniformRandomVariable > m_beaconShift
Add randomness to beacon shift.
Definition: peer-management-protocol.h:402
ns3::dot11s::PeerManagementProtocol::TransmissionFailure
void TransmissionFailure(uint32_t interface, const Mac48Address peerAddress)
Cancels peer link due to successive transmission failures.
Definition: peer-management-protocol.cc:250
sample-rng-plot.x
list x
Definition: sample-rng-plot.py:34
ns3::dot11s::PeerManagementProtocol::BeaconInfoMap
std::map< uint32_t, BeaconsOnInterface > BeaconInfoMap
This map keeps beacon information on all interfaces.
Definition: peer-management-protocol.h:253
ns3::dot11s::PeerManagementProtocol::ShiftOwnBeacon
void ShiftOwnBeacon(uint32_t interface)
Shift own beacon function.
Definition: peer-management-protocol.cc:444
ns3::TracedCallback< Mac48Address, Mac48Address >
ns3::dot11s::PeerManagementProtocol::m_lastLocalLinkId
uint16_t m_lastLocalLinkId
last local link ID
Definition: peer-management-protocol.h:350
ns3::dot11s::PeerManagementProtocol::CheckBeaconCollisions
void CheckBeaconCollisions(uint32_t interface)
BCA.
Definition: peer-management-protocol.cc:384
ns3::dot11s::PeerManagementProtocol::TuToTime
Time TuToTime(int x)
Time<-->TU converters:
Definition: peer-management-protocol.cc:459
ns3::dot11s::PeerManagementProtocol::m_lastBeacon
std::map< uint32_t, Time > m_lastBeacon
Last beacon at each interface.
Definition: peer-management-protocol.h:357
ns3::dot11s::PeerManagementProtocol::PeerLinksOnInterface
std::vector< Ptr< PeerLink > > PeerLinksOnInterface
We keep a vector of pointers to PeerLink class.
Definition: peer-management-protocol.h:247
ns3::dot11s::PeerManagementProtocol::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition: peer-management-protocol.cc:48
ns3::dot11s::PeerManagementProtocol::TimeToTu
int TimeToTu(Time x)
Time<-->TU converters:
Definition: peer-management-protocol.cc:464
ns3::dot11s::PeerManagementProtocol::BeaconInfo
Keeps information about beacon of peer station: beacon interval, association ID, last time we have re...
Definition: peer-management-protocol.h:240
ie-dot11s-beacon-timing.h
ns3::dot11s::PeerManagementProtocol::AssignStreams
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
Definition: peer-management-protocol.cc:590
ns3::dot11s::IePeerManagement
according to IEEE 802.11 - 2012
Definition: ie-dot11s-peer-management.h:51
ns3::dot11s::PeerManagementProtocol::BeaconsOnInterface
std::map< Mac48Address, BeaconInfo > BeaconsOnInterface
This map keeps relationship between peer address and its beacon information.
Definition: peer-management-protocol.h:251
ns3::dot11s::PeerManagementProtocol::operator=
PeerManagementProtocol & operator=(const PeerManagementProtocol &peer)
assignment operator
ns3::dot11s::PeerManagementProtocol::GetNumberOfLinks
uint8_t GetNumberOfLinks()
Get number of links.
Definition: peer-management-protocol.cc:521
ns3::dot11s::PeerManagementProtocol::Install
bool Install(Ptr< MeshPointDevice > mp)
Install PMP on given mesh point.
Definition: peer-management-protocol.cc:118
ns3::dot11s::PeerManagementProtocol::NotifyBeaconSent
void NotifyBeaconSent(uint32_t interface, Time beaconInterval)
Notify about beacon send event, needed to schedule BCA.
Definition: peer-management-protocol.cc:542
ns3::dot11s::PeerManagementProtocol::Statistics::linksClosed
uint16_t linksClosed
links closed
Definition: peer-management-protocol.h:385
ns3::dot11s::PeerManagementProtocol::ResetStats
void ResetStats()
Reset statistics function.
Definition: peer-management-protocol.cc:580
ns3::dot11s::PeerManagementProtocol::SetBeaconCollisionAvoidance
void SetBeaconCollisionAvoidance(bool enable)
Enable or disable beacon collision avoidance.
Definition: peer-management-protocol.cc:608
ns3::dot11s::PeerManagementProtocol::PeerLinkStatus
void PeerLinkStatus(uint32_t interface, Mac48Address peerAddress, Mac48Address peerMeshPointAddres, PeerLink::PeerState ostate, PeerLink::PeerState nstate)
Indicates changes in peer links.
Definition: peer-management-protocol.cc:496