A Discrete-Event Network Simulator
API
dl-mac-messages.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,2009 INRIA, UDcast
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  * Authors: Jahanzeb Farooq <jahanzeb.farooq@sophia.inria.fr>
19  * Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
20  * <amine.ismail@UDcast.com>
21  */
22 
23 
24 #include <stdint.h>
25 #include "dl-mac-messages.h"
26 #include "ns3/address-utils.h"
27 
28 namespace ns3 {
29 
31  : m_bsEirp (0),
32  m_eirXPIrMax (0),
33  m_frequency (0)
34 {
35 }
36 
38 {
39 }
40 
41 void
43 {
44  m_bsEirp = bs_eirp;
45 }
46 
47 void
48 DcdChannelEncodings::SetEirxPIrMax (uint16_t eir_x_p_ir_max)
49 {
50  m_eirXPIrMax = eir_x_p_ir_max;
51 }
52 
53 void
55 {
56  m_frequency = frequency;
57 }
58 
59 uint16_t
61 {
62  return m_bsEirp;
63 }
64 
65 uint16_t
67 {
68  return m_eirXPIrMax;
69 }
70 
71 uint32_t
73 {
74  return m_frequency;
75 }
76 
77 uint16_t
79 {
80  return 2 + 2 + 4;
81 }
82 
85 {
87  i.WriteU16 (m_bsEirp);
90  return DoWrite (i);
91 }
92 
95 {
97  m_bsEirp = i.ReadU16 ();
98  m_eirXPIrMax = i.ReadU16 ();
99  m_frequency = i.ReadU32 ();
100  return DoRead (i);
101 }
102 
103 // ----------------------------------------------------------------------------------------------------------
104 
106  : m_channelNr (0),
107  m_ttg (0),
108  m_rtg (0),
109  m_baseStationId (Mac48Address ("00:00:00:00:00:00")),
110  m_frameDurationCode (0),
111  m_frameNumber (0)
112 {
113 }
114 
116 {
117 }
118 
119 void
121 {
122  m_channelNr = channelNr;
123 }
124 
125 void
127 {
128  m_ttg = ttg;
129 }
130 
131 void
133 {
134  m_rtg = rtg;
135 }
136 
137 void
139 {
140  m_baseStationId = baseStationId;
141 }
142 
143 void
145 {
146  m_frameDurationCode = frameDurationCode;
147 }
148 
149 void
151 {
152  m_frameNumber = frameNumber;
153 }
154 
155 uint8_t
157 {
158  return m_channelNr;
159 }
160 
161 uint8_t
163 {
164  return m_ttg;
165 }
166 
167 uint8_t
169 {
170  return m_rtg;
171 }
172 
175 {
176  return m_baseStationId;
177 }
178 
179 uint8_t
181 {
182  return m_frameDurationCode;
183 }
184 
185 uint32_t
187 {
188  return m_frameNumber;
189 }
190 
191 uint16_t
193 {
194  return DcdChannelEncodings::GetSize () + 1 + 1 + 1 + 6 + 1 + 4;
195 }
196 
199 {
201  i.WriteU8 (m_channelNr);
202  i.WriteU8 (m_ttg);
203  i.WriteU8 (m_rtg);
207  return i;
208 }
209 
212 {
214  m_channelNr = i.ReadU8 ();
215  m_ttg = i.ReadU8 ();
216  m_rtg = i.ReadU8 ();
217  ReadFrom (i, m_baseStationId); // length (6) shall also be written in packet instead of hard coded, see ARP example
219  m_frameNumber = i.ReadU32 ();
220  return i;
221 }
222 
223 // ----------------------------------------------------------------------------------------------------------
224 
226  : m_type (0),
227  m_length (0),
228  m_diuc (0),
229  m_fecCodeType (0)
230 {
231 }
232 
234 {
235 }
236 
237 void
239 {
240  m_type = type;
241 }
242 
243 void
245 {
246  m_length = length;
247 }
248 
249 void
251 {
252  m_diuc = diuc;
253 }
254 
255 void
257 {
258  m_fecCodeType = fecCodeType;
259 }
260 
261 uint8_t
263 {
264  return m_type;
265 }
266 
267 uint8_t
269 {
270  return m_length;
271 }
272 
273 uint8_t
275 {
276  return m_diuc;
277 }
278 
279 uint8_t
281 {
282  return m_fecCodeType;
283 }
284 
285 uint16_t
287 {
288  return 1 + 1 + 1 + 1;
289 }
290 
293 {
295  i.WriteU8 (m_type);
296  i.WriteU8 (m_length);
297  i.WriteU8 (m_diuc);
299  return i;
300 }
301 
304 {
306  m_type = i.ReadU8 ();
307  m_length = i.ReadU8 ();
308  m_diuc = i.ReadU8 ();
309  m_fecCodeType = i.ReadU8 ();
310  return i;
311 }
312 
313 // ----------------------------------------------------------------------------------------------------------
314 
316 
317 Dcd::Dcd (void)
318  : m_reserved (0),
319  m_configurationChangeCount (0),
320  m_nrDlBurstProfiles (0)
321 {
322 }
323 
324 Dcd::~Dcd (void)
325 {
326 }
327 
328 void
329 Dcd::SetConfigurationChangeCount (uint8_t configurationChangeCount)
330 {
331  m_configurationChangeCount = configurationChangeCount;
332 }
333 
334 void
336 {
337  m_channelEncodings = channelEncodings;
338 }
339 
340 void
341 Dcd::SetNrDlBurstProfiles (uint8_t nrDlBurstProfiles)
342 {
343  m_nrDlBurstProfiles = nrDlBurstProfiles;
344 }
345 
346 void
348 {
349  m_dlBurstProfiles.push_back (dlBurstProfile);
350 }
351 
352 uint8_t
354 {
356 }
357 
360 {
361  return m_channelEncodings;
362 }
363 
364 std::vector<OfdmDlBurstProfile>
366 {
367  return m_dlBurstProfiles;
368 }
369 
370 uint8_t
372 {
373  return m_nrDlBurstProfiles;
374 }
375 
376 std::string
377 Dcd::GetName (void) const
378 {
379  return "DCD";
380 }
381 
382 TypeId
384 {
385  static TypeId tid = TypeId ("ns3::Dcd")
386  .SetParent<Header> ()
387  .SetGroupName("Wimax")
388  .AddConstructor<Dcd> ()
389  ;
390  return tid;
391 }
392 
393 TypeId
395 {
396  return GetTypeId ();
397 }
398 
399 void
400 Dcd::Print (std::ostream &os) const
401 {
402  os << " configuration change count = "
403  << (uint32_t) m_configurationChangeCount
404  << ", number of dl burst profiles = " << m_dlBurstProfiles.size ();
405 }
406 
407 uint32_t
409 {
410  uint32_t dlBurstProfilesSize = 0;
411 
412  for (std::vector<OfdmDlBurstProfile>::const_iterator iter =
413  m_dlBurstProfiles.begin (); iter != m_dlBurstProfiles.end (); ++iter)
414  {
415  OfdmDlBurstProfile burstProfile = *iter;
416  dlBurstProfilesSize += burstProfile.GetSize ();
417  }
418 
419  return 1 + 1 + m_channelEncodings.GetSize () + dlBurstProfilesSize;
420 }
421 
422 void
424 {
426  i.WriteU8 (m_reserved);
428  i = m_channelEncodings.Write (i);
429 
430  for (std::vector<OfdmDlBurstProfile>::const_iterator iter =
431  m_dlBurstProfiles.begin (); iter != m_dlBurstProfiles.end (); ++iter)
432  {
433  OfdmDlBurstProfile burstProfile = *iter;
434  i = burstProfile.Write (i);
435  }
436 }
437 
438 uint32_t
440 {
442  m_reserved = i.ReadU8 ();
444  i = m_channelEncodings.Read (i);
445 
446  for (uint8_t j = 0; j < m_nrDlBurstProfiles; j++)
447  {
448  OfdmDlBurstProfile burstProfile;
449  i = burstProfile.Read (i);
450  AddDlBurstProfile (burstProfile);
451  }
452 
453  return i.GetDistanceFrom (start);
454 }
455 
456 // ----------------------------------------------------------------------------------------------------------
457 
459  : m_cid (),
460  m_diuc (0),
461  m_preamblePresent (0),
462  m_startTime (0)
463 {
464 }
465 
467 {
468 }
469 
470 void
472 {
473  m_cid = cid;
474 }
475 
476 void
477 OfdmDlMapIe::SetDiuc (uint8_t diuc)
478 {
479  m_diuc = diuc;
480 }
481 
482 void
483 OfdmDlMapIe::SetPreamblePresent (uint8_t preamblePresent)
484 {
485  m_preamblePresent = preamblePresent;
486 }
487 
488 void
490 {
492 }
493 
494 Cid
496 {
497  return m_cid;
498 }
499 
500 uint8_t
502 {
503  return m_diuc;
504 }
505 
506 uint8_t
508 {
509  return m_preamblePresent;
510 }
511 
512 uint16_t
514 {
515  return m_startTime;
516 }
517 
518 uint16_t
520 {
521  return 2 + 1 + 1 + 2;
522 }
523 
526 {
529  i.WriteU8 (m_diuc);
531  i.WriteU16 (m_startTime);
532  return i;
533 }
534 
537 {
539  m_cid = i.ReadU16 ();
540  m_diuc = i.ReadU8 ();
541  m_preamblePresent = i.ReadU8 ();
542  m_startTime = i.ReadU16 ();
543  return i;
544 }
545 
546 // ----------------------------------------------------------------------------------------------------------
547 
549 
551  : m_dcdCount (0),
552  m_baseStationId (Mac48Address ("00:00:00:00:00:00"))
553 {
554 }
555 
557 {
558 }
559 
560 void
561 DlMap::SetDcdCount (uint8_t dcdCount)
562 {
563  m_dcdCount = dcdCount;
564 }
565 
566 void
568 {
569  m_baseStationId = baseStationId;
570 }
571 
572 void
574 {
575  m_dlMapElements.push_back (dlMapElement);
576 }
577 
578 uint8_t
579 DlMap::GetDcdCount (void) const
580 {
581  return m_dcdCount;
582 }
583 
586 {
587  return m_baseStationId;
588 }
589 
590 std::list<OfdmDlMapIe>
592 {
593  return m_dlMapElements;
594 }
595 
596 std::string
597 DlMap::GetName (void) const
598 {
599  return "DL-MAP";
600 }
601 
602 TypeId
604 {
605  static TypeId tid = TypeId ("ns3::DlMap")
606  .SetParent<Header> ()
607  .SetGroupName("Wimax")
608  .AddConstructor<DlMap> ()
609  ;
610  return tid;
611 }
612 
613 TypeId
615 {
616  return GetTypeId ();
617 }
618 
619 void
620 DlMap::Print (std::ostream &os) const
621 {
622  os << " dcd count = " << (uint32_t) m_dcdCount << ", base station id = "
623  << m_baseStationId << ", number of dl-map elements = "
624  << m_dlMapElements.size ();
625 }
626 
627 uint32_t
629 {
630  uint32_t dlMapElementsSize = 0;
631 
632  for (std::list<OfdmDlMapIe>::const_iterator iter = m_dlMapElements.begin (); iter
633  != m_dlMapElements.end (); ++iter)
634  {
635  OfdmDlMapIe dlMapIe = *iter;
636  dlMapElementsSize += dlMapIe.GetSize ();
637  }
638 
639  return 1 + 6 + dlMapElementsSize;
640 }
641 
642 void
644 {
646  i.WriteU8 (m_dcdCount);
648 
649  for (std::list<OfdmDlMapIe>::const_iterator iter = m_dlMapElements.begin (); iter
650  != m_dlMapElements.end (); ++iter)
651  {
652  OfdmDlMapIe dlMapIe = *iter;
653  i = dlMapIe.Write (i);
654  }
655 }
656 
657 uint32_t
659 {
661  m_dcdCount = i.ReadU8 ();
662  ReadFrom (i, m_baseStationId); // length (6) shall also be written in packet instead of hard coded, see ARP example
663 
664  m_dlMapElements.clear (); // only for printing, otherwise it shows wrong number of elements
665 
666  while (true)
667  {
668  OfdmDlMapIe dlMapIe;
669  i = dlMapIe.Read (i);
670 
671  AddDlMapElement (dlMapIe);
672 
673  if (dlMapIe.GetDiuc () == 14) // End of Map IE
674  {
675  break;
676  }
677  }
678  return i.GetDistanceFrom (start);
679 }
680 
681 } // namespace ns3
682 
uint16_t ReadU16(void)
Definition: buffer.h:1029
Protocol header serialization and deserialization.
Definition: header.h:42
uint16_t GetSize(void) const
Get size.
uint32_t ReadU32(void)
Definition: buffer.cc:972
virtual Buffer::Iterator DoRead(Buffer::Iterator start)=0
Read item.
uint32_t GetSerializedSize(void) const
This class implements DL-MAP as described by "IEEE Standard for Local and metropolitan area networks ...
void SetRtg(uint8_t rtg)
Set RTG field.
uint16_t GetStartTime(void) const
Get start time field.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
uint8_t m_configurationChangeCount
configuration change count
void SetEirxPIrMax(uint16_t rss_ir_max)
Set EIRX IR MAX field.
void SetLength(uint8_t length)
Set length field.
uint8_t GetDiuc(void) const
void SetBsEirp(uint16_t bs_eirp)
Set BS EIRP field.
uint8_t GetDcdCount(void) const
Get DCD count field.
uint16_t GetSize(void) const
void ReadFrom(Buffer::Iterator &i, Ipv4Address &ad)
Read an Ipv4Address from a Buffer.
def start()
Definition: core.py:1844
Buffer::Iterator Read(Buffer::Iterator start)
Read item.
static TypeId GetTypeId(void)
Get the type ID.
void WriteTo(Buffer::Iterator &i, Ipv4Address ad)
Write an Ipv4Address to a Buffer.
void Print(std::ostream &os) const
virtual Buffer::Iterator DoWrite(Buffer::Iterator start) const =0
Write item.
uint8_t GetFrameDurationCode(void) const
Get frame duration code field.
uint8_t m_frameDurationCode
frame duration code
std::list< OfdmDlMapIe > GetDlMapElements(void) const
Get DL Map elements field.
uint8_t m_channelNr
channel number
Buffer::Iterator Read(Buffer::Iterator start)
Read item.
void SetChannelNr(uint8_t channelNr)
Set channel number field.
uint8_t GetType(void) const
Get type function.
uint8_t GetTtg(void) const
Get TTG field.
void SetType(uint8_t type)
Set type field.
void SetDiuc(uint8_t diuc)
Set DIUC field.
void SetStartTime(uint16_t startTime)
Set start time field.
iterator in a Buffer instance
Definition: buffer.h:98
void SetPreamblePresent(uint8_t preamblePresent)
Set preamble present field.
uint32_t m_frequency
frequency
void SetFrameDurationCode(uint8_t frameDurationCode)
Set frame duration code field.
uint32_t GetDistanceFrom(Iterator const &o) const
Definition: buffer.cc:783
void SetBaseStationId(Mac48Address baseStationID)
Set base station ID field.
uint8_t m_nrDlBurstProfiles
number DL purst profiles
Mac48Address GetBaseStationId(void) const
Get base station ID field.
void Serialize(Buffer::Iterator start) const
void SetNrDlBurstProfiles(uint8_t nrDlBurstProfiles)
Set number DL burst profile field.
uint16_t m_eirXPIrMax
EIRX IR MAX.
void SetDiuc(uint8_t diuc)
Set DIUC field.
uint8_t GetConfigurationChangeCount(void) const
Get configuration change count field.
static TypeId GetTypeId(void)
Get the type ID.
void SetTtg(uint8_t ttg)
Set TTG field.
void SetDcdCount(uint8_t dcdCount)
Set DCD count field.
double startTime
std::list< OfdmDlMapIe > m_dlMapElements
DL Map elements.
void WriteU16(uint16_t data)
Definition: buffer.cc:870
std::string GetName(void) const
Get name field.
Buffer::Iterator Write(Buffer::Iterator start) const
Wrtie item.
uint8_t GetChannelNr(void) const
Get channel number field.
void Serialize(Buffer::Iterator start) const
OfdmDcdChannelEncodings m_channelEncodings
TLV Encoded information for the overall channel.
uint16_t GetEirxPIrMax(void) const
Get EIRX IR MAX field.
uint32_t Deserialize(Buffer::Iterator start)
void Print(std::ostream &os) const
Mac48Address GetBaseStationId(void) const
Get base station ID field.
This class implements Downlink channel descriptor as described by "IEEE Standard for Local and metrop...
uint8_t m_dcdCount
DCD count.
void SetFrameNumber(uint32_t frameNumber)
Set frame number field.
virtual ~Dcd(void)
uint8_t m_diuc
DIUC.
uint16_t m_startTime
start time
Mac48Address m_baseStationId
base station ID
uint16_t GetBsEirp(void) const
Get BS EIRP field.
void SetChannelEncodings(OfdmDcdChannelEncodings channelEncodings)
Set channel encodings field.
uint16_t GetSize(void) const
Get size field.
uint32_t m_frameNumber
frame number
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::string GetName(void) const
Get name field.
uint32_t Deserialize(Buffer::Iterator start)
void SetFrequency(uint32_t frequency)
Set frequency field.
Cid class.
Definition: cid.h:37
void AddDlBurstProfile(OfdmDlBurstProfile dlBurstProfile)
Add DL burst profile field.
an EUI-48 address
Definition: mac48-address.h:43
uint32_t GetSerializedSize(void) const
This class implements the OFDM DCD channel encodings as described by "IEEE Standard for Local and met...
uint16_t GetSize(void) const
Get size field.
Mac48Address m_baseStationId
base station ID
uint8_t GetDiuc(void) const
Get DIUC field.
std::vector< OfdmDlBurstProfile > m_dlBurstProfiles
vector of download burst profiles
Buffer::Iterator Write(Buffer::Iterator start) const
Write item.
uint8_t GetPreamblePresent(void) const
Get preamble present field.
uint8_t GetNrDlBurstProfiles(void) const
Get number DL burst profiles field.
void WriteU8(uint8_t data)
Definition: buffer.h:869
virtual Buffer::Iterator DoWrite(Buffer::Iterator start) const
Write item.
uint8_t GetRtg(void) const
Get RTG field.
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
uint16_t m_bsEirp
BS EIRP.
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
uint8_t ReadU8(void)
Definition: buffer.h:1021
uint8_t m_fecCodeType
FEC code type.
void SetBaseStationId(Mac48Address baseStationId)
Set base station ID field.
void SetCid(Cid cid)
Set CID function.
virtual ~DcdChannelEncodings(void)
uint8_t m_preamblePresent
preamble present
uint32_t GetFrameNumber(void) const
Get frame number field.
uint16_t GetIdentifier(void) const
Definition: cid.cc:45
void AddDlMapElement(OfdmDlMapIe dlMapElement)
Add DL Map element field.
void WriteU32(uint32_t data)
Definition: buffer.cc:878
uint32_t GetFrequency(void) const
Get frequency function.
uint8_t m_reserved
changed as per the amendment 802.16e-2005
a unique identifier for an interface.
Definition: type-id.h:58
uint8_t GetLength(void) const
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:915
Buffer::Iterator Write(Buffer::Iterator start) const
Write item.
Cid GetCid(void) const
Set CID field.
Buffer::Iterator Read(Buffer::Iterator start)
Read item.
This class implements the OFDM DL-MAP information element as described by "IEEE Standard for Local an...
virtual Buffer::Iterator DoRead(Buffer::Iterator start)
Read item.
This class implements the OFDM Downlink burst profile descriptor as described by "IEEE Standard for L...
OfdmDcdChannelEncodings GetChannelEncodings(void) const
Get channel encodings field.
void SetConfigurationChangeCount(uint8_t configurationChangeCount)
Set configuration change count field.
uint8_t GetFecCodeType(void) const
void SetFecCodeType(uint8_t fecCodeType)
Set FEC code type.
std::vector< OfdmDlBurstProfile > GetDlBurstProfiles(void) const
Get DL burst profile field.
virtual ~DlMap(void)