A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
peer-link.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2009 IITP RAS
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Authors: Kirill Andreev <andreev@iitp.ru>
7 * Aleksey Kovalenko <kovalenko@iitp.ru>
8 */
9
10#ifndef PEER_LINK_H
11#define PEER_LINK_H
12
16
17#include "ns3/callback.h"
18#include "ns3/event-id.h"
19#include "ns3/mac48-address.h"
20#include "ns3/nstime.h"
21#include "ns3/object.h"
22
23namespace ns3
24{
25namespace dot11s
26{
27
28class PeerManagementProtocolMac;
29
30/**
31 * @ingroup dot11s
32 *
33 * @brief Peer link model for 802.11s Peer Management protocol
34 */
35class PeerLink : public Object
36{
37 public:
38 /// allow PeerManagementProtocol class friend access
40 /**
41 * @brief Get the type ID.
42 * @return the object TypeId
43 */
44 static TypeId GetTypeId();
45 /// C-tor create empty link
46 PeerLink();
47 ~PeerLink() override;
48
49 // Delete copy constructor and assignment operator to avoid misuse
50 PeerLink(const PeerLink&) = delete;
51 PeerLink& operator=(const PeerLink&) = delete;
52
53 void DoDispose() override;
54
55 /// Peer Link state:
65
66 /**
67 * @brief Literal names of Mesh Peer Management states for use in log messages
68 */
69 static const char* const PeerStateNames[6];
70 /**
71 * Process beacon received from peer
72 *
73 * @param lastBeacon the last beacon
74 * @param BeaconInterval the beacon interval
75 */
77 /**
78 * @brief Method used to detect peer link changes
79 *
80 * @param cb is a callback, which notifies, that on interface (uint32_t), peer link
81 * with address (Mac48Address) was opened (bool is true) or closed (bool is false)
82 */
84 /// @name Peer link getters/setters
85 ///@{
86 /**
87 * Set the peer address
88 * @param macaddr the peer mac address
89 */
91 /**
92 * Set the peer mesh point address
93 * @param macaddr the peer mesh point address
94 */
96 /**
97 * Set the interface
98 * @param interface the interface
99 */
100 void SetInterface(uint32_t interface);
101 /**
102 * Set the local link ID
103 * @param id the local link ID
104 */
105 void SetLocalLinkId(uint16_t id);
106 /**
107 * Set the local association ID
108 * @param aid the local association ID
109 */
110 void SetLocalAid(uint16_t aid);
111 /**
112 * Set the peer association ID
113 * @return The peer association ID
114 */
115 uint16_t GetPeerAid() const;
116 /**
117 * Set the beacon timing element
118 * @param beaconTiming the beacon timing element
119 */
121 /**
122 * Get the peer address
123 * @return The peer address
124 */
126 /**
127 * Get the local association ID
128 * @return The local association ID
129 */
130 uint16_t GetLocalAid() const;
131 /**
132 * Get the time of the last received beacon
133 * @return The time of the last received beacon
134 */
135 Time GetLastBeacon() const;
136 /**
137 * Get the beacon interval
138 * @return The beacon interval
139 */
140 Time GetBeaconInterval() const;
141 /**
142 * Get the beacon timing element
143 * @return The beacon timing element
144 */
146 // IePeerManagement GetPeerLinkDescriptorElement ()const;
147 ///@}
148
149 /// @name MLME
150 ///@{
151 /**
152 * MLME-CancelPeerLink.request
153 * @param reason the reason for the request
154 */
156 /// MLME-ActivePeerLinkOpen.request
158 /// MLME-PeeringRequestReject
160 /// Callback type for MLME-SignalPeerLinkStatus event
161 typedef Callback<void,
162 uint32_t,
168 /**
169 * Set callback
170 * @param cb the callback function
171 */
173 /// Reports about transmission success/failure
174 void TransmissionSuccess();
175 void TransmissionFailure();
176 ///@}
177
178 /**
179 * @brief Statistics
180 * @param os the output stream
181 */
182 void Report(std::ostream& os) const;
183
184 private:
185 /// Peer link events, see 802.11s draft 11B.3.3.2
187 {
188 CNCL, ///< Cancel peer link
189 ACTOPN, ///< Active peer link open
190 CLS_ACPT, ///< PeerLinkClose_Accept
191 OPN_ACPT, ///< PeerLinkOpen_Accept
192 OPN_RJCT, ///< PeerLinkOpen_Reject
193 REQ_RJCT, ///< PeerLinkOpenReject by internal reason
194 CNF_ACPT, ///< PeerLinkConfirm_Accept
195 CNF_RJCT, ///< PeerLinkConfirm_Reject
196 TOR1, ///< Timeout of retry timer
197 TOR2, ///< also timeout of retry timer
198 TOC, ///< Timeout of confirm timer
199 TOH ///< Timeout of holding (graceful closing) timer
200 };
201
202 /**
203 * State transition
204 *
205 * @param event the event to update the state machine
206 * @param reasoncode the reason for the state transition
207 */
209 /**
210 * @name Link response to received management frames
211 *
212 * @attention In all this methods {local/peer}LinkID correspond to _peer_ station, as written in
213 * received frame, e.g. I am peerLinkID and peer link is localLinkID .
214 *
215 */
216 ///@{
217 /**
218 * Close link
219 *
220 * @param localLinkID the local link ID
221 * @param peerLinkID the peer link ID
222 * @param reason the reason to close
223 */
224 void Close(uint16_t localLinkID, uint16_t peerLinkID, PmpReasonCode reason);
225 /**
226 * Accept open link
227 *
228 * @param localLinkId the local link ID
229 * @param conf the IE configuration
230 * @param peerMp the peer MP
231 */
232 void OpenAccept(uint16_t localLinkId, IeConfiguration conf, Mac48Address peerMp);
233 /**
234 * Reject open link
235 *
236 * @param localLinkId the local link ID
237 * @param conf the IE configuration
238 * @param peerMp the peer MP
239 * @param reason the reason to close
240 */
241 void OpenReject(uint16_t localLinkId,
244 PmpReasonCode reason);
245 /**
246 * Confirm accept
247 *
248 * @param localLinkId the local link ID
249 * @param peerLinkId the peer link ID
250 * @param peerAid the peer AID
251 * @param conf the IE configuration
252 * @param peerMp the peer MP
253 */
254 void ConfirmAccept(uint16_t localLinkId,
255 uint16_t peerLinkId,
256 uint16_t peerAid,
259 /**
260 * Confirm reject
261 *
262 * @param localLinkId the local link ID
263 * @param peerLinkId the peer link ID
264 * @param conf the IE configuration
265 * @param peerMp the peer MP
266 * @param reason the reason to close
267 */
268 void ConfirmReject(uint16_t localLinkId,
269 uint16_t peerLinkId,
272 PmpReasonCode reason);
273 ///@}
274
275 /**
276 * @returns True if link is established
277 */
278 bool LinkIsEstab() const;
279 /**
280 * @returns True if link is idle. Link can be deleted in this state
281 */
282 bool LinkIsIdle() const;
283 /**
284 * Set pointer to MAC-plugin, which is responsible for sending peer
285 * link management frames
286 * @param plugin the peer management protocol MAC
287 */
289 /**
290 * @name Event handlers
291 */
292 ///@{
293 /// Clear the retry timer
294 void ClearRetryTimer();
295 /// Clear the confirm timer
296 void ClearConfirmTimer();
297 /// Clear the holding timer
298 void ClearHoldingTimer();
299 /// Set the holding timer
300 void SetHoldingTimer();
301 /// Set the retry timer
302 void SetRetryTimer();
303 /// Set the confirm timer
304 void SetConfirmTimer();
305 ///@}
306
307 /**
308 * @name Work with management frames
309 */
310 ///@{
311 /**
312 * Send a peer link close
313 * @param reasoncode reason for closing the line
314 */
316 /// Send a peer link open
317 void SendPeerLinkOpen();
318 /// Send a peer link confirm
319 void SendPeerLinkConfirm();
320 ///@}
321
322 /**
323 * @name Timeout handlers
324 */
325 ///@{
326 /// Holding Timeout event handler
327 void HoldingTimeout();
328 /// Retry Timeout event handler
329 void RetryTimeout();
330 /// Confirm Timeout event handler
331 void ConfirmTimeout();
332 ///@}
333
334 /// Several successive beacons were lost, close link
335 void BeaconLoss();
336
337 private:
338 /// The number of interface I am associated with
340 /// pointer to MAC plugin, which is responsible for peer management
342 /// Peer address
344 /// Mesh point address, equal to peer address in case of single
345 /// interface mesh point
347 /// My ID of this link
349 /// Peer ID of this link
350 uint16_t m_peerLinkId;
351 /// My association ID
352 uint16_t m_assocId;
353 /// Assoc Id assigned to me by peer
355
356 /// When last beacon was received
358 /// Current beacon interval on corresponding interface
360 /// How many successive packets were failed to transmit
361 uint16_t m_packetFail;
362
363 /// Current state
365 /**
366 * @brief Mesh interface configuration
367 * @attention Is not used now, nothing to configure :)
368 */
370 /// Beacon timing element received from the peer. Needed by BCA
372
373 /**
374 * @name Timers & counters used for internal state transitions
375 */
376 ///@{
377 uint16_t m_dot11MeshMaxRetries; //!< Maximum number of retries
378 Time m_dot11MeshRetryTimeout; //!< Retry timeout
379 Time m_dot11MeshHoldingTimeout; //!< Holding timeout
380 Time m_dot11MeshConfirmTimeout; //!< Confirm timeout
381
382 EventId m_retryTimer; //!< Retry timer
383 EventId m_holdingTimer; //!< Holding timer
384 EventId m_confirmTimer; //!< Confirm timer
385 uint16_t m_retryCounter; //!< Retry counter
386 EventId m_beaconLossTimer; //!< Beacon loss timer
387 uint16_t m_maxBeaconLoss; //!< Maximum number of lost beacons before link will be closed
388 uint16_t m_maxPacketFail; //!< Maximum number of failed packets before link will be closed
389 ///@}
390
391 /// How to report my status change
393};
394
395} // namespace dot11s
396} // namespace ns3
397
398#endif /* PEER_LINK_H */
Callback template class.
Definition callback.h:422
An identifier for simulation events.
Definition event-id.h:45
an EUI-48 address
A base class which provides memory management and object aggregation.
Definition object.h:78
Smart pointer class similar to boost::intrusive_ptr.
Definition ptr.h:66
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
a unique identifier for an interface.
Definition type-id.h:49
See 7.3.2.89 of 802.11s draft 2.07.
Describes Mesh Configuration Element see 7.3.2.86 of 802.11s draft 3.0.
802.11s Peer Management Protocol model
PmpReasonCode
Codes used by 802.11s Peer Management Protocol.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Definition ptr.h:436
Definition conf.py:1
Every class exported by the ns3 library is enclosed in the ns3 namespace.