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>
22 #include <stdint.h>
24 #include "ns3/address-utils.h"
25 
26 namespace ns3 {
27 
29  : m_rateId (0),
30  m_diuc (0),
31  m_preamblePresent (0),
32  m_length (0),
33  m_startTime (0)
34 {
35 }
36 
38 {
39 }
40 
41 void
43 {
44  m_rateId = rateId;
45 }
46 
47 void
49 {
50  m_diuc = diuc;
51 }
52 
53 void
54 DlFramePrefixIe::SetPreamblePresent (uint8_t preamblePresent)
55 {
56  m_preamblePresent = preamblePresent;
57 }
58 
59 void
60 DlFramePrefixIe::SetLength (uint16_t length)
61 {
62  m_length = length;
63 }
64 
65 void
67 {
69 }
70 
71 uint8_t
73 {
74  return m_rateId;
75 }
76 
77 uint8_t
79 {
80  return m_diuc;
81 }
82 
83 uint8_t
85 {
86  return m_preamblePresent;
87 }
88 
89 uint16_t
91 {
92  return m_length;
93 }
94 
95 uint16_t
97 {
98  return m_startTime;
99 }
100 
101 uint16_t
103 {
104  return 1 + 1 + 1 + 2 + 2;
105 }
106 
109 {
111  i.WriteU8 (m_rateId);
112  i.WriteU8 (m_diuc);
114  i.WriteU16 (m_length);
115  i.WriteU16 (m_startTime);
116  return i;
117 }
118 
121 {
123  m_rateId = i.ReadU8 ();
124  m_diuc = i.ReadU8 ();
125  m_preamblePresent = i.ReadU8 ();
126  m_length = i.ReadU16 ();
127  m_startTime = i.ReadU16 ();
128  return i;
129 }
130 
132  : m_baseStationId (Mac48Address ("00:00:00:00:00:00")),
133  m_frameNumber (0),
134  m_configurationChangeCount (0),
135  m_hcs (0)
136 {
137 }
138 
140 {
141 }
142 
143 /* static */
144 TypeId
146 {
147  static TypeId tid = TypeId ("ns3::OfdmDownlinkFramePrefix")
148  .SetParent<Header> ()
149  .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  uint8_t configurationChangeCount)
170 {
171  m_configurationChangeCount = configurationChangeCount;
172 }
173 
174 void
176  DlFramePrefixIe dlFramePrefixElement)
177 {
178  m_dlFramePrefixElements.push_back (dlFramePrefixElement);
179 }
180 
181 void
183 {
184  m_hcs = hcs;
185 }
186 
189 {
190  return m_baseStationId;
191 }
192 
193 uint32_t
195 {
196  return m_frameNumber;
197 }
198 
199 uint8_t
201 {
203 }
204 
205 std::vector<DlFramePrefixIe>
207 {
209 }
210 
211 uint8_t
213 {
214  return m_hcs;
215 }
216 
217 std::string
219 {
220  return "OFDM Downlink Frame Prefix";
221 }
222 
223 void
224 OfdmDownlinkFramePrefix::Print (std::ostream &os) const
225 {
226  os << " base station id = " << m_baseStationId << ", frame number = "
227  << m_frameNumber << ", configuration change count = "
228  << (uint32_t) m_configurationChangeCount
229  << ", number of dl frame prefix elements = "
230  << m_dlFramePrefixElements.size () << ", hcs = " << (uint32_t) m_hcs;
231 }
232 
233 uint32_t
235 {
236  int dlFramePrefixElementsSize = 0;
237 
238  for (std::vector<DlFramePrefixIe>::const_iterator iter =
239  m_dlFramePrefixElements.begin (); iter != m_dlFramePrefixElements.end (); iter++)
240  {
241  DlFramePrefixIe dlFramePrefixElement = *iter;
242  dlFramePrefixElementsSize += dlFramePrefixElement.GetSize ();
243  }
244 
245  return 6 + 4 + 1 + dlFramePrefixElementsSize + 1;
246 }
247 
248 void
250 {
255 
256  for (std::vector<DlFramePrefixIe>::const_iterator iter =
257  m_dlFramePrefixElements.begin (); iter != m_dlFramePrefixElements.end (); iter++)
258  {
259  DlFramePrefixIe dlFramePrefixElement = *iter;
260  i = dlFramePrefixElement.Write (i);
261  }
262 
263  i.WriteU8 (m_hcs);
264 }
265 
266 uint32_t
268 {
271  m_frameNumber = i.ReadU32 ();
273 
274  bool end = false;
275 
276  while (!end)
277  {
278  DlFramePrefixIe dlFramePrefixElement;
279  i = dlFramePrefixElement.Read (i);
280 
281  AddDlFramePrefixElement (dlFramePrefixElement);
282 
283  if (dlFramePrefixElement.GetDiuc () == 14)
284  {
285  end = true;
286  }
287  }
288 
289  m_hcs = i.ReadU8 ();
290 
291  return GetSerializedSize ();
292 }
293 
294 } // namespace ns3
295 
uint16_t ReadU16(void)
Definition: buffer.h:1029
Protocol header serialization and deserialization.
Definition: header.h:42
uint32_t ReadU32(void)
Definition: buffer.cc:975
uint16_t GetSize(void) const
Get size field.
void ReadFrom(Buffer::Iterator &i, Ipv4Address &ad)
Read an Ipv4Address from a Buffer.
def start()
Definition: core.py:1790
void SetLength(uint16_t length)
Set length field.
void WriteTo(Buffer::Iterator &i, Ipv4Address ad)
Write an Ipv4Address to a Buffer.
uint8_t GetDiuc(void) const
Get DIUC field.
Buffer::Iterator Read(Buffer::Iterator start)
Read item function.
uint8_t m_preamblePresent
preamble present
Buffer::Iterator Write(Buffer::Iterator start) const
Write item function.
void SetDiuc(uint8_t diuc)
Set DIUC field.
iterator in a Buffer instance
Definition: buffer.h:98
uint8_t GetPreamblePresent(void) const
Get preamble present field.
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:873
uint16_t GetStartTime(void) const
Get start time field.
void SetRateId(uint8_t rateId)
Set rate ID field.
uint16_t GetLength(void) const
Get length field.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
an EUI-48 address
Definition: mac48-address.h:43
void WriteU8(uint8_t data)
Definition: buffer.h:869
uint8_t ReadU8(void)
Definition: buffer.h:1021
void SetPreamblePresent(uint8_t preamblePresent)
Set preamble present field.
void WriteU32(uint32_t data)
Definition: buffer.cc:881
uint8_t GetRateId(void) const
Get rate ID field.
a unique identifier for an interface.
Definition: type-id.h:58
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:914
void SetStartTime(uint16_t startTime)
Set start time field.