A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ul-mac-messages.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2007,2008,2009 INRIA, UDcast
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Authors: Jahanzeb Farooq <jahanzeb.farooq@sophia.inria.fr>
18 * Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
19 * <amine.ismail@UDcast.com>
20 */
21
22#include "ul-mac-messages.h"
23
24#include <stdint.h>
25
26namespace ns3
27{
28
30
32 : m_bwReqOppSize(0),
33 m_rangReqOppSize(0),
34 m_frequency(0)
35{
36}
37
39{
40}
41
42void
44{
45 m_bwReqOppSize = bwReqOppSize;
46}
47
48void
50{
51 m_rangReqOppSize = rangReqOppSize;
52}
53
54void
56{
57 m_frequency = frequency;
58}
59
60uint16_t
62{
63 return m_bwReqOppSize;
64}
65
66uint16_t
68{
69 return m_rangReqOppSize;
70}
71
74{
75 return m_frequency;
76}
77
78uint16_t
80{
81 return 2 + 2 + 4;
82}
83
86{
87 Buffer::Iterator i = start;
91 return DoWrite(i);
92}
93
96{
97 Buffer::Iterator i = start;
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
116void
118{
119 m_sbchnlReqRegionFullParams = sbchnlReqRegionFullParams;
120}
121
122void
124{
125 m_sbchnlFocContCodes = sbchnlFocContCodes;
126}
127
128uint8_t
130{
132}
133
134uint8_t
136{
138}
139
140uint16_t
142{
143 return UcdChannelEncodings::GetSize() + 1 + 1;
144}
145
148{
149 Buffer::Iterator i = start;
152 return i;
153}
154
157{
158 Buffer::Iterator i = start;
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
178void
180{
181 m_type = type;
182}
183
184void
186{
187 m_length = length;
188}
189
190void
192{
193 m_uiuc = uiuc;
194}
195
196void
198{
199 m_fecCodeType = fecCodeType;
200}
201
202uint8_t
204{
205 return m_type;
206}
207
208uint8_t
210{
211 return m_length;
212}
213
214uint8_t
216{
217 return m_uiuc;
218}
219
220uint8_t
222{
223 return m_fecCodeType;
224}
225
226uint16_t
228{
229 return 1 + 1 + 1 + 1;
230}
231
234{
235 Buffer::Iterator i = start;
236 i.WriteU8(m_type);
237 i.WriteU8(m_length);
238 i.WriteU8(m_uiuc);
240 return i;
241}
242
245{
246 Buffer::Iterator i = start;
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
257 : m_configurationChangeCount(0),
258 m_rangingBackoffStart(0),
259 m_rangingBackoffEnd(0),
260 m_requestBackoffStart(0),
261 m_requestBackoffEnd(0),
262 m_nrUlBurstProfiles(0)
263{
264}
265
267{
268}
269
270void
271Ucd::SetConfigurationChangeCount(uint8_t configurationChangeCount)
272{
273 m_configurationChangeCount = configurationChangeCount;
274}
275
276void
277Ucd::SetRangingBackoffStart(uint8_t rangingBackoffStart)
278{
279 m_rangingBackoffStart = rangingBackoffStart;
280}
281
282void
283Ucd::SetRangingBackoffEnd(uint8_t rangingBackoffEnd)
284{
285 m_rangingBackoffEnd = rangingBackoffEnd;
286}
287
288void
289Ucd::SetRequestBackoffStart(uint8_t requestBackoffStart)
290{
291 m_requestBackoffStart = requestBackoffStart;
292}
293
294void
295Ucd::SetRequestBackoffEnd(uint8_t requestBackoffEnd)
296{
297 m_requestBackoffEnd = requestBackoffEnd;
298}
299
300void
302{
303 m_channelEncodings = channelEncodings;
304}
305
306void
308{
309 m_ulBurstProfiles.push_back(ulBurstProfile);
310}
311
312void
313Ucd::SetNrUlBurstProfiles(uint8_t nrUlBurstProfiles)
314{
315 // number of burst profiles is set to number of UL-MAP IEs after processing UL-MAP
316 m_nrUlBurstProfiles = nrUlBurstProfiles;
317}
318
319uint8_t
321{
323}
324
325uint8_t
327{
329}
330
331uint8_t
333{
334 return m_rangingBackoffEnd;
335}
336
337uint8_t
339{
341}
342
343uint8_t
345{
346 return m_requestBackoffEnd;
347}
348
351{
352 return m_channelEncodings;
353}
354
355std::vector<OfdmUlBurstProfile>
357{
358 return m_ulBurstProfiles;
359}
360
361uint8_t
363{
364 return m_nrUlBurstProfiles;
365}
366
367std::string
369{
370 return "UCD";
371}
372
373TypeId
375{
376 static TypeId tid =
377 TypeId("ns3::Ucd").SetParent<Header>().SetGroupName("Wimax").AddConstructor<Ucd>();
378 return tid;
379}
380
381TypeId
383{
384 return GetTypeId();
385}
386
387void
388Ucd::Print(std::ostream& os) const
389{
390 os << " configuration change count = " << (uint32_t)m_configurationChangeCount
391 << ", ranging backoff start = " << (uint32_t)m_rangingBackoffStart
392 << ", ranging backoff end = " << (uint32_t)m_rangingBackoffEnd
393 << ", request backoff start = " << (uint32_t)m_requestBackoffStart
394 << ", request backoff end = " << (uint32_t)m_requestBackoffEnd
395 << ", number of ul burst profiles = " << m_ulBurstProfiles.size();
396}
397
400{
401 uint32_t ulBurstProfilesSize = 0;
402
403 for (const auto& burstProfile : m_ulBurstProfiles)
404 {
405 ulBurstProfilesSize += burstProfile.GetSize();
406 }
407
408 return 5 + m_channelEncodings.GetSize() + ulBurstProfilesSize;
409}
410
411void
413{
414 Buffer::Iterator i = start;
421
422 for (const auto& burstProfile : m_ulBurstProfiles)
423 {
424 i = burstProfile.Write(i);
425 }
426}
427
430{
431 Buffer::Iterator i = start;
438
439 for (uint8_t j = 0; j < m_nrUlBurstProfiles; j++)
440 {
441 OfdmUlBurstProfile burstProfile;
442 i = burstProfile.Read(i);
443 AddUlBurstProfile(burstProfile);
444 }
445
446 return i.GetDistanceFrom(start);
447}
448
449// ----------------------------------------------------------------------------------------------------------
450
452 : m_cid(),
453 m_startTime(0),
454 m_subchannelIndex(0),
455 m_uiuc(0),
456 m_duration(0),
457 m_midambleRepetitionInterval(0)
458{
459}
460
462{
463}
464
465void
467{
468 m_cid = cid;
469}
470
471void
472OfdmUlMapIe::SetStartTime(uint16_t startTime)
473{
474 m_startTime = startTime;
475}
476
477void
478OfdmUlMapIe::SetSubchannelIndex(uint8_t subchannelIndex)
479{
480 m_subchannelIndex = subchannelIndex;
481}
482
483void
485{
486 m_uiuc = uiuc;
487}
488
489void
490OfdmUlMapIe::SetDuration(uint16_t duration)
491{
492 m_duration = duration;
493}
494
495void
496OfdmUlMapIe::SetMidambleRepetitionInterval(uint8_t midambleRepetitionInterval)
497{
498 m_midambleRepetitionInterval = midambleRepetitionInterval;
499}
500
501Cid
503{
504 return m_cid;
505}
506
507uint16_t
509{
510 return m_startTime;
511}
512
513uint8_t
515{
516 return m_subchannelIndex;
517}
518
519uint8_t
521{
522 return m_uiuc;
523}
524
525uint16_t
527{
528 return m_duration;
529}
530
531uint8_t
533{
535}
536
537uint16_t
539{
540 return 2 + 2 + 1 + 1 + 2 + 1;
541}
542
545{
546 Buffer::Iterator i = start;
550 i.WriteU8(m_uiuc);
553 return i;
554}
555
558{
559 Buffer::Iterator i = start;
560 m_cid = i.ReadU16();
561 m_startTime = i.ReadU16();
563 m_uiuc = i.ReadU8();
564 m_duration = i.ReadU16();
566 return i;
567}
568
569// ----------------------------------------------------------------------------------------------------------
570
572
574 : m_reserved(0),
575 m_ucdCount(0),
576 m_allocationStartTime(0)
577{
578}
579
581{
582}
583
584void
585UlMap::SetUcdCount(uint8_t ucdCount)
586{
587 m_ucdCount = ucdCount;
588}
589
590void
592{
593 m_allocationStartTime = allocationStartTime;
594}
595
596void
598{
599 m_ulMapElements.push_back(ulMapElement);
600}
601
602uint8_t
604{
605 return m_ucdCount;
606}
607
610{
612}
613
614std::list<OfdmUlMapIe>
616{
617 return m_ulMapElements;
618}
619
620std::string
622{
623 return "UL-MAP";
624}
625
626TypeId
628{
629 static TypeId tid =
630 TypeId("ns3::UlMap").SetParent<Header>().SetGroupName("Wimax").AddConstructor<UlMap>();
631 return tid;
632}
633
634TypeId
636{
637 return GetTypeId();
638}
639
640void
641UlMap::Print(std::ostream& os) const
642{
643 os << " ucd count = " << (uint32_t)m_ucdCount
644 << ", allocation start time = " << m_allocationStartTime
645 << ", number of ul-map elements = " << m_ulMapElements.size();
646}
647
650{
651 uint32_t ulMapElementsSize = 0;
652
653 for (const auto& ulMapIe : m_ulMapElements)
654 {
655 ulMapElementsSize += ulMapIe.GetSize();
656 }
657
658 return 1 + 1 + 4 + ulMapElementsSize;
659}
660
661void
663{
664 Buffer::Iterator i = start;
668
669 for (const auto& ulMapIe : m_ulMapElements)
670 {
671 i = ulMapIe.Write(i);
672 }
673}
674
677{
678 Buffer::Iterator i = start;
679 m_reserved = i.ReadU8();
680 m_ucdCount = i.ReadU8();
682
683 m_ulMapElements.clear(); // only for printing, otherwise it shows wrong number of elements
684
685 while (true)
686 {
687 OfdmUlMapIe ulMapIe;
688 i = ulMapIe.Read(i);
689
690 AddUlMapElement(ulMapIe);
691
692 if (ulMapIe.GetUiuc() == 14) // End of Map IE
693 {
694 break;
695 }
696 }
697 return i.GetDistanceFrom(start);
698}
699
700} // namespace ns3
iterator in a Buffer instance
Definition: buffer.h:100
void WriteU32(uint32_t data)
Definition: buffer.cc:868
uint8_t ReadU8()
Definition: buffer.h:1027
void WriteU8(uint8_t data)
Definition: buffer.h:881
void Write(const uint8_t *buffer, uint32_t size)
Definition: buffer.cc:948
void WriteU16(uint16_t data)
Definition: buffer.cc:859
uint32_t ReadU32()
Definition: buffer.cc:966
uint32_t GetDistanceFrom(const Iterator &o) const
Definition: buffer.cc:780
uint16_t ReadU16()
Definition: buffer.h:1035
Cid class.
Definition: cid.h:37
uint16_t GetIdentifier() const
Definition: cid.cc:45
Protocol header serialization and deserialization.
Definition: header.h:44
This class implements the OFDM UCD channel encodings as described by "IEEE Standard for Local and met...
uint16_t GetSize() const
Get size.
Buffer::Iterator DoWrite(Buffer::Iterator start) const override
Write item.
uint8_t m_sbchnlFocContCodes
SB channel for control codes.
Buffer::Iterator DoRead(Buffer::Iterator start) override
Read item.
void SetSbchnlReqRegionFullParams(uint8_t sbchnlReqRegionFullParams)
Set SB channel reguest region full parameters.
uint8_t GetSbchnlReqRegionFullParams() const
Get SB channel request region full parameters.
void SetSbchnlFocContCodes(uint8_t sbchnlFocContCodes)
Set SB channel for control codes.
uint8_t GetSbchnlFocContCodes() const
Get SB channel for control codes.
uint8_t m_sbchnlReqRegionFullParams
SB channel request region full parameters.
This class implements the UL burst profile as described by "IEEE Standard for Local and metropolitan ...
uint16_t GetSize() const
Get size.
void SetLength(uint8_t length)
Set length.
void SetUiuc(uint8_t uiuc)
Set UIUC.
void SetFecCodeType(uint8_t fecCodeType)
Set FEC code type.
void SetType(uint8_t type)
Set type.
uint8_t GetFecCodeType() const
Get FEC code type.
uint8_t GetType() const
Get type.
uint8_t GetLength() const
Get length.
uint8_t GetUiuc() const
Get UIUC.
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 GetSize() const
Get size.
uint16_t GetDuration() const
Get duration.
void SetStartTime(uint16_t startTime)
Set start time.
Buffer::Iterator Write(Buffer::Iterator start) const
Write item.
Cid GetCid() const
Get CID.
uint8_t GetUiuc() const
Get UIUC.
void SetDuration(uint16_t duration)
Set duration.
void SetMidambleRepetitionInterval(uint8_t midambleRepetitionInterval)
Set midambe repetition interval.
void SetSubchannelIndex(uint8_t subchannelIndex)
Set subchannel index.
uint16_t GetStartTime() const
Get start time.
uint8_t m_subchannelIndex
subchannel index
uint8_t m_midambleRepetitionInterval
midamble repetition interval
uint8_t GetSubchannelIndex() const
Get subchannel index.
uint16_t m_startTime
start time
uint8_t m_uiuc
UIUC.
void SetCid(const Cid &cid)
Set CID.
Buffer::Iterator Read(Buffer::Iterator start)
Read item.
uint16_t m_duration
duration
void SetUiuc(uint8_t uiuc)
Set UIUC.
uint8_t GetMidambleRepetitionInterval() const
Get Midamble repetition interval.
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:932
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.
virtual Buffer::Iterator DoWrite(Buffer::Iterator start) const =0
Write item.
uint32_t m_frequency
frequency
uint16_t m_rangReqOppSize
range request opp size
uint16_t GetSize() const
Get size.
uint16_t GetRangReqOppSize() const
Get range request opp size.
Buffer::Iterator Read(Buffer::Iterator start)
Read item.
void SetBwReqOppSize(uint16_t bwReqOppSize)
Set BW request opp size.
uint16_t GetBwReqOppSize() const
Get BW request opp size.
uint32_t GetFrequency() const
Get frequency.
This class implements the UCD message as described by "IEEE Standard for Local and metropolitan area ...
static TypeId GetTypeId()
Get the type ID.
uint8_t GetRangingBackoffEnd() const
Get ranging backoff end.
void SetNrUlBurstProfiles(uint8_t nrUlBurstProfiles)
Set NR UL burst profiles.
uint8_t m_nrUlBurstProfiles
number UL burst profiles
uint8_t GetNrUlBurstProfiles() const
Get number UL burst profiles.
uint8_t m_rangingBackoffStart
ranging backoff start
uint8_t m_requestBackoffEnd
request backoff end
uint8_t m_requestBackoffStart
request backoff start
uint8_t m_rangingBackoffEnd
ranging backoff end
uint8_t GetRequestBackoffStart() const
Get request backoff start.
void AddUlBurstProfile(OfdmUlBurstProfile ulBurstProfile)
Add UL burst profile.
void Print(std::ostream &os) const override
void SetChannelEncodings(OfdmUcdChannelEncodings channelEncodings)
Set channel encodings.
std::vector< OfdmUlBurstProfile > GetUlBurstProfiles() const
Get UL burst profiles.
uint8_t GetConfigurationChangeCount() const
Get configuration change count.
void SetConfigurationChangeCount(uint8_t ucdCount)
Set configuration change count.
uint32_t Deserialize(Buffer::Iterator start) override
void SetRangingBackoffStart(uint8_t rangingBackoffStart)
Set ranging backoff start.
void Serialize(Buffer::Iterator start) const override
void SetRangingBackoffEnd(uint8_t rangingBackoffEnd)
Set ranging backoff end.
uint32_t GetSerializedSize() const override
OfdmUcdChannelEncodings GetChannelEncodings() const
Get channel encodings.
void SetRequestBackoffEnd(uint8_t requestBackoffEnd)
Set request backoff end.
std::vector< OfdmUlBurstProfile > m_ulBurstProfiles
UL burst profiles.
uint8_t GetRangingBackoffStart() const
Get ranging backoff start.
uint8_t m_configurationChangeCount
configuration change count
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
~Ucd() override
uint8_t GetRequestBackoffEnd() const
Get request backoff end.
std::string GetName() const
Get name.
void SetRequestBackoffStart(uint8_t requestBackoffStart)
Set request backoff start.
OfdmUcdChannelEncodings m_channelEncodings
TLV Encoded information for the overall channel.
This class implements the UL-MAP_IE message as described by "IEEE Standard for Local and metropolitan...
void SetAllocationStartTime(uint32_t allocationStartTime)
Set allocation start time.
uint8_t m_ucdCount
UCD count.
std::list< OfdmUlMapIe > GetUlMapElements() const
Get UL map elements.
uint32_t GetAllocationStartTime() const
Get allocation start time.
std::string GetName() const
Get name.
uint8_t m_reserved
changed as per the amendment 802.16e-2005
void AddUlMapElement(OfdmUlMapIe ulMapElement)
Add UL map element.
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
~UlMap() override
void SetUcdCount(uint8_t ucdCount)
Set UCD count.
uint32_t GetSerializedSize() const override
void Serialize(Buffer::Iterator start) const override
void Print(std::ostream &os) const override
uint32_t m_allocationStartTime
allocation start time
std::list< OfdmUlMapIe > m_ulMapElements
UL map elements.
static TypeId GetTypeId()
Get the type ID.
uint32_t Deserialize(Buffer::Iterator start) override
uint8_t GetUcdCount() const
Get UCD count.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:46
Every class exported by the ns3 library is enclosed in the ns3 namespace.