Loading...
Searching...
No Matches
lorawan-mac-command.h
Go to the documentation of this file.
1/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2017 University of Padova
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: Davide Magrin <magrinda@dei.unipd.it>
19 *
20 * Modified by: Bastien Tauran <bastien.tauran@viveris.fr>
21 */
22
23#ifndef LORAWAN_MAC_COMMAND_H
24#define LORAWAN_MAC_COMMAND_H
25
26#include "ns3/buffer.h"
27#include "ns3/nstime.h"
28#include "ns3/object.h"
29
30#include <list>
31#include <ostream>
32#include <stdint.h>
33
34namespace ns3
35{
36
62
70class LorawanMacCommand : public Object
71{
72 public:
73 static TypeId GetTypeId(void);
74
76 virtual ~LorawanMacCommand();
77
84 virtual void Serialize(Buffer::Iterator& start) const = 0;
85
92 virtual uint8_t Deserialize(Buffer::Iterator& start) = 0;
93
99 virtual void Print(std::ostream& os) const = 0;
100
106 virtual uint8_t GetSerializedSize(void) const;
107
113 virtual enum MacCommandType GetCommandType(void) const;
114
120 static uint8_t GetCIDFromLorawanMacCommand(enum MacCommandType commandType);
121
122 protected:
127
132};
133
140{
141 public:
142 LinkCheckReq();
144 virtual void Serialize(Buffer::Iterator& start) const;
145 virtual uint8_t Deserialize(Buffer::Iterator& start);
146 virtual void Print(std::ostream& os) const;
147};
148
156{
157 public:
158 LinkCheckAns();
159 LinkCheckAns(uint8_t margin, uint8_t gwCnt);
160
161 virtual void Serialize(Buffer::Iterator& start) const;
162 virtual uint8_t Deserialize(Buffer::Iterator& start);
163 virtual void Print(std::ostream& os) const;
164
170 void SetMargin(uint8_t margin);
171
177 uint8_t GetMargin(void) const;
178
184 void SetGwCnt(uint8_t gwCnt);
185
191 uint8_t GetGwCnt(void) const;
192
196 void IncrementGwCnt(void);
197
198 private:
202 uint8_t m_margin;
203
207 uint8_t m_gwCnt;
208};
209
218{
219 public:
220 LinkAdrReq();
221
222 LinkAdrReq(uint8_t dataRate,
223 uint8_t txPower,
224 uint16_t channelMask,
225 uint8_t chMaskCntl,
226 uint8_t nbRep);
227
228 virtual void Serialize(Buffer::Iterator& start) const;
229 virtual uint8_t Deserialize(Buffer::Iterator& start);
230 virtual void Print(std::ostream& os) const;
231
237 uint8_t GetDataRate(void);
238
248 uint8_t GetTxPower(void);
249
256 std::list<int> GetEnabledChannelsList(void);
257
263 int GetRepetitions(void);
264
265 private:
266 uint8_t m_dataRate;
267 uint8_t m_txPower;
270 uint8_t m_nbRep;
271};
272
279{
280 public:
281 LinkAdrAns();
282
283 LinkAdrAns(bool powerAck, bool dataRateAck, bool channelMaskAck);
284
285 virtual void Serialize(Buffer::Iterator& start) const;
286 virtual uint8_t Deserialize(Buffer::Iterator& start);
287 virtual void Print(std::ostream& os) const;
288
289 private:
293};
294
303{
304 public:
305 DutyCycleReq();
311 DutyCycleReq(uint8_t dutyCycle);
312
313 virtual void Serialize(Buffer::Iterator& start) const;
314 virtual uint8_t Deserialize(Buffer::Iterator& start);
315 virtual void Print(std::ostream& os) const;
316
322 double GetMaximumAllowedDutyCycle(void) const;
323
324 private:
325 uint8_t m_maxDCycle;
326};
327
334{
335 public:
336 DutyCycleAns();
337
338 virtual void Serialize(Buffer::Iterator& start) const;
339 virtual uint8_t Deserialize(Buffer::Iterator& start);
340 virtual void Print(std::ostream& os) const;
341};
342
347{
348 public:
350
358 RxParamSetupReq(uint8_t rx1DrOffset, uint8_t rx2DataRate, double frequency);
359
360 virtual void Serialize(Buffer::Iterator& start) const;
361 virtual uint8_t Deserialize(Buffer::Iterator& start);
362 virtual void Print(std::ostream& os) const;
363
369 uint8_t GetRx1DrOffset(void);
370
376 uint8_t GetRx2DataRate(void);
377
383 double GetFrequency(void);
384
385 private:
388 double m_frequency;
389};
390
395{
396 public:
405 RxParamSetupAns(bool rx1DrOffsetAck, bool rx2DataRateAck, bool channelAck);
406
407 virtual void Serialize(Buffer::Iterator& start) const;
408 virtual uint8_t Deserialize(Buffer::Iterator& start);
409 virtual void Print(std::ostream& os) const;
410
411 private:
415};
416
421{
422 public:
423 DevStatusReq();
424
425 virtual void Serialize(Buffer::Iterator& start) const;
426 virtual uint8_t Deserialize(Buffer::Iterator& start);
427 virtual void Print(std::ostream& os) const;
428};
429
434{
435 public:
436 DevStatusAns();
443 DevStatusAns(uint8_t battery, uint8_t margin);
444
445 virtual void Serialize(Buffer::Iterator& start) const;
446 virtual uint8_t Deserialize(Buffer::Iterator& start);
447 virtual void Print(std::ostream& os) const;
448
454 uint8_t GetBattery(void);
455
461 uint8_t GetMargin(void);
462
463 private:
464 uint8_t m_battery;
465 uint8_t m_margin;
466};
467
472{
473 public:
475
484 NewChannelReq(uint8_t chIndex, double frequency, uint8_t minDataRate, uint8_t maxDataRate);
485
486 virtual void Serialize(Buffer::Iterator& start) const;
487 virtual uint8_t Deserialize(Buffer::Iterator& start);
488 virtual void Print(std::ostream& os) const;
489
490 uint8_t GetChannelIndex(void);
491 double GetFrequency(void);
492 uint8_t GetMinDataRate(void);
493 uint8_t GetMaxDataRate(void);
494
495 private:
496 uint8_t m_chIndex;
500};
501
506{
507 public:
509
518 NewChannelAns(bool dataRateRangeOk, bool channelFrequencyOk);
519
520 virtual void Serialize(Buffer::Iterator& start) const;
521 virtual uint8_t Deserialize(Buffer::Iterator& start);
522 virtual void Print(std::ostream& os) const;
523
524 private:
527};
528
533{
534 public:
536
542 RxTimingSetupReq(uint8_t delay);
543
544 virtual void Serialize(Buffer::Iterator& start) const;
545 virtual uint8_t Deserialize(Buffer::Iterator& start);
546 virtual void Print(std::ostream& os) const;
547
553 Time GetDelay(void);
554
555 private:
556 uint8_t m_delay;
557};
558
565{
566 public:
568
569 virtual void Serialize(Buffer::Iterator& start) const;
570 virtual uint8_t Deserialize(Buffer::Iterator& start);
571 virtual void Print(std::ostream& os) const;
572
573 private:
574};
575
580{
581 public:
583
584 virtual void Serialize(Buffer::Iterator& start) const;
585 virtual uint8_t Deserialize(Buffer::Iterator& start);
586 virtual void Print(std::ostream& os) const;
587
588 private:
589};
590
595{
596 public:
598
599 virtual void Serialize(Buffer::Iterator& start) const;
600 virtual uint8_t Deserialize(Buffer::Iterator& start);
601 virtual void Print(std::ostream& os) const;
602
603 private:
604};
605
610{
611 public:
612 DlChannelAns();
613
614 virtual void Serialize(Buffer::Iterator& start) const;
615 virtual uint8_t Deserialize(Buffer::Iterator& start);
616 virtual void Print(std::ostream& os) const;
617
618 private:
619};
620
621} // namespace ns3
622
623#endif /* LORAWAN_MAC_COMMAND_H */
virtual void Print(std::ostream &os) const
Print the contents of this MAC command in human-readable format.
uint8_t GetBattery(void)
Get the battery information contained in this MAC command.
virtual uint8_t Deserialize(Buffer::Iterator &start)
Deserialize the buffer into a MAC command.
uint8_t GetMargin(void)
Get the demodulation margin contained in this MAC command.
virtual void Serialize(Buffer::Iterator &start) const
Serialize the contents of this MAC command into a buffer, according to the LoRaWAN standard.
virtual uint8_t Deserialize(Buffer::Iterator &start)
Deserialize the buffer into a MAC command.
virtual void Print(std::ostream &os) const
Print the contents of this MAC command in human-readable format.
virtual void Serialize(Buffer::Iterator &start) const
Serialize the contents of this MAC command into a buffer, according to the LoRaWAN standard.
virtual void Print(std::ostream &os) const
Print the contents of this MAC command in human-readable format.
virtual uint8_t Deserialize(Buffer::Iterator &start)
Deserialize the buffer into a MAC command.
virtual void Serialize(Buffer::Iterator &start) const
Serialize the contents of this MAC command into a buffer, according to the LoRaWAN standard.
virtual void Print(std::ostream &os) const
Print the contents of this MAC command in human-readable format.
virtual uint8_t Deserialize(Buffer::Iterator &start)
Deserialize the buffer into a MAC command.
virtual void Serialize(Buffer::Iterator &start) const
Serialize the contents of this MAC command into a buffer, according to the LoRaWAN standard.
virtual void Serialize(Buffer::Iterator &start) const
Serialize the contents of this MAC command into a buffer, according to the LoRaWAN standard.
virtual void Print(std::ostream &os) const
Print the contents of this MAC command in human-readable format.
virtual uint8_t Deserialize(Buffer::Iterator &start)
Deserialize the buffer into a MAC command.
double GetMaximumAllowedDutyCycle(void) const
Get the maximum duty cycle prescribed by this Mac command, in fraction form.
static uint8_t GetCIDFromLorawanMacCommand(enum MacCommandType commandType)
Get the CID that corresponds to this MAC command.
virtual uint8_t Deserialize(Buffer::Iterator &start)=0
Deserialize the buffer into a MAC command.
enum MacCommandType m_commandType
The type of this command.
virtual uint8_t GetSerializedSize(void) const
Get serialized length of this MAC command.
virtual void Print(std::ostream &os) const =0
Print the contents of this MAC command in human-readable format.
static TypeId GetTypeId(void)
virtual enum MacCommandType GetCommandType(void) const
Get the commandType of this MAC command.
uint8_t m_serializedSize
This MAC command's serialized size.
virtual void Serialize(Buffer::Iterator &start) const =0
Serialize the contents of this MAC command into a buffer, according to the LoRaWAN standard.
virtual uint8_t Deserialize(Buffer::Iterator &start)
Deserialize the buffer into a MAC command.
virtual void Serialize(Buffer::Iterator &start) const
Serialize the contents of this MAC command into a buffer, according to the LoRaWAN standard.
virtual void Print(std::ostream &os) const
Print the contents of this MAC command in human-readable format.
virtual void Serialize(Buffer::Iterator &start) const
Serialize the contents of this MAC command into a buffer, according to the LoRaWAN standard.
virtual void Print(std::ostream &os) const
Print the contents of this MAC command in human-readable format.
virtual uint8_t Deserialize(Buffer::Iterator &start)
Deserialize the buffer into a MAC command.
virtual void Print(std::ostream &os) const
Print the contents of this MAC command in human-readable format.
virtual void Serialize(Buffer::Iterator &start) const
Serialize the contents of this MAC command into a buffer, according to the LoRaWAN standard.
virtual uint8_t Deserialize(Buffer::Iterator &start)
Deserialize the buffer into a MAC command.
double m_frequency
The frequency in Hz.
uint8_t GetRx1DrOffset(void)
Get this command's Rx1DrOffset parameter.
virtual void Print(std::ostream &os) const
Print the contents of this MAC command in human-readable format.
uint8_t GetRx2DataRate(void)
Get this command's Rx2DataRate parameter.
virtual uint8_t Deserialize(Buffer::Iterator &start)
Deserialize the buffer into a MAC command.
virtual void Serialize(Buffer::Iterator &start) const
Serialize the contents of this MAC command into a buffer, according to the LoRaWAN standard.
double GetFrequency(void)
Get this command's frequency.
virtual void Print(std::ostream &os) const
Print the contents of this MAC command in human-readable format.
virtual uint8_t Deserialize(Buffer::Iterator &start)
Deserialize the buffer into a MAC command.
virtual void Serialize(Buffer::Iterator &start) const
Serialize the contents of this MAC command into a buffer, according to the LoRaWAN standard.
virtual void Serialize(Buffer::Iterator &start) const
Serialize the contents of this MAC command into a buffer, according to the LoRaWAN standard.
virtual uint8_t Deserialize(Buffer::Iterator &start)
Deserialize the buffer into a MAC command.
Time GetDelay(void)
Get the first window delay as a Time instance.
virtual void Print(std::ostream &os) const
Print the contents of this MAC command in human-readable format.
virtual void Serialize(Buffer::Iterator &start) const
Serialize the contents of this MAC command into a buffer, according to the LoRaWAN standard.
virtual void Print(std::ostream &os) const
Print the contents of this MAC command in human-readable format.
virtual uint8_t Deserialize(Buffer::Iterator &start)
Deserialize the buffer into a MAC command.
virtual void Serialize(Buffer::Iterator &start) const
Serialize the contents of this MAC command into a buffer, according to the LoRaWAN standard.
virtual void Print(std::ostream &os) const
Print the contents of this MAC command in human-readable format.
virtual uint8_t Deserialize(Buffer::Iterator &start)
Deserialize the buffer into a MAC command.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.
MacCommandType
Enum for every possible command type.
@ RX_TIMING_SETUP_REQ
@ RX_TIMING_SETUP_ANS