A Discrete-Event Network Simulator
API
ul-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 #include <stdint.h>
24 #include "ul-mac-messages.h"
25 
26 namespace ns3 {
27 
29 
31  : m_bwReqOppSize (0),
32  m_rangReqOppSize (0),
33  m_frequency (0)
34 {
35 }
36 
38 {
39 }
40 
41 void
42 UcdChannelEncodings::SetBwReqOppSize (uint16_t bwReqOppSize)
43 {
44  m_bwReqOppSize = bwReqOppSize;
45 }
46 
47 void
48 UcdChannelEncodings::SetRangReqOppSize (uint16_t rangReqOppSize)
49 {
50  m_rangReqOppSize = rangReqOppSize;
51 }
52 
53 void
55 {
56  m_frequency = frequency;
57 }
58 
59 uint16_t
61 {
62  return m_bwReqOppSize;
63 }
64 
65 uint16_t
67 {
68  return m_rangReqOppSize;
69 }
70 
71 uint32_t
73 {
74  return m_frequency;
75 }
76 
77 uint16_t
79 {
80  return 2 + 2 + 4;
81 }
82 
85 {
90  return DoWrite (i);
91 }
92 
95 {
97  m_bwReqOppSize = i.ReadU16 ();
99  m_frequency = i.ReadU32 ();
100  return DoRead (i);
101 }
102 
103 // ----------------------------------------------------------------------------------------------------------
104 
106  : m_sbchnlReqRegionFullParams (0),
107  m_sbchnlFocContCodes (0)
108 {
109 }
110 
112 {
113 }
114 
115 void
117  uint8_t sbchnlReqRegionFullParams)
118 {
119  m_sbchnlReqRegionFullParams = sbchnlReqRegionFullParams;
120 }
121 
122 void
124 {
125  m_sbchnlFocContCodes = sbchnlFocContCodes;
126 }
127 
128 uint8_t
130 {
132 }
133 
134 uint8_t
136 {
137  return m_sbchnlFocContCodes;
138 }
139 
140 uint16_t
142 {
143  return UcdChannelEncodings::GetSize () + 1 + 1;
144 }
145 
148 {
152  return i;
153 }
154 
157 {
161  return i;
162 }
163 
164 // ----------------------------------------------------------------------------------------------------------
165 
167  : m_type (0),
168  m_length (0),
169  m_uiuc (0),
170  m_fecCodeType (0)
171 {
172 }
173 
175 {
176 }
177 
178 void
180 {
181  m_type = type;
182 }
183 
184 void
186 {
187  m_length = length;
188 }
189 
190 void
192 {
193  m_uiuc = uiuc;
194 }
195 
196 void
198 {
199  m_fecCodeType = fecCodeType;
200 }
201 
202 uint8_t
204 {
205  return m_type;
206 }
207 
208 uint8_t
210 {
211  return m_length;
212 }
213 
214 uint8_t
216 {
217  return m_uiuc;
218 }
219 
220 uint8_t
222 {
223  return m_fecCodeType;
224 }
225 
226 uint16_t
228 {
229  return 1 + 1 + 1 + 1;
230 }
231 
234 {
236  i.WriteU8 (m_type);
237  i.WriteU8 (m_length);
238  i.WriteU8 (m_uiuc);
240  return i;
241 }
242 
245 {
247  m_type = i.ReadU8 ();
248  m_length = i.ReadU8 ();
249  m_uiuc = i.ReadU8 ();
250  m_fecCodeType = i.ReadU8 ();
251  return i;
252 }
253 
254 // ----------------------------------------------------------------------------------------------------------
255 
256 Ucd::Ucd (void)
257  : m_configurationChangeCount (0),
258  m_rangingBackoffStart (0),
259  m_rangingBackoffEnd (0),
260  m_requestBackoffStart (0),
261  m_requestBackoffEnd (
262  0),
263  m_nrUlBurstProfiles (0)
264 {
265 }
266 
267 Ucd::~Ucd (void)
268 {
269 }
270 
271 void
272 Ucd::SetConfigurationChangeCount (uint8_t configurationChangeCount)
273 {
274  m_configurationChangeCount = configurationChangeCount;
275 }
276 
277 void
278 Ucd::SetRangingBackoffStart (uint8_t rangingBackoffStart)
279 {
280  m_rangingBackoffStart = rangingBackoffStart;
281 }
282 
283 void
284 Ucd::SetRangingBackoffEnd (uint8_t rangingBackoffEnd)
285 {
286  m_rangingBackoffEnd = rangingBackoffEnd;
287 }
288 
289 void
290 Ucd::SetRequestBackoffStart (uint8_t requestBackoffStart)
291 {
292  m_requestBackoffStart = requestBackoffStart;
293 }
294 
295 void
296 Ucd::SetRequestBackoffEnd (uint8_t requestBackoffEnd)
297 {
298  m_requestBackoffEnd = requestBackoffEnd;
299 }
300 
301 void
303 {
304  m_channelEncodings = channelEncodings;
305 }
306 
307 void
309 {
310  m_ulBurstProfiles.push_back (ulBurstProfile);
311 }
312 
313 void
314 Ucd::SetNrUlBurstProfiles (uint8_t nrUlBurstProfiles)
315 {
316  // number of burst profiles is set to number of UL-MAP IEs after processing UL-MAP
317  m_nrUlBurstProfiles = nrUlBurstProfiles;
318 }
319 
320 uint8_t
322 {
324 }
325 
326 uint8_t
328 {
329  return m_rangingBackoffStart;
330 }
331 
332 uint8_t
334 {
335  return m_rangingBackoffEnd;
336 }
337 
338 uint8_t
340 {
341  return m_requestBackoffStart;
342 }
343 
344 uint8_t
346 {
347  return m_requestBackoffEnd;
348 }
349 
352 {
353  return m_channelEncodings;
354 }
355 
356 std::vector<OfdmUlBurstProfile>
358 {
359  return m_ulBurstProfiles;
360 }
361 
362 uint8_t
364 {
365  return m_nrUlBurstProfiles;
366 }
367 
368 std::string
369 Ucd::GetName (void) const
370 {
371  return "UCD";
372 }
373 
374 TypeId
376 {
377  static TypeId tid = TypeId ("ns3::Ucd")
378  .SetParent<Header> ()
379  .SetGroupName("Wimax")
380  .AddConstructor<Ucd> ()
381  ;
382  return tid;
383 }
384 
385 TypeId
387 {
388  return GetTypeId ();
389 }
390 
391 void
392 Ucd::Print (std::ostream &os) const
393 {
394  os << " configuration change count = "
395  << (uint32_t) m_configurationChangeCount << ", ranging backoff start = "
396  << (uint32_t) m_rangingBackoffStart << ", ranging backoff end = "
397  << (uint32_t) m_rangingBackoffEnd << ", request backoff start = "
398  << (uint32_t) m_requestBackoffStart << ", request backoff end = "
399  << (uint32_t) m_requestBackoffEnd << ", number of ul burst profiles = "
400  << m_ulBurstProfiles.size ();
401 }
402 
403 uint32_t
405 {
406  uint32_t ulBurstProfilesSize = 0;
407 
408  for (std::vector<OfdmUlBurstProfile>::const_iterator iter =
409  m_ulBurstProfiles.begin (); iter != m_ulBurstProfiles.end (); ++iter)
410  {
411  OfdmUlBurstProfile burstProfile = *iter;
412  ulBurstProfilesSize += burstProfile.GetSize ();
413  }
414 
415  return 5 + m_channelEncodings.GetSize () + ulBurstProfilesSize;
416 }
417 
418 void
420 {
427  i = m_channelEncodings.Write (i);
428 
429  for (std::vector<OfdmUlBurstProfile>::const_iterator iter =
430  m_ulBurstProfiles.begin (); iter != m_ulBurstProfiles.end (); ++iter)
431  {
432  OfdmUlBurstProfile burstProfile = *iter;
433  i = burstProfile.Write (i);
434  }
435 }
436 
437 uint32_t
439 {
446  i = m_channelEncodings.Read (i);
447 
448  for (uint8_t j = 0; j < m_nrUlBurstProfiles; j++)
449  {
450  OfdmUlBurstProfile burstProfile;
451  i = burstProfile.Read (i);
452  AddUlBurstProfile (burstProfile);
453  }
454 
455  return i.GetDistanceFrom (start);
456 }
457 
458 // ----------------------------------------------------------------------------------------------------------
459 
461  : m_cid (),
462  m_startTime (0),
463  m_subchannelIndex (0),
464  m_uiuc (0),
465  m_duration (0),
466  m_midambleRepetitionInterval (0)
467 {
468 }
469 
471 {
472 }
473 
474 void
476 {
477  m_cid = cid;
478 }
479 
480 void
482 {
484 }
485 
486 void
487 OfdmUlMapIe::SetSubchannelIndex (uint8_t subchannelIndex)
488 {
489  m_subchannelIndex = subchannelIndex;
490 }
491 
492 void
493 OfdmUlMapIe::SetUiuc (uint8_t uiuc)
494 {
495  m_uiuc = uiuc;
496 }
497 
498 void
499 OfdmUlMapIe::SetDuration (uint16_t duration)
500 {
501  m_duration = duration;
502 }
503 
504 void
506  uint8_t midambleRepetitionInterval)
507 {
508  m_midambleRepetitionInterval = midambleRepetitionInterval;
509 }
510 
511 Cid
513 {
514  return m_cid;
515 }
516 
517 uint16_t
519 {
520  return m_startTime;
521 }
522 
523 uint8_t
525 {
526  return m_subchannelIndex;
527 }
528 
529 uint8_t
531 {
532  return m_uiuc;
533 }
534 
535 uint16_t
537 {
538  return m_duration;
539 }
540 
541 uint8_t
543 {
545 }
546 
547 uint16_t
549 {
550  return 2 + 2 + 1 + 1 + 2 + 1;
551 }
552 
555 {
558  i.WriteU16 (m_startTime);
560  i.WriteU8 (m_uiuc);
561  i.WriteU16 (m_duration);
563  return i;
564 }
565 
568 {
570  m_cid = i.ReadU16 ();
571  m_startTime = i.ReadU16 ();
572  m_subchannelIndex = i.ReadU8 ();
573  m_uiuc = i.ReadU8 ();
574  m_duration = i.ReadU16 ();
576  return i;
577 }
578 
579 // ----------------------------------------------------------------------------------------------------------
580 
582 
584  : m_reserved (0),
585  m_ucdCount (0),
586  m_allocationStartTime (0)
587 {
588 }
589 
591 {
592 }
593 
594 void
595 UlMap::SetUcdCount (uint8_t ucdCount)
596 {
597  m_ucdCount = ucdCount;
598 }
599 
600 void
601 UlMap::SetAllocationStartTime (uint32_t allocationStartTime)
602 {
603  m_allocationStartTime = allocationStartTime;
604 }
605 
606 void
608 {
609  m_ulMapElements.push_back (ulMapElement);
610 }
611 
612 uint8_t
613 UlMap::GetUcdCount (void) const
614 {
615  return m_ucdCount;
616 }
617 
618 uint32_t
620 {
621  return m_allocationStartTime;
622 }
623 
624 std::list<OfdmUlMapIe>
626 {
627  return m_ulMapElements;
628 }
629 
630 std::string
631 UlMap::GetName (void) const
632 {
633  return "UL-MAP";
634 }
635 
636 TypeId
638 {
639  static TypeId tid = TypeId ("ns3::UlMap")
640  .SetParent<Header> ()
641  .SetGroupName("Wimax")
642  .AddConstructor<UlMap> ()
643  ;
644  return tid;
645 }
646 
647 TypeId
649 {
650  return GetTypeId ();
651 }
652 
653 void
654 UlMap::Print (std::ostream &os) const
655 {
656  os << " ucd count = " << (uint32_t) m_ucdCount
657  << ", allocation start time = " << m_allocationStartTime
658  << ", number of ul-map elements = " << m_ulMapElements.size ();
659 }
660 
661 uint32_t
663 {
664  uint32_t ulMapElementsSize = 0;
665  for (std::list<OfdmUlMapIe>::const_iterator iter = m_ulMapElements.begin (); iter
666  != m_ulMapElements.end (); ++iter)
667  {
668  OfdmUlMapIe ulMapIe = *iter;
669  ulMapElementsSize += ulMapIe.GetSize ();
670  }
671 
672  return 1 + 1 + 4 + ulMapElementsSize;
673 }
674 
675 void
677 {
679  i.WriteU8 (m_reserved);
680  i.WriteU8 (m_ucdCount);
682 
683  for (std::list<OfdmUlMapIe>::const_iterator iter = m_ulMapElements.begin (); iter
684  != m_ulMapElements.end (); ++iter)
685  {
686  OfdmUlMapIe ulMapIe = *iter;
687  i = ulMapIe.Write (i);
688  }
689 }
690 
691 uint32_t
693 {
695  m_reserved = i.ReadU8 ();
696  m_ucdCount = i.ReadU8 ();
698 
699  m_ulMapElements.clear (); // only for printing, otherwise it shows wrong number of elements
700 
701  while (true)
702  {
703  OfdmUlMapIe ulMapIe;
704  i = ulMapIe.Read (i);
705 
706  AddUlMapElement (ulMapIe);
707 
708  if (ulMapIe.GetUiuc () == 14) // End of Map IE
709  {
710  break;
711  }
712  }
713  return i.GetDistanceFrom (start);
714 }
715 
716 } // namespace ns3
iterator in a Buffer instance
Definition: buffer.h:99
void WriteU32(uint32_t data)
Definition: buffer.cc:879
void WriteU8(uint8_t data)
Definition: buffer.h:869
void WriteU16(uint16_t data)
Definition: buffer.cc:871
uint16_t ReadU16(void)
Definition: buffer.h:1029
uint8_t ReadU8(void)
Definition: buffer.h:1021
uint32_t GetDistanceFrom(Iterator const &o) const
Definition: buffer.cc:788
uint32_t ReadU32(void)
Definition: buffer.cc:973
Cid class.
Definition: cid.h:38
uint16_t GetIdentifier(void) const
Definition: cid.cc:45
Protocol header serialization and deserialization.
Definition: header.h:43
virtual uint32_t Deserialize(Buffer::Iterator start)=0
Deserialize the object from a buffer iterator.
This class implements the OFDM UCD channel encodings as described by "IEEE Standard for Local and met...
uint16_t GetSize(void) const
Get size.
uint8_t GetSbchnlFocContCodes(void) const
Get SB channel for control codes.
uint8_t m_sbchnlFocContCodes
SB channel for control codes.
void SetSbchnlReqRegionFullParams(uint8_t sbchnlReqRegionFullParams)
Set SB channel reguest region full parameters.
void SetSbchnlFocContCodes(uint8_t sbchnlFocContCodes)
Set SB channel for control codes.
uint8_t m_sbchnlReqRegionFullParams
SB channel request region full parameters.
uint8_t GetSbchnlReqRegionFullParams(void) const
Get SB channel request region full parameters.
virtual Buffer::Iterator DoWrite(Buffer::Iterator start) const
Write item.
virtual Buffer::Iterator DoRead(Buffer::Iterator start)
Read item.
This class implements the UL burst profile as described by "IEEE Standard for Local and metropolitan ...
void SetLength(uint8_t length)
Set length.
void SetUiuc(uint8_t uiuc)
Set UIUC.
uint8_t GetType(void) const
Get type.
uint8_t GetFecCodeType(void) const
Get FEC code type.
void SetFecCodeType(uint8_t fecCodeType)
Set FEC code type.
void SetType(uint8_t type)
Set type.
uint16_t GetSize(void) const
Get size.
uint8_t GetUiuc(void) const
Get UIUC.
uint8_t GetLength(void) const
Get length.
Buffer::Iterator Write(Buffer::Iterator start) const
Write item.
uint8_t m_fecCodeType
FEC code type.
Buffer::Iterator Read(Buffer::Iterator start)
Read item.
This class implements the UL-MAP_IE message as described by "IEEE Standard for Local and metropolitan...
uint16_t GetDuration(void) const
Get duration.
uint8_t GetUiuc(void) const
Get UIUC.
void SetStartTime(uint16_t startTime)
Set start time.
Buffer::Iterator Write(Buffer::Iterator start) const
Write item.
uint8_t GetSubchannelIndex(void) const
Get subchannel index.
void SetDuration(uint16_t duration)
Set duration.
void SetMidambleRepetitionInterval(uint8_t midambleRepetitionInterval)
Set midambe repetition interval.
void SetSubchannelIndex(uint8_t subchannelIndex)
Set subchannel index.
uint8_t m_subchannelIndex
subchannel index
uint16_t GetSize(void) const
Get size.
uint8_t m_midambleRepetitionInterval
midamble repetition interval
uint16_t m_startTime
start time
uint8_t m_uiuc
UIUC.
uint16_t GetStartTime(void) const
Get start time.
void SetCid(const Cid &cid)
Set CID.
Buffer::Iterator Read(Buffer::Iterator start)
Read item.
uint8_t GetMidambleRepetitionInterval(void) const
Get Midamble repetition interval.
uint16_t m_duration
duration
void SetUiuc(uint8_t uiuc)
Set UIUC.
Cid GetCid(void) const
Get CID.
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:922
void SetRangReqOppSize(uint16_t rangReqOppSize)
Set range request opp size.
void SetFrequency(uint32_t frequency)
Set frequency.
virtual Buffer::Iterator DoRead(Buffer::Iterator start)=0
Read item.
uint16_t m_bwReqOppSize
BW request opp size.
Buffer::Iterator Write(Buffer::Iterator start) const
Write item.
uint16_t GetSize(void) const
Get size.
virtual Buffer::Iterator DoWrite(Buffer::Iterator start) const =0
Write item.
uint32_t m_frequency
frequency
uint16_t GetRangReqOppSize(void) const
Get range request opp size.
uint16_t m_rangReqOppSize
range request opp size
uint16_t GetBwReqOppSize(void) const
Get BW request opp size.
uint32_t GetFrequency(void) const
Get frequency.
Buffer::Iterator Read(Buffer::Iterator start)
Read item.
void SetBwReqOppSize(uint16_t bwReqOppSize)
Set BW request opp size.
virtual ~UcdChannelEncodings(void)
This class implements the UCD message as described by "IEEE Standard for Local and metropolitan area ...
void SetNrUlBurstProfiles(uint8_t nrUlBurstProfiles)
Set NR UL burst profiles.
OfdmUcdChannelEncodings GetChannelEncodings(void) const
Get channel encodings.
uint8_t m_nrUlBurstProfiles
number UL burst profiles
uint8_t m_rangingBackoffStart
ranging backoff start
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
uint8_t m_requestBackoffEnd
request backoff end
uint8_t m_requestBackoffStart
request backoff start
uint8_t m_rangingBackoffEnd
ranging backoff end
uint8_t GetNrUlBurstProfiles(void) const
Get number UL burst profiles.
void AddUlBurstProfile(OfdmUlBurstProfile ulBurstProfile)
Add UL burst profile.
uint8_t GetRequestBackoffEnd(void) const
Get request backoff end.
void SetChannelEncodings(OfdmUcdChannelEncodings channelEncodings)
Set channel encodings.
virtual ~Ucd(void)
void SetConfigurationChangeCount(uint8_t ucdCount)
Set configuration change count.
void Serialize(Buffer::Iterator start) const
void SetRangingBackoffStart(uint8_t rangingBackoffStart)
Set ranging backoff start.
void SetRangingBackoffEnd(uint8_t rangingBackoffEnd)
Set ranging backoff end.
uint8_t GetRangingBackoffEnd(void) const
Get ranging backoff end.
void Print(std::ostream &os) const
std::string GetName(void) const
Get name.
uint32_t GetSerializedSize(void) const
void SetRequestBackoffEnd(uint8_t requestBackoffEnd)
Set request backoff end.
std::vector< OfdmUlBurstProfile > m_ulBurstProfiles
UL burst profiles.
uint8_t m_configurationChangeCount
configuration change count
uint8_t GetRequestBackoffStart(void) const
Get request backoff start.
void SetRequestBackoffStart(uint8_t requestBackoffStart)
Set request backoff start.
uint8_t GetRangingBackoffStart(void) const
Get ranging backoff start.
uint8_t GetConfigurationChangeCount(void) const
Get configuration change count.
std::vector< OfdmUlBurstProfile > GetUlBurstProfiles(void) const
Get UL burst profiles.
OfdmUcdChannelEncodings m_channelEncodings
TLV Encoded information for the overall channel.
static TypeId GetTypeId(void)
Get the type ID.
This class implements the UL-MAP_IE message as described by "IEEE Standard for Local and metropolitan...
std::string GetName(void) const
Get name.
void SetAllocationStartTime(uint32_t allocationStartTime)
Set allocation start time.
uint32_t GetSerializedSize(void) const
uint8_t m_ucdCount
UCD count.
static TypeId GetTypeId(void)
Get the type ID.
uint8_t m_reserved
changed as per the amendment 802.16e-2005
void AddUlMapElement(OfdmUlMapIe ulMapElement)
Add UL map element.
uint32_t GetAllocationStartTime(void) const
Get allocation start time.
void SetUcdCount(uint8_t ucdCount)
Set UCD count.
uint8_t GetUcdCount(void) const
Get UCD count.
std::list< OfdmUlMapIe > GetUlMapElements(void) const
Get UL map elements.
uint32_t m_allocationStartTime
allocation start time
std::list< OfdmUlMapIe > m_ulMapElements
UL map elements.
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
void Print(std::ostream &os) const
void Serialize(Buffer::Iterator start) const
virtual ~UlMap(void)
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
Every class exported by the ns3 library is enclosed in the ns3 namespace.
def start()
Definition: core.py:1853
double startTime