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 
26 namespace 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 
42 void
44 {
45  m_rateId = rateId;
46 }
47 
48 void
50 {
51  m_diuc = diuc;
52 }
53 
54 void
55 DlFramePrefixIe::SetPreamblePresent(uint8_t preamblePresent)
56 {
57  m_preamblePresent = preamblePresent;
58 }
59 
60 void
62 {
63  m_length = length;
64 }
65 
66 void
67 DlFramePrefixIe::SetStartTime(uint16_t startTime)
68 {
69  m_startTime = startTime;
70 }
71 
72 uint8_t
74 {
75  return m_rateId;
76 }
77 
78 uint8_t
80 {
81  return m_diuc;
82 }
83 
84 uint8_t
86 {
87  return m_preamblePresent;
88 }
89 
90 uint16_t
92 {
93  return m_length;
94 }
95 
96 uint16_t
98 {
99  return m_startTime;
100 }
101 
102 uint16_t
104 {
105  return 1 + 1 + 1 + 2 + 2;
106 }
107 
110 {
112  i.WriteU8(m_rateId);
113  i.WriteU8(m_diuc);
115  i.WriteU16(m_length);
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 */
145 TypeId
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 
155 void
157 {
158  m_baseStationId = baseStationId;
159 }
160 
161 void
163 {
164  m_frameNumber = frameNumber;
165 }
166 
167 void
169 {
170  m_configurationChangeCount = configurationChangeCount;
171 }
172 
173 void
175 {
176  m_dlFramePrefixElements.push_back(dlFramePrefixElement);
177 }
178 
179 void
181 {
182  m_hcs = hcs;
183 }
184 
187 {
188  return m_baseStationId;
189 }
190 
191 uint32_t
193 {
194  return m_frameNumber;
195 }
196 
197 uint8_t
199 {
201 }
202 
203 std::vector<DlFramePrefixIe>
205 {
207 }
208 
209 uint8_t
211 {
212  return m_hcs;
213 }
214 
215 std::string
217 {
218  return "OFDM Downlink Frame Prefix";
219 }
220 
221 void
222 OfdmDownlinkFramePrefix::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 
230 uint32_t
232 {
233  int dlFramePrefixElementsSize = 0;
234 
235  for (const auto& dlFramePrefixElement : m_dlFramePrefixElements)
236  {
237  dlFramePrefixElementsSize += dlFramePrefixElement.GetSize();
238  }
239 
240  return 6 + 4 + 1 + dlFramePrefixElementsSize + 1;
241 }
242 
243 void
245 {
250 
251  for (const auto& dlFramePrefixElement : m_dlFramePrefixElements)
252  {
253  i = dlFramePrefixElement.Write(i);
254  }
255 
256  i.WriteU8(m_hcs);
257 }
258 
259 uint32_t
261 {
264  m_frameNumber = i.ReadU32();
266 
267  bool end = false;
268 
269  while (!end)
270  {
271  DlFramePrefixIe dlFramePrefixElement;
272  i = dlFramePrefixElement.Read(i);
273 
274  AddDlFramePrefixElement(dlFramePrefixElement);
275 
276  if (dlFramePrefixElement.GetDiuc() == 14)
277  {
278  end = true;
279  }
280  }
281 
282  m_hcs = i.ReadU8();
283 
284  return GetSerializedSize();
285 }
286 
287 } // namespace ns3
iterator in a Buffer instance
Definition: buffer.h:100
void WriteU32(uint32_t data)
Definition: buffer.cc:868
uint8_t ReadU8()
Definition: buffer.h:1027
void WriteU8(uint8_t data)
Definition: buffer.h:881
void Write(const uint8_t *buffer, uint32_t size)
Definition: buffer.cc:948
void WriteU16(uint16_t data)
Definition: buffer.cc:859
uint32_t ReadU32()
Definition: buffer.cc:966
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
virtual uint32_t Deserialize(Buffer::Iterator start)=0
Deserialize the object from a buffer iterator.
an EUI-48 address
Definition: mac48-address.h:46
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:931
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.