A Discrete-Event Network Simulator
API
ofdm-downlink-frame-prefix.cc
Go to the documentation of this file.
1/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2007,2008 INRIA
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: Jahanzeb Farooq <jahanzeb.farooq@sophia.inria.fr>
19 */
20
21#include <stdint.h>
23#include "ns3/address-utils.h"
24
25namespace ns3 {
26
28 : m_rateId (0),
29 m_diuc (0),
30 m_preamblePresent (0),
31 m_length (0),
32 m_startTime (0)
33{
34}
35
37{
38}
39
40void
42{
43 m_rateId = rateId;
44}
45
46void
48{
49 m_diuc = diuc;
50}
51
52void
53DlFramePrefixIe::SetPreamblePresent (uint8_t preamblePresent)
54{
55 m_preamblePresent = preamblePresent;
56}
57
58void
60{
61 m_length = length;
62}
63
64void
66{
67 m_startTime = startTime;
68}
69
70uint8_t
72{
73 return m_rateId;
74}
75
76uint8_t
78{
79 return m_diuc;
80}
81
82uint8_t
84{
85 return m_preamblePresent;
86}
87
88uint16_t
90{
91 return m_length;
92}
93
94uint16_t
96{
97 return m_startTime;
98}
99
100uint16_t
102{
103 return 1 + 1 + 1 + 2 + 2;
104}
105
108{
110 i.WriteU8 (m_rateId);
111 i.WriteU8 (m_diuc);
113 i.WriteU16 (m_length);
115 return i;
116}
117
120{
122 m_rateId = i.ReadU8 ();
123 m_diuc = i.ReadU8 ();
125 m_length = i.ReadU16 ();
126 m_startTime = i.ReadU16 ();
127 return i;
128}
129
131 : m_baseStationId (Mac48Address ("00:00:00:00:00:00")),
132 m_frameNumber (0),
133 m_configurationChangeCount (0),
134 m_hcs (0)
135{
136}
137
139{
140}
141
142/* static */
143TypeId
145{
146 static TypeId tid = TypeId ("ns3::OfdmDownlinkFramePrefix")
147 .SetParent<Header> ()
148 .SetGroupName ("Wimax")
149 // No AddConstructor because this is an abstract class.
150 ;
151 return tid;
152}
153
154void
156{
157 m_baseStationId = baseStationId;
158}
159
160void
162{
163 m_frameNumber = frameNumber;
164}
165
166void
168 uint8_t configurationChangeCount)
169{
170 m_configurationChangeCount = configurationChangeCount;
171}
172
173void
175 DlFramePrefixIe dlFramePrefixElement)
176{
177 m_dlFramePrefixElements.push_back (dlFramePrefixElement);
178}
179
180void
182{
183 m_hcs = hcs;
184}
185
188{
189 return m_baseStationId;
190}
191
194{
195 return m_frameNumber;
196}
197
198uint8_t
200{
202}
203
204std::vector<DlFramePrefixIe>
206{
208}
209
210uint8_t
212{
213 return m_hcs;
214}
215
216std::string
218{
219 return "OFDM Downlink Frame Prefix";
220}
221
222void
223OfdmDownlinkFramePrefix::Print (std::ostream &os) const
224{
225 os << " base station id = " << m_baseStationId << ", frame number = "
226 << m_frameNumber << ", configuration change count = "
228 << ", number of dl frame prefix elements = "
229 << m_dlFramePrefixElements.size () << ", hcs = " << (uint32_t) m_hcs;
230}
231
234{
235 int dlFramePrefixElementsSize = 0;
236
237 for (std::vector<DlFramePrefixIe>::const_iterator iter =
238 m_dlFramePrefixElements.begin (); iter != m_dlFramePrefixElements.end (); iter++)
239 {
240 DlFramePrefixIe dlFramePrefixElement = *iter;
241 dlFramePrefixElementsSize += dlFramePrefixElement.GetSize ();
242 }
243
244 return 6 + 4 + 1 + dlFramePrefixElementsSize + 1;
245}
246
247void
249{
254
255 for (std::vector<DlFramePrefixIe>::const_iterator iter =
256 m_dlFramePrefixElements.begin (); iter != m_dlFramePrefixElements.end (); iter++)
257 {
258 DlFramePrefixIe dlFramePrefixElement = *iter;
259 i = dlFramePrefixElement.Write (i);
260 }
261
262 i.WriteU8 (m_hcs);
263}
264
267{
270 m_frameNumber = i.ReadU32 ();
272
273 bool end = false;
274
275 while (!end)
276 {
277 DlFramePrefixIe dlFramePrefixElement;
278 i = dlFramePrefixElement.Read (i);
279
280 AddDlFramePrefixElement (dlFramePrefixElement);
281
282 if (dlFramePrefixElement.GetDiuc () == 14)
283 {
284 end = true;
285 }
286 }
287
288 m_hcs = i.ReadU8 ();
289
290 return GetSerializedSize ();
291}
292
293} // namespace ns3
294
iterator in a Buffer instance
Definition: buffer.h:99
void WriteU32(uint32_t data)
Definition: buffer.cc:879
void WriteU8(uint8_t data)
Definition: buffer.h:869
void WriteU16(uint16_t data)
Definition: buffer.cc:871
uint16_t ReadU16(void)
Definition: buffer.h:1029
uint8_t ReadU8(void)
Definition: buffer.h:1021
uint32_t ReadU32(void)
Definition: buffer.cc:973
This class implements the DL Frame Prefix IE as described by IEEE-802.16 standard.
uint8_t GetPreamblePresent(void) const
Get preamble present field.
uint8_t m_preamblePresent
preamble present
uint16_t GetSize(void) const
Get size field.
void SetStartTime(uint16_t startTime)
Set start time field.
uint16_t GetLength(void) const
Get length field.
void SetDiuc(uint8_t diuc)
Set DIUC field.
void SetLength(uint16_t length)
Set length field.
Buffer::Iterator Read(Buffer::Iterator start)
Read item function.
void SetPreamblePresent(uint8_t preamblePresent)
Set preamble present field.
uint8_t GetDiuc(void) const
Get DIUC field.
uint8_t GetRateId(void) const
Get rate ID field.
Buffer::Iterator Write(Buffer::Iterator start) const
Write item function.
void SetRateId(uint8_t rateId)
Set rate ID field.
uint16_t GetStartTime(void) const
Get start time field.
Protocol header serialization and deserialization.
Definition: header.h:43
an EUI-48 address
Definition: mac48-address.h:44
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:922
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void WriteTo(Buffer::Iterator &i, Ipv4Address ad)
Write an Ipv4Address to a Buffer.
void ReadFrom(Buffer::Iterator &i, Ipv4Address &ad)
Read an Ipv4Address from a Buffer.
def start()
Definition: core.py:1852