A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
peer-management-protocol.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2008,2009 IITP RAS
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Authors: Kirill Andreev <andreev@iitp.ru>
18 * Aleksey Kovalenko <kovalenko@iitp.ru>
19 */
20
21#ifndef DOT11S_PEER_MAN_H
22#define DOT11S_PEER_MAN_H
23
26#include "peer-link.h"
27
28#include "ns3/event-id.h"
29#include "ns3/mac48-address.h"
30#include "ns3/net-device.h"
31#include "ns3/nstime.h"
32#include "ns3/traced-value.h"
33
34#include <map>
35
36namespace ns3
37{
38class MeshPointDevice;
39class UniformRandomVariable;
40
41namespace dot11s
42{
43class PeerManagementProtocolMac;
44class PeerLink;
45class IeMeshId;
46class IePeerManagement;
47class IeConfiguration;
48
55{
56 public:
58 ~PeerManagementProtocol() override;
59
60 // Delete copy constructor and assignment operator to avoid misuse
63
68 static TypeId GetTypeId();
69 void DoDispose() override;
87
101 void ReceiveBeacon(uint32_t interface,
102 Mac48Address peerAddress,
103 Time beaconInterval,
104 Ptr<IeBeaconTiming> beaconTiming);
106
111
122 void ReceivePeerLinkFrame(uint32_t interface,
123 Mac48Address peerAddress,
124 Mac48Address peerMeshPointAddress,
125 uint16_t aid,
126 IePeerManagement peerManagementElement,
127 IeConfiguration meshConfig);
134 void ConfigurationMismatch(uint32_t interface, Mac48Address peerAddress);
140 void TransmissionFailure(uint32_t interface, const Mac48Address peerAddress);
146 void TransmissionSuccess(uint32_t interface, const Mac48Address peerAddress);
153 bool IsActiveLink(uint32_t interface, Mac48Address peerAddress);
155
158
169 Ptr<PeerLink> FindPeerLink(uint32_t interface, Mac48Address peerAddress);
174 std::vector<Ptr<PeerLink>> GetPeerLinks() const;
180 std::vector<Mac48Address> GetPeers(uint32_t interface) const;
192 uint8_t GetNumberOfLinks() const;
197 void SetMeshId(std::string s);
202 Ptr<IeMeshId> GetMeshId() const;
207 void SetBeaconCollisionAvoidance(bool enable);
212 bool GetBeaconCollisionAvoidance() const;
218 void NotifyBeaconSent(uint32_t interface, Time beaconInterval);
220
225 void Report(std::ostream& os) const;
227 void ResetStats();
236 int64_t AssignStreams(int64_t stream);
237
245
246 private:
247 void DoInitialize() override;
248
249 // Private structures
253 {
254 uint16_t aid;
257 };
258
261 typedef std::vector<Ptr<PeerLink>> PeerLinksOnInterface;
263 typedef std::map<uint32_t, PeerLinksOnInterface> PeerLinksMap;
265 typedef std::map<Mac48Address, BeaconInfo> BeaconsOnInterface;
267 typedef std::map<uint32_t, BeaconsOnInterface> BeaconInfoMap;
269 typedef std::map<uint32_t, Ptr<PeerManagementProtocolMac>> PeerManagementProtocolMacMap;
270
280 Mac48Address peerAddress,
281 Mac48Address peerMeshPointAddress);
288 bool ShouldSendOpen(uint32_t interface, Mac48Address peerAddress) const;
296 bool ShouldAcceptOpen(uint32_t interface,
297 Mac48Address peerAddress,
298 PmpReasonCode& reasonCode) const;
307 void PeerLinkStatus(uint32_t interface,
308 Mac48Address peerAddress,
309 Mac48Address peerMeshPointAddress,
310 PeerLink::PeerState ostate,
311 PeerLink::PeerState nstate);
316 void CheckBeaconCollisions(uint32_t interface);
321 void ShiftOwnBeacon(uint32_t interface);
327 Time TuToTime(int x);
333 int TimeToTu(Time x);
334
342 void NotifyLinkOpen(Mac48Address peerMp,
343 Mac48Address peerIface,
344 Mac48Address myIface,
345 uint32_t interface);
353 void NotifyLinkClose(Mac48Address peerMp,
354 Mac48Address peerIface,
355 Mac48Address myIface,
356 uint32_t interface);
357
358 private:
362
363 uint16_t m_lastAssocId;
371 std::map<uint32_t, Time> m_lastBeacon;
373 std::map<uint32_t, Time> m_beaconInterval;
374
387
394
397 {
398 uint16_t linksTotal;
399 uint16_t linksOpened;
400 uint16_t linksClosed;
401
407 Statistics(uint16_t t = 0);
412 void Print(std::ostream& os) const;
413 };
414
416
419};
420
421} // namespace dot11s
422} // namespace ns3
423#endif
Callback template class.
Definition: callback.h:438
an EUI-48 address
Definition: mac48-address.h:46
A base class which provides memory management and object aggregation.
Definition: object.h:89
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:78
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
Forward calls to a chain of Callback.
a unique identifier for an interface.
Definition: type-id.h:59
Describes Mesh Configuration Element see 7.3.2.86 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.
void DoDispose() override
Destructor implementation.
bool GetBeaconCollisionAvoidance() const
Get beacon collision avoidance.
std::map< Mac48Address, BeaconInfo > BeaconsOnInterface
This map keeps relationship between peer address and its beacon information.
bool ShouldSendOpen(uint32_t interface, Mac48Address peerAddress) const
External peer-chooser.
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) const
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)
Aux.
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.
void DoInitialize() override
Initialize() implementation.
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.
uint8_t GetNumberOfLinks() const
Get number of links.
static TypeId GetTypeId()
Get the type ID.
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
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)
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.
void PeerLinkStatus(uint32_t interface, Mac48Address peerAddress, Mac48Address peerMeshPointAddress, PeerLink::PeerState ostate, PeerLink::PeerState nstate)
Indicates changes in peer links.
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)
BCA.
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)
Aux.
void ResetStats()
Reset statistics function.
PeerManagementProtocol & operator=(const PeerManagementProtocol &)=delete
void SetBeaconCollisionAvoidance(bool enable)
Enable or disable beacon collision avoidance.
PmpReasonCode
Codes used by 802.11s Peer Management Protocol.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
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.