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  ;
30 
32  : m_bwReqOppSize (0),
33  m_rangReqOppSize (0),
34  m_frequency (0)
35 {
36 }
37 
39 {
40 }
41 
42 void
43 UcdChannelEncodings::SetBwReqOppSize (uint16_t bwReqOppSize)
44 {
45  m_bwReqOppSize = bwReqOppSize;
46 }
47 
48 void
49 UcdChannelEncodings::SetRangReqOppSize (uint16_t rangReqOppSize)
50 {
51  m_rangReqOppSize = rangReqOppSize;
52 }
53 
54 void
56 {
57  m_frequency = frequency;
58 }
59 
60 uint16_t
62 {
63  return m_bwReqOppSize;
64 }
65 
66 uint16_t
68 {
69  return m_rangReqOppSize;
70 }
71 
72 uint32_t
74 {
75  return m_frequency;
76 }
77 
78 uint16_t
80 {
81  return 2 + 2 + 4;
82 }
83 
86 {
91  return DoWrite (i);
92 }
93 
96 {
98  m_bwReqOppSize = i.ReadU16 ();
100  m_frequency = i.ReadU32 ();
101  return DoRead (i);
102 }
103 
104 // ----------------------------------------------------------------------------------------------------------
105 
107  : m_sbchnlReqRegionFullParams (0),
108  m_sbchnlFocContCodes (0)
109 {
110 }
111 
113 {
114 }
115 
116 void
118  uint8_t sbchnlReqRegionFullParams)
119 {
120  m_sbchnlReqRegionFullParams = sbchnlReqRegionFullParams;
121 }
122 
123 void
125 {
126  m_sbchnlFocContCodes = sbchnlFocContCodes;
127 }
128 
129 uint8_t
131 {
133 }
134 
135 uint8_t
137 {
138  return m_sbchnlFocContCodes;
139 }
140 
141 uint16_t
143 {
144  return UcdChannelEncodings::GetSize () + 1 + 1;
145 }
146 
149 {
153  return i;
154 }
155 
158 {
162  return i;
163 }
164 
165 // ----------------------------------------------------------------------------------------------------------
166 
168  : m_type (0),
169  m_length (0),
170  m_uiuc (0),
171  m_fecCodeType (0)
172 {
173 }
174 
176 {
177 }
178 
179 void
181 {
182  m_type = type;
183 }
184 
185 void
187 {
188  m_length = length;
189 }
190 
191 void
193 {
194  m_uiuc = uiuc;
195 }
196 
197 void
199 {
200  m_fecCodeType = fecCodeType;
201 }
202 
203 uint8_t
205 {
206  return m_type;
207 }
208 
209 uint8_t
211 {
212  return m_length;
213 }
214 
215 uint8_t
217 {
218  return m_uiuc;
219 }
220 
221 uint8_t
223 {
224  return m_fecCodeType;
225 }
226 
227 uint16_t
229 {
230  return 1 + 1 + 1 + 1;
231 }
232 
235 {
237  i.WriteU8 (m_type);
238  i.WriteU8 (m_length);
239  i.WriteU8 (m_uiuc);
241  return i;
242 }
243 
246 {
248  m_type = i.ReadU8 ();
249  m_length = i.ReadU8 ();
250  m_uiuc = i.ReadU8 ();
251  m_fecCodeType = i.ReadU8 ();
252  return i;
253 }
254 
255 // ----------------------------------------------------------------------------------------------------------
256 
257 Ucd::Ucd (void)
258  : m_configurationChangeCount (0),
259  m_rangingBackoffStart (0),
260  m_rangingBackoffEnd (0),
261  m_requestBackoffStart (0),
262  m_requestBackoffEnd (
263  0),
264  m_nrUlBurstProfiles (0)
265 {
266 }
267 
268 Ucd::~Ucd (void)
269 {
270 }
271 
272 void
273 Ucd::SetConfigurationChangeCount (uint8_t configurationChangeCount)
274 {
275  m_configurationChangeCount = configurationChangeCount;
276 }
277 
278 void
279 Ucd::SetRangingBackoffStart (uint8_t rangingBackoffStart)
280 {
281  m_rangingBackoffStart = rangingBackoffStart;
282 }
283 
284 void
285 Ucd::SetRangingBackoffEnd (uint8_t rangingBackoffEnd)
286 {
287  m_rangingBackoffEnd = rangingBackoffEnd;
288 }
289 
290 void
291 Ucd::SetRequestBackoffStart (uint8_t requestBackoffStart)
292 {
293  m_requestBackoffStart = requestBackoffStart;
294 }
295 
296 void
297 Ucd::SetRequestBackoffEnd (uint8_t requestBackoffEnd)
298 {
299  m_requestBackoffEnd = requestBackoffEnd;
300 }
301 
302 void
304 {
305  m_channelEncodings = channelEncodings;
306 }
307 
308 void
310 {
311  m_ulBurstProfiles.push_back (ulBurstProfile);
312 }
313 
314 void
315 Ucd::SetNrUlBurstProfiles (uint8_t nrUlBurstProfiles)
316 {
317  // number of burst profiles is set to number of UL-MAP IEs after processing UL-MAP
318  m_nrUlBurstProfiles = nrUlBurstProfiles;
319 }
320 
321 uint8_t
323 {
325 }
326 
327 uint8_t
329 {
330  return m_rangingBackoffStart;
331 }
332 
333 uint8_t
335 {
336  return m_rangingBackoffEnd;
337 }
338 
339 uint8_t
341 {
342  return m_requestBackoffStart;
343 }
344 
345 uint8_t
347 {
348  return m_requestBackoffEnd;
349 }
350 
353 {
354  return m_channelEncodings;
355 }
356 
357 std::vector<OfdmUlBurstProfile>
359 {
360  return m_ulBurstProfiles;
361 }
362 
363 uint8_t
365 {
366  return m_nrUlBurstProfiles;
367 }
368 
369 std::string
370 Ucd::GetName (void) const
371 {
372  return "UCD";
373 }
374 
375 TypeId
377 {
378  static TypeId tid = TypeId ("ns3::Ucd")
379  .SetParent<Header> ()
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  ;
583 
585  : m_reserved (0),
586  m_ucdCount (0),
587  m_allocationStartTime (0)
588 {
589 }
590 
592 {
593 }
594 
595 void
596 UlMap::SetUcdCount (uint8_t ucdCount)
597 {
598  m_ucdCount = ucdCount;
599 }
600 
601 void
602 UlMap::SetAllocationStartTime (uint32_t allocationStartTime)
603 {
604  m_allocationStartTime = allocationStartTime;
605 }
606 
607 void
609 {
610  m_ulMapElements.push_back (ulMapElement);
611 }
612 
613 uint8_t
614 UlMap::GetUcdCount (void) const
615 {
616  return m_ucdCount;
617 }
618 
619 uint32_t
621 {
622  return m_allocationStartTime;
623 }
624 
625 std::list<OfdmUlMapIe>
627 {
628  return m_ulMapElements;
629 }
630 
631 std::string
632 UlMap::GetName (void) const
633 {
634  return "UL-MAP";
635 }
636 
637 TypeId
639 {
640  static TypeId tid = TypeId ("ns3::UlMap")
641  .SetParent<Header> ()
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
uint16_t ReadU16(void)
Definition: buffer.h:845
Protocol header serialization and deserialization.
Definition: header.h:42
virtual ~UlMap(void)
uint32_t ReadU32(void)
Definition: buffer.cc:997
void SetUcdCount(uint8_t ucdCount)
virtual ~UcdChannelEncodings(void)
uint8_t m_ucdCount
void SetCid(Cid cid)
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
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
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:807
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:895
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:690
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:819
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:903
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:611
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