/usr/include/ns3.27/ns3/peer-management-protocol.h is in libns3-dev 3.27+dfsg-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2008,2009 IITP RAS
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Authors: Kirill Andreev <andreev@iitp.ru>
* Aleksey Kovalenko <kovalenko@iitp.ru>
*/
#ifndef DOT11S_PEER_MAN_H
#define DOT11S_PEER_MAN_H
#include "ns3/mac48-address.h"
#include "ns3/net-device.h"
#include "ns3/event-id.h"
#include "ns3/nstime.h"
#include "ns3/traced-value.h"
#include "ie-dot11s-beacon-timing.h"
#include "ie-dot11s-peer-management.h"
#include "peer-link.h"
#include <map>
namespace ns3 {
class MeshPointDevice;
class UniformRandomVariable;
namespace dot11s {
class PeerManagementProtocolMac;
class PeerLink;
class IeMeshId;
class IePeerManagement;
class IeConfiguration;
/**
* \ingroup dot11s
*
* \brief 802.11s Peer Management Protocol model
*/
class PeerManagementProtocol : public Object
{
public:
PeerManagementProtocol ();
~PeerManagementProtocol ();
/**
* \brief Get the type ID.
* \return the object TypeId
*/
static TypeId GetTypeId ();
void DoDispose ();
/**
* \brief Install PMP on given mesh point.
* \return true if successful
*
* Installing protocol causes installation of its interface MAC plugins.
*
* Also MP aggregates all installed protocols, PMP protocol can be accessed
* via MeshPointDevice::GetObject<PeerManagementProtocol>();
*/
bool Install (Ptr<MeshPointDevice>);
/**
* \brief Methods that handle beacon sending/receiving procedure.
*
* \name This methods interact with MAC_layer plug-in
* \{
*/
/**
* \brief When we are sending a beacon - we fill beacon timing
* element
* \return IeBeaconTiming is a beacon timing element that should be present in beacon
* \param interface is a interface sending a beacon
*/
Ptr<IeBeaconTiming> GetBeaconTimingElement (uint32_t interface);
/**
* \brief To initiate peer link we must notify about received beacon
* \param interface the interface where a beacon was received from
* \param peerAddress address of station, which sent a beacon
* \param beaconInterval beacon interval (needed by beacon loss counter)
* \param beaconTiming beacon timing element (needed by BCA)
*/
void ReceiveBeacon (uint32_t interface, Mac48Address peerAddress, Time beaconInterval, Ptr<IeBeaconTiming> beaconTiming);
// \}
/**
* \brief Methods that handle Peer link management frames
* interaction:
* \{
*/
/**
* Deliver Peer link management information to the protocol-part
* \param interface is a interface ID of a given MAC (interfaceID rather
* than MAC address, because many interfaces may have the same MAC)
* \param peerAddress is address of peer
* \param peerMeshPointAddress is address of peer mesh point device (equal
* to peer address when only one interface)
* \param aid is association ID, which peer has assigned to us
* \param peerManagementElement is peer link management element
* \param meshConfig is mesh configuration element taken from the peer management frame
*/
void ReceivePeerLinkFrame (
uint32_t interface,
Mac48Address peerAddress,
Mac48Address peerMeshPointAddress,
uint16_t aid,
IePeerManagement peerManagementElement,
IeConfiguration meshConfig
);
/**
* \brief Cancels peer link due to broken configuration (Mesh ID or Supported
* rates)
*/
void ConfigurationMismatch (uint32_t interface, Mac48Address peerAddress);
/**
* \brief Cancels peer link due to successive transmission failures
*/
void TransmissionFailure (uint32_t interface, const Mac48Address peerAddress);
/**
* \brief resets transmission failure statistics
*/
void TransmissionSuccess (uint32_t interface, const Mac48Address peerAddress);
/**
* \brief Checks if there is established link
*/
bool IsActiveLink (uint32_t interface, Mac48Address peerAddress);
// \}
///\name Interface to other protocols (MLME)
// \{
/// Set peer link status change callback
void SetPeerLinkStatusCallback (Callback<void, Mac48Address, Mac48Address, uint32_t, bool> cb);
/// Find active peer link by my interface and peer interface MAC
Ptr<PeerLink> FindPeerLink (uint32_t interface, Mac48Address peerAddress);
/// Get list of all active peer links
std::vector < Ptr<PeerLink> > GetPeerLinks () const;
/// Get list of active peers of my given interface
std::vector<Mac48Address> GetPeers (uint32_t interface) const;
/**
* Get mesh point address. \todo this used by plugins only. Now MAC plugins can ask MP address directly from main MAC
*
* \return Mac48Address
*/
Mac48Address GetAddress ();
/**
* Get number of links
* \returns the number of links
*/
uint8_t GetNumberOfLinks ();
/**
* Set mesh ID to a string value
* \param s the mesh ID string value
*/
void SetMeshId (std::string s);
/**
* Get mesh ID information element
* \returns the mesh ID information element
*/
Ptr<IeMeshId> GetMeshId () const;
/**
* Enable or disable beacon collision avoidance
* \param enable true to enable beacon collision avoidance
*/
void SetBeaconCollisionAvoidance (bool enable);
/**
* Get beacon collision avoidance
* \returns the beacon collision avoidance flag
*/
bool GetBeaconCollisionAvoidance () const;
/**
* Notify about beacon send event, needed to schedule BCA
* \param interface the interface to use
* \param beaconInterval the beacon interval
*/
void NotifyBeaconSent (uint32_t interface, Time beaconInterval);
// \}
/**
* \brief: Report statistics
* \param os the output stream
*/
void Report (std::ostream & os) const;
/// Reset statistics function
void ResetStats ();
/**
* Assign a fixed random variable stream number to the random variables
* used by this model. Return the number of streams (possibly zero) that
* have been assigned.
*
* \param stream first stream index to use
* \return the number of stream indices assigned by this model
*/
int64_t AssignStreams (int64_t stream);
/**
* TracedCallback signature for link open/close events.
*
* \param [in] src MAC address of source interface.
* \param [in] dst MAC address of destination interface.
*/
typedef void (* LinkOpenCloseTracedCallback)
(Mac48Address src, const Mac48Address dst);
private:
virtual void DoInitialize ();
// Private structures
/// Keeps information about beacon of peer station: beacon interval, association ID, last time we have received a beacon
struct BeaconInfo
{
uint16_t aid; ///< Assoc ID
Time referenceTbtt; ///< When one of my station's beacons was put into a beacon queue;
Time beaconInterval; ///< Beacon interval of my station;
};
/// We keep a vector of pointers to PeerLink class. This vector
/// keeps all peer links at a given interface.
typedef std::vector<Ptr<PeerLink> > PeerLinksOnInterface;
/// This map keeps all peer links.
typedef std::map<uint32_t, PeerLinksOnInterface> PeerLinksMap;
/// This map keeps relationship between peer address and its beacon information
typedef std::map<Mac48Address, BeaconInfo> BeaconsOnInterface;
///\brief This map keeps beacon information on all interfaces
typedef std::map<uint32_t, BeaconsOnInterface> BeaconInfoMap;
///\brief this vector keeps pointers to MAC-plugins
typedef std::map<uint32_t, Ptr<PeerManagementProtocolMac> > PeerManagementProtocolMacMap;
private:
/**
* assignment operator
*
* \param peer the value to assign
* \returns the assigned value
*/
PeerManagementProtocol& operator= (const PeerManagementProtocol & peer);
/// type conversion operator
PeerManagementProtocol (const PeerManagementProtocol &);
/**
* Initiate link functon
*
* \param interface the interface to use
* \param peerAddress the peer address
* \param peerMeshPointAddress the peer mesh point address
* \returns the peer link
*/
Ptr<PeerLink> InitiateLink (
uint32_t interface,
Mac48Address peerAddress,
Mac48Address peerMeshPointAddress
);
/**
* \name External peer-chooser
* \param interface the interface to use
* \param peerAddress the peer address
* \returns true is should send an open
*/
bool ShouldSendOpen (uint32_t interface, Mac48Address peerAddress);
/**
* \name External peer-chooser
*/
bool ShouldAcceptOpen (uint32_t interface, Mac48Address peerAddress, PmpReasonCode & reasonCode);
/**
* \brief Indicates changes in peer links
*/
void PeerLinkStatus (uint32_t interface, Mac48Address peerAddress, Mac48Address peerMeshPointAddres, PeerLink::PeerState ostate, PeerLink::PeerState nstate);
///\brief BCA
void CheckBeaconCollisions (uint32_t interface);
/// Shift own beacon function
void ShiftOwnBeacon (uint32_t interface);
/**
* \name Time<-->TU converters:
*/
Time TuToTime (int x);
/**
* \name Time<-->TU converters:
*/
int TimeToTu (Time x);
/// Aux. method to register open links
void NotifyLinkOpen (Mac48Address peerMp, Mac48Address peerIface, Mac48Address myIface, uint32_t interface);
/// Aux. method to register closed links
void NotifyLinkClose (Mac48Address peerMp, Mac48Address peerIface, Mac48Address myIface, uint32_t interface);
private:
PeerManagementProtocolMacMap m_plugins; ///< plugins
Mac48Address m_address; ///< addresss
Ptr<IeMeshId> m_meshId; ///< mesh ID
uint16_t m_lastAssocId; ///< last associated ID
uint16_t m_lastLocalLinkId; ///< last local link ID
uint8_t m_maxNumberOfPeerLinks; ///< maimum number of peer links
/// Flag which enables BCA
bool m_enableBca;
/// Beacon can be shifted at [-m_maxBeaconShift; +m_maxBeaconShift] TUs
uint16_t m_maxBeaconShift;
/// Last beacon at each interface
std::map<uint32_t, Time> m_lastBeacon;
/// Beacon interval at each interface
std::map<uint32_t, Time> m_beaconInterval;
/**
* \name Peer Links
*/
PeerLinksMap m_peerLinks;
/**
* \brief 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,
*/
Callback <void, Mac48Address, Mac48Address, uint32_t, bool> m_peerStatusCallback;
/// Simple link open/close trace source type. Addresses are: src interface, dst interface
typedef TracedCallback <Mac48Address, Mac48Address> LinkEventCallback;
/// LinkOpen trace source
LinkEventCallback m_linkOpenTraceSrc;
/// LinkClose trace source
LinkEventCallback m_linkCloseTraceSrc;
/// Statistics structure
struct Statistics {
uint16_t linksTotal; ///< total links
uint16_t linksOpened; ///< opened links
uint16_t linksClosed; ///< links closed
/**
* Constructor
*
* \param t
*/
Statistics (uint16_t t = 0);
/**
* Print function
* \param os the output stream to print to
*/
void Print (std::ostream & os) const;
};
struct Statistics m_stats; ///< statistics
/// Add randomness to beacon shift
Ptr<UniformRandomVariable> m_beaconShift;
};
} // namespace dot11s
} // namespace ns3
#endif
|