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 
25 namespace 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 
40 void
42 {
43  m_rateId = rateId;
44 }
45 
46 void
48 {
49  m_diuc = diuc;
50 }
51 
52 void
53 DlFramePrefixIe::SetPreamblePresent (uint8_t preamblePresent)
54 {
55  m_preamblePresent = preamblePresent;
56 }
57 
58 void
59 DlFramePrefixIe::SetLength (uint16_t length)
60 {
61  m_length = length;
62 }
63 
64 void
66 {
68 }
69 
70 uint8_t
72 {
73  return m_rateId;
74 }
75 
76 uint8_t
78 {
79  return m_diuc;
80 }
81 
82 uint8_t
84 {
85  return m_preamblePresent;
86 }
87 
88 uint16_t
90 {
91  return m_length;
92 }
93 
94 uint16_t
96 {
97  return m_startTime;
98 }
99 
100 uint16_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);
114  i.WriteU16 (m_startTime);
115  return i;
116 }
117 
120 {
122  m_rateId = i.ReadU8 ();
123  m_diuc = i.ReadU8 ();
124  m_preamblePresent = 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 */
143 TypeId
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 
154 void
156 {
157  m_baseStationId = baseStationId;
158 }
159 
160 void
162 {
163  m_frameNumber = frameNumber;
164 }
165 
166 void
168  uint8_t configurationChangeCount)
169 {
170  m_configurationChangeCount = configurationChangeCount;
171 }
172 
173 void
175  DlFramePrefixIe dlFramePrefixElement)
176 {
177  m_dlFramePrefixElements.push_back (dlFramePrefixElement);
178 }
179 
180 void
182 {
183  m_hcs = hcs;
184 }
185 
188 {
189  return m_baseStationId;
190 }
191 
192 uint32_t
194 {
195  return m_frameNumber;
196 }
197 
198 uint8_t
200 {
202 }
203 
204 std::vector<DlFramePrefixIe>
206 {
208 }
209 
210 uint8_t
212 {
213  return m_hcs;
214 }
215 
216 std::string
218 {
219  return "OFDM Downlink Frame Prefix";
220 }
221 
222 void
223 OfdmDownlinkFramePrefix::Print (std::ostream &os) const
224 {
225  os << " base station id = " << m_baseStationId << ", frame number = "
226  << m_frameNumber << ", configuration change count = "
227  << (uint32_t) m_configurationChangeCount
228  << ", number of dl frame prefix elements = "
229  << m_dlFramePrefixElements.size () << ", hcs = " << (uint32_t) m_hcs;
230 }
231 
232 uint32_t
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 
247 void
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 
265 uint32_t
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 
uint16_t ReadU16(void)
Definition: buffer.h:1029
Protocol header serialization and deserialization.
Definition: header.h:42
uint32_t ReadU32(void)
Definition: buffer.cc:972
void ReadFrom(Buffer::Iterator &i, Ipv4Address &ad)
Read an Ipv4Address from a Buffer.
def start()
Definition: core.py:1844
uint8_t GetPreamblePresent(void) const
Get preamble present field.
void SetLength(uint16_t length)
Set length field.
uint8_t GetRateId(void) const
Get rate ID field.
void WriteTo(Buffer::Iterator &i, Ipv4Address ad)
Write an Ipv4Address to a Buffer.
Buffer::Iterator Read(Buffer::Iterator start)
Read item function.
uint16_t GetStartTime(void) const
Get start time field.
uint8_t m_preamblePresent
preamble present
void SetDiuc(uint8_t diuc)
Set DIUC field.
uint16_t GetLength(void) const
Get length field.
iterator in a Buffer instance
Definition: buffer.h:98
This class implements the DL Frame Prefix IE as described by IEEE-802.16 standard.
double startTime
void WriteU16(uint16_t data)
Definition: buffer.cc:870
void SetRateId(uint8_t rateId)
Set rate ID field.
uint16_t GetSize(void) const
Get size field.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
an EUI-48 address
Definition: mac48-address.h:43
uint8_t GetDiuc(void) const
Get DIUC field.
void WriteU8(uint8_t data)
Definition: buffer.h:869
uint8_t ReadU8(void)
Definition: buffer.h:1021
Buffer::Iterator Write(Buffer::Iterator start) const
Write item function.
void SetPreamblePresent(uint8_t preamblePresent)
Set preamble present field.
void WriteU32(uint32_t data)
Definition: buffer.cc:878
a unique identifier for an interface.
Definition: type-id.h:58
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:915
void SetStartTime(uint16_t startTime)
Set start time field.