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 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Alberto Gallegos Ramonet <ramonet@fc.ritsumei.ac.jp>
18 */
19
20#ifndef LR_WPAN_MAC_PL_HEADERS_H
21#define LR_WPAN_MAC_PL_HEADERS_H
22
23#include "lr-wpan-fields.h"
24
25#include <ns3/header.h>
26#include <ns3/mac16-address.h>
27#include <ns3/mac64-address.h>
28
29namespace ns3
30{
31namespace lrwpan
32{
33
34/**
35 * \ingroup lr-wpan
36 * Implements the header for the MAC payload beacon frame according to
37 * the IEEE 802.15.4-2011 Std.
38 */
40{
41 public:
43 /**
44 * \brief Get the type ID.
45 * \return the object TypeId
46 */
47 static TypeId GetTypeId();
48 TypeId GetInstanceTypeId() const override;
49 uint32_t GetSerializedSize() const override;
50 void Serialize(Buffer::Iterator start) const override;
52 void Print(std::ostream& os) const override;
53 /**
54 * Set the superframe specification field to the beacon payload header.
55 * \param sfrmField The superframe specification field (bitmap)
56 */
57 void SetSuperframeSpecField(uint16_t sfrmField);
58 /**
59 * Set the superframe Guaranteed Time Slot (GTS) fields to the beacon payload header.
60 * \param gtsFields The GTS fields.
61 */
62 void SetGtsFields(GtsFields gtsFields);
63 /**
64 * Set the superframe Pending Address fields to the beacon payload header.
65 * \param pndAddrFields The Pending Address fields.
66 */
67 void SetPndAddrFields(PendingAddrFields pndAddrFields);
68 /**
69 * Get the superframe specification field from the beacon payload header.
70 * \return The superframe specification field (bitmap)
71 */
72 uint16_t GetSuperframeSpecField() const;
73 /**
74 * Get the Guaranteed Time Slots (GTS) fields from the beacon payload header.
75 * \return The GTS fields.
76 */
77 GtsFields GetGtsFields() const;
78 /**
79 * Get the pending address fields from the beacon payload header.
80 * \return The Pending Address fields.
81 */
83
84 private:
85 /**
86 * Superframe Specification Field
87 */
89 /**
90 * GTS Fields
91 */
93 /**
94 * Pending Address Fields
95 */
97};
98
99/**
100 * \ingroup lr-wpan
101 * Implements the header for the MAC payload command frame according to
102 * the IEEE 802.15.4-2011 Std.
103 * - Association Response Command (See 5.3.2.2.)
104 * - Coordinator Realigment Command (See 5.3.8.)
105 * - Association Request Command (See 5.3.1.)
106 */
108{
109 public:
110 /**
111 * The MAC command frames.
112 * See IEEE 802.15.4-2011, Table 5
113 */
115 {
116 ASSOCIATION_REQ = 0x01, //!< Association request (RFD true: Tx)
117 ASSOCIATION_RESP = 0x02, //!< Association response (RFD true: Rx)
118 DISASSOCIATION_NOTIF = 0x03, //!< Disassociation notification (RFD true: TX, Rx)
119 DATA_REQ = 0x04, //!< Data Request (RFD true: Tx)
120 PANID_CONFLICT = 0x05, //!< Pan ID conflict notification (RFD true: Tx)
121 ORPHAN_NOTIF = 0x06, //!< Orphan Notification (RFD true: Tx)
122 BEACON_REQ = 0x07, //!< Beacon Request (RFD true: none )
123 COOR_REALIGN = 0x08, //!< Coordinator Realignment (RFD true: Rx)
124 GTS_REQ = 0x09, //!< GTS Request (RFD true: none)
125 CMD_RESERVED = 0xff //!< Reserved
126 };
127
129 /**
130 * Constructor
131 * \param macCmd the command type of this command header
132 */
134 /**
135 * \brief Get the type ID.
136 * \return the object TypeId
137 */
138 static TypeId GetTypeId();
139 TypeId GetInstanceTypeId() const override;
140 uint32_t GetSerializedSize() const override;
141 void Serialize(Buffer::Iterator start) const override;
142 uint32_t Deserialize(Buffer::Iterator start) override;
143 void Print(std::ostream& os) const override;
144
145 /**
146 * Set the command frame type
147 * \param macCmd the command frame type
148 */
149 void SetCommandFrameType(MacCommand macCmd);
150 /**
151 * Set the Capability Information Field to the command payload header (Association Request
152 * Command).
153 * \param cap The capability Information field
154 */
155 void SetCapabilityField(uint8_t cap);
156 /**
157 * Set the coordinator short address (16 bit address).
158 * \param addr The coordinator short address.
159 */
161 /**
162 * Set the logical channel number.
163 * \param channel The channel number.
164 */
165 void SetChannel(uint8_t channel);
166 /**
167 * Set the logical channel page number.
168 * \param page The page number.
169 */
170 void SetPage(uint8_t page);
171 /**
172 * Get the PAN identifier.
173 * \param id The PAN identifier.
174 */
175 void SetPanId(uint16_t id);
176 /**
177 * Set the Short Address Assigned by the coordinator
178 * (Association Response and Coordinator Realigment Commands).
179 * \param shortAddr The short address assigned by the coordinator
180 */
181 void SetShortAddr(Mac16Address shortAddr);
182 /**
183 * Set status resulting from the association attempt (Association Response Command).
184 * \param status The status resulting from the association attempt
185 */
186 void SetAssociationStatus(uint8_t status);
187 /**
188 * Get the Short address assigned by the coordinator
189 * (Association Response and Coordinator Realigment commands).
190 * \return The Mac16Address assigned by the coordinator
191 */
193 /**
194 * Get the status resulting from an association request (Association Response Command).
195 * \return The resulting status from an association request
196 */
197 uint8_t GetAssociationStatus() const;
198 /**
199 * Get the command frame type ID
200 * \return The command type ID from the command payload header
201 */
203 /**
204 * Get the Capability Information Field from the command payload header.
205 * (Association Request Command)
206 * \return The Capability Information Field (8 bit bitmap)
207 */
208 uint8_t GetCapabilityField() const;
209 /**
210 * Get the coordinator short address.
211 * \return The coordinator short address (16 bit address)
212 */
214 /**
215 * Get the logical channel number.
216 * \return The channel number
217 */
218 uint8_t GetChannel() const;
219 /**
220 * Get the logical channel page number.
221 * \return The page number.
222 */
223 uint8_t GetPage() const;
224 /**
225 * Get the PAN identifier.
226 * \return The PAN Identifier
227 */
228 uint16_t GetPanId() const;
229
230 private:
231 MacCommand m_cmdFrameId; //!< The command Frame Identifier (Used by all commands)
232 uint8_t m_capabilityInfo; //!< Capability Information Field
233 //!< (Association Request Command)
234 Mac16Address m_shortAddr; //!< Contains the short address assigned by the coordinator
235 //!< (Association Response and Coordinator Realiagment Command)
236 Mac16Address m_coordShortAddr; //!< The coordinator short address
237 //!< (Coordinator realigment command)
238 uint16_t m_panid; //!< The PAN identifier (Coordinator realigment command)
239 uint8_t m_logCh; //!< The channel number (Coordinator realigment command)
240 uint8_t m_logChPage; //!< The channel page number (Coordinator realigment command)
241 uint8_t m_assocStatus; //!< Association Status (Association Response Command)
242};
243
244} // namespace lrwpan
245} // namespace ns3
246
247#endif /* LR_WPAN_MAC_PL_HEADERS_H */
iterator in a Buffer instance
Definition: buffer.h:100
Protocol header serialization and deserialization.
Definition: header.h:44
This class can contain 16 bit addresses.
Definition: mac16-address.h:44
a unique identifier for an interface.
Definition: type-id.h:59
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.