A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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  .AddConstructor<Ucd> ()
380  ;
381  return tid;
382 }
383 
384 TypeId
386 {
387  return GetTypeId ();
388 }
389 
390 void
391 Ucd::Print (std::ostream &os) const
392 {
393  os << " configuration change count = "
394  << (uint32_t) m_configurationChangeCount << ", ranging backoff start = "
395  << (uint32_t) m_rangingBackoffStart << ", ranging backoff end = "
396  << (uint32_t) m_rangingBackoffEnd << ", request backoff start = "
397  << (uint32_t) m_requestBackoffStart << ", request backoff end = "
398  << (uint32_t) m_requestBackoffEnd << ", number of ul burst profiles = "
399  << m_ulBurstProfiles.size ();
400 }
401 
402 uint32_t
404 {
405  uint32_t ulBurstProfilesSize = 0;
406 
407  for (std::vector<OfdmUlBurstProfile>::const_iterator iter =
408  m_ulBurstProfiles.begin (); iter != m_ulBurstProfiles.end (); ++iter)
409  {
410  OfdmUlBurstProfile burstProfile = *iter;
411  ulBurstProfilesSize += burstProfile.GetSize ();
412  }
413 
414  return 5 + m_channelEncodings.GetSize () + ulBurstProfilesSize;
415 }
416 
417 void
419 {
426  i = m_channelEncodings.Write (i);
427 
428  for (std::vector<OfdmUlBurstProfile>::const_iterator iter =
429  m_ulBurstProfiles.begin (); iter != m_ulBurstProfiles.end (); ++iter)
430  {
431  OfdmUlBurstProfile burstProfile = *iter;
432  i = burstProfile.Write (i);
433  }
434 }
435 
436 uint32_t
438 {
445  i = m_channelEncodings.Read (i);
446 
447  for (uint8_t j = 0; j < m_nrUlBurstProfiles; j++)
448  {
449  OfdmUlBurstProfile burstProfile;
450  i = burstProfile.Read (i);
451  AddUlBurstProfile (burstProfile);
452  }
453 
454  return i.GetDistanceFrom (start);
455 }
456 
457 // ----------------------------------------------------------------------------------------------------------
458 
460  : m_cid (),
461  m_startTime (0),
462  m_subchannelIndex (0),
463  m_uiuc (0),
464  m_duration (0),
465  m_midambleRepetitionInterval (0)
466 {
467 }
468 
470 {
471 }
472 
473 void
475 {
476  m_cid = cid;
477 }
478 
479 void
481 {
483 }
484 
485 void
486 OfdmUlMapIe::SetSubchannelIndex (uint8_t subchannelIndex)
487 {
488  m_subchannelIndex = subchannelIndex;
489 }
490 
491 void
492 OfdmUlMapIe::SetUiuc (uint8_t uiuc)
493 {
494  m_uiuc = uiuc;
495 }
496 
497 void
498 OfdmUlMapIe::SetDuration (uint16_t duration)
499 {
500  m_duration = duration;
501 }
502 
503 void
505  uint8_t midambleRepetitionInterval)
506 {
507  m_midambleRepetitionInterval = midambleRepetitionInterval;
508 }
509 
510 Cid
512 {
513  return m_cid;
514 }
515 
516 uint16_t
518 {
519  return m_startTime;
520 }
521 
522 uint8_t
524 {
525  return m_subchannelIndex;
526 }
527 
528 uint8_t
530 {
531  return m_uiuc;
532 }
533 
534 uint16_t
536 {
537  return m_duration;
538 }
539 
540 uint8_t
542 {
544 }
545 
546 uint16_t
548 {
549  return 2 + 2 + 1 + 1 + 2 + 1;
550 }
551 
554 {
557  i.WriteU16 (m_startTime);
559  i.WriteU8 (m_uiuc);
560  i.WriteU16 (m_duration);
562  return i;
563 }
564 
567 {
569  m_cid = i.ReadU16 ();
570  m_startTime = i.ReadU16 ();
571  m_subchannelIndex = i.ReadU8 ();
572  m_uiuc = i.ReadU8 ();
573  m_duration = i.ReadU16 ();
575  return i;
576 }
577 
578 // ----------------------------------------------------------------------------------------------------------
579 
581 
583  : m_reserved (0),
584  m_ucdCount (0),
585  m_allocationStartTime (0)
586 {
587 }
588 
590 {
591 }
592 
593 void
594 UlMap::SetUcdCount (uint8_t ucdCount)
595 {
596  m_ucdCount = ucdCount;
597 }
598 
599 void
600 UlMap::SetAllocationStartTime (uint32_t allocationStartTime)
601 {
602  m_allocationStartTime = allocationStartTime;
603 }
604 
605 void
607 {
608  m_ulMapElements.push_back (ulMapElement);
609 }
610 
611 uint8_t
612 UlMap::GetUcdCount (void) const
613 {
614  return m_ucdCount;
615 }
616 
617 uint32_t
619 {
620  return m_allocationStartTime;
621 }
622 
623 std::list<OfdmUlMapIe>
625 {
626  return m_ulMapElements;
627 }
628 
629 std::string
630 UlMap::GetName (void) const
631 {
632  return "UL-MAP";
633 }
634 
635 TypeId
637 {
638  static TypeId tid = TypeId ("ns3::UlMap")
639  .SetParent<Header> ()
640  .AddConstructor<UlMap> ()
641  ;
642  return tid;
643 }
644 
645 TypeId
647 {
648  return GetTypeId ();
649 }
650 
651 void
652 UlMap::Print (std::ostream &os) const
653 {
654  os << " ucd count = " << (uint32_t) m_ucdCount
655  << ", allocation start time = " << m_allocationStartTime
656  << ", number of ul-map elements = " << m_ulMapElements.size ();
657 }
658 
659 uint32_t
661 {
662  uint32_t ulMapElementsSize = 0;
663  for (std::list<OfdmUlMapIe>::const_iterator iter = m_ulMapElements.begin (); iter
664  != m_ulMapElements.end (); ++iter)
665  {
666  OfdmUlMapIe ulMapIe = *iter;
667  ulMapElementsSize += ulMapIe.GetSize ();
668  }
669 
670  return 1 + 1 + 4 + ulMapElementsSize;
671 }
672 
673 void
675 {
677  i.WriteU8 (m_reserved);
678  i.WriteU8 (m_ucdCount);
680 
681  for (std::list<OfdmUlMapIe>::const_iterator iter = m_ulMapElements.begin (); iter
682  != m_ulMapElements.end (); ++iter)
683  {
684  OfdmUlMapIe ulMapIe = *iter;
685  i = ulMapIe.Write (i);
686  }
687 }
688 
689 uint32_t
691 {
693  m_reserved = i.ReadU8 ();
694  m_ucdCount = i.ReadU8 ();
696 
697  m_ulMapElements.clear (); // only for printing, otherwise it shows wrong number of elements
698 
699  while (true)
700  {
701  OfdmUlMapIe ulMapIe;
702  i = ulMapIe.Read (i);
703 
704  AddUlMapElement (ulMapIe);
705 
706  if (ulMapIe.GetUiuc () == 14) // End of Map IE
707  {
708  break;
709  }
710  }
711  return i.GetDistanceFrom (start);
712 }
713 
714 } // namespace ns3
uint16_t ReadU16(void)
Definition: buffer.h:1036
Protocol header serialization and deserialization.
Definition: header.h:42
virtual ~UlMap(void)
uint32_t ReadU32(void)
Definition: buffer.cc:1001
void SetUcdCount(uint8_t ucdCount)
virtual ~UcdChannelEncodings(void)
uint8_t m_ucdCount
void SetCid(Cid cid)
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register the class in the ns-3 factory.
Definition: object-base.h:38
virtual Buffer::Iterator DoWrite(Buffer::Iterator start) const
virtual Buffer::Iterator DoRead(Buffer::Iterator start)=0
void Serialize(Buffer::Iterator start) const
uint8_t GetConfigurationChangeCount(void) const
uint32_t GetSerializedSize(void) const
OfdmUlMapIe(void)
This class implements the UL-MAP_IE message as described by "IEEE Standard for Local and metropolitan...
void SetSubchannelIndex(uint8_t subchannelIndex)
uint8_t m_nrUlBurstProfiles
void SetRangingBackoffEnd(uint8_t rangingBackoffEnd)
uint16_t GetSize(void) const
Cid GetCid(void) const
uint32_t GetSerializedSize(void) const
Buffer::Iterator Write(Buffer::Iterator start) const
UlMap(void)
This class implements the UL-MAP_IE message as described by "IEEE Standard for Local and metropolitan...
static TypeId GetTypeId(void)
void SetLength(uint8_t length)
uint8_t GetRequestBackoffEnd(void) const
std::list< OfdmUlMapIe > m_ulMapElements
uint16_t GetRangReqOppSize(void) const
void SetChannelEncodings(OfdmUcdChannelEncodings channelEncodings)
uint32_t GetDistanceFrom(Iterator const &o) const
Definition: buffer.cc:811
iterator in a Buffer instance
Definition: buffer.h:98
uint8_t m_requestBackoffStart
void SetNrUlBurstProfiles(uint8_t nrUlBurstProfiles)
Buffer::Iterator Write(Buffer::Iterator start) const
void SetSbchnlReqRegionFullParams(uint8_t sbchnlReqRegionFullParams)
OfdmUcdChannelEncodings(void)
This class implements the UCD channel encodings as described by "IEEE Standard for Local and metropol...
void SetRequestBackoffStart(uint8_t requestBackoffStart)
virtual Buffer::Iterator DoWrite(Buffer::Iterator start) const =0
uint32_t GetFrequency(void) const
uint32_t Deserialize(Buffer::Iterator start)
uint8_t GetSbchnlReqRegionFullParams(void) const
uint8_t m_rangingBackoffEnd
uint8_t m_configurationChangeCount
void SetSbchnlFocContCodes(uint8_t sbchnlFocContCodes)
uint8_t m_rangingBackoffStart
void SetFecCodeType(uint8_t fecCodeType)
static TypeId GetTypeId(void)
OfdmUcdChannelEncodings GetChannelEncodings(void) const
double startTime
void SetUiuc(uint8_t uiuc)
void SetAllocationStartTime(uint32_t allocationStartTime)
void WriteU16(uint16_t data)
Definition: buffer.cc:899
uint8_t GetRangingBackoffStart(void) const
void SetRangingBackoffStart(uint8_t rangingBackoffStart)
uint8_t GetFecCodeType(void) const
void SetDuration(uint16_t duration)
std::string GetName(void) const
std::list< OfdmUlMapIe > GetUlMapElements(void) const
uint8_t GetType(void) const
void SetBwReqOppSize(uint16_t bwReqOppSize)
void AddUlBurstProfile(OfdmUlBurstProfile ulBurstProfile)
uint8_t GetUiuc(void) const
void Print(std::ostream &os) const
Buffer::Iterator Read(Buffer::Iterator start)
uint8_t GetUiuc(void) const
std::vector< OfdmUlBurstProfile > m_ulBurstProfiles
uint16_t GetDuration(void) const
Buffer::Iterator Write(Buffer::Iterator start) const
virtual ~Ucd(void)
uint16_t GetSize(void) const
uint8_t m_reserved
Definition: cid.h:35
Buffer::Iterator Read(Buffer::Iterator start)
void SetMidambleRepetitionInterval(uint8_t midambleRepetitionInterval)
uint8_t GetUcdCount(void) const
void SetRangReqOppSize(uint16_t rangReqOppSize)
uint8_t GetNrUlBurstProfiles(void) const
uint8_t GetSubchannelIndex(void) const
void SetStartTime(uint16_t startTime)
std::string GetName(void) const
virtual TypeId GetInstanceTypeId(void) const
uint8_t GetSbchnlFocContCodes(void) const
void SetFrequency(uint32_t frequency)
void WriteU8(uint8_t data)
Definition: buffer.h:876
uint8_t GetMidambleRepetitionInterval(void) const
virtual Buffer::Iterator DoRead(Buffer::Iterator start)
std::vector< OfdmUlBurstProfile > GetUlBurstProfiles(void) const
void SetConfigurationChangeCount(uint8_t ucdCount)
Doxygen introspection did not find any typical Config paths.
void SetRequestBackoffEnd(uint8_t requestBackoffEnd)
uint8_t m_midambleRepetitionInterval
uint32_t GetAllocationStartTime(void) const
uint8_t ReadU8(void)
Definition: buffer.h:1028
OfdmUcdChannelEncodings m_channelEncodings
uint16_t GetIdentifier(void) const
Definition: cid.cc:45
uint8_t GetLength(void) const
uint32_t Deserialize(Buffer::Iterator start)
void Serialize(Buffer::Iterator start) const
uint32_t m_allocationStartTime
void Print(std::ostream &os) const
void WriteU32(uint32_t data)
Definition: buffer.cc:907
void AddUlMapElement(OfdmUlMapIe ulMapElement)
a unique identifier for an interface.
Definition: type-id.h:49
void SetUiuc(uint8_t uiuc)
Ucd(void)
This class implements the UCD message as described by "IEEE Standard for Local and metropolitan area ...
uint8_t m_requestBackoffEnd
TypeId SetParent(TypeId tid)
Definition: type-id.cc:610
uint8_t GetRequestBackoffStart(void) const
uint16_t GetBwReqOppSize(void) const
virtual TypeId GetInstanceTypeId(void) const
uint16_t GetStartTime(void) const
uint8_t GetRangingBackoffEnd(void) const
Buffer::Iterator Read(Buffer::Iterator start)
void SetType(uint8_t type)
uint16_t GetSize(void) const
uint16_t GetSize(void) const