A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
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
28
NS_OBJECT_ENSURE_REGISTERED
(Ucd);
29
30
UcdChannelEncodings::UcdChannelEncodings
(
void
)
31
: m_bwReqOppSize (0),
32
m_rangReqOppSize (0),
33
m_frequency (0)
34
{
35
}
36
37
UcdChannelEncodings::~UcdChannelEncodings
(
void
)
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
54
UcdChannelEncodings::SetFrequency
(uint32_t frequency)
55
{
56
m_frequency
= frequency;
57
}
58
59
uint16_t
60
UcdChannelEncodings::GetBwReqOppSize
(
void
)
const
61
{
62
return
m_bwReqOppSize
;
63
}
64
65
uint16_t
66
UcdChannelEncodings::GetRangReqOppSize
(
void
)
const
67
{
68
return
m_rangReqOppSize
;
69
}
70
71
uint32_t
72
UcdChannelEncodings::GetFrequency
(
void
)
const
73
{
74
return
m_frequency
;
75
}
76
77
uint16_t
78
UcdChannelEncodings::GetSize
(
void
)
const
79
{
80
return
2 + 2 + 4;
81
}
82
83
Buffer::Iterator
84
UcdChannelEncodings::Write
(
Buffer::Iterator
start
)
const
85
{
86
Buffer::Iterator
i =
start
;
87
i.
WriteU16
(
m_bwReqOppSize
);
88
i.
WriteU16
(
m_rangReqOppSize
);
89
i.
WriteU32
(
m_frequency
);
90
return
DoWrite
(i);
91
}
92
93
Buffer::Iterator
94
UcdChannelEncodings::Read
(
Buffer::Iterator
start
)
95
{
96
Buffer::Iterator
i =
start
;
97
m_bwReqOppSize
= i.
ReadU16
();
98
m_rangReqOppSize
= i.
ReadU16
();
99
m_frequency
= i.
ReadU32
();
100
return
DoRead
(i);
101
}
102
103
// ----------------------------------------------------------------------------------------------------------
104
105
OfdmUcdChannelEncodings::OfdmUcdChannelEncodings
(
void
)
106
: m_sbchnlReqRegionFullParams (0),
107
m_sbchnlFocContCodes (0)
108
{
109
}
110
111
OfdmUcdChannelEncodings::~OfdmUcdChannelEncodings
(
void
)
112
{
113
}
114
115
void
116
OfdmUcdChannelEncodings::SetSbchnlReqRegionFullParams
(
117
uint8_t sbchnlReqRegionFullParams)
118
{
119
m_sbchnlReqRegionFullParams
= sbchnlReqRegionFullParams;
120
}
121
122
void
123
OfdmUcdChannelEncodings::SetSbchnlFocContCodes
(uint8_t sbchnlFocContCodes)
124
{
125
m_sbchnlFocContCodes
= sbchnlFocContCodes;
126
}
127
128
uint8_t
129
OfdmUcdChannelEncodings::GetSbchnlReqRegionFullParams
(
void
)
const
130
{
131
return
m_sbchnlReqRegionFullParams
;
132
}
133
134
uint8_t
135
OfdmUcdChannelEncodings::GetSbchnlFocContCodes
(
void
)
const
136
{
137
return
m_sbchnlFocContCodes
;
138
}
139
140
uint16_t
141
OfdmUcdChannelEncodings::GetSize
(
void
)
const
142
{
143
return
UcdChannelEncodings::GetSize
() + 1 + 1;
144
}
145
146
Buffer::Iterator
147
OfdmUcdChannelEncodings::DoWrite
(
Buffer::Iterator
start
)
const
148
{
149
Buffer::Iterator
i =
start
;
150
i.
WriteU8
(
m_sbchnlReqRegionFullParams
);
151
i.
WriteU8
(
m_sbchnlFocContCodes
);
152
return
i;
153
}
154
155
Buffer::Iterator
156
OfdmUcdChannelEncodings::DoRead
(
Buffer::Iterator
start
)
157
{
158
Buffer::Iterator
i =
start
;
159
m_sbchnlReqRegionFullParams
= i.
ReadU8
();
160
m_sbchnlFocContCodes
= i.
ReadU8
();
161
return
i;
162
}
163
164
// ----------------------------------------------------------------------------------------------------------
165
166
OfdmUlBurstProfile::OfdmUlBurstProfile
(
void
)
167
: m_type (0),
168
m_length (0),
169
m_uiuc (0),
170
m_fecCodeType (0)
171
{
172
}
173
174
OfdmUlBurstProfile::~OfdmUlBurstProfile
(
void
)
175
{
176
}
177
178
void
179
OfdmUlBurstProfile::SetType
(uint8_t type)
180
{
181
m_type
= type;
182
}
183
184
void
185
OfdmUlBurstProfile::SetLength
(uint8_t length)
186
{
187
m_length
= length;
188
}
189
190
void
191
OfdmUlBurstProfile::SetUiuc
(uint8_t uiuc)
192
{
193
m_uiuc
= uiuc;
194
}
195
196
void
197
OfdmUlBurstProfile::SetFecCodeType
(uint8_t fecCodeType)
198
{
199
m_fecCodeType
= fecCodeType;
200
}
201
202
uint8_t
203
OfdmUlBurstProfile::GetType
(
void
)
const
204
{
205
return
m_type
;
206
}
207
208
uint8_t
209
OfdmUlBurstProfile::GetLength
(
void
)
const
210
{
211
return
m_length
;
212
}
213
214
uint8_t
215
OfdmUlBurstProfile::GetUiuc
(
void
)
const
216
{
217
return
m_uiuc
;
218
}
219
220
uint8_t
221
OfdmUlBurstProfile::GetFecCodeType
(
void
)
const
222
{
223
return
m_fecCodeType
;
224
}
225
226
uint16_t
227
OfdmUlBurstProfile::GetSize
(
void
)
const
228
{
229
return
1 + 1 + 1 + 1;
230
}
231
232
Buffer::Iterator
233
OfdmUlBurstProfile::Write
(
Buffer::Iterator
start
)
const
234
{
235
Buffer::Iterator
i =
start
;
236
i.
WriteU8
(
m_type
);
237
i.
WriteU8
(
m_length
);
238
i.
WriteU8
(
m_uiuc
);
239
i.
WriteU8
(
m_fecCodeType
);
240
return
i;
241
}
242
243
Buffer::Iterator
244
OfdmUlBurstProfile::Read
(
Buffer::Iterator
start
)
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
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
302
Ucd::SetChannelEncodings
(
OfdmUcdChannelEncodings
channelEncodings)
303
{
304
m_channelEncodings
= channelEncodings;
305
}
306
307
void
308
Ucd::AddUlBurstProfile
(
OfdmUlBurstProfile
ulBurstProfile)
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
321
Ucd::GetConfigurationChangeCount
(
void
)
const
322
{
323
return
m_configurationChangeCount
;
324
}
325
326
uint8_t
327
Ucd::GetRangingBackoffStart
(
void
)
const
328
{
329
return
m_rangingBackoffStart
;
330
}
331
332
uint8_t
333
Ucd::GetRangingBackoffEnd
(
void
)
const
334
{
335
return
m_rangingBackoffEnd
;
336
}
337
338
uint8_t
339
Ucd::GetRequestBackoffStart
(
void
)
const
340
{
341
return
m_requestBackoffStart
;
342
}
343
344
uint8_t
345
Ucd::GetRequestBackoffEnd
(
void
)
const
346
{
347
return
m_requestBackoffEnd
;
348
}
349
350
OfdmUcdChannelEncodings
351
Ucd::GetChannelEncodings
(
void
)
const
352
{
353
return
m_channelEncodings
;
354
}
355
356
std::vector<OfdmUlBurstProfile>
357
Ucd::GetUlBurstProfiles
(
void
)
const
358
{
359
return
m_ulBurstProfiles
;
360
}
361
362
uint8_t
363
Ucd::GetNrUlBurstProfiles
(
void
)
const
364
{
365
return
m_nrUlBurstProfiles
;
366
}
367
368
std::string
369
Ucd::GetName
(
void
)
const
370
{
371
return
"UCD"
;
372
}
373
374
TypeId
375
Ucd::GetTypeId
(
void
)
376
{
377
static
TypeId
tid =
TypeId
(
"ns3::Ucd"
)
378
.
SetParent
<
Header
> ()
379
.AddConstructor<Ucd> ()
380
;
381
return
tid;
382
}
383
384
TypeId
385
Ucd::GetInstanceTypeId
(
void
)
const
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
403
Ucd::GetSerializedSize
(
void
)
const
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
418
Ucd::Serialize
(
Buffer::Iterator
start
)
const
419
{
420
Buffer::Iterator
i =
start
;
421
i.
WriteU8
(
m_configurationChangeCount
);
422
i.
WriteU8
(
m_rangingBackoffStart
);
423
i.
WriteU8
(
m_rangingBackoffEnd
);
424
i.
WriteU8
(
m_requestBackoffStart
);
425
i.
WriteU8
(
m_requestBackoffEnd
);
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
437
Ucd::Deserialize
(
Buffer::Iterator
start
)
438
{
439
Buffer::Iterator
i =
start
;
440
m_configurationChangeCount
= i.
ReadU8
();
441
m_rangingBackoffStart
= i.
ReadU8
();
442
m_rangingBackoffEnd
= i.
ReadU8
();
443
m_requestBackoffStart
= i.
ReadU8
();
444
m_requestBackoffEnd
= i.
ReadU8
();
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
459
OfdmUlMapIe::OfdmUlMapIe
(
void
)
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
469
OfdmUlMapIe::~OfdmUlMapIe
(
void
)
470
{
471
}
472
473
void
474
OfdmUlMapIe::SetCid
(
Cid
cid)
475
{
476
m_cid
= cid;
477
}
478
479
void
480
OfdmUlMapIe::SetStartTime
(uint16_t startTime)
481
{
482
m_startTime
= startTime;
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
504
OfdmUlMapIe::SetMidambleRepetitionInterval
(
505
uint8_t midambleRepetitionInterval)
506
{
507
m_midambleRepetitionInterval
= midambleRepetitionInterval;
508
}
509
510
Cid
511
OfdmUlMapIe::GetCid
(
void
)
const
512
{
513
return
m_cid
;
514
}
515
516
uint16_t
517
OfdmUlMapIe::GetStartTime
(
void
)
const
518
{
519
return
m_startTime
;
520
}
521
522
uint8_t
523
OfdmUlMapIe::GetSubchannelIndex
(
void
)
const
524
{
525
return
m_subchannelIndex
;
526
}
527
528
uint8_t
529
OfdmUlMapIe::GetUiuc
(
void
)
const
530
{
531
return
m_uiuc
;
532
}
533
534
uint16_t
535
OfdmUlMapIe::GetDuration
(
void
)
const
536
{
537
return
m_duration
;
538
}
539
540
uint8_t
541
OfdmUlMapIe::GetMidambleRepetitionInterval
(
void
)
const
542
{
543
return
m_midambleRepetitionInterval
;
544
}
545
546
uint16_t
547
OfdmUlMapIe::GetSize
(
void
)
const
548
{
549
return
2 + 2 + 1 + 1 + 2 + 1;
550
}
551
552
Buffer::Iterator
553
OfdmUlMapIe::Write
(
Buffer::Iterator
start
)
const
554
{
555
Buffer::Iterator
i =
start
;
556
i.
WriteU16
(
m_cid
.
GetIdentifier
());
557
i.
WriteU16
(
m_startTime
);
558
i.
WriteU8
(
m_subchannelIndex
);
559
i.
WriteU8
(
m_uiuc
);
560
i.
WriteU16
(
m_duration
);
561
i.
WriteU8
(
m_midambleRepetitionInterval
);
562
return
i;
563
}
564
565
Buffer::Iterator
566
OfdmUlMapIe::Read
(
Buffer::Iterator
start
)
567
{
568
Buffer::Iterator
i =
start
;
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
();
574
m_midambleRepetitionInterval
= i.
ReadU8
();
575
return
i;
576
}
577
578
// ----------------------------------------------------------------------------------------------------------
579
580
NS_OBJECT_ENSURE_REGISTERED
(
UlMap
);
581
582
UlMap::UlMap
(
void
)
583
: m_reserved (0),
584
m_ucdCount (0),
585
m_allocationStartTime (0)
586
{
587
}
588
589
UlMap::~UlMap
(
void
)
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
606
UlMap::AddUlMapElement
(
OfdmUlMapIe
ulMapElement)
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
618
UlMap::GetAllocationStartTime
(
void
)
const
619
{
620
return
m_allocationStartTime
;
621
}
622
623
std::list<OfdmUlMapIe>
624
UlMap::GetUlMapElements
(
void
)
const
625
{
626
return
m_ulMapElements
;
627
}
628
629
std::string
630
UlMap::GetName
(
void
)
const
631
{
632
return
"UL-MAP"
;
633
}
634
635
TypeId
636
UlMap::GetTypeId
(
void
)
637
{
638
static
TypeId
tid =
TypeId
(
"ns3::UlMap"
)
639
.
SetParent
<
Header
> ()
640
.AddConstructor<UlMap> ()
641
;
642
return
tid;
643
}
644
645
TypeId
646
UlMap::GetInstanceTypeId
(
void
)
const
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
660
UlMap::GetSerializedSize
(
void
)
const
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
674
UlMap::Serialize
(
Buffer::Iterator
start
)
const
675
{
676
Buffer::Iterator
i =
start
;
677
i.
WriteU8
(
m_reserved
);
678
i.
WriteU8
(
m_ucdCount
);
679
i.
WriteU32
(
m_allocationStartTime
);
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
690
UlMap::Deserialize
(
Buffer::Iterator
start
)
691
{
692
Buffer::Iterator
i =
start
;
693
m_reserved
= i.
ReadU8
();
694
m_ucdCount
= i.
ReadU8
();
695
m_allocationStartTime
= i.
ReadU32
();
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
src
wimax
model
ul-mac-messages.cc
Generated on Tue May 14 2013 11:08:38 for ns-3 by
1.8.1.2