A Discrete-Event Network Simulator
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
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  */
22 #ifndef DOT11S_PEER_MAN_H
23 #define DOT11S_PEER_MAN_H
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"
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);
83  Ptr<IeBeaconTiming> GetBeaconTimingElement (uint32_t interface);
91  void ReceiveBeacon (uint32_t interface, Mac48Address peerAddress, Time beaconInterval, Ptr<IeBeaconTiming> beaconTiming);
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);
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);
211  void Report (std::ostream & os) const;
213  void ResetStats ();
222  int64_t AssignStreams (int64_t stream);
230  typedef void (* LinkOpenCloseTracedCallback)
231  (Mac48Address src, const Mac48Address dst);
234 private:
235  virtual void DoInitialize ();
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;
257 private:
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);
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:
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;
382  struct Statistics {
383  uint16_t linksTotal;
384  uint16_t linksOpened;
385  uint16_t linksClosed;
392  Statistics (uint16_t t = 0);
397  void Print (std::ostream & os) const;
398  };
403 };
405 } // namespace dot11s
406 } // namespace ns3
407 #endif
PeerLinksMap m_peerLinks
Simple link open/close trace source type. Addresses are: src interface, dst interface.
Time referenceTbtt
When one of my station&#39;s beacons was put into a beacon queue;.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:103
void NotifyLinkClose(Mac48Address peerMp, Mac48Address peerIface, Mac48Address myIface, uint32_t interface)
virtual void DoInitialize()
Initialize() implementation.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
Callback template class.
Definition: callback.h:1278
PeerManagementProtocol & operator=(const PeerManagementProtocol &peer)
assignment operator
uint8_t m_maxNumberOfPeerLinks
maimum number of peer links
Time beaconInterval
Beacon interval of my station;.
void NotifyLinkOpen(Mac48Address peerMp, Mac48Address peerIface, Mac48Address myIface, uint32_t interface)
Ptr< UniformRandomVariable > m_beaconShift
Add randomness to beacon shift.
static TypeId GetTypeId()
Get the type ID.
Ptr< PeerLink > FindPeerLink(uint32_t interface, Mac48Address peerAddress)
Find active peer link by my interface and peer interface MAC.
LinkEventCallback m_linkCloseTraceSrc
LinkClose trace source.
TracedCallback< Mac48Address, Mac48Address > LinkEventCallback
Simple link open/close trace source type. Addresses are: src interface, dst interface.
uint16_t m_lastLocalLinkId
last local link ID
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.
according to IEEE 802.11 - 2012
void Report(std::ostream &os) const
Report statistics.
int TimeToTu(Time x)
Time<–>TU converters:
std::vector< Ptr< PeerLink > > GetPeerLinks() const
Get list of all active peer links.
void SetMeshId(std::string s)
Set mesh ID to a string value.
void DoDispose()
Destructor implementation.
bool Install(Ptr< MeshPointDevice > mp)
Install PMP on given mesh point.
void NotifyBeaconSent(uint32_t interface, Time beaconInterval)
Notify about beacon send event, needed to schedule BCA.
Mac48Address GetAddress()
Get mesh point address.
void SetPeerLinkStatusCallback(Callback< void, Mac48Address, Mac48Address, uint32_t, bool > cb)
Set peer link status change callback.
uint8_t GetNumberOfLinks()
Get number of links.
std::vector< Mac48Address > GetPeers(uint32_t interface) const
Get list of active peers of my given interface.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::map< uint32_t, PeerLinksOnInterface > PeerLinksMap
This map keeps all peer links.
void(* LinkOpenCloseTracedCallback)(Mac48Address src, const Mac48Address dst)
TracedCallback signature for link open/close events.
PeerManagementProtocolMacMap m_plugins
an EUI-48 address
Definition: mac48-address.h:43
LinkEventCallback m_linkOpenTraceSrc
LinkOpen trace source.
void ShiftOwnBeacon(uint32_t interface)
Shift own beacon function.
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.
void ResetStats()
Reset statistics function.
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.
bool ShouldSendOpen(uint32_t interface, Mac48Address peerAddress)
External peer-chooser.
std::map< Mac48Address, BeaconInfo > BeaconsOnInterface
This map keeps relationship between peer address and its beacon information.
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.
Ptr< IeMeshId > GetMeshId() const
Get mesh ID information element.
bool GetBeaconCollisionAvoidance() const
Get beacon collision avoidance.
void CheckBeaconCollisions(uint32_t interface)
std::map< uint32_t, Time > m_lastBeacon
Last beacon at each interface.
Codes used by 802.11s Peer Management Protocol.
bool ShouldAcceptOpen(uint32_t interface, Mac48Address peerAddress, PmpReasonCode &reasonCode)
External peer-chooser.
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.
Time TuToTime(int x)
Time<–>TU converters:
Describes Mesh Configuration Element see 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:87
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
std::map< uint32_t, Ptr< PeerManagementProtocolMac > > PeerManagementProtocolMacMap
this vector keeps pointers to MAC-plugins
Keeps information about beacon of peer station: beacon interval, association ID, last time we have re...
uint16_t m_maxBeaconShift
Beacon can be shifted at [-m_maxBeaconShift; +m_maxBeaconShift] TUs.
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,.
std::map< uint32_t, BeaconsOnInterface > BeaconInfoMap
This map keeps beacon information on all interfaces.
a unique identifier for an interface.
Definition: type-id.h:58
Ptr< PeerLink > InitiateLink(uint32_t interface, Mac48Address peerAddress, Mac48Address peerMeshPointAddress)
Initiate link function.
void Print(std::ostream &os) const
Print function.
void TransmissionSuccess(uint32_t interface, const Mac48Address peerAddress)
resets transmission failure statistics
802.11s Peer Management Protocol model