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 * 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 PEER_LINK_H
22#define PEER_LINK_H
23
27
28#include "ns3/callback.h"
29#include "ns3/event-id.h"
30#include "ns3/mac48-address.h"
31#include "ns3/nstime.h"
32#include "ns3/object.h"
33
34namespace ns3
35{
36namespace dot11s
37{
38
39class PeerManagementProtocolMac;
40
41/**
42 * \ingroup dot11s
43 *
44 * \brief Peer link model for 802.11s Peer Management protocol
45 */
46class PeerLink : public Object
47{
48 public:
49 /// allow PeerManagementProtocol class friend access
51 /**
52 * \brief Get the type ID.
53 * \return the object TypeId
54 */
55 static TypeId GetTypeId();
56 /// C-tor create empty link
57 PeerLink();
58 ~PeerLink() override;
59
60 // Delete copy constructor and assignment operator to avoid misuse
61 PeerLink(const PeerLink&) = delete;
62 PeerLink& operator=(const PeerLink&) = delete;
63
64 void DoDispose() override;
65
66 /// Peer Link state:
68 {
75 };
76
77 /**
78 * \brief Literal names of Mesh Peer Management states for use in log messages
79 */
80 static const char* const PeerStateNames[6];
81 /**
82 * Process beacon received from peer
83 *
84 * \param lastBeacon the last beacon
85 * \param BeaconInterval the beacon interval
86 */
87 void SetBeaconInformation(Time lastBeacon, Time BeaconInterval);
88 /**
89 * \brief Method used to detect peer link changes
90 *
91 * \param cb is a callback, which notifies, that on interface (uint32_t), peer link
92 * with address (Mac48Address) was opened (bool is true) or closed (bool is false)
93 */
95 /// \name Peer link getters/setters
96 ///@{
97 /**
98 * Set the peer address
99 * \param macaddr the peer mac address
100 */
101 void SetPeerAddress(Mac48Address macaddr);
102 /**
103 * Set the peer mesh point address
104 * \param macaddr the peer mesh point address
105 */
107 /**
108 * Set the interface
109 * \param interface the interface
110 */
111 void SetInterface(uint32_t interface);
112 /**
113 * Set the local link ID
114 * \param id the local link ID
115 */
116 void SetLocalLinkId(uint16_t id);
117 /**
118 * Set the local association ID
119 * \param aid the local association ID
120 */
121 void SetLocalAid(uint16_t aid);
122 /**
123 * Set the peer association ID
124 * \return The peer association ID
125 */
126 uint16_t GetPeerAid() const;
127 /**
128 * Set the beacon timing element
129 * \param beaconTiming the beacon timing element
130 */
131 void SetBeaconTimingElement(IeBeaconTiming beaconTiming);
132 /**
133 * Get the peer address
134 * \return The peer address
135 */
137 /**
138 * Get the local association ID
139 * \return The local association ID
140 */
141 uint16_t GetLocalAid() const;
142 /**
143 * Get the time of the last received beacon
144 * \return The time of the last received beacon
145 */
146 Time GetLastBeacon() const;
147 /**
148 * Get the beacon interval
149 * \return The beacon interval
150 */
151 Time GetBeaconInterval() const;
152 /**
153 * Get the beacon timing element
154 * \return The beacon timing element
155 */
157 // IePeerManagement GetPeerLinkDescriptorElement ()const;
158 ///@}
159
160 /// \name MLME
161 ///@{
162 /**
163 * MLME-CancelPeerLink.request
164 * \param reason the reason for the request
165 */
167 /// MLME-ActivePeerLinkOpen.request
169 /// MLME-PeeringRequestReject
171 /// Callback type for MLME-SignalPeerLinkStatus event
172 typedef Callback<void,
173 uint32_t,
179 /**
180 * Set callback
181 * \param cb the callback function
182 */
184 /// Reports about transmission success/failure
185 void TransmissionSuccess();
186 void TransmissionFailure();
187 ///@}
188
189 /**
190 * \brief Statistics
191 * \param os the output stream
192 */
193 void Report(std::ostream& os) const;
194
195 private:
196 /// Peer link events, see 802.11s draft 11B.3.3.2
198 {
199 CNCL, ///< Cancel peer link
200 ACTOPN, ///< Active peer link open
201 CLS_ACPT, ///< PeerLinkClose_Accept
202 OPN_ACPT, ///< PeerLinkOpen_Accept
203 OPN_RJCT, ///< PeerLinkOpen_Reject
204 REQ_RJCT, ///< PeerLinkOpenReject by internal reason
205 CNF_ACPT, ///< PeerLinkConfirm_Accept
206 CNF_RJCT, ///< PeerLinkConfirm_Reject
207 TOR1, ///< Timeout of retry timer
208 TOR2, ///< also timeout of retry timer
209 TOC, ///< Timeout of confirm timer
210 TOH ///< Timeout of holding (graceful closing) timer
211 };
212
213 /**
214 * State transition
215 *
216 * \param event the event to update the state machine
217 * \param reasoncode the reason for the state transition
218 */
220 /**
221 * \name Link response to received management frames
222 *
223 * \attention In all this methods {local/peer}LinkID correspond to _peer_ station, as written in
224 * received frame, e.g. I am peerLinkID and peer link is localLinkID .
225 *
226 */
227 ///@{
228 /**
229 * Close link
230 *
231 * \param localLinkID the local link ID
232 * \param peerLinkID the peer link ID
233 * \param reason the reason to close
234 */
235 void Close(uint16_t localLinkID, uint16_t peerLinkID, PmpReasonCode reason);
236 /**
237 * Accept open link
238 *
239 * \param localLinkId the local link ID
240 * \param conf the IE configuration
241 * \param peerMp the peer MP
242 */
243 void OpenAccept(uint16_t localLinkId, IeConfiguration conf, Mac48Address peerMp);
244 /**
245 * Reject open link
246 *
247 * \param localLinkId the local link ID
248 * \param conf the IE configuration
249 * \param peerMp the peer MP
250 * \param reason the reason to close
251 */
252 void OpenReject(uint16_t localLinkId,
254 Mac48Address peerMp,
255 PmpReasonCode reason);
256 /**
257 * Confirm accept
258 *
259 * \param localLinkId the local link ID
260 * \param peerLinkId the peer link ID
261 * \param peerAid the peer AID
262 * \param conf the IE configuration
263 * \param peerMp the peer MP
264 */
265 void ConfirmAccept(uint16_t localLinkId,
266 uint16_t peerLinkId,
267 uint16_t peerAid,
269 Mac48Address peerMp);
270 /**
271 * Confirm reject
272 *
273 * \param localLinkId the local link ID
274 * \param peerLinkId the peer link ID
275 * \param conf the IE configuration
276 * \param peerMp the peer MP
277 * \param reason the reason to close
278 */
279 void ConfirmReject(uint16_t localLinkId,
280 uint16_t peerLinkId,
282 Mac48Address peerMp,
283 PmpReasonCode reason);
284 ///@}
285
286 /**
287 * \returns True if link is established
288 */
289 bool LinkIsEstab() const;
290 /**
291 * \returns True if link is idle. Link can be deleted in this state
292 */
293 bool LinkIsIdle() const;
294 /**
295 * Set pointer to MAC-plugin, which is responsible for sending peer
296 * link management frames
297 * \param plugin the peer management protocol MAC
298 */
300 /**
301 * \name Event handlers
302 */
303 ///@{
304 /// Clear the retry timer
305 void ClearRetryTimer();
306 /// Clear the confirm timer
307 void ClearConfirmTimer();
308 /// Clear the holding timer
309 void ClearHoldingTimer();
310 /// Set the holding timer
311 void SetHoldingTimer();
312 /// Set the retry timer
313 void SetRetryTimer();
314 /// Set the confirm timer
315 void SetConfirmTimer();
316 ///@}
317
318 /**
319 * \name Work with management frames
320 */
321 ///@{
322 /**
323 * Send a peer link close
324 * \param reasoncode reason for closing the line
325 */
326 void SendPeerLinkClose(PmpReasonCode reasoncode);
327 /// Send a peer link open
328 void SendPeerLinkOpen();
329 /// Send a peer link confirm
330 void SendPeerLinkConfirm();
331 ///@}
332
333 /**
334 * \name Timeout handlers
335 */
336 ///@{
337 /// Holding Timeout event handler
338 void HoldingTimeout();
339 /// Retry Timeout event handler
340 void RetryTimeout();
341 /// Confirm Timeout event handler
342 void ConfirmTimeout();
343 ///@}
344
345 /// Several successive beacons were lost, close link
346 void BeaconLoss();
347
348 private:
349 /// The number of interface I am associated with
351 /// pointer to MAC plugin, which is responsible for peer management
353 /// Peer address
355 /// Mesh point address, equal to peer address in case of single
356 /// interface mesh point
358 /// My ID of this link
360 /// Peer ID of this link
361 uint16_t m_peerLinkId;
362 /// My association ID
363 uint16_t m_assocId;
364 /// Assoc Id assigned to me by peer
366
367 /// When last beacon was received
369 /// Current beacon interval on corresponding interface
371 /// How many successive packets were failed to transmit
372 uint16_t m_packetFail;
373
374 /// Current state
376 /**
377 * \brief Mesh interface configuration
378 * \attention Is not used now, nothing to configure :)
379 */
381 /// Beacon timing element received from the peer. Needed by BCA
383
384 /**
385 * \name Timers & counters used for internal state transitions
386 */
387 ///@{
388 uint16_t m_dot11MeshMaxRetries; //!< Maximum number of retries
389 Time m_dot11MeshRetryTimeout; //!< Retry timeout
390 Time m_dot11MeshHoldingTimeout; //!< Holding timeout
391 Time m_dot11MeshConfirmTimeout; //!< Confirm timeout
392
393 EventId m_retryTimer; //!< Retry timer
394 EventId m_holdingTimer; //!< Holding timer
395 EventId m_confirmTimer; //!< Confirm timer
396 uint16_t m_retryCounter; //!< Retry counter
397 EventId m_beaconLossTimer; //!< Beacon loss timer
398 uint16_t m_maxBeaconLoss; //!< Maximum number of lost beacons before link will be closed
399 uint16_t m_maxPacketFail; //!< Maximum number of failed packets before link will be closed
400 ///@}
401
402 /// How to report my status change
404};
405
406} // namespace dot11s
407} // namespace ns3
408
409#endif /* PEER_LINK_H */
Callback template class.
Definition: callback.h:438
An identifier for simulation events.
Definition: event-id.h:55
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:77
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
a unique identifier for an interface.
Definition: type-id.h:59
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.
Definition: conf.py:1
Every class exported by the ns3 library is enclosed in the ns3 namespace.