A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 void
145 {
146  m_baseStationId = baseStationId;
147 }
148 
149 void
151 {
152  m_frameNumber = frameNumber;
153 }
154 
155 void
157  uint8_t configurationChangeCount)
158 {
159  m_configurationChangeCount = configurationChangeCount;
160 }
161 
162 void
164  DlFramePrefixIe dlFramePrefixElement)
165 {
166  m_dlFramePrefixElements.push_back (dlFramePrefixElement);
167 }
168 
169 void
171 {
172  m_hcs = hcs;
173 }
174 
177 {
178  return m_baseStationId;
179 }
180 
181 uint32_t
183 {
184  return m_frameNumber;
185 }
186 
187 uint8_t
189 {
191 }
192 
193 std::vector<DlFramePrefixIe>
195 {
197 }
198 
199 uint8_t
201 {
202  return m_hcs;
203 }
204 
205 std::string
207 {
208  return "OFDM Downlink Frame Prefix";
209 }
210 
211 void
212 OfdmDownlinkFramePrefix::Print (std::ostream &os) const
213 {
214  os << " base station id = " << m_baseStationId << ", frame number = "
215  << m_frameNumber << ", configuration change count = "
216  << (uint32_t) m_configurationChangeCount
217  << ", number of dl frame prefix elements = "
218  << m_dlFramePrefixElements.size () << ", hcs = " << (uint32_t) m_hcs;
219 }
220 
221 uint32_t
223 {
224  int dlFramePrefixElementsSize = 0;
225 
226  for (std::vector<DlFramePrefixIe>::const_iterator iter =
227  m_dlFramePrefixElements.begin (); iter != m_dlFramePrefixElements.end (); iter++)
228  {
229  DlFramePrefixIe dlFramePrefixElement = *iter;
230  dlFramePrefixElementsSize += dlFramePrefixElement.GetSize ();
231  }
232 
233  return 6 + 4 + 1 + dlFramePrefixElementsSize + 1;
234 }
235 
236 void
238 {
243 
244  for (std::vector<DlFramePrefixIe>::const_iterator iter =
245  m_dlFramePrefixElements.begin (); iter != m_dlFramePrefixElements.end (); iter++)
246  {
247  DlFramePrefixIe dlFramePrefixElement = *iter;
248  i = dlFramePrefixElement.Write (i);
249  }
250 
251  i.WriteU8 (m_hcs);
252 }
253 
254 uint32_t
256 {
259  m_frameNumber = i.ReadU32 ();
261 
262  bool end = false;
263 
264  while (!end)
265  {
266  DlFramePrefixIe dlFramePrefixElement;
267  i = dlFramePrefixElement.Read (i);
268 
269  AddDlFramePrefixElement (dlFramePrefixElement);
270 
271  if (dlFramePrefixElement.GetDiuc () == 14)
272  {
273  end = true;
274  }
275  }
276 
277  m_hcs = i.ReadU8 ();
278 
279  return GetSerializedSize ();
280 }
281 
282 } // namespace ns3
283 
uint16_t ReadU16(void)
Definition: buffer.h:1036
uint32_t ReadU32(void)
Definition: buffer.cc:1001
void ReadFrom(Buffer::Iterator &i, Ipv4Address &ad)
Read an Ipv4Address from a Buffer.
void SetLength(uint16_t length)
void WriteTo(Buffer::Iterator &i, Ipv4Address ad)
Write an Ipv4Address to a Buffer.
Buffer::Iterator Read(Buffer::Iterator start)
Buffer::Iterator Write(Buffer::Iterator start) const
iterator in a Buffer instance
Definition: buffer.h:98
uint8_t GetPreamblePresent(void) const
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:899
uint16_t GetStartTime(void) const
void SetRateId(uint8_t rateId)
uint16_t GetLength(void) const
an EUI-48 address
Definition: mac48-address.h:41
void WriteU8(uint8_t data)
Definition: buffer.h:876
uint8_t ReadU8(void)
Definition: buffer.h:1028
void SetPreamblePresent(uint8_t preamblePresent)
void WriteU32(uint32_t data)
Definition: buffer.cc:907
uint8_t GetRateId(void) const
void SetStartTime(uint16_t startTime)