A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
uan-header-rc.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2009 University of Washington
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Leonard Tracy <lentracy@gmail.com>
7 */
8
9#ifndef UAN_HEADER_RC_H
10#define UAN_HEADER_RC_H
11
12#include "ns3/header.h"
13#include "ns3/mac8-address.h"
14#include "ns3/nstime.h"
15
16#include <set>
17
18namespace ns3
19{
20
21/**
22 * @ingroup uan
23 *
24 * Extra data header information.
25 *
26 * Adds propagation delay measure, and frame number info to
27 * transmitted data packet.
28 */
29class UanHeaderRcData : public Header
30{
31 public:
32 /** Default constructor */
34 /**
35 * Constructor.
36 *
37 * @param frameNum Data frame # of reservation being transmitted.
38 * @param propDelay Measured propagation delay found in handshaking.
39 * @note Prop. delay is transmitted with 16 bits and ms accuracy.
40 */
41 UanHeaderRcData(uint8_t frameNum, Time propDelay);
42 /** Destructor */
43 ~UanHeaderRcData() override;
44
45 /**
46 * Register this type.
47 * @return The TypeId.
48 */
49 static TypeId GetTypeId();
50
51 /**
52 * Set the frame number of the reservation being transmitted.
53 *
54 * @param frameNum The data frame number.
55 */
56 void SetFrameNo(uint8_t frameNum);
57 /**
58 * Set the propagation delay as found in handshaking.
59 *
60 * @param propDelay The measured propagation delay.
61 * @note Prop. delay is transmitted with 16 bits and ms accuracy.
62 */
63 void SetPropDelay(Time propDelay);
64 /**
65 * Get the frame number of the reservation being transmitted.
66 *
67 * @return The data frame number.
68 */
69 uint8_t GetFrameNo() const;
70 /**
71 * Get the propagation delay found in handshaking.
72 *
73 * @return The measured propagation delay.
74 * @note Prop. delay is transmitted with 16 bits and ms accuracy
75 */
76 Time GetPropDelay() const;
77 /**
78 * Specialized Print with Time::Unit declared.
79 *
80 * @param os ostream.
81 * @param unit Time unit.
82 */
83 void Print(std::ostream& os, Time::Unit unit) const;
84
85 // Inherited methods
86 uint32_t GetSerializedSize() const override;
87 void Serialize(Buffer::Iterator start) const override;
89 void Print(std::ostream& os) const override;
90 TypeId GetInstanceTypeId() const override;
91
92 private:
93 uint8_t m_frameNo; //!< Data frame number.
94 Time m_propDelay; //!< Propagation delay.
95
96 // end of class UanHeaderRcData
97};
98
99/**
100 * @ingroup uan
101 *
102 * RTS header.
103 *
104 * Contains frame number, retry number, number of frames, length, and timestamp.
105 */
106class UanHeaderRcRts : public Header
107{
108 public:
109 /** Default constructor */
111 /**
112 * Constructor.
113 *
114 * @param frameNo Reservation frame number.
115 * @param retryNo Retry number of RTS packet.
116 * @param noFrames Number of data frames in reservation.
117 * @param length Number of bytes (including headers) in data.
118 * @param ts RTS TX timestamp.
119 * @note Timestamp is serialized into 32 bits with ms accuracy.
120 */
121 UanHeaderRcRts(uint8_t frameNo, uint8_t retryNo, uint8_t noFrames, uint16_t length, Time ts);
122 /** Destructor */
123 ~UanHeaderRcRts() override;
124
125 /**
126 * Register this type.
127 * @return The TypeId.
128 */
129 static TypeId GetTypeId();
130
131 /**
132 * Set the frame number.
133 *
134 * @param fno TX frame number
135 */
136 void SetFrameNo(uint8_t fno);
137 /**
138 * Set the number of data frames included in this reservation request.
139 *
140 * @param no Number of frames.
141 */
142 void SetNoFrames(uint8_t no);
143 /**
144 * Set RTS transmission time.
145 *
146 * @param timeStamp The RTS transmission time.
147 */
148 void SetTimeStamp(Time timeStamp);
149 /**
150 * Set the number of data bytes in the reservation.
151 *
152 * @param length Total number of data bytes in reservation (including headers).
153 * @note Timestamp is serialized with 32 bits in ms precision.
154 */
155 void SetLength(uint16_t length);
156 /**
157 * Set the retry number of this RTS packet.
158 *
159 * This is used to match timestamp to correctly received RTS.
160 *
161 * @param no Retry number.
162 */
163 void SetRetryNo(uint8_t no);
164
165 /**
166 * Get the frame number.
167 *
168 * @return The frame number.
169 */
170 uint8_t GetFrameNo() const;
171 /**
172 * Get the number of data frames in the reservation.
173 *
174 * @return The number of data frames.
175 */
176 uint8_t GetNoFrames() const;
177 /**
178 * Get the transmit timestamp of this RTS packet.
179 *
180 * @return The TX time.
181 * @note Timestamp is serialized with 32 bits in ms precision.
182 */
183 Time GetTimeStamp() const;
184 /**
185 * Get the total number of bytes in the reservation, including headers.
186 *
187 * @return Total number of bytes in data packets for reservation.
188 */
189 uint16_t GetLength() const;
190 /**
191 * Get the retry number of this RTS packet.
192 *
193 * @return The retry number.
194 */
195 uint8_t GetRetryNo() const;
196 /**
197 * Specialized Print with Time::Unit declared.
198 *
199 * @param os ostream.
200 * @param unit Time unit.
201 */
202 void Print(std::ostream& os, Time::Unit unit) const;
203
204 // Inherited methods
205 uint32_t GetSerializedSize() const override;
206 void Serialize(Buffer::Iterator start) const override;
207 uint32_t Deserialize(Buffer::Iterator start) override;
208 void Print(std::ostream& os) const override;
209 TypeId GetInstanceTypeId() const override;
210
211 private:
212 uint8_t m_frameNo; //!< Reservation frame number.
213 uint8_t m_noFrames; //!< Number of data frames in reservation.
214 uint16_t m_length; //!< Number of bytes (including headers) in data.
215 Time m_timeStamp; //!< RTS TX timestamp.
216 uint8_t m_retryNo; //!< Retry number of RTS packet.
217
218 // end of class UanHeaderRcRts
219};
220
221/**
222 * @ingroup uan
223 *
224 * Cycle broadcast information.
225 *
226 * This includes the rate number, retry rate and window time.
227 */
229{
230 public:
231 /** Default constructor */
233 /**
234 * Constructor
235 *
236 * @param wt Window time.
237 * @param ts Timestamp.
238 * @param rate Rate number.
239 * @param retryRate Retry rate value.
240 */
241 UanHeaderRcCtsGlobal(Time wt, Time ts, uint16_t rate, uint16_t retryRate);
242 /** Destructor */
243 ~UanHeaderRcCtsGlobal() override;
244
245 /**
246 * Register this type.
247 * @return The TypeId.
248 */
249 static TypeId GetTypeId();
250
251 /**
252 * Set the rate number corresponding to data rate of current cycle.
253 * @param rate The rate number.
254 */
255 void SetRateNum(uint16_t rate);
256 /**
257 * Set the retry rate number for the current cycle.
258 * @param rate The retry rate number
259 */
260 void SetRetryRate(uint16_t rate);
261 /**
262 * Set the window time (time duration following blocking time
263 * to allow RTS transmissions).
264 *
265 * @param t The window time.
266 */
267 void SetWindowTime(Time t);
268
269 /**
270 * Set the CTS timestamp.
271 *
272 * @param timeStamp The time of CTS transmission.
273 */
274 void SetTxTimeStamp(Time timeStamp);
275
276 /**
277 * Get the data rate number.
278 *
279 * @return The rate number.
280 */
281 uint16_t GetRateNum() const;
282 /**
283 * Get the retry rate number.
284 *
285 * @return The retry rate number.
286 */
287 uint16_t GetRetryRate() const;
288 /**
289 * Get the window time (time duration following blocking time
290 * to allow RTS transmissions).
291 *
292 * @return The window time.
293 */
294 Time GetWindowTime() const;
295 /**
296 * Get the CTS transmit timestamp.
297 *
298 * @return The timestamp.
299 */
300 Time GetTxTimeStamp() const;
301 /**
302 * Specialized Print with Time::Unit declared.
303 *
304 * @param os ostream.
305 * @param unit Time unit.
306 */
307 void Print(std::ostream& os, Time::Unit unit) const;
308
309 // Inherited methods
310 uint32_t GetSerializedSize() const override;
311 void Serialize(Buffer::Iterator start) const override;
312 uint32_t Deserialize(Buffer::Iterator start) override;
313 void Print(std::ostream& os) const override;
314 TypeId GetInstanceTypeId() const override;
315
316 private:
317 Time m_timeStampTx; //!< Timestamp.
318 Time m_winTime; //!< Window time.
319 uint16_t m_retryRate; //!< Retry rate.
320 uint16_t m_rateNum; //!< Rate number.
321
322 // end of class UanHeaderRcCtsGlobal
323};
324
325/**
326 * @ingroup uan
327 *
328 * CTS header
329 *
330 * Includes RTS RX time, CTS TX time, delay until TX, RTS blocking period,
331 * RTS tx period, rate #, and retry rate #
332 */
333class UanHeaderRcCts : public Header
334{
335 public:
336 /** Default constructor */
338 /**
339 * Constructor
340 *
341 * @param frameNo Reservation frame # being cleared.
342 * @param retryNo Retry # of received RTS packet.
343 * @param rtsTs RX time of RTS packet at gateway.
344 * @param delay Delay until transmission.
345 * @param addr Destination of CTS packet.
346 * @note Times are serialized, with ms precision, into 32 bit fields.
347 */
348 UanHeaderRcCts(uint8_t frameNo, uint8_t retryNo, Time rtsTs, Time delay, Mac8Address addr);
349 /** Destructor */
350 ~UanHeaderRcCts() override;
351
352 /**
353 * Register this type.
354 * @return The TypeId.
355 */
356 static TypeId GetTypeId();
357
358 /**
359 * Set the RTS frame number being cleared.
360 *
361 * @param frameNo The frame number.
362 */
363 void SetFrameNo(uint8_t frameNo);
364 /**
365 * Set the timestamp for RTS reception.
366 *
367 * @param timeStamp The timestamp.
368 */
369 void SetRtsTimeStamp(Time timeStamp);
370 /**
371 * Set the time delay from CTS transmission to first data frame arrival.
372 *
373 * @param delay The delay time.
374 */
375 void SetDelayToTx(Time delay);
376 /**
377 * Set the retry number of the RTS frame being cleared.
378 *
379 * @param no The retry number.
380 */
381 void SetRetryNo(uint8_t no);
382 /**
383 * Set the destination address, for scheduling info.
384 *
385 * @param addr The destination address.
386 */
387 void SetAddress(Mac8Address addr);
388
389 /**
390 * Get the frame number of the RTS being cleared.
391 *
392 * @return The frame number.
393 */
394 uint8_t GetFrameNo() const;
395 /**
396 * Get the receive time of the RTS being cleared.
397 *
398 * @return The RX time.
399 */
400 Time GetRtsTimeStamp() const;
401 /**
402 * Get the time delay from TX time of CTS packet until
403 * arrival of first data frame.
404 *
405 * @return The delay time.
406 */
407 Time GetDelayToTx() const;
408 /**
409 * Get the retry number of the RTS packet being cleared.
410 *
411 * @return The retry number
412 */
413 uint8_t GetRetryNo() const;
414 /**
415 * Get the destination address, for scheduling info.
416 *
417 * @return The destination address.
418 */
419 Mac8Address GetAddress() const;
420 /**
421 * Specialized Print with Time::Unit declared.
422 *
423 * @param os ostream.
424 * @param unit Time unit.
425 */
426 void Print(std::ostream& os, Time::Unit unit) const;
427
428 // Inherited methods
429 uint32_t GetSerializedSize() const override;
430 void Serialize(Buffer::Iterator start) const override;
431 uint32_t Deserialize(Buffer::Iterator start) override;
432 void Print(std::ostream& os) const override;
433 TypeId GetInstanceTypeId() const override;
434
435 private:
436 uint8_t m_frameNo; //!< Reservation frame number being cleared.
437 Time m_timeStampRts; //!< RX time of RTS packet at gateway.
438 uint8_t m_retryNo; //!< Retry number of received RTS packet.
439 Time m_delay; //!< Delay until transmission.
440 Mac8Address m_address; //!< Destination of CTS packet.
441
442 // end of class UanHeaderRcCts
443};
444
445/**
446 * @ingroup uan
447 *
448 * Header used for ACK packets by protocol UanMacRc
449 */
450class UanHeaderRcAck : public Header
451{
452 public:
453 /** Default constructor */
455 /** Destructor */
456 ~UanHeaderRcAck() override;
457
458 /**
459 * Register this type.
460 * @return The TypeId.
461 */
462 static TypeId GetTypeId();
463
464 /**
465 * Set the frame number of the reservation being acknowledged.
466 *
467 * @param frameNo The frame number.
468 */
469 void SetFrameNo(uint8_t frameNo);
470 /**
471 * NACK a frame.
472 *
473 * @param frame The data frame number being NACKed.
474 */
475 void AddNackedFrame(uint8_t frame);
476
477 /**
478 * Get the set of NACK'ed frames.
479 *
480 * @return The set of NACK'ed frames.
481 */
482 const std::set<uint8_t>& GetNackedFrames() const;
483 /**
484 * Get the reservation frame number being ACKed.
485 *
486 * @return The frame number.
487 */
488 uint8_t GetFrameNo() const;
489 /**
490 * Get the number of data frames being NACKed.
491 *
492 * @return The number of NACKed frames.
493 */
494 uint8_t GetNoNacks() const;
495
496 // Inherited methods
497 uint32_t GetSerializedSize() const override;
498 void Serialize(Buffer::Iterator start) const override;
499 uint32_t Deserialize(Buffer::Iterator start) override;
500 void Print(std::ostream& os) const override;
501 TypeId GetInstanceTypeId() const override;
502
503 private:
504 uint8_t m_frameNo; //!< Next frame number.
505 std::set<uint8_t> m_nackedFrames; //!< Marker for nacked frames.
506
507 // end of class UanHeaderRcAck
508};
509
510} // namespace ns3
511
512#endif /* UAN_HEADER_RC_H */
iterator in a Buffer instance
Definition buffer.h:89
Protocol header serialization and deserialization.
Definition header.h:33
A class used for addressing MAC8 MAC's.
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
Unit
The unit to use to interpret a number representing time.
Definition nstime.h:100
a unique identifier for an interface.
Definition type-id.h:49
Header used for ACK packets by protocol UanMacRc.
static TypeId GetTypeId()
Register this type.
uint8_t m_frameNo
Next frame number.
uint32_t GetSerializedSize() const override
uint32_t Deserialize(Buffer::Iterator start) override
std::set< uint8_t > m_nackedFrames
Marker for nacked frames.
const std::set< uint8_t > & GetNackedFrames() const
Get the set of NACK'ed frames.
~UanHeaderRcAck() override
Destructor.
void Serialize(Buffer::Iterator start) const override
UanHeaderRcAck()
Default constructor.
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
uint8_t GetFrameNo() const
Get the reservation frame number being ACKed.
void AddNackedFrame(uint8_t frame)
NACK a frame.
void Print(std::ostream &os) const override
uint8_t GetNoNacks() const
Get the number of data frames being NACKed.
void SetFrameNo(uint8_t frameNo)
Set the frame number of the reservation being acknowledged.
Cycle broadcast information.
void Print(std::ostream &os, Time::Unit unit) const
Specialized Print with Time::Unit declared.
uint32_t Deserialize(Buffer::Iterator start) override
UanHeaderRcCtsGlobal()
Default constructor.
static TypeId GetTypeId()
Register this type.
void Serialize(Buffer::Iterator start) const override
void SetRateNum(uint16_t rate)
Set the rate number corresponding to data rate of current cycle.
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
~UanHeaderRcCtsGlobal() override
Destructor.
void SetRetryRate(uint16_t rate)
Set the retry rate number for the current cycle.
void SetTxTimeStamp(Time timeStamp)
Set the CTS timestamp.
Time m_winTime
Window time.
uint16_t GetRetryRate() const
Get the retry rate number.
uint16_t m_retryRate
Retry rate.
Time GetTxTimeStamp() const
Get the CTS transmit timestamp.
uint16_t m_rateNum
Rate number.
Time GetWindowTime() const
Get the window time (time duration following blocking time to allow RTS transmissions).
void SetWindowTime(Time t)
Set the window time (time duration following blocking time to allow RTS transmissions).
uint16_t GetRateNum() const
Get the data rate number.
uint32_t GetSerializedSize() const override
Time GetDelayToTx() const
Get the time delay from TX time of CTS packet until arrival of first data frame.
uint8_t GetFrameNo() const
Get the frame number of the RTS being cleared.
uint32_t Deserialize(Buffer::Iterator start) override
void SetRtsTimeStamp(Time timeStamp)
Set the timestamp for RTS reception.
UanHeaderRcCts()
Default constructor.
void SetFrameNo(uint8_t frameNo)
Set the RTS frame number being cleared.
uint32_t GetSerializedSize() const override
~UanHeaderRcCts() override
Destructor.
void SetDelayToTx(Time delay)
Set the time delay from CTS transmission to first data frame arrival.
void Serialize(Buffer::Iterator start) const override
Mac8Address m_address
Destination of CTS packet.
uint8_t GetRetryNo() const
Get the retry number of the RTS packet being cleared.
Mac8Address GetAddress() const
Get the destination address, for scheduling info.
Time m_delay
Delay until transmission.
Time m_timeStampRts
RX time of RTS packet at gateway.
void Print(std::ostream &os, Time::Unit unit) const
Specialized Print with Time::Unit declared.
uint8_t m_frameNo
Reservation frame number being cleared.
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
void SetRetryNo(uint8_t no)
Set the retry number of the RTS frame being cleared.
static TypeId GetTypeId()
Register this type.
Time GetRtsTimeStamp() const
Get the receive time of the RTS being cleared.
void SetAddress(Mac8Address addr)
Set the destination address, for scheduling info.
uint8_t m_retryNo
Retry number of received RTS packet.
Extra data header information.
Time m_propDelay
Propagation delay.
~UanHeaderRcData() override
Destructor.
uint8_t m_frameNo
Data frame number.
void SetFrameNo(uint8_t frameNum)
Set the frame number of the reservation being transmitted.
UanHeaderRcData()
Default constructor.
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
uint8_t GetFrameNo() const
Get the frame number of the reservation being transmitted.
static TypeId GetTypeId()
Register this type.
uint32_t GetSerializedSize() const override
void Serialize(Buffer::Iterator start) const override
void SetPropDelay(Time propDelay)
Set the propagation delay as found in handshaking.
Time GetPropDelay() const
Get the propagation delay found in handshaking.
uint32_t Deserialize(Buffer::Iterator start) override
void Print(std::ostream &os, Time::Unit unit) const
Specialized Print with Time::Unit declared.
uint16_t m_length
Number of bytes (including headers) in data.
void Print(std::ostream &os, Time::Unit unit) const
Specialized Print with Time::Unit declared.
UanHeaderRcRts()
Default constructor.
uint8_t GetFrameNo() const
Get the frame number.
uint16_t GetLength() const
Get the total number of bytes in the reservation, including headers.
uint8_t m_retryNo
Retry number of RTS packet.
uint8_t GetNoFrames() const
Get the number of data frames in the reservation.
void SetFrameNo(uint8_t fno)
Set the frame number.
void SetTimeStamp(Time timeStamp)
Set RTS transmission time.
static TypeId GetTypeId()
Register this type.
uint8_t m_noFrames
Number of data frames in reservation.
Time GetTimeStamp() const
Get the transmit timestamp of this RTS packet.
~UanHeaderRcRts() override
Destructor.
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
void SetRetryNo(uint8_t no)
Set the retry number of this RTS packet.
uint32_t GetSerializedSize() const override
uint8_t m_frameNo
Reservation frame number.
void Serialize(Buffer::Iterator start) const override
uint8_t GetRetryNo() const
Get the retry number of this RTS packet.
void SetNoFrames(uint8_t no)
Set the number of data frames included in this reservation request.
void SetLength(uint16_t length)
Set the number of data bytes in the reservation.
Time m_timeStamp
RTS TX timestamp.
uint32_t Deserialize(Buffer::Iterator start) override
Every class exported by the ns3 library is enclosed in the ns3 namespace.