A Discrete-Event Network Simulator
API
lr-wpan-mac-pl-headers.cc
Go to the documentation of this file.
1/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2020 Ritsumeikan University, Shiga, Japan.
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: Alberto Gallegos Ramonet <ramonet@fc.ritsumei.ac.jp>
19 */
20
22#include <ns3/simulator.h>
23
24namespace ns3 {
25
26/***********************************************************
27 * Beacon MAC Payload
28 ***********************************************************/
29
31{
32}
33
35
38{
39 static TypeId tid = TypeId ("ns3::BeaconPayloadHeader")
40 .SetParent<Header> ()
41 .SetGroupName ("LrWpan")
42 .AddConstructor<BeaconPayloadHeader> ()
43 ;
44 return tid;
45}
46
49{
50 return GetTypeId ();
51}
52
55{
56 uint32_t size = 0;
60
61 return size;
62}
63
64void
66{
69 i = m_gtsFields.Serialize (i);
71}
72
75{
80
81 return i.GetDistanceFrom (start);
82}
83
84
85void
86BeaconPayloadHeader::Print (std::ostream &os) const
87{
88 os << "| Superframe Spec Field | = " << m_superframeField
89 << "| GTS Spec Field | = " << m_gtsFields.GetGtsSpecField ()
90 << "| Pending Spec Field| =" << m_pndAddrFields.GetPndAddrSpecField ();
91}
92
93
94void
96{
98}
99
100void
102{
103 m_gtsFields = gtsFields;
104}
105
106void
108{
109 m_pndAddrFields = pndAddrFields;
110}
111
114{
115 return m_superframeField;
116}
117
120{
121 return m_gtsFields;
122}
123
126{
127 return m_pndAddrFields;
128}
129
130
131/***********************************************************
132 * Command MAC Payload
133 ***********************************************************/
134
136{
138}
139
140
142{
143 SetCommandFrameType (macCmd);
144}
145
147
148TypeId
150{
151 static TypeId tid = TypeId ("ns3::CommandPayloadHeader")
152 .SetParent<Header> ()
153 .SetGroupName ("LrWpan")
154 .AddConstructor<CommandPayloadHeader> ()
155 ;
156 return tid;
157}
158
159TypeId
161{
162 return GetTypeId ();
163}
164
167{
168 uint32_t size = 1;
169
170 return size;
171}
172
173void
175{
178}
179
182{
184 m_cmdFrameId = i.ReadU8 ();
185
186 return i.GetDistanceFrom (start);
187}
188
189void
190CommandPayloadHeader::Print (std::ostream &os) const
191{
192 os << "| MAC Command Frame ID | = " << (uint32_t) m_cmdFrameId;
193}
194
195void
197{
198 m_cmdFrameId = macCommand;
199}
200
201
204{
205 switch (m_cmdFrameId)
206 {
207 case 0x01:
208 return ASSOCIATION_REQ;
209 break;
210 case 0x02:
211 return ASSOCIATION_RESP;
212 break;
213 case 0x03:
215 break;
216 case 0x04:
217 return DATA_REQ;
218 break;
219 case 0x05:
220 return PANID_CONFLICT;
221 break;
222 case 0x06:
223 return ORPHAN_NOTIF;
224 break;
225 case 0x07:
226 return BEACON_REQ;
227 break;
228 case 0x08:
229 return COOR_REALIGN;
230 break;
231 case 0x09:
232 return GTS_REQ;
233 break;
234 default:
235 return CMD_RESERVED;
236 }
237}
238
239
240} // ns3 namespace
Implements the header for the MAC payload beacon frame according to the IEEE 802.15....
virtual void Serialize(Buffer::Iterator start) const
static TypeId GetTypeId(void)
Get the type ID.
GtsFields m_gtsFields
GTS Fields.
PendingAddrFields m_pndAddrFields
Pending Address Fields.
uint32_t Deserialize(Buffer::Iterator start)
GtsFields GetGtsFields(void) const
Get the Guaranteed Time Slots (GTS) fields from the beacon payload header.
SuperframeField m_superframeField
Superframe Specification Field.
SuperframeField GetSuperframeSpecField(void) const
Get the superframe specification field from the beacon payload header.
TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
void Print(std::ostream &os) const
void SetSuperframeSpecField(SuperframeField sfrmField)
Set the superframe specification field to the beacon payload header.
void SetGtsFields(GtsFields gtsFields)
Set the superframe Guaranteed Time Slot (GTS) fields to the beacon payload header.
PendingAddrFields GetPndAddrFields(void) const
Get the pending address fields from the beacon payload header.
void SetPndAddrFields(PendingAddrFields pndAddrFields)
Set the superframe Pending Address fields to the beacon payload header.
uint32_t GetSerializedSize(void) const
iterator in a Buffer instance
Definition: buffer.h:99
void WriteU8(uint8_t data)
Definition: buffer.h:869
uint8_t ReadU8(void)
Definition: buffer.h:1021
uint32_t GetDistanceFrom(Iterator const &o) const
Definition: buffer.cc:788
Implements the header for the MAC payload command frame according to the IEEE 802....
TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
uint8_t m_cmdFrameId
The command Frame Identifier.
uint32_t GetSerializedSize(void) const
virtual void Serialize(Buffer::Iterator start) const
MacCommand
The MAC command frames.
@ ASSOCIATION_RESP
Association response (RFD true: Rx)
@ BEACON_REQ
Beacon Request (RFD true: none )
@ DATA_REQ
Data Request (RFD true: Tx)
@ ORPHAN_NOTIF
Orphan Notification (RFD true: Tx)
@ ASSOCIATION_REQ
Association request (RFD true: Tx)
@ DISASSOCIATION_NOTIF
Disassociation notification (RFD true: TX, Rx)
@ COOR_REALIGN
Coordinator Realignment (RFD true: Rx)
@ PANID_CONFLICT
Pan ID conflict notification (RFD true: Tx)
@ GTS_REQ
GTS Request (RFD true: none)
void SetCommandFrameType(MacCommand macCmd)
Set the command frame type.
uint32_t Deserialize(Buffer::Iterator start)
void Print(std::ostream &os) const
MacCommand GetCommandFrameType(void) const
Get the command frame type.
static TypeId GetTypeId(void)
Get the type ID.
Represent the GTS information fields.
uint8_t GetGtsSpecField(void) const
Get the GTS Specification Field from the GTS Fields.
uint32_t GetSerializedSize(void) const
Get the size of the serialized GTS fields.
Buffer::Iterator Serialize(Buffer::Iterator i) const
Serialize the entire GTS fields.
Buffer::Iterator Deserialize(Buffer::Iterator i)
Deserialize the entire GTS fields.
Protocol header serialization and deserialization.
Definition: header.h:43
Represent the Pending Address Specification field.
Buffer::Iterator Deserialize(Buffer::Iterator i)
Deserialize the all the Pending Address Fields.
uint32_t GetSerializedSize(void) const
Get the size of the serialized Pending Address Fields.
Buffer::Iterator Serialize(Buffer::Iterator i) const
Serialize the entire Pending Address Fields.
uint8_t GetPndAddrSpecField(void) const
Get the whole Pending Address Specification Field from the Pending Address Fields.
Represent the Superframe Specification information field.
uint32_t GetSerializedSize(void) const
Get the size of the serialized Superframe specification information field.
Buffer::Iterator Serialize(Buffer::Iterator i) const
Serialize the entire superframe specification field.
Buffer::Iterator Deserialize(Buffer::Iterator i)
Deserialize the entire superframe specification field.
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:922
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
Every class exported by the ns3 library is enclosed in the ns3 namespace.
def start()
Definition: core.py:1853