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}; // class UanHeaderRcData
97
98/**
99 * \ingroup uan
100 *
101 * RTS header.
102 *
103 * Contains frame number, retry number, number of frames, length, and timestamp.
104 */
105class UanHeaderRcRts : public Header
106{
107 public:
108 /** Default constructor */
110 /**
111 * Constructor.
112 *
113 * \param frameNo Reservation frame number.
114 * \param retryNo Retry number of RTS packet.
115 * \param noFrames Number of data frames in reservation.
116 * \param length Number of bytes (including headers) in data.
117 * \param ts RTS TX timestamp.
118 * \note Timestamp is serialized into 32 bits with ms accuracy.
119 */
120 UanHeaderRcRts(uint8_t frameNo, uint8_t retryNo, uint8_t noFrames, uint16_t length, Time ts);
121 /** Destructor */
122 ~UanHeaderRcRts() override;
123
124 /**
125 * Register this type.
126 * \return The TypeId.
127 */
128 static TypeId GetTypeId();
129
130 /**
131 * Set the frame number.
132 *
133 * \param fno TX frame number
134 */
135 void SetFrameNo(uint8_t fno);
136 /**
137 * Set the number of data frames included in this reservation request.
138 *
139 * \param no Number of frames.
140 */
141 void SetNoFrames(uint8_t no);
142 /**
143 * Set RTS transmission time.
144 *
145 * \param timeStamp The RTS transmission time.
146 */
147 void SetTimeStamp(Time timeStamp);
148 /**
149 * Set the number of data bytes in the reservation.
150 *
151 * \param length Total number of data bytes in reservation (including headers).
152 * \note Timestamp is serialized with 32 bits in ms precision.
153 */
154 void SetLength(uint16_t length);
155 /**
156 * Set the retry number of this RTS packet.
157 *
158 * This is used to match timestamp to correctly received RTS.
159 *
160 * \param no Retry number.
161 */
162 void SetRetryNo(uint8_t no);
163
164 /**
165 * Get the frame number.
166 *
167 * \return The frame number.
168 */
169 uint8_t GetFrameNo() const;
170 /**
171 * Get the number of data frames in the reservation.
172 *
173 * \return The number of data frames.
174 */
175 uint8_t GetNoFrames() const;
176 /**
177 * Get the transmit timestamp of this RTS packet.
178 *
179 * \return The TX time.
180 * \note Timestamp is serialized with 32 bits in ms precision.
181 */
182 Time GetTimeStamp() const;
183 /**
184 * Get the total number of bytes in the reservation, including headers.
185 *
186 * \return Total number of bytes in data packets for reservation.
187 */
188 uint16_t GetLength() const;
189 /**
190 * Get the retry number of this RTS packet.
191 *
192 * \return The retry number.
193 */
194 uint8_t GetRetryNo() const;
195 /**
196 * Specialized Print with Time::Unit declared.
197 *
198 * \param os ostream.
199 * \param unit Time unit.
200 */
201 void Print(std::ostream& os, Time::Unit unit) const;
202
203 // Inherited methods
204 uint32_t GetSerializedSize() const override;
205 void Serialize(Buffer::Iterator start) const override;
206 uint32_t Deserialize(Buffer::Iterator start) override;
207 void Print(std::ostream& os) const override;
208 TypeId GetInstanceTypeId() const override;
209
210 private:
211 uint8_t m_frameNo; //!< Reservation frame number.
212 uint8_t m_noFrames; //!< Number of data frames in reservation.
213 uint16_t m_length; //!< Number of bytes (including headers) in data.
214 Time m_timeStamp; //!< RTS TX timestamp.
215 uint8_t m_retryNo; //!< Retry number of RTS packet.
216
217}; // class UanHeaderRcRts
218
219/**
220 * \ingroup uan
221 *
222 * Cycle broadcast information.
223 *
224 * This includes the rate number, retry rate and window time.
225 */
227{
228 public:
229 /** Default constructor */
231 /**
232 * Constructor
233 *
234 * \param wt Window time.
235 * \param ts Timestamp.
236 * \param rate Rate number.
237 * \param retryRate Retry rate value.
238 */
239 UanHeaderRcCtsGlobal(Time wt, Time ts, uint16_t rate, uint16_t retryRate);
240 /** Destructor */
241 ~UanHeaderRcCtsGlobal() override;
242
243 /**
244 * Register this type.
245 * \return The TypeId.
246 */
247 static TypeId GetTypeId();
248
249 /**
250 * Set the rate number corresponding to data rate of current cycle.
251 * \param rate The rate number.
252 */
253 void SetRateNum(uint16_t rate);
254 /**
255 * Set the retry rate number for the current cycle.
256 * \param rate The retry rate number
257 */
258 void SetRetryRate(uint16_t rate);
259 /**
260 * Set the window time (time duration following blocking time
261 * to allow RTS transmissions).
262 *
263 * \param t The window time.
264 */
265 void SetWindowTime(Time t);
266
267 /**
268 * Set the CTS timestamp.
269 *
270 * \param timeStamp The time of CTS transmission.
271 */
272 void SetTxTimeStamp(Time timeStamp);
273
274 /**
275 * Get the data rate number.
276 *
277 * \return The rate number.
278 */
279 uint16_t GetRateNum() const;
280 /**
281 * Get the retry rate number.
282 *
283 * \return The retry rate number.
284 */
285 uint16_t GetRetryRate() const;
286 /**
287 * Get the window time (time duration following blocking time
288 * to allow RTS transmissions).
289 *
290 * \return The window time.
291 */
292 Time GetWindowTime() const;
293 /**
294 * Get the CTS transmit timestamp.
295 *
296 * \return The timestamp.
297 */
298 Time GetTxTimeStamp() const;
299 /**
300 * Specialized Print with Time::Unit declared.
301 *
302 * \param os ostream.
303 * \param unit Time unit.
304 */
305 void Print(std::ostream& os, Time::Unit unit) const;
306
307 // Inherited methods
308 uint32_t GetSerializedSize() const override;
309 void Serialize(Buffer::Iterator start) const override;
310 uint32_t Deserialize(Buffer::Iterator start) override;
311 void Print(std::ostream& os) const override;
312 TypeId GetInstanceTypeId() const override;
313
314 private:
315 Time m_timeStampTx; //!< Timestamp.
316 Time m_winTime; //!< Window time.
317 uint16_t m_retryRate; //!< Retry rate.
318 uint16_t m_rateNum; //!< Rate number.
319
320}; // class UanHeaderRcCtsGlobal
321
322/**
323 * \ingroup uan
324 *
325 * CTS header
326 *
327 * Includes RTS RX time, CTS TX time, delay until TX, RTS blocking period,
328 * RTS tx period, rate #, and retry rate #
329 */
330class UanHeaderRcCts : public Header
331{
332 public:
333 /** Default constructor */
335 /**
336 * Constructor
337 *
338 * \param frameNo Reservation frame # being cleared.
339 * \param retryNo Retry # of received RTS packet.
340 * \param rtsTs RX time of RTS packet at gateway.
341 * \param delay Delay until transmission.
342 * \param addr Destination of CTS packet.
343 * \note Times are serialized, with ms precision, into 32 bit fields.
344 */
345 UanHeaderRcCts(uint8_t frameNo, uint8_t retryNo, Time rtsTs, Time delay, Mac8Address addr);
346 /** Destructor */
347 ~UanHeaderRcCts() override;
348
349 /**
350 * Register this type.
351 * \return The TypeId.
352 */
353 static TypeId GetTypeId();
354
355 /**
356 * Set the RTS frame number being cleared.
357 *
358 * \param frameNo The frame number.
359 */
360 void SetFrameNo(uint8_t frameNo);
361 /**
362 * Set the timestamp for RTS reception.
363 *
364 * \param timeStamp The timestamp.
365 */
366 void SetRtsTimeStamp(Time timeStamp);
367 /**
368 * Set the time delay from CTS transmission to first data frame arrival.
369 *
370 * \param delay The delay time.
371 */
372 void SetDelayToTx(Time delay);
373 /**
374 * Set the retry number of the RTS frame being cleared.
375 *
376 * \param no The retry number.
377 */
378 void SetRetryNo(uint8_t no);
379 /**
380 * Set the destination address, for scheduling info.
381 *
382 * \param addr The destination address.
383 */
384 void SetAddress(Mac8Address addr);
385
386 /**
387 * Get the frame number of the RTS being cleared.
388 *
389 * \return The frame number.
390 */
391 uint8_t GetFrameNo() const;
392 /**
393 * Get the receive time of the RTS being cleared.
394 *
395 * \return The RX time.
396 */
397 Time GetRtsTimeStamp() const;
398 /**
399 * Get the time delay from TX time of CTS packet until
400 * arrival of first data frame.
401 *
402 * \return The delay time.
403 */
404 Time GetDelayToTx() const;
405 /**
406 * Get the retry number of the RTS packet being cleared.
407 *
408 * \return The retry number
409 */
410 uint8_t GetRetryNo() const;
411 /**
412 * Get the destination address, for scheduling info.
413 *
414 * \return The destination address.
415 */
416 Mac8Address GetAddress() const;
417 /**
418 * Specialized Print with Time::Unit declared.
419 *
420 * \param os ostream.
421 * \param unit Time unit.
422 */
423 void Print(std::ostream& os, Time::Unit unit) const;
424
425 // Inherited methods
426 uint32_t GetSerializedSize() const override;
427 void Serialize(Buffer::Iterator start) const override;
428 uint32_t Deserialize(Buffer::Iterator start) override;
429 void Print(std::ostream& os) const override;
430 TypeId GetInstanceTypeId() const override;
431
432 private:
433 uint8_t m_frameNo; //!< Reservation frame number being cleared.
434 Time m_timeStampRts; //!< RX time of RTS packet at gateway.
435 uint8_t m_retryNo; //!< Retry number of received RTS packet.
436 Time m_delay; //!< Delay until transmission.
437 Mac8Address m_address; //!< Destination of CTS packet.
438
439}; // class UanHeaderRcCts
440
441/**
442 * \ingroup uan
443 *
444 * Header used for ACK packets by protocol UanMacRc
445 */
446class UanHeaderRcAck : public Header
447{
448 public:
449 /** Default constructor */
451 /** Destructor */
452 ~UanHeaderRcAck() override;
453
454 /**
455 * Register this type.
456 * \return The TypeId.
457 */
458 static TypeId GetTypeId();
459
460 /**
461 * Set the frame number of the reservation being acknowledged.
462 *
463 * \param frameNo The frame number.
464 */
465 void SetFrameNo(uint8_t frameNo);
466 /**
467 * NACK a frame.
468 *
469 * \param frame The data frame number being NACKed.
470 */
471 void AddNackedFrame(uint8_t frame);
472
473 /**
474 * Get the set of NACK'ed frames.
475 *
476 * \return The set of NACK'ed frames.
477 */
478 const std::set<uint8_t>& GetNackedFrames() const;
479 /**
480 * Get the reservation frame number being ACKed.
481 *
482 * \return The frame number.
483 */
484 uint8_t GetFrameNo() const;
485 /**
486 * Get the number of data frames being NACKed.
487 *
488 * \return The number of NACKed frames.
489 */
490 uint8_t GetNoNacks() const;
491
492 // Inherited methods
493 uint32_t GetSerializedSize() const override;
494 void Serialize(Buffer::Iterator start) const override;
495 uint32_t Deserialize(Buffer::Iterator start) override;
496 void Print(std::ostream& os) const override;
497 TypeId GetInstanceTypeId() const override;
498
499 private:
500 uint8_t m_frameNo; //!< Next frame number.
501 std::set<uint8_t> m_nackedFrames; //!< Marker for nacked frames.
502
503}; // class UanHeaderRcAck
504
505} // namespace ns3
506
507#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:48
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.