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
dl-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
24
#include <stdint.h>
25
#include "
dl-mac-messages.h
"
26
#include "ns3/address-utils.h"
27
28
namespace
ns3 {
29
30
DcdChannelEncodings::DcdChannelEncodings
(
void
)
31
: m_bsEirp (0),
32
m_eirXPIrMax (0),
33
m_frequency (0)
34
{
35
}
36
37
DcdChannelEncodings::~DcdChannelEncodings
(
void
)
38
{
39
}
40
41
void
42
DcdChannelEncodings::SetBsEirp
(uint16_t bs_eirp)
43
{
44
m_bsEirp
= bs_eirp;
45
}
46
47
void
48
DcdChannelEncodings::SetEirxPIrMax
(uint16_t eir_x_p_ir_max)
49
{
50
m_eirXPIrMax
= eir_x_p_ir_max;
51
}
52
53
void
54
DcdChannelEncodings::SetFrequency
(uint32_t frequency)
55
{
56
m_frequency
= frequency;
57
}
58
59
uint16_t
60
DcdChannelEncodings::GetBsEirp
(
void
)
const
61
{
62
return
m_bsEirp
;
63
}
64
65
uint16_t
66
DcdChannelEncodings::GetEirxPIrMax
(
void
)
const
67
{
68
return
m_eirXPIrMax
;
69
}
70
71
uint32_t
72
DcdChannelEncodings::GetFrequency
(
void
)
const
73
{
74
return
m_frequency
;
75
}
76
77
uint16_t
78
DcdChannelEncodings::GetSize
(
void
)
const
79
{
80
return
2 + 2 + 4;
81
}
82
83
Buffer::Iterator
84
DcdChannelEncodings::Write
(
Buffer::Iterator
start
)
const
85
{
86
Buffer::Iterator
i =
start
;
87
i.
WriteU16
(
m_bsEirp
);
88
i.
WriteU16
(
m_eirXPIrMax
);
89
i.
WriteU32
(
m_frequency
);
90
return
DoWrite
(i);
91
}
92
93
Buffer::Iterator
94
DcdChannelEncodings::Read
(
Buffer::Iterator
start
)
95
{
96
Buffer::Iterator
i =
start
;
97
m_bsEirp
= i.
ReadU16
();
98
m_eirXPIrMax
= i.
ReadU16
();
99
m_frequency
= i.
ReadU32
();
100
return
DoRead
(i);
101
}
102
103
// ----------------------------------------------------------------------------------------------------------
104
105
OfdmDcdChannelEncodings::OfdmDcdChannelEncodings
(
void
)
106
: m_channelNr (0),
107
m_ttg (0),
108
m_rtg (0),
109
m_baseStationId (
Mac48Address
(
"00:00:00:00:00:00"
)),
110
m_frameDurationCode (0),
111
m_frameNumber (0)
112
{
113
}
114
115
OfdmDcdChannelEncodings::~OfdmDcdChannelEncodings
(
void
)
116
{
117
}
118
119
void
120
OfdmDcdChannelEncodings::SetChannelNr
(uint8_t channelNr)
121
{
122
m_channelNr
= channelNr;
123
}
124
125
void
126
OfdmDcdChannelEncodings::SetTtg
(uint8_t ttg)
127
{
128
m_ttg
= ttg;
129
}
130
131
void
132
OfdmDcdChannelEncodings::SetRtg
(uint8_t rtg)
133
{
134
m_rtg
= rtg;
135
}
136
137
void
138
OfdmDcdChannelEncodings::SetBaseStationId
(
Mac48Address
baseStationId)
139
{
140
m_baseStationId
= baseStationId;
141
}
142
143
void
144
OfdmDcdChannelEncodings::SetFrameDurationCode
(uint8_t frameDurationCode)
145
{
146
m_frameDurationCode
= frameDurationCode;
147
}
148
149
void
150
OfdmDcdChannelEncodings::SetFrameNumber
(uint32_t frameNumber)
151
{
152
m_frameNumber
= frameNumber;
153
}
154
155
uint8_t
156
OfdmDcdChannelEncodings::GetChannelNr
(
void
)
const
157
{
158
return
m_channelNr
;
159
}
160
161
uint8_t
162
OfdmDcdChannelEncodings::GetTtg
(
void
)
const
163
{
164
return
m_ttg
;
165
}
166
167
uint8_t
168
OfdmDcdChannelEncodings::GetRtg
(
void
)
const
169
{
170
return
m_rtg
;
171
}
172
173
Mac48Address
174
OfdmDcdChannelEncodings::GetBaseStationId
(
void
)
const
175
{
176
return
m_baseStationId
;
177
}
178
179
uint8_t
180
OfdmDcdChannelEncodings::GetFrameDurationCode
(
void
)
const
181
{
182
return
m_frameDurationCode
;
183
}
184
185
uint32_t
186
OfdmDcdChannelEncodings::GetFrameNumber
(
void
)
const
187
{
188
return
m_frameNumber
;
189
}
190
191
uint16_t
192
OfdmDcdChannelEncodings::GetSize
(
void
)
const
193
{
194
return
DcdChannelEncodings::GetSize
() + 1 + 1 + 1 + 6 + 1 + 4;
195
}
196
197
Buffer::Iterator
198
OfdmDcdChannelEncodings::DoWrite
(
Buffer::Iterator
start
)
const
199
{
200
Buffer::Iterator
i =
start
;
201
i.
WriteU8
(
m_channelNr
);
202
i.
WriteU8
(
m_ttg
);
203
i.
WriteU8
(
m_rtg
);
204
WriteTo
(i,
m_baseStationId
);
205
i.
WriteU8
(
m_frameDurationCode
);
206
i.
WriteU32
(
m_frameNumber
);
207
return
i;
208
}
209
210
Buffer::Iterator
211
OfdmDcdChannelEncodings::DoRead
(
Buffer::Iterator
start
)
212
{
213
Buffer::Iterator
i =
start
;
214
m_channelNr
= i.
ReadU8
();
215
m_ttg
= i.
ReadU8
();
216
m_rtg
= i.
ReadU8
();
217
ReadFrom
(i,
m_baseStationId
);
// length (6) shall also be written in packet instead of hard coded, see ARP example
218
m_frameDurationCode
= i.
ReadU8
();
219
m_frameNumber
= i.
ReadU32
();
220
return
i;
221
}
222
223
// ----------------------------------------------------------------------------------------------------------
224
225
OfdmDlBurstProfile::OfdmDlBurstProfile
(
void
)
226
: m_type (0),
227
m_length (0),
228
m_diuc (0),
229
m_fecCodeType (0)
230
{
231
}
232
233
OfdmDlBurstProfile::~OfdmDlBurstProfile
(
void
)
234
{
235
}
236
237
void
238
OfdmDlBurstProfile::SetType
(uint8_t type)
239
{
240
m_type
= type;
241
}
242
243
void
244
OfdmDlBurstProfile::SetLength
(uint8_t length)
245
{
246
m_length
= length;
247
}
248
249
void
250
OfdmDlBurstProfile::SetDiuc
(uint8_t diuc)
251
{
252
m_diuc
= diuc;
253
}
254
255
void
256
OfdmDlBurstProfile::SetFecCodeType
(uint8_t fecCodeType)
257
{
258
m_fecCodeType
= fecCodeType;
259
}
260
261
uint8_t
262
OfdmDlBurstProfile::GetType
(
void
)
const
263
{
264
return
m_type
;
265
}
266
267
uint8_t
268
OfdmDlBurstProfile::GetLength
(
void
)
const
269
{
270
return
m_length
;
271
}
272
273
uint8_t
274
OfdmDlBurstProfile::GetDiuc
(
void
)
const
275
{
276
return
m_diuc
;
277
}
278
279
uint8_t
280
OfdmDlBurstProfile::GetFecCodeType
(
void
)
const
281
{
282
return
m_fecCodeType
;
283
}
284
285
uint16_t
286
OfdmDlBurstProfile::GetSize
(
void
)
const
287
{
288
return
1 + 1 + 1 + 1;
289
}
290
291
Buffer::Iterator
292
OfdmDlBurstProfile::Write
(
Buffer::Iterator
start
)
const
293
{
294
Buffer::Iterator
i =
start
;
295
i.
WriteU8
(
m_type
);
296
i.
WriteU8
(
m_length
);
297
i.
WriteU8
(
m_diuc
);
298
i.
WriteU8
(
m_fecCodeType
);
299
return
i;
300
}
301
302
Buffer::Iterator
303
OfdmDlBurstProfile::Read
(
Buffer::Iterator
start
)
304
{
305
Buffer::Iterator
i =
start
;
306
m_type
= i.
ReadU8
();
307
m_length
= i.
ReadU8
();
308
m_diuc
= i.
ReadU8
();
309
m_fecCodeType
= i.
ReadU8
();
310
return
i;
311
}
312
313
// ----------------------------------------------------------------------------------------------------------
314
315
NS_OBJECT_ENSURE_REGISTERED
(
Dcd
);
316
317
Dcd::Dcd
(
void
)
318
: m_reserved (0),
319
m_configurationChangeCount (0),
320
m_nrDlBurstProfiles (0)
321
{
322
}
323
324
Dcd::~Dcd
(
void
)
325
{
326
}
327
328
void
329
Dcd::SetConfigurationChangeCount
(uint8_t configurationChangeCount)
330
{
331
m_configurationChangeCount
= configurationChangeCount;
332
}
333
334
void
335
Dcd::SetChannelEncodings
(
OfdmDcdChannelEncodings
channelEncodings)
336
{
337
m_channelEncodings
= channelEncodings;
338
}
339
340
void
341
Dcd::SetNrDlBurstProfiles
(uint8_t nrDlBurstProfiles)
342
{
343
m_nrDlBurstProfiles
= nrDlBurstProfiles;
344
}
345
346
void
347
Dcd::AddDlBurstProfile
(
OfdmDlBurstProfile
dlBurstProfile)
348
{
349
m_dlBurstProfiles
.push_back (dlBurstProfile);
350
}
351
352
uint8_t
353
Dcd::GetConfigurationChangeCount
(
void
)
const
354
{
355
return
m_configurationChangeCount
;
356
}
357
358
OfdmDcdChannelEncodings
359
Dcd::GetChannelEncodings
(
void
)
const
360
{
361
return
m_channelEncodings
;
362
}
363
364
std::vector<OfdmDlBurstProfile>
365
Dcd::GetDlBurstProfiles
(
void
)
const
366
{
367
return
m_dlBurstProfiles
;
368
}
369
370
uint8_t
371
Dcd::GetNrDlBurstProfiles
(
void
)
const
372
{
373
return
m_nrDlBurstProfiles
;
374
}
375
376
std::string
377
Dcd::GetName
(
void
)
const
378
{
379
return
"DCD"
;
380
}
381
382
TypeId
383
Dcd::GetTypeId
(
void
)
384
{
385
static
TypeId
tid =
TypeId
(
"ns3::Dcd"
)
386
.
SetParent
<
Header
> ()
387
.AddConstructor<Dcd> ()
388
;
389
return
tid;
390
}
391
392
TypeId
393
Dcd::GetInstanceTypeId
(
void
)
const
394
{
395
return
GetTypeId
();
396
}
397
398
void
399
Dcd::Print
(std::ostream &os)
const
400
{
401
os <<
" configuration change count = "
402
<< (uint32_t)
m_configurationChangeCount
403
<<
", number of dl burst profiles = "
<<
m_dlBurstProfiles
.size ();
404
}
405
406
uint32_t
407
Dcd::GetSerializedSize
(
void
)
const
408
{
409
uint32_t dlBurstProfilesSize = 0;
410
411
for
(std::vector<OfdmDlBurstProfile>::const_iterator iter =
412
m_dlBurstProfiles
.begin (); iter !=
m_dlBurstProfiles
.end (); ++iter)
413
{
414
OfdmDlBurstProfile
burstProfile = *iter;
415
dlBurstProfilesSize += burstProfile.
GetSize
();
416
}
417
418
return
1 + 1 +
m_channelEncodings
.
GetSize
() + dlBurstProfilesSize;
419
}
420
421
void
422
Dcd::Serialize
(
Buffer::Iterator
start
)
const
423
{
424
Buffer::Iterator
i =
start
;
425
i.
WriteU8
(
m_reserved
);
426
i.
WriteU8
(
m_configurationChangeCount
);
427
i =
m_channelEncodings
.
Write
(i);
428
429
for
(std::vector<OfdmDlBurstProfile>::const_iterator iter =
430
m_dlBurstProfiles
.begin (); iter !=
m_dlBurstProfiles
.end (); ++iter)
431
{
432
OfdmDlBurstProfile
burstProfile = *iter;
433
i = burstProfile.
Write
(i);
434
}
435
}
436
437
uint32_t
438
Dcd::Deserialize
(
Buffer::Iterator
start
)
439
{
440
Buffer::Iterator
i =
start
;
441
m_reserved
= i.
ReadU8
();
442
m_configurationChangeCount
= i.
ReadU8
();
443
i =
m_channelEncodings
.
Read
(i);
444
445
for
(uint8_t j = 0; j <
m_nrDlBurstProfiles
; j++)
446
{
447
OfdmDlBurstProfile
burstProfile;
448
i = burstProfile.
Read
(i);
449
AddDlBurstProfile
(burstProfile);
450
}
451
452
return
i.
GetDistanceFrom
(start);
453
}
454
455
// ----------------------------------------------------------------------------------------------------------
456
457
OfdmDlMapIe::OfdmDlMapIe
(
void
)
458
: m_cid (),
459
m_diuc (0),
460
m_preamblePresent (0),
461
m_startTime (0)
462
{
463
}
464
465
OfdmDlMapIe::~OfdmDlMapIe
(
void
)
466
{
467
}
468
469
void
470
OfdmDlMapIe::SetCid
(
Cid
cid)
471
{
472
m_cid
= cid;
473
}
474
475
void
476
OfdmDlMapIe::SetDiuc
(uint8_t diuc)
477
{
478
m_diuc
= diuc;
479
}
480
481
void
482
OfdmDlMapIe::SetPreamblePresent
(uint8_t preamblePresent)
483
{
484
m_preamblePresent
= preamblePresent;
485
}
486
487
void
488
OfdmDlMapIe::SetStartTime
(uint16_t startTime)
489
{
490
m_startTime
= startTime;
491
}
492
493
Cid
494
OfdmDlMapIe::GetCid
(
void
)
const
495
{
496
return
m_cid
;
497
}
498
499
uint8_t
500
OfdmDlMapIe::GetDiuc
(
void
)
const
501
{
502
return
m_diuc
;
503
}
504
505
uint8_t
506
OfdmDlMapIe::GetPreamblePresent
(
void
)
const
507
{
508
return
m_preamblePresent
;
509
}
510
511
uint16_t
512
OfdmDlMapIe::GetStartTime
(
void
)
const
513
{
514
return
m_startTime
;
515
}
516
517
uint16_t
518
OfdmDlMapIe::GetSize
(
void
)
const
519
{
520
return
2 + 1 + 1 + 2;
521
}
522
523
Buffer::Iterator
524
OfdmDlMapIe::Write
(
Buffer::Iterator
start
)
const
525
{
526
Buffer::Iterator
i =
start
;
527
i.
WriteU16
(
m_cid
.
GetIdentifier
());
528
i.
WriteU8
(
m_diuc
);
529
i.
WriteU8
(
m_preamblePresent
);
530
i.
WriteU16
(
m_startTime
);
531
return
i;
532
}
533
534
Buffer::Iterator
535
OfdmDlMapIe::Read
(
Buffer::Iterator
start
)
536
{
537
Buffer::Iterator
i =
start
;
538
m_cid
= i.
ReadU16
();
539
m_diuc
= i.
ReadU8
();
540
m_preamblePresent
= i.
ReadU8
();
541
m_startTime
= i.
ReadU16
();
542
return
i;
543
}
544
545
// ----------------------------------------------------------------------------------------------------------
546
547
NS_OBJECT_ENSURE_REGISTERED
(
DlMap
);
548
549
DlMap::DlMap
(
void
)
550
: m_dcdCount (0),
551
m_baseStationId (
Mac48Address
(
"00:00:00:00:00:00"
))
552
{
553
}
554
555
DlMap::~DlMap
(
void
)
556
{
557
}
558
559
void
560
DlMap::SetDcdCount
(uint8_t dcdCount)
561
{
562
m_dcdCount
= dcdCount;
563
}
564
565
void
566
DlMap::SetBaseStationId
(
Mac48Address
baseStationId)
567
{
568
m_baseStationId
= baseStationId;
569
}
570
571
void
572
DlMap::AddDlMapElement
(
OfdmDlMapIe
dlMapElement)
573
{
574
m_dlMapElements
.push_back (dlMapElement);
575
}
576
577
uint8_t
578
DlMap::GetDcdCount
(
void
)
const
579
{
580
return
m_dcdCount
;
581
}
582
583
Mac48Address
584
DlMap::GetBaseStationId
(
void
)
const
585
{
586
return
m_baseStationId
;
587
}
588
589
std::list<OfdmDlMapIe>
590
DlMap::GetDlMapElements
(
void
)
const
591
{
592
return
m_dlMapElements
;
593
}
594
595
std::string
596
DlMap::GetName
(
void
)
const
597
{
598
return
"DL-MAP"
;
599
}
600
601
TypeId
602
DlMap::GetTypeId
(
void
)
603
{
604
static
TypeId
tid =
TypeId
(
"ns3::DlMap"
)
605
.
SetParent
<
Header
> ()
606
.AddConstructor<DlMap> ()
607
;
608
return
tid;
609
}
610
611
TypeId
612
DlMap::GetInstanceTypeId
(
void
)
const
613
{
614
return
GetTypeId
();
615
}
616
617
void
618
DlMap::Print
(std::ostream &os)
const
619
{
620
os <<
" dcd count = "
<< (uint32_t)
m_dcdCount
<<
", base station id = "
621
<<
m_baseStationId
<<
", number of dl-map elements = "
622
<<
m_dlMapElements
.size ();
623
}
624
625
uint32_t
626
DlMap::GetSerializedSize
(
void
)
const
627
{
628
uint32_t dlMapElementsSize = 0;
629
630
for
(std::list<OfdmDlMapIe>::const_iterator iter =
m_dlMapElements
.begin (); iter
631
!=
m_dlMapElements
.end (); ++iter)
632
{
633
OfdmDlMapIe
dlMapIe = *iter;
634
dlMapElementsSize += dlMapIe.
GetSize
();
635
}
636
637
return
1 + 6 + dlMapElementsSize;
638
}
639
640
void
641
DlMap::Serialize
(
Buffer::Iterator
start
)
const
642
{
643
Buffer::Iterator
i =
start
;
644
i.
WriteU8
(
m_dcdCount
);
645
WriteTo
(i,
m_baseStationId
);
646
647
for
(std::list<OfdmDlMapIe>::const_iterator iter =
m_dlMapElements
.begin (); iter
648
!=
m_dlMapElements
.end (); ++iter)
649
{
650
OfdmDlMapIe
dlMapIe = *iter;
651
i = dlMapIe.
Write
(i);
652
}
653
}
654
655
uint32_t
656
DlMap::Deserialize
(
Buffer::Iterator
start
)
657
{
658
Buffer::Iterator
i =
start
;
659
m_dcdCount
= i.
ReadU8
();
660
ReadFrom
(i,
m_baseStationId
);
// length (6) shall also be written in packet instead of hard coded, see ARP example
661
662
m_dlMapElements
.clear ();
// only for printing, otherwise it shows wrong number of elements
663
664
while
(
true
)
665
{
666
OfdmDlMapIe
dlMapIe;
667
i = dlMapIe.
Read
(i);
668
669
AddDlMapElement
(dlMapIe);
670
671
if
(dlMapIe.
GetDiuc
() == 14)
// End of Map IE
672
{
673
break
;
674
}
675
}
676
return
i.
GetDistanceFrom
(start);
677
}
678
679
}
// namespace ns3
680
src
wimax
model
dl-mac-messages.cc
Generated on Tue May 14 2013 11:08:37 for ns-3 by
1.8.1.2