A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
lr-wpan-mac-pl-headers.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2019 Ritsumeikan University, Shiga, Japan.
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Alberto Gallegos Ramonet <ramonet@fc.ritsumei.ac.jp>
7 */
8
9#ifndef LR_WPAN_MAC_PL_HEADERS_H
10#define LR_WPAN_MAC_PL_HEADERS_H
11
12#include "lr-wpan-fields.h"
13
14#include <ns3/header.h>
15#include <ns3/mac16-address.h>
16#include <ns3/mac64-address.h>
17
18namespace ns3
19{
20namespace lrwpan
21{
22
23/**
24 * \ingroup lr-wpan
25 * Implements the header for the MAC payload beacon frame according to
26 * the IEEE 802.15.4-2011 Std.
27 */
29{
30 public:
32 /**
33 * \brief Get the type ID.
34 * \return the object TypeId
35 */
36 static TypeId GetTypeId();
37 TypeId GetInstanceTypeId() const override;
38 uint32_t GetSerializedSize() const override;
39 void Serialize(Buffer::Iterator start) const override;
41 void Print(std::ostream& os) const override;
42 /**
43 * Set the superframe specification field to the beacon payload header.
44 * \param sfrmField The superframe specification field (bitmap)
45 */
46 void SetSuperframeSpecField(uint16_t sfrmField);
47 /**
48 * Set the superframe Guaranteed Time Slot (GTS) fields to the beacon payload header.
49 * \param gtsFields The GTS fields.
50 */
51 void SetGtsFields(GtsFields gtsFields);
52 /**
53 * Set the superframe Pending Address fields to the beacon payload header.
54 * \param pndAddrFields The Pending Address fields.
55 */
56 void SetPndAddrFields(PendingAddrFields pndAddrFields);
57 /**
58 * Get the superframe specification field from the beacon payload header.
59 * \return The superframe specification field (bitmap)
60 */
61 uint16_t GetSuperframeSpecField() const;
62 /**
63 * Get the Guaranteed Time Slots (GTS) fields from the beacon payload header.
64 * \return The GTS fields.
65 */
66 GtsFields GetGtsFields() const;
67 /**
68 * Get the pending address fields from the beacon payload header.
69 * \return The Pending Address fields.
70 */
72
73 private:
74 /**
75 * Superframe Specification Field
76 */
78 /**
79 * GTS Fields
80 */
82 /**
83 * Pending Address Fields
84 */
86};
87
88/**
89 * \ingroup lr-wpan
90 * Implements the header for the MAC payload command frame according to
91 * the IEEE 802.15.4-2011 Std.
92 * - Association Response Command (See 5.3.2.2.)
93 * - Coordinator Realigment Command (See 5.3.8.)
94 * - Association Request Command (See 5.3.1.)
95 */
97{
98 public:
99 /**
100 * The MAC command frames.
101 * See IEEE 802.15.4-2011, Table 5
102 */
104 {
105 ASSOCIATION_REQ = 0x01, //!< Association request (RFD true: Tx)
106 ASSOCIATION_RESP = 0x02, //!< Association response (RFD true: Rx)
107 DISASSOCIATION_NOTIF = 0x03, //!< Disassociation notification (RFD true: TX, Rx)
108 DATA_REQ = 0x04, //!< Data Request (RFD true: Tx)
109 PANID_CONFLICT = 0x05, //!< Pan ID conflict notification (RFD true: Tx)
110 ORPHAN_NOTIF = 0x06, //!< Orphan Notification (RFD true: Tx)
111 BEACON_REQ = 0x07, //!< Beacon Request (RFD true: none )
112 COOR_REALIGN = 0x08, //!< Coordinator Realignment (RFD true: Rx)
113 GTS_REQ = 0x09, //!< GTS Request (RFD true: none)
114 CMD_RESERVED = 0xff //!< Reserved
115 };
116
118 /**
119 * Constructor
120 * \param macCmd the command type of this command header
121 */
122 CommandPayloadHeader(MacCommand macCmd);
123 /**
124 * \brief Get the type ID.
125 * \return the object TypeId
126 */
127 static TypeId GetTypeId();
128 TypeId GetInstanceTypeId() const override;
129 uint32_t GetSerializedSize() const override;
130 void Serialize(Buffer::Iterator start) const override;
131 uint32_t Deserialize(Buffer::Iterator start) override;
132 void Print(std::ostream& os) const override;
133
134 /**
135 * Set the command frame type
136 * \param macCmd the command frame type
137 */
138 void SetCommandFrameType(MacCommand macCmd);
139 /**
140 * Set the Capability Information Field to the command payload header (Association Request
141 * Command).
142 * \param cap The capability Information field
143 */
144 void SetCapabilityField(uint8_t cap);
145 /**
146 * Set the coordinator short address (16 bit address).
147 * \param addr The coordinator short address.
148 */
150 /**
151 * Set the logical channel number.
152 * \param channel The channel number.
153 */
154 void SetChannel(uint8_t channel);
155 /**
156 * Set the logical channel page number.
157 * \param page The page number.
158 */
159 void SetPage(uint8_t page);
160 /**
161 * Get the PAN identifier.
162 * \param id The PAN identifier.
163 */
164 void SetPanId(uint16_t id);
165 /**
166 * Set the Short Address Assigned by the coordinator
167 * (Association Response and Coordinator Realigment Commands).
168 * \param shortAddr The short address assigned by the coordinator
169 */
170 void SetShortAddr(Mac16Address shortAddr);
171 /**
172 * Set status resulting from the association attempt (Association Response Command).
173 * \param status The status resulting from the association attempt
174 */
175 void SetAssociationStatus(uint8_t status);
176 /**
177 * Get the Short address assigned by the coordinator
178 * (Association Response and Coordinator Realigment commands).
179 * \return The Mac16Address assigned by the coordinator
180 */
182 /**
183 * Get the status resulting from an association request (Association Response Command).
184 * \return The resulting status from an association request
185 */
186 uint8_t GetAssociationStatus() const;
187 /**
188 * Get the command frame type ID
189 * \return The command type ID from the command payload header
190 */
191 MacCommand GetCommandFrameType() const;
192 /**
193 * Get the Capability Information Field from the command payload header.
194 * (Association Request Command)
195 * \return The Capability Information Field (8 bit bitmap)
196 */
197 uint8_t GetCapabilityField() const;
198 /**
199 * Get the coordinator short address.
200 * \return The coordinator short address (16 bit address)
201 */
203 /**
204 * Get the logical channel number.
205 * \return The channel number
206 */
207 uint8_t GetChannel() const;
208 /**
209 * Get the logical channel page number.
210 * \return The page number.
211 */
212 uint8_t GetPage() const;
213 /**
214 * Get the PAN identifier.
215 * \return The PAN Identifier
216 */
217 uint16_t GetPanId() const;
218
219 private:
220 MacCommand m_cmdFrameId; //!< The command Frame Identifier (Used by all commands)
221 uint8_t m_capabilityInfo; //!< Capability Information Field
222 //!< (Association Request Command)
223 Mac16Address m_shortAddr; //!< Contains the short address assigned by the coordinator
224 //!< (Association Response and Coordinator Realiagment Command)
225 Mac16Address m_coordShortAddr; //!< The coordinator short address
226 //!< (Coordinator realigment command)
227 uint16_t m_panid; //!< The PAN identifier (Coordinator realigment command)
228 uint8_t m_logCh; //!< The channel number (Coordinator realigment command)
229 uint8_t m_logChPage; //!< The channel page number (Coordinator realigment command)
230 uint8_t m_assocStatus; //!< Association Status (Association Response Command)
231};
232
233} // namespace lrwpan
234} // namespace ns3
235
236#endif /* LR_WPAN_MAC_PL_HEADERS_H */
iterator in a Buffer instance
Definition buffer.h:89
Protocol header serialization and deserialization.
Definition header.h:33
This class can contain 16 bit addresses.
a unique identifier for an interface.
Definition type-id.h:48
Implements the header for the MAC payload beacon frame according to the IEEE 802.15....
static TypeId GetTypeId()
Get the type ID.
void SetSuperframeSpecField(uint16_t sfrmField)
Set the superframe specification field to the beacon payload header.
uint16_t GetSuperframeSpecField() const
Get the superframe specification field from the beacon payload header.
GtsFields GetGtsFields() const
Get the Guaranteed Time Slots (GTS) fields from the beacon payload header.
uint32_t GetSerializedSize() const override
void SetGtsFields(GtsFields gtsFields)
Set the superframe Guaranteed Time Slot (GTS) fields to the beacon payload header.
PendingAddrFields GetPndAddrFields() const
Get the pending address fields from the beacon payload header.
uint16_t m_superframeField
Superframe Specification Field.
void Serialize(Buffer::Iterator start) const override
void Print(std::ostream &os) const override
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
uint32_t Deserialize(Buffer::Iterator start) override
PendingAddrFields m_pndAddrFields
Pending Address Fields.
void SetPndAddrFields(PendingAddrFields pndAddrFields)
Set the superframe Pending Address fields to the beacon payload header.
Implements the header for the MAC payload command frame according to the IEEE 802....
uint16_t m_panid
The PAN identifier (Coordinator realigment command)
MacCommand GetCommandFrameType() const
Get the command frame type ID.
Mac16Address GetShortAddr() const
Get the Short address assigned by the coordinator (Association Response and Coordinator Realigment co...
void Print(std::ostream &os) const override
uint8_t GetChannel() const
Get the logical channel number.
Mac16Address m_coordShortAddr
The coordinator short address (Coordinator realigment command)
uint16_t GetPanId() const
Get the PAN identifier.
void SetPage(uint8_t page)
Set the logical channel page number.
void SetShortAddr(Mac16Address shortAddr)
Set the Short Address Assigned by the coordinator (Association Response and Coordinator Realigment Co...
uint8_t GetCapabilityField() const
Get the Capability Information Field from the command payload header.
void SetCommandFrameType(MacCommand macCmd)
Set the command frame type.
Mac16Address GetCoordShortAddr() const
Get the coordinator short address.
MacCommand m_cmdFrameId
The command Frame Identifier (Used by all commands)
void SetCapabilityField(uint8_t cap)
Set the Capability Information Field to the command payload header (Association Request Command).
void SetCoordShortAddr(Mac16Address addr)
Set the coordinator short address (16 bit address).
void Serialize(Buffer::Iterator start) const override
uint8_t m_logChPage
The channel page number (Coordinator realigment command)
uint32_t GetSerializedSize() const override
uint32_t Deserialize(Buffer::Iterator start) override
uint8_t GetPage() const
Get the logical channel page number.
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
@ ASSOCIATION_RESP
Association response (RFD true: Rx)
@ PANID_CONFLICT
Pan ID conflict notification (RFD true: Tx)
@ DISASSOCIATION_NOTIF
Disassociation notification (RFD true: TX, Rx)
@ DATA_REQ
Data Request (RFD true: Tx)
@ COOR_REALIGN
Coordinator Realignment (RFD true: Rx)
@ GTS_REQ
GTS Request (RFD true: none)
@ ORPHAN_NOTIF
Orphan Notification (RFD true: Tx)
@ ASSOCIATION_REQ
Association request (RFD true: Tx)
@ BEACON_REQ
Beacon Request (RFD true: none )
Mac16Address m_shortAddr
Contains the short address assigned by the coordinator (Association Response and Coordinator Realiagm...
void SetAssociationStatus(uint8_t status)
Set status resulting from the association attempt (Association Response Command).
uint8_t GetAssociationStatus() const
Get the status resulting from an association request (Association Response Command).
void SetPanId(uint16_t id)
Get the PAN identifier.
void SetChannel(uint8_t channel)
Set the logical channel number.
uint8_t m_capabilityInfo
Capability Information Field (Association Request Command)
uint8_t m_logCh
The channel number (Coordinator realigment command)
static TypeId GetTypeId()
Get the type ID.
uint8_t m_assocStatus
Association Status (Association Response Command)
Represent the GTS information fields.
Represent the Pending Address Specification field.
Every class exported by the ns3 library is enclosed in the ns3 namespace.