A Discrete-Event Network Simulator
API
ofdm-downlink-frame-prefix.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2007,2008 INRIA
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: Jahanzeb Farooq <jahanzeb.farooq@sophia.inria.fr>
18 */
19
21
22#include "ns3/address-utils.h"
23
24#include <stdint.h>
25
26namespace ns3
27{
28
30 : m_rateId(0),
31 m_diuc(0),
32 m_preamblePresent(0),
33 m_length(0),
34 m_startTime(0)
35{
36}
37
39{
40}
41
42void
44{
45 m_rateId = rateId;
46}
47
48void
50{
51 m_diuc = diuc;
52}
53
54void
56{
57 m_preamblePresent = preamblePresent;
58}
59
60void
62{
63 m_length = length;
64}
65
66void
68{
69 m_startTime = startTime;
70}
71
72uint8_t
74{
75 return m_rateId;
76}
77
78uint8_t
80{
81 return m_diuc;
82}
83
84uint8_t
86{
87 return m_preamblePresent;
88}
89
90uint16_t
92{
93 return m_length;
94}
95
96uint16_t
98{
99 return m_startTime;
100}
101
102uint16_t
104{
105 return 1 + 1 + 1 + 2 + 2;
106}
107
110{
112 i.WriteU8(m_rateId);
113 i.WriteU8(m_diuc);
117 return i;
118}
119
122{
124 m_rateId = i.ReadU8();
125 m_diuc = i.ReadU8();
127 m_length = i.ReadU16();
128 m_startTime = i.ReadU16();
129 return i;
130}
131
133 : m_baseStationId(Mac48Address("00:00:00:00:00:00")),
134 m_frameNumber(0),
135 m_configurationChangeCount(0),
136 m_hcs(0)
137{
138}
139
141{
142}
143
144/* static */
145TypeId
147{
148 static TypeId tid =
149 TypeId("ns3::OfdmDownlinkFramePrefix").SetParent<Header>().SetGroupName("Wimax")
150 // No AddConstructor because this is an abstract class.
151 ;
152 return tid;
153}
154
155void
157{
158 m_baseStationId = baseStationId;
159}
160
161void
163{
164 m_frameNumber = frameNumber;
165}
166
167void
169{
170 m_configurationChangeCount = configurationChangeCount;
171}
172
173void
175{
176 m_dlFramePrefixElements.push_back(dlFramePrefixElement);
177}
178
179void
181{
182 m_hcs = hcs;
183}
184
187{
188 return m_baseStationId;
189}
190
193{
194 return m_frameNumber;
195}
196
197uint8_t
199{
201}
202
203std::vector<DlFramePrefixIe>
205{
207}
208
209uint8_t
211{
212 return m_hcs;
213}
214
215std::string
217{
218 return "OFDM Downlink Frame Prefix";
219}
220
221void
222OfdmDownlinkFramePrefix::Print(std::ostream& os) const
223{
224 os << " base station id = " << m_baseStationId << ", frame number = " << m_frameNumber
225 << ", configuration change count = " << (uint32_t)m_configurationChangeCount
226 << ", number of dl frame prefix elements = " << m_dlFramePrefixElements.size()
227 << ", hcs = " << (uint32_t)m_hcs;
228}
229
232{
233 int dlFramePrefixElementsSize = 0;
234
235 for (std::vector<DlFramePrefixIe>::const_iterator iter = m_dlFramePrefixElements.begin();
236 iter != m_dlFramePrefixElements.end();
237 iter++)
238 {
239 DlFramePrefixIe dlFramePrefixElement = *iter;
240 dlFramePrefixElementsSize += dlFramePrefixElement.GetSize();
241 }
242
243 return 6 + 4 + 1 + dlFramePrefixElementsSize + 1;
244}
245
246void
248{
253
254 for (std::vector<DlFramePrefixIe>::const_iterator iter = m_dlFramePrefixElements.begin();
255 iter != m_dlFramePrefixElements.end();
256 iter++)
257 {
258 DlFramePrefixIe dlFramePrefixElement = *iter;
259 i = dlFramePrefixElement.Write(i);
260 }
261
262 i.WriteU8(m_hcs);
263}
264
267{
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
iterator in a Buffer instance
Definition: buffer.h:100
void WriteU32(uint32_t data)
Definition: buffer.cc:871
uint8_t ReadU8()
Definition: buffer.h:1027
void WriteU8(uint8_t data)
Definition: buffer.h:881
void WriteU16(uint16_t data)
Definition: buffer.cc:862
uint32_t ReadU32()
Definition: buffer.cc:969
uint16_t ReadU16()
Definition: buffer.h:1035
This class implements the DL Frame Prefix IE as described by IEEE-802.16 standard.
uint8_t GetDiuc() const
Get DIUC field.
uint8_t m_preamblePresent
preamble present
uint16_t GetStartTime() const
Get start time field.
uint8_t GetPreamblePresent() const
Get preamble present field.
uint16_t GetLength() const
Get length field.
uint8_t GetRateId() const
Get rate ID field.
void SetStartTime(uint16_t startTime)
Set start time 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.
Buffer::Iterator Write(Buffer::Iterator start) const
Write item function.
uint16_t GetSize() const
Get size field.
void SetRateId(uint8_t rateId)
Set rate ID field.
Protocol header serialization and deserialization.
Definition: header.h:44
an EUI-48 address
Definition: mac48-address.h:46
a unique identifier for an interface.
Definition: type-id.h:60
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:935
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:1861