LEFT | RIGHT |
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2009 IITP RAS | 3 * Copyright (c) 2009 IITP RAS |
4 * | 4 * |
5 * This program is free software; you can redistribute it and/or modify | 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 | 6 * it under the terms of the GNU General Public License version 2 as |
7 * published by the Free Software Foundation; | 7 * published by the Free Software Foundation; |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU General Public License | 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 | 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 | 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
17 * | 17 * |
18 * Authors: Kirill Andreev <andreev@iitp.ru> | 18 * Authors: Kirill Andreev <andreev@iitp.ru> |
19 * Aleksey Kovalenko <kovalenko@iitp.ru> | 19 * Aleksey Kovalenko <kovalenko@iitp.ru> |
20 */ | 20 */ |
21 | 21 |
22 #ifndef PEERLLINK_H_ | 22 #ifndef PEERLLINK_H_ |
23 #define PEERLLINK_H_ | 23 #define PEERLLINK_H_ |
24 | 24 |
25 #include "ns3/nstime.h" | 25 #include "ns3/nstime.h" |
| 26 #include "ns3/object.h" |
26 #include "ns3/callback.h" | 27 #include "ns3/callback.h" |
27 #include "ns3/mac48-address.h" | 28 #include "ns3/mac48-address.h" |
28 #include "ns3/event-id.h" | 29 #include "ns3/event-id.h" |
29 #include "ie-dot11s-beacon-timing.h" | 30 #include "ns3/ie-dot11s-beacon-timing.h" |
30 #include "ie-dot11s-peer-management.h" | 31 #include "ns3/ie-dot11s-peer-management.h" |
31 #include "ie-dot11s-configuration.h" | 32 #include "ns3/ie-dot11s-configuration.h" |
32 #include "peer-management-protocol-mac.h" | |
33 namespace ns3 { | 33 namespace ns3 { |
34 namespace dot11s { | 34 namespace dot11s { |
| 35 class PeerManagementProtocolMac; |
35 /** | 36 /** |
36 * \ingroup dot11s | 37 * \ingroup dot11s |
37 * | 38 * |
38 * \brief Peer link model for 802.11s Peer Management protocol | 39 * \brief Peer link model for 802.11s Peer Management protocol |
39 */ | 40 */ |
40 class PeerLink : public Object | 41 class PeerLink : public Object |
41 { | 42 { |
42 public: | 43 public: |
43 friend class PeerManagementProtocol; | 44 friend class PeerManagementProtocol; |
44 /// Support object system | 45 /// Support object system |
45 static TypeId GetTypeId (); | 46 static TypeId GetTypeId (); |
46 /// C-tor create empty link | 47 /// C-tor create empty link |
47 PeerLink (); | 48 PeerLink (); |
48 ~PeerLink (); | 49 ~PeerLink (); |
49 void DoDispose (); | 50 void DoDispose (); |
50 | 51 /// Peer Link state: |
| 52 enum PeerState { |
| 53 IDLE, |
| 54 OPN_SNT, |
| 55 CNF_RCVD, |
| 56 OPN_RCVD, |
| 57 ESTAB, |
| 58 HOLDING, |
| 59 }; |
51 /// Process beacon received from peer | 60 /// Process beacon received from peer |
52 void SetBeaconInformation (Time lastBeacon, Time BeaconInterval); | 61 void SetBeaconInformation (Time lastBeacon, Time BeaconInterval); |
53 /** | 62 /** |
54 * \brief Method used to detecet peer link changes | 63 * \brief Method used to detect peer link changes |
55 * | 64 * |
56 * \param bool if true - opened new link, if false - link closed | 65 * \param cb is a callback, which notifyes, that on interface (uint32_t), peer
link |
| 66 * with address (Mac48Address) was opened (bool is true) or closed (bool is fa
lse)· |
57 */ | 67 */ |
58 void SetLinkStatusCallback (Callback<void, uint32_t, Mac48Address, bool> cb); | 68 void SetLinkStatusCallback (Callback<void, uint32_t, Mac48Address, bool> cb); |
59 /** | 69 /** |
60 * \name Peer link geeters/setters | 70 * \name Peer link getters/setters |
61 * \{ | 71 * \{ |
62 */ | 72 */ |
63 void SetPeerAddress (Mac48Address macaddr); | 73 void SetPeerAddress (Mac48Address macaddr); |
64 void SetPeerMeshPointAddress (Mac48Address macaddr); | 74 void SetPeerMeshPointAddress (Mac48Address macaddr); |
65 void SetInterface (uint32_t interface); | 75 void SetInterface (uint32_t interface); |
66 void SetLocalLinkId (uint16_t id); | 76 void SetLocalLinkId (uint16_t id); |
67 void SetPeerLinkId (uint16_t id); | 77 void SetPeerLinkId (uint16_t id); |
68 void SetLocalAid (uint16_t aid); | 78 void SetLocalAid (uint16_t aid); |
69 void SetPeerAid (uint16_t aid); | 79 void SetPeerAid (uint16_t aid); |
70 void SetBeaconTimingElement (IeBeaconTiming beaconTiming); | 80 void SetBeaconTimingElement (IeBeaconTiming beaconTiming); |
71 void SetPeerLinkDescriptorElement (IePeerManagement peerLinkElement); | 81 void SetPeerLinkDescriptorElement (IePeerManagement peerLinkElement); |
72 Mac48Address GetPeerAddress () const; | 82 Mac48Address GetPeerAddress () const; |
73 uint16_t GetLocalAid () const; | 83 uint16_t GetLocalAid () const; |
74 Time GetLastBeacon () const; | 84 Time GetLastBeacon () const; |
75 Time GetBeaconInterval () const; | 85 Time GetBeaconInterval () const; |
76 IeBeaconTiming GetBeaconTimingElement ()const; | 86 IeBeaconTiming GetBeaconTimingElement ()const; |
77 IePeerManagement GetPeerLinkDescriptorElement ()const; | 87 IePeerManagement GetPeerLinkDescriptorElement ()const; |
78 //\} | 88 //\} |
79 | 89 |
80 /** | 90 /** |
81 * \name MLME | 91 * \name MLME |
82 * \{ | 92 * \{ |
83 */ | 93 */ |
84 /// MLME-CancelPeerLink.request | 94 /// MLME-CancelPeerLink.request |
85 void MLMECancelPeerLink (PmpReasonCode reason); | 95 void MLMECancelPeerLink (PmpReasonCode reason); |
86 /// MLME-ActivePeerLinkOpen.request | 96 /// MLME-ActivePeerLinkOpen.request |
87 void MLMEActivePeerLinkOpen (); | 97 void MLMEActivePeerLinkOpen (); |
88 /// MLME-PeeringRequestReject | 98 /// MLME-PeeringRequestReject |
89 void MLMEPeeringRequestReject (); | 99 void MLMEPeeringRequestReject (); |
90 enum PeerState { | |
91 IDLE, | |
92 OPN_SNT, | |
93 CNF_RCVD, | |
94 OPN_RCVD, | |
95 ESTAB, | |
96 HOLDING, | |
97 }; | |
98 /// Callback type for MLME-SignalPeerLinkStatus event | 100 /// Callback type for MLME-SignalPeerLinkStatus event |
99 typedef Callback<void, uint32_t, Mac48Address, Mac48Address, PeerLink::PeerSta
te, PeerLink::PeerState> SignalStatusCallback; | 101 typedef Callback<void, uint32_t, Mac48Address, Mac48Address, PeerLink::PeerSta
te, PeerLink::PeerState> SignalStatusCallback; |
100 /// Set callback | 102 /// Set callback |
101 void MLMESetSignalStatusCallback (SignalStatusCallback); | 103 void MLMESetSignalStatusCallback (SignalStatusCallback); |
| 104 /// Reports about transmission success/failure |
| 105 void TransmissionSuccess (); |
| 106 void TransmissionFailure (); |
102 //\} | 107 //\} |
103 ///\brief Statistics | 108 ///\brief Statistics |
104 void Report (std::ostream & os) const; | 109 void Report (std::ostream & os) const; |
105 private: | 110 private: |
| 111 /// Peer link events, see 802.11s draft 11B.3.3.2 |
| 112 enum PeerEvent |
| 113 { |
| 114 CNCL, ///< Cancel peer link |
| 115 ACTOPN, ///< Active peer link open |
| 116 CLS_ACPT, ///< PeerLinkClose_Accept |
| 117 OPN_ACPT, ///< PeerLinkOpen_Accept |
| 118 OPN_RJCT, ///< PeerLinkOpen_Reject |
| 119 REQ_RJCT, ///< PeerLinkOpenReject by internal reason |
| 120 CNF_ACPT, ///< PeerLinkConfirm_Accept |
| 121 CNF_RJCT, ///< PeerLinkConfirm_Reject |
| 122 TOR1, ///< Timeout of retry timer |
| 123 TOR2, ///< also timeout of retry timer |
| 124 TOC, ///< Timeout of confirm timer |
| 125 TOH, ///< Timeout of holding (gracefull closing) timer |
| 126 }; |
| 127 /// State transition |
| 128 void StateMachine (PeerEvent event, PmpReasonCode = REASON11S_RESERVED); |
106 /** | 129 /** |
107 * \name Link response to received management frames | 130 * \name Link response to received management frames |
108 * | 131 * |
109 * \attention In all this methods {local/peer}LinkID correspond to _peer_ stat
ion, as written in | 132 * \attention In all this methods {local/peer}LinkID correspond to _peer_ stat
ion, as written in |
110 * received frame, e.g. I am peerLinkID and peer link is localLinkID . | 133 * received frame, e.g. I am peerLinkID and peer link is localLinkID . |
111 * | 134 * |
112 * \{ | 135 * \{ |
113 */ | 136 */ |
114 /// Close link | 137 /// Close link |
115 void Close (uint16_t localLinkID, uint16_t peerLinkID, PmpReasonCode reason); | 138 void Close (uint16_t localLinkID, uint16_t peerLinkID, PmpReasonCode reason); |
(...skipping 11 matching lines...) Expand all Loading... |
127 ); | 150 ); |
128 /// Confirm reject | 151 /// Confirm reject |
129 void ConfirmReject ( | 152 void ConfirmReject ( |
130 uint16_t localLinkId, | 153 uint16_t localLinkId, |
131 uint16_t peerLinkId, | 154 uint16_t peerLinkId, |
132 IeConfiguration conf, | 155 IeConfiguration conf, |
133 Mac48Address peerMp, | 156 Mac48Address peerMp, |
134 PmpReasonCode reason | 157 PmpReasonCode reason |
135 ); | 158 ); |
136 //\} | 159 //\} |
137 | |
138 /// True if link is established | 160 /// True if link is established |
139 bool LinkIsEstab () const; | 161 bool LinkIsEstab () const; |
140 /// True if link is idle. Link can be deleted in this state | 162 /// True if link is idle. Link can be deleted in this state |
141 bool LinkIsIdle () const; | 163 bool LinkIsIdle () const; |
142 /** | 164 /** |
143 * Set pointer to MAC-plugin, which is responsible for sending peer | 165 * Set pointer to MAC-plugin, which is responsible for sending peer |
144 * link management frames | 166 * link management frames |
145 */ | 167 */ |
146 void SetMacPlugin (Ptr<PeerManagementProtocolMac> plugin); | 168 void SetMacPlugin (Ptr<PeerManagementProtocolMac> plugin); |
147 /// Peer link states, see 802.11s draft 11B.3.3.1 | |
148 private: | |
149 /// Peer link events, see 802.11s draft 11B.3.3.2 | |
150 enum PeerEvent | |
151 { | |
152 CNCL, ///< Cancel peer link | |
153 ACTOPN, ///< Active peer link open | |
154 CLS_ACPT, ///< PeerLinkClose_Accept | |
155 OPN_ACPT, ///< PeerLinkOpen_Accept | |
156 OPN_RJCT, ///< PeerLinkOpen_Reject | |
157 REQ_RJCT, ///< PeerLinkOpenReject by internal reason | |
158 CNF_ACPT, ///< PeerLinkConfirm_Accept | |
159 CNF_RJCT, ///< PeerLinkConfirm_Reject | |
160 TOR1, ///< Timeout of retry timer | |
161 TOR2, ///< also timeout of retry timer | |
162 TOC, ///< Timeout of confirm timer | |
163 TOH, ///< Timeout of holding (gracefull closing) timer | |
164 }; | |
165 | |
166 private: | |
167 /// State transition | |
168 void StateMachine (PeerEvent event, PmpReasonCode = REASON11S_RESERVED); | |
169 | |
170 /** | 169 /** |
171 * \name Event handlers | 170 * \name Event handlers |
172 * \{ | 171 * \{ |
173 */ | 172 */ |
174 void ClearRetryTimer (); | 173 void ClearRetryTimer (); |
175 void ClearConfirmTimer (); | 174 void ClearConfirmTimer (); |
176 void ClearHoldingTimer (); | 175 void ClearHoldingTimer (); |
177 void SetHoldingTimer (); | 176 void SetHoldingTimer (); |
178 void SetRetryTimer (); | 177 void SetRetryTimer (); |
179 void SetConfirmTimer (); | 178 void SetConfirmTimer (); |
180 //\} | 179 //\} |
181 | 180 |
182 /** | 181 /** |
183 * \name Work with management frames | 182 * \name Work with management frames |
184 * \{ | 183 * \{ |
185 */ | 184 */ |
186 void SendPeerLinkClose (PmpReasonCode reasoncode); | 185 void SendPeerLinkClose (PmpReasonCode reasoncode); |
187 void SendPeerLinkOpen (); | 186 void SendPeerLinkOpen (); |
188 void SendPeerLinkConfirm (); | 187 void SendPeerLinkConfirm (); |
189 //\} | 188 //\} |
190 | 189 |
191 /** | 190 /** |
192 * \name Timeout handlers | 191 * \name Timeout handlers |
193 * \{ | 192 * \{ |
194 */ | 193 */ |
195 void HoldingTimeout (); | 194 void HoldingTimeout (); |
196 void RetryTimeout (); | 195 void RetryTimeout (); |
197 void ConfirmTimeout (); | 196 void ConfirmTimeout (); |
198 //\} | 197 //\} |
199 | 198 /// Several successive beacons were lost, close link |
| 199 void BeaconLoss (); |
200 private: | 200 private: |
201 ///The number of interface I am associated with | 201 ///The number of interface I am associated with |
202 uint32_t m_interface; | 202 uint32_t m_interface; |
203 /// pointer to mac plugin, which is responsible for peer management | 203 /// pointer to MAC plugin, which is responsible for peer management |
204 Ptr<PeerManagementProtocolMac> m_macPlugin; | 204 Ptr<PeerManagementProtocolMac> m_macPlugin; |
205 /// Peer address | 205 /// Peer address |
206 Mac48Address m_peerAddress; | 206 Mac48Address m_peerAddress; |
207 /// Mesh point address, equal to peer address in case of single | 207 /// Mesh point address, equal to peer address in case of single |
208 //interface mesh point | 208 //interface mesh point |
209 Mac48Address m_peerMeshPointAddress; | 209 Mac48Address m_peerMeshPointAddress; |
210 /// My ID of this link | 210 /// My ID of this link |
211 uint16_t m_localLinkId; | 211 uint16_t m_localLinkId; |
212 /// Peer ID of this link | 212 /// Peer ID of this link |
213 uint16_t m_peerLinkId; | 213 uint16_t m_peerLinkId; |
214 /// My association ID | 214 /// My association ID |
215 uint16_t m_assocId; | 215 uint16_t m_assocId; |
216 /// Assoc Id assigned to me by peer | 216 /// Assoc Id assigned to me by peer |
217 uint16_t m_peerAssocId; | 217 uint16_t m_peerAssocId; |
218 | 218 |
219 /// When last beacon was received | 219 /// When last beacon was received |
220 Time m_lastBeacon; | 220 Time m_lastBeacon; |
221 /// Current beacon interval on corresponding interface | 221 /// Current beacon interval on corresponding interface |
222 Time m_beaconInterval; | 222 Time m_beaconInterval; |
| 223 /// How many successive packets were failed to transmit |
| 224 uint16_t m_packetFail; |
223 | 225 |
224 /// Current state | 226 /// Current state |
225 PeerState m_state; | 227 PeerState m_state; |
226 /// Mesh interface configuration | 228 /** |
| 229 * \brief Mesh interface configuration |
| 230 * \attention Is not used now, nothing to configure :) |
| 231 */ |
227 IeConfiguration m_configuration; | 232 IeConfiguration m_configuration; |
228 | 233 /// Beacon timing element received from the peer. Needed by BCA |
229 // State is a bitfield as defined as follows: | |
230 // This are states for a given | |
231 IeBeaconTiming m_beaconTiming; | 234 IeBeaconTiming m_beaconTiming; |
232 | 235 |
233 /** | 236 /** |
234 * \name Timers & counters used for internal state transitions | 237 * \name Timers & counters used for internal state transitions |
235 * \{ | 238 * \{ |
236 */ | 239 */ |
237 uint16_t m_dot11MeshMaxRetries; | 240 uint16_t m_dot11MeshMaxRetries; |
238 Time m_dot11MeshRetryTimeout; | 241 Time m_dot11MeshRetryTimeout; |
239 Time m_dot11MeshHoldingTimeout; | 242 Time m_dot11MeshHoldingTimeout; |
240 Time m_dot11MeshConfirmTimeout; | 243 Time m_dot11MeshConfirmTimeout; |
241 | 244 |
242 EventId m_retryTimer; | 245 EventId m_retryTimer; |
243 EventId m_holdingTimer; | 246 EventId m_holdingTimer; |
244 EventId m_confirmTimer; | 247 EventId m_confirmTimer; |
245 uint16_t m_retryCounter; | 248 uint16_t m_retryCounter; |
246 EventId m_beaconLossTimer; | 249 EventId m_beaconLossTimer; |
247 uint16_t m_maxBeaconLoss; | 250 uint16_t m_maxBeaconLoss; |
248 //\} | 251 uint16_t m_maxPacketFail; |
249 | 252 //\} |
250 /// Several successive beacons were lost, close link | |
251 void BeaconLoss (); | |
252 | |
253 /// How to report my status change | 253 /// How to report my status change |
254 SignalStatusCallback m_linkStatusCallback; | 254 SignalStatusCallback m_linkStatusCallback; |
255 }; | 255 }; |
256 | 256 |
257 } // namespace dot11s | 257 } // namespace dot11s |
258 } //namespace ns3 | 258 } //namespace ns3 |
259 #endif /* PEERLLINK_H_ */ | 259 #endif /* PEERLLINK_H_ */ |
LEFT | RIGHT |