OLD | NEW |
(Empty) | |
| 1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
| 2 /* |
| 3 * Copyright (c) 2009 University of Washington |
| 4 * |
| 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 |
| 7 * published by the Free Software Foundation; |
| 8 * |
| 9 * This program is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 * GNU General Public License for more details. |
| 13 * |
| 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 |
| 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 17 * |
| 18 * Author: Leonard Tracy <lentracy@gmail.com> |
| 19 */ |
| 20 |
| 21 |
| 22 #ifndef UANHEADERRC_H |
| 23 #define UANHEADERRC_H |
| 24 |
| 25 #include "ns3/header.h" |
| 26 #include "ns3/nstime.h" |
| 27 #include "ns3/uan-address.h" |
| 28 |
| 29 #include <set> |
| 30 |
| 31 namespace ns3 { |
| 32 |
| 33 /** |
| 34 * \class UanHeaderRcData |
| 35 * |
| 36 * \brief Extra data header information |
| 37 * |
| 38 * Adds prop. delay measure, and frame number info to |
| 39 * transmitted data packet |
| 40 */ |
| 41 class UanHeaderRcData : public ns3::Header |
| 42 { |
| 43 public: |
| 44 UanHeaderRcData (); |
| 45 /** |
| 46 * \param frameNum Data frame # of reservation being transmitted |
| 47 * \param propDelay Measured propagation delay found in handshaking |
| 48 * \note Prop. delay is transmitted with 16 bits and ms accuracy |
| 49 */ |
| 50 UanHeaderRcData (uint8_t frameNum, Time propDelay); |
| 51 virtual ~UanHeaderRcData (); |
| 52 |
| 53 static TypeId GetTypeId (void); |
| 54 |
| 55 /** |
| 56 * \param frameNum Data frame # of reservation being transmitted |
| 57 */ |
| 58 void SetFrameNo (uint8_t frameNum); |
| 59 /** |
| 60 * \param propDelay Measured propagation delay found in handshaking |
| 61 * \note Prop. delay is transmitted with 16 bits and ms accuracy |
| 62 */ |
| 63 void SetPropDelay (Time propDelay); |
| 64 /** |
| 65 * \returns Data frame # of reservation being transmitted |
| 66 */ |
| 67 uint8_t GetFrameNo (void) const; |
| 68 /** |
| 69 * \returns Measured propagation delay found in handshaking |
| 70 * \note Prop. delay is transmitted with 16 bits and ms accuracy |
| 71 */ |
| 72 Time GetPropDelay (void) const; |
| 73 |
| 74 // Inherrited methods |
| 75 virtual uint32_t GetSerializedSize (void) const; |
| 76 virtual void Serialize (Buffer::Iterator start) const; |
| 77 virtual uint32_t Deserialize (Buffer::Iterator start); |
| 78 virtual void Print (std::ostream &os) const; |
| 79 virtual TypeId GetInstanceTypeId (void) const; |
| 80 |
| 81 private: |
| 82 uint8_t m_frameNo; |
| 83 Time m_propDelay; |
| 84 }; |
| 85 |
| 86 /** |
| 87 * \class UanHeaderRcRts |
| 88 * |
| 89 * \brief RTS header |
| 90 * |
| 91 * Contains frame #, retry #, # frames, length, and timestamp |
| 92 */ |
| 93 class UanHeaderRcRts : public ns3::Header |
| 94 { |
| 95 public: |
| 96 UanHeaderRcRts (); |
| 97 /** |
| 98 * \param frameNo Reservation frame # |
| 99 * \param retryNo Retry # of RTS packet |
| 100 * \param noFrames # of data frames in reservation |
| 101 * \param length # of bytes (including headers) in data |
| 102 * \param ts RTS TX timestamp |
| 103 * \note Timestamp is serialized into 32 bits with ms accuracy |
| 104 */ |
| 105 UanHeaderRcRts (uint8_t frameNo, uint8_t retryNo, uint8_t noFrames, uint16_t l
ength, Time ts); |
| 106 virtual ~UanHeaderRcRts (); |
| 107 |
| 108 static TypeId GetTypeId (void); |
| 109 |
| 110 /** |
| 111 * \param fno TX frame # |
| 112 */ |
| 113 void SetFrameNo (uint8_t fno); |
| 114 /** |
| 115 * \param no Number of data frames included in this reservation request |
| 116 */ |
| 117 void SetNoFrames (uint8_t no); |
| 118 /** |
| 119 * \param timeStamp RTS transmission time |
| 120 */ |
| 121 void SetTimeStamp (Time timeStamp); |
| 122 /** |
| 123 * \param length Total number of data bytes in reservation (including headers) |
| 124 * \note Timestamp is serialized with 32 bits in ms precision |
| 125 */ |
| 126 void SetLength (uint16_t length); |
| 127 /** |
| 128 * \param no Retry number of this RTS (Used to match timestamp to correctly re
ceived RTS) |
| 129 */ |
| 130 void SetRetryNo (uint8_t no); |
| 131 |
| 132 /** |
| 133 * \returns Frame # |
| 134 */ |
| 135 uint8_t GetFrameNo (void) const; |
| 136 /** |
| 137 * \returns # of data frames in reservation |
| 138 */ |
| 139 uint8_t GetNoFrames (void) const; |
| 140 /** |
| 141 * \returns TX time of the RTS packet |
| 142 * \note Timestamp is serialized with 32 bits in ms precision |
| 143 */ |
| 144 Time GetTimeStamp (void) const; |
| 145 /** |
| 146 * \returns Total # of bytes in data packets for reservation (including header
s) |
| 147 */ |
| 148 uint16_t GetLength (void) const; |
| 149 /** |
| 150 * \returns Retry number of this RTS packet |
| 151 */ |
| 152 uint8_t GetRetryNo (void) const; |
| 153 |
| 154 // Inherrited methods |
| 155 virtual uint32_t GetSerializedSize (void) const; |
| 156 virtual void Serialize (Buffer::Iterator start) const; |
| 157 virtual uint32_t Deserialize (Buffer::Iterator start); |
| 158 virtual void Print (std::ostream &os) const; |
| 159 virtual TypeId GetInstanceTypeId (void) const; |
| 160 |
| 161 private: |
| 162 uint8_t m_frameNo; |
| 163 uint8_t m_noFrames; |
| 164 uint16_t m_length; |
| 165 Time m_timeStamp; |
| 166 uint8_t m_retryNo; |
| 167 }; |
| 168 |
| 169 /** |
| 170 * \class UanHeaderRcCtsGlobal |
| 171 * |
| 172 * \brief Cycle broadcast information for |
| 173 */ |
| 174 |
| 175 |
| 176 class UanHeaderRcCtsGlobal : public Header |
| 177 { |
| 178 public: |
| 179 UanHeaderRcCtsGlobal (); |
| 180 UanHeaderRcCtsGlobal (Time wt, Time ts, uint16_t rate, uint16_t retryRate); |
| 181 ~UanHeaderRcCtsGlobal (); |
| 182 |
| 183 static TypeId GetTypeId (); |
| 184 |
| 185 /** |
| 186 * \param rate Rate number corresponding to data rate of current cycle |
| 187 */ |
| 188 void SetRateNum (uint16_t rate); |
| 189 /** |
| 190 * \param rate Retry rate number for current cycle |
| 191 */ |
| 192 void SetRetryRate (uint16_t rate); |
| 193 /** |
| 194 * \param t Time duration following blocking time to allow RTS transmissions |
| 195 */ |
| 196 void SetWindowTime (Time t); |
| 197 |
| 198 /** |
| 199 * \param timeStamp Time of CTS transmission |
| 200 */ |
| 201 void SetTxTimeStamp (Time timeStamp); |
| 202 |
| 203 /** |
| 204 * \returns Rate # corresponding to data rate of current cycle |
| 205 */ |
| 206 uint16_t GetRateNum (void) const; |
| 207 /** |
| 208 * \returns retry rate # of retry rate for current cycle |
| 209 */ |
| 210 uint16_t GetRetryRate (void) const; |
| 211 /** |
| 212 * \returns Time duration after blocking time allowed for RTS transmissions |
| 213 */ |
| 214 Time GetWindowTime (void) const; |
| 215 /** |
| 216 * \returns Timestamp of CTS transmission |
| 217 */ |
| 218 Time GetTxTimeStamp (void) const; |
| 219 |
| 220 // Inherrited methods |
| 221 virtual uint32_t GetSerializedSize (void) const; |
| 222 virtual void Serialize (Buffer::Iterator start) const; |
| 223 virtual uint32_t Deserialize (Buffer::Iterator start); |
| 224 virtual void Print (std::ostream &os) const; |
| 225 virtual TypeId GetInstanceTypeId (void) const; |
| 226 |
| 227 private: |
| 228 Time m_timeStampTx; |
| 229 Time m_winTime; |
| 230 uint16_t m_retryRate; |
| 231 uint16_t m_rateNum; |
| 232 }; |
| 233 /** |
| 234 * \class UanHeaderRcCts |
| 235 * |
| 236 * \brief CTS header |
| 237 * |
| 238 * Includes RTS RX time, CTS TX time, delay until TX, RTS blocking period, |
| 239 * RTS tx period, rate #, and retry rate # |
| 240 */ |
| 241 |
| 242 class UanHeaderRcCts : public ns3::Header |
| 243 { |
| 244 public: |
| 245 UanHeaderRcCts (); |
| 246 /** |
| 247 * \param frameNo Resrvation frame # being cleared |
| 248 * \param retryNo Retry # of received RTS packet |
| 249 * \param rtsTs RX time of RTS packet at gateway |
| 250 * \param delay Delay until transmission |
| 251 * \param addr Destination of CTS packet |
| 252 * \note Times are serialized, with ms precission, into 32 bit fields. |
| 253 */ |
| 254 UanHeaderRcCts (uint8_t frameNo, uint8_t retryNo, Time rtsTs, Time delay, UanA
ddress addr); |
| 255 virtual ~UanHeaderRcCts (); |
| 256 |
| 257 static TypeId GetTypeId (void); |
| 258 |
| 259 /** |
| 260 * \param frameNo Frame # of RTS being cleared |
| 261 */ |
| 262 void SetFrameNo (uint8_t frameNo); |
| 263 /** |
| 264 * \param timeStamp Time of RTS reception |
| 265 */ |
| 266 void SetRtsTimeStamp (Time timeStamp); |
| 267 /** |
| 268 * \param delay Time duration, from CTS TX, before first data frame arrival |
| 269 */ |
| 270 void SetDelayToTx (Time delay); |
| 271 /** |
| 272 * \param no Retry number of RTS frame being cleared |
| 273 */ |
| 274 void SetRetryNo (uint8_t no); |
| 275 /** |
| 276 * \param addr Destination for scheduling info |
| 277 */ |
| 278 void SetAddress (UanAddress addr); |
| 279 |
| 280 /** |
| 281 * \returns Frame # of RTS being cleared |
| 282 */ |
| 283 uint8_t GetFrameNo (void) const; |
| 284 /** |
| 285 * \returns RX time of RTS being cleared |
| 286 */ |
| 287 Time GetRtsTimeStamp (void) const; |
| 288 /** |
| 289 * \returns Delay from TX time of CTS packet until arrival of first data frame |
| 290 */ |
| 291 Time GetDelayToTx (void) const; |
| 292 /** |
| 293 * \returns Retry # of RTS packet being cleared |
| 294 */ |
| 295 uint8_t GetRetryNo (void) const; |
| 296 /** |
| 297 * \returns Destination for scheduling info |
| 298 */ |
| 299 UanAddress GetAddress (void) const; |
| 300 |
| 301 // Inherrited methods |
| 302 virtual uint32_t GetSerializedSize (void) const; |
| 303 virtual void Serialize (Buffer::Iterator start) const; |
| 304 virtual uint32_t Deserialize (Buffer::Iterator start); |
| 305 virtual void Print (std::ostream &os) const; |
| 306 virtual TypeId GetInstanceTypeId (void) const; |
| 307 |
| 308 private: |
| 309 uint8_t m_frameNo; |
| 310 Time m_timeStampRts; |
| 311 uint8_t m_retryNo; |
| 312 Time m_delay; |
| 313 UanAddress m_address; |
| 314 }; |
| 315 |
| 316 class UanHeaderRcAck : public Header |
| 317 { |
| 318 public: |
| 319 UanHeaderRcAck (); |
| 320 virtual ~UanHeaderRcAck (); |
| 321 |
| 322 static TypeId GetTypeId (void); |
| 323 |
| 324 /** |
| 325 * \params frameNo Frame # of reservation being acknowledged |
| 326 */ |
| 327 void SetFrameNo (uint8_t frameNo); |
| 328 /** |
| 329 * \params frame Data frame # being nacked |
| 330 */ |
| 331 void AddNackedFrame (uint8_t frame); |
| 332 |
| 333 /** |
| 334 * \returns Set of nacked frames |
| 335 */ |
| 336 const std::set<uint8_t> &GetNackedFrames (void) const; |
| 337 /** |
| 338 * \returns Reservation frame # being acknowledged. |
| 339 */ |
| 340 uint8_t GetFrameNo (void) const; |
| 341 /** |
| 342 * \returns Number of data frames being NACKED |
| 343 */ |
| 344 uint8_t GetNoNacks (void) const; |
| 345 |
| 346 // Inherrited methods |
| 347 virtual uint32_t GetSerializedSize (void) const; |
| 348 virtual void Serialize (Buffer::Iterator start) const; |
| 349 virtual uint32_t Deserialize (Buffer::Iterator start); |
| 350 virtual void Print (std::ostream &os) const; |
| 351 virtual TypeId GetInstanceTypeId (void) const; |
| 352 |
| 353 private: |
| 354 uint8_t m_frameNo; |
| 355 std::set<uint8_t> m_nackedFrames; |
| 356 |
| 357 }; |
| 358 |
| 359 } |
| 360 |
| 361 #endif // UANHEADERRC_H |
OLD | NEW |