A Discrete-Event Network Simulator
Go to the documentation of this file.
1/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
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>
35namespace ns3 {
36class MeshPointDevice;
37class UniformRandomVariable;
38namespace dot11s {
39class PeerManagementProtocolMac;
40class PeerLink;
41class IeMeshId;
42class IePeerManagement;
43class IeConfiguration;
55 // Delete copy constructor and assignment operator to avoid misuse
63 static TypeId GetTypeId ();
64 void DoDispose ();
96 void ReceiveBeacon (uint32_t interface, Mac48Address peerAddress, Time beaconInterval, Ptr<IeBeaconTiming> beaconTiming);
113 uint32_t interface,
114 Mac48Address peerAddress,
115 Mac48Address peerMeshPointAddress,
116 uint16_t aid,
117 IePeerManagement peerManagementElement,
118 IeConfiguration meshConfig
119 );
126 void ConfigurationMismatch (uint32_t interface, Mac48Address peerAddress);
132 void TransmissionFailure (uint32_t interface, const Mac48Address peerAddress);
138 void TransmissionSuccess (uint32_t interface, const Mac48Address peerAddress);
145 bool IsActiveLink (uint32_t interface, Mac48Address peerAddress);
161 Ptr<PeerLink> FindPeerLink (uint32_t interface, Mac48Address peerAddress);
166 std::vector < Ptr<PeerLink> > GetPeerLinks () const;
172 std::vector<Mac48Address> GetPeers (uint32_t interface) const;
183 uint8_t GetNumberOfLinks ();
188 void SetMeshId (std::string s);
193 Ptr<IeMeshId> GetMeshId () const;
198 void SetBeaconCollisionAvoidance (bool enable);
203 bool GetBeaconCollisionAvoidance () const;
209 void NotifyBeaconSent (uint32_t interface, Time beaconInterval);
216 void Report (std::ostream & os) const;
218 void ResetStats ();
227 int64_t AssignStreams (int64_t stream);
236 (Mac48Address src, const Mac48Address dst);
240 virtual void DoInitialize ();
242 // Private structures
245 {
246 uint16_t aid;
249 };
252 typedef std::vector<Ptr<PeerLink> > PeerLinksOnInterface;
254 typedef std::map<uint32_t, PeerLinksOnInterface> PeerLinksMap;
256 typedef std::map<Mac48Address, BeaconInfo> BeaconsOnInterface;
258 typedef std::map<uint32_t, BeaconsOnInterface> BeaconInfoMap;
260 typedef std::map<uint32_t, Ptr<PeerManagementProtocolMac> > PeerManagementProtocolMacMap;
271 uint32_t interface,
272 Mac48Address peerAddress,
273 Mac48Address peerMeshPointAddress
274 );
281 bool ShouldSendOpen (uint32_t interface, Mac48Address peerAddress);
289 bool ShouldAcceptOpen (uint32_t interface, Mac48Address peerAddress, PmpReasonCode & reasonCode);
298 void PeerLinkStatus (uint32_t interface, Mac48Address peerAddress, Mac48Address peerMeshPointAddres, PeerLink::PeerState ostate, PeerLink::PeerState nstate);
303 void CheckBeaconCollisions (uint32_t interface);
308 void ShiftOwnBeacon (uint32_t interface);
314 Time TuToTime (int x);
320 int TimeToTu (Time x);
329 void NotifyLinkOpen (Mac48Address peerMp, Mac48Address peerIface, Mac48Address myIface, uint32_t interface);
337 void NotifyLinkClose (Mac48Address peerMp, Mac48Address peerIface, Mac48Address myIface, uint32_t interface);
343 uint16_t m_lastAssocId;
351 std::map<uint32_t, Time> m_lastBeacon;
353 std::map<uint32_t, Time> m_beaconInterval;
376 struct Statistics {
377 uint16_t linksTotal;
378 uint16_t linksOpened;
379 uint16_t linksClosed;
386 Statistics (uint16_t t = 0);
391 void Print (std::ostream & os) const;
392 };
399} // namespace dot11s
400} // namespace ns3
Callback template class.
Definition: callback.h:1279
an EUI-48 address
Definition: mac48-address.h:44
A base class which provides memory management and object aggregation.
Definition: object.h:88
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:74
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:103
a unique identifier for an interface.
Definition: type-id.h:59
Describes Mesh Configuration Element see of 802.11s draft 3.0.
according to IEEE 802.11 - 2012
802.11s Peer Management Protocol model
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.
bool GetBeaconCollisionAvoidance() const
Get beacon collision avoidance.
std::map< Mac48Address, BeaconInfo > BeaconsOnInterface
This map keeps relationship between peer address and its beacon information.
Callback< void, Mac48Address, Mac48Address, uint32_t, bool > m_peerStatusCallback
Callback to notify about peer link changes: Mac48Address is peer address of mesh point,...
void SetMeshId(std::string s)
Set mesh ID to a string value.
uint8_t m_maxNumberOfPeerLinks
maimum number of peer links
int TimeToTu(Time x)
Time<-->TU converters:
void Report(std::ostream &os) const
Report statistics.
void TransmissionFailure(uint32_t interface, const Mac48Address peerAddress)
Cancels peer link due to successive transmission failures.
uint16_t m_maxBeaconShift
Beacon can be shifted at [-m_maxBeaconShift; +m_maxBeaconShift] TUs.
void(* LinkOpenCloseTracedCallback)(Mac48Address src, const Mac48Address dst)
TracedCallback signature for link open/close events.
std::map< uint32_t, Ptr< PeerManagementProtocolMac > > PeerManagementProtocolMacMap
this vector keeps pointers to MAC-plugins
LinkEventCallback m_linkOpenTraceSrc
LinkOpen trace source.
void TransmissionSuccess(uint32_t interface, const Mac48Address peerAddress)
resets transmission failure statistics
bool ShouldAcceptOpen(uint32_t interface, Mac48Address peerAddress, PmpReasonCode &reasonCode)
External peer-chooser.
std::vector< Ptr< PeerLink > > GetPeerLinks() const
Get list of all active peer links.
void ReceiveBeacon(uint32_t interface, Mac48Address peerAddress, Time beaconInterval, Ptr< IeBeaconTiming > beaconTiming)
To initiate peer link we must notify about received beacon.
void NotifyLinkClose(Mac48Address peerMp, Mac48Address peerIface, Mac48Address myIface, uint32_t interface)
std::map< uint32_t, BeaconsOnInterface > BeaconInfoMap
This map keeps beacon information on all interfaces.
PeerManagementProtocol(const PeerManagementProtocol &)=delete
Ptr< PeerLink > InitiateLink(uint32_t interface, Mac48Address peerAddress, Mac48Address peerMeshPointAddress)
Initiate link function.
Ptr< IeMeshId > GetMeshId() const
Get mesh ID information element.
std::map< uint32_t, PeerLinksOnInterface > PeerLinksMap
This map keeps all peer links.
void SetPeerLinkStatusCallback(Callback< void, Mac48Address, Mac48Address, uint32_t, bool > cb)
Set peer link status change callback.
static TypeId GetTypeId()
Get the type ID.
void DoDispose()
Destructor implementation.
std::map< uint32_t, Time > m_lastBeacon
Last beacon at each interface.
bool Install(Ptr< MeshPointDevice > mp)
Install PMP on given mesh point.
PeerManagementProtocolMacMap m_plugins
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, Time > m_beaconInterval
Beacon interval at each interface.
void NotifyBeaconSent(uint32_t interface, Time beaconInterval)
Notify about beacon send event, needed to schedule BCA.
void ShiftOwnBeacon(uint32_t interface)
Shift own beacon function.
std::vector< Ptr< PeerLink > > PeerLinksOnInterface
We keep a vector of pointers to PeerLink class.
void ConfigurationMismatch(uint32_t interface, Mac48Address peerAddress)
Cancels peer link due to broken configuration (Mesh ID or Supported rates)
uint8_t GetNumberOfLinks()
Get number of links.
PeerLinksMap m_peerLinks
Simple link open/close trace source type. Addresses are: src interface, dst interface.
Ptr< UniformRandomVariable > m_beaconShift
Add randomness to beacon shift.
virtual void DoInitialize()
Initialize() implementation.
bool IsActiveLink(uint32_t interface, Mac48Address peerAddress)
Checks if there is established link.
std::vector< Mac48Address > GetPeers(uint32_t interface) const
Get list of active peers of my given interface.
LinkEventCallback m_linkCloseTraceSrc
LinkClose trace source.
TracedCallback< Mac48Address, Mac48Address > LinkEventCallback
Simple link open/close trace source type. Addresses are: src interface, dst interface.
void CheckBeaconCollisions(uint32_t interface)
Ptr< IeBeaconTiming > GetBeaconTimingElement(uint32_t interface)
When we are sending a beacon - we fill beacon timing element.
Mac48Address GetAddress()
Get mesh point address.
Ptr< PeerLink > FindPeerLink(uint32_t interface, Mac48Address peerAddress)
Find active peer link by my interface and peer interface MAC.
Time TuToTime(int x)
Time<-->TU converters:
uint16_t m_lastLocalLinkId
last local link ID
void NotifyLinkOpen(Mac48Address peerMp, Mac48Address peerIface, Mac48Address myIface, uint32_t interface)
void ResetStats()
Reset statistics function.
PeerManagementProtocol & operator=(const PeerManagementProtocol &)=delete
void SetBeaconCollisionAvoidance(bool enable)
Enable or disable beacon collision avoidance.
bool ShouldSendOpen(uint32_t interface, Mac48Address peerAddress)
External peer-chooser.
void PeerLinkStatus(uint32_t interface, Mac48Address peerAddress, Mac48Address peerMeshPointAddres, PeerLink::PeerState ostate, PeerLink::PeerState nstate)
Indicates changes in peer links.
Codes used by 802.11s Peer Management Protocol.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
list x
Random number samples.
Keeps information about beacon of peer station: beacon interval, association ID, last time we have re...
Time referenceTbtt
When one of my station's beacons was put into a beacon queue;.
Time beaconInterval
Beacon interval of my station;.
void Print(std::ostream &os) const
Print function.