A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
318 Dcd::Dcd (void)
319  : m_reserved (0),
320  m_configurationChangeCount (0),
321  m_nrDlBurstProfiles (0)
322 {
323 }
324 
325 Dcd::~Dcd (void)
326 {
327 }
328 
329 void
330 Dcd::SetConfigurationChangeCount (uint8_t configurationChangeCount)
331 {
332  m_configurationChangeCount = configurationChangeCount;
333 }
334 
335 void
337 {
338  m_channelEncodings = channelEncodings;
339 }
340 
341 void
342 Dcd::SetNrDlBurstProfiles (uint8_t nrDlBurstProfiles)
343 {
344  m_nrDlBurstProfiles = nrDlBurstProfiles;
345 }
346 
347 void
349 {
350  m_dlBurstProfiles.push_back (dlBurstProfile);
351 }
352 
353 uint8_t
355 {
357 }
358 
361 {
362  return m_channelEncodings;
363 }
364 
365 std::vector<OfdmDlBurstProfile>
367 {
368  return m_dlBurstProfiles;
369 }
370 
371 uint8_t
373 {
374  return m_nrDlBurstProfiles;
375 }
376 
377 std::string
378 Dcd::GetName (void) const
379 {
380  return "DCD";
381 }
382 
383 TypeId
385 {
386  static TypeId tid = TypeId ("ns3::Dcd")
387  .SetParent<Header> ()
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  ;
550 
552  : m_dcdCount (0),
553  m_baseStationId (Mac48Address ("00:00:00:00:00:00"))
554 {
555 }
556 
558 {
559 }
560 
561 void
562 DlMap::SetDcdCount (uint8_t dcdCount)
563 {
564  m_dcdCount = dcdCount;
565 }
566 
567 void
569 {
570  m_baseStationId = baseStationId;
571 }
572 
573 void
575 {
576  m_dlMapElements.push_back (dlMapElement);
577 }
578 
579 uint8_t
580 DlMap::GetDcdCount (void) const
581 {
582  return m_dcdCount;
583 }
584 
587 {
588  return m_baseStationId;
589 }
590 
591 std::list<OfdmDlMapIe>
593 {
594  return m_dlMapElements;
595 }
596 
597 std::string
598 DlMap::GetName (void) const
599 {
600  return "DL-MAP";
601 }
602 
603 TypeId
605 {
606  static TypeId tid = TypeId ("ns3::DlMap")
607  .SetParent<Header> ()
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:845
Protocol header serialization and deserialization.
Definition: header.h:42
uint8_t GetFecCodeType(void) const
OfdmDcdChannelEncodings GetChannelEncodings(void) const
uint8_t GetPreamblePresent(void) const
uint32_t ReadU32(void)
Definition: buffer.cc:997
virtual Buffer::Iterator DoRead(Buffer::Iterator start)=0
Doxygen introspection did not find any typical Config paths.
uint16_t GetSize(void) const
uint8_t m_configurationChangeCount
void SetEirxPIrMax(uint16_t rss_ir_max)
uint8_t GetFrameDurationCode(void) const
std::list< OfdmDlMapIe > GetDlMapElements(void) const
void SetLength(uint8_t length)
void SetBsEirp(uint16_t bs_eirp)
std::string GetName(void) const
void ReadFrom(Buffer::Iterator &i, Ipv4Address &ad)
Read an Ipv4Address from a Buffer.
Buffer::Iterator Read(Buffer::Iterator start)
static TypeId GetTypeId(void)
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
void WriteTo(Buffer::Iterator &i, Ipv4Address ad)
Write an Ipv4Address to a Buffer.
virtual Buffer::Iterator DoWrite(Buffer::Iterator start) const =0
uint8_t GetConfigurationChangeCount(void) const
void Serialize(Buffer::Iterator start) const
virtual TypeId GetInstanceTypeId(void) const
Buffer::Iterator Read(Buffer::Iterator start)
void SetChannelNr(uint8_t channelNr)
uint8_t GetDcdCount(void) const
void SetType(uint8_t type)
uint16_t GetSize(void) const
void SetDiuc(uint8_t diuc)
OfdmDcdChannelEncodings(void)
This class implements the DCD channel encodings as described by "IEEE Standard for Local and metropol...
uint32_t GetDistanceFrom(Iterator const &o) const
Definition: buffer.cc:807
void SetStartTime(uint16_t startTime)
iterator in a Buffer instance
Definition: buffer.h:98
void SetPreamblePresent(uint8_t preamblePresent)
void SetFrameDurationCode(uint8_t frameDurationCode)
void SetBaseStationId(Mac48Address baseStationID)
uint8_t m_nrDlBurstProfiles
void SetNrDlBurstProfiles(uint8_t nrDlBurstProfiles)
void SetDiuc(uint8_t diuc)
uint8_t GetLength(void) const
static TypeId GetTypeId(void)
void SetDcdCount(uint8_t dcdCount)
double startTime
uint32_t GetSerializedSize(void) const
void Print(std::ostream &os) const
std::list< OfdmDlMapIe > m_dlMapElements
void WriteU16(uint16_t data)
Definition: buffer.cc:895
uint32_t GetSerializedSize(void) const
uint8_t GetRtg(void) const
uint8_t GetChannelNr(void) const
OfdmDcdChannelEncodings m_channelEncodings
Buffer::Iterator Write(Buffer::Iterator start) const
uint32_t Deserialize(Buffer::Iterator start)
Doxygen introspection did not find any typical Config paths.
uint8_t m_dcdCount
void SetFrameNumber(uint32_t frameNumber)
uint16_t GetSize(void) const
virtual ~Dcd(void)
uint16_t GetEirxPIrMax(void) const
uint8_t GetTtg(void) const
void SetChannelEncodings(OfdmDcdChannelEncodings channelEncodings)
Buffer::Iterator Write(Buffer::Iterator start) const
uint16_t GetBsEirp(void) const
uint16_t GetSize(void) const
DlMap(void)
This class implements DL-map ie as described by "IEEE Standard for Local and metropolitan area networ...
OfdmDlMapIe(void)
This class implements DL-map ie as described by "IEEE Standard for Local and metropolitan area networ...
uint32_t Deserialize(Buffer::Iterator start)
void SetFrequency(uint32_t frequency)
Definition: cid.h:35
uint32_t GetFrequency(void) const
void AddDlBurstProfile(OfdmDlBurstProfile dlBurstProfile)
an EUI-48 address
Definition: mac48-address.h:41
void Print(std::ostream &os) const
Mac48Address GetBaseStationId(void) const
uint8_t GetType(void) const
Cid GetCid(void) const
Mac48Address m_baseStationId
uint8_t GetNrDlBurstProfiles(void) const
virtual Buffer::Iterator DoWrite(Buffer::Iterator start) const
std::vector< OfdmDlBurstProfile > m_dlBurstProfiles
void WriteU8(uint8_t data)
Definition: buffer.h:690
std::vector< OfdmDlBurstProfile > GetDlBurstProfiles(void) const
virtual TypeId GetInstanceTypeId(void) const
uint16_t GetStartTime(void) const
uint8_t ReadU8(void)
Definition: buffer.h:819
std::string GetName(void) const
uint8_t GetDiuc(void) const
void SetBaseStationId(Mac48Address baseStationId)
uint16_t GetIdentifier(void) const
Definition: cid.cc:45
uint8_t GetDiuc(void) const
void SetCid(Cid cid)
virtual ~DcdChannelEncodings(void)
void AddDlMapElement(OfdmDlMapIe dlMapElement)
void WriteU32(uint32_t data)
Definition: buffer.cc:903
uint32_t GetFrameNumber(void) const
Mac48Address GetBaseStationId(void) const
uint8_t m_reserved
a unique identifier for an interface.
Definition: type-id.h:49
TypeId SetParent(TypeId tid)
Definition: type-id.cc:611
Dcd(void)
This class implements Downlink channel descriptor as described by "IEEE Standard for Local and metrop...
Buffer::Iterator Read(Buffer::Iterator start)
virtual Buffer::Iterator DoRead(Buffer::Iterator start)
void SetConfigurationChangeCount(uint8_t configurationChangeCount)
Buffer::Iterator Write(Buffer::Iterator start) const
void SetFecCodeType(uint8_t fecCodeType)
virtual ~DlMap(void)
void Serialize(Buffer::Iterator start) const