A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
dl-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 "dl-mac-messages.h"
23
24#include "ns3/address-utils.h"
25
26#include <stdint.h>
27
28namespace ns3
29{
30
32 : m_bsEirp(0),
33 m_eirXPIrMax(0),
34 m_frequency(0)
35{
36}
37
39{
40}
41
42void
44{
45 m_bsEirp = bs_eirp;
46}
47
48void
49DcdChannelEncodings::SetEirxPIrMax(uint16_t eir_x_p_ir_max)
50{
51 m_eirXPIrMax = eir_x_p_ir_max;
52}
53
54void
56{
57 m_frequency = frequency;
58}
59
60uint16_t
62{
63 return m_bsEirp;
64}
65
66uint16_t
68{
69 return m_eirXPIrMax;
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;
98 m_bsEirp = i.ReadU16();
100 m_frequency = i.ReadU32();
101 return DoRead(i);
102}
103
104// ----------------------------------------------------------------------------------------------------------
105
107 : m_channelNr(0),
108 m_ttg(0),
109 m_rtg(0),
110 m_baseStationId(Mac48Address("00:00:00:00:00:00")),
111 m_frameDurationCode(0),
112 m_frameNumber(0)
113{
114}
115
117{
118}
119
120void
122{
123 m_channelNr = channelNr;
124}
125
126void
128{
129 m_ttg = ttg;
130}
131
132void
134{
135 m_rtg = rtg;
136}
137
138void
140{
141 m_baseStationId = baseStationId;
142}
143
144void
146{
147 m_frameDurationCode = frameDurationCode;
148}
149
150void
152{
153 m_frameNumber = frameNumber;
154}
155
156uint8_t
158{
159 return m_channelNr;
160}
161
162uint8_t
164{
165 return m_ttg;
166}
167
168uint8_t
170{
171 return m_rtg;
172}
173
176{
177 return m_baseStationId;
178}
179
180uint8_t
182{
183 return m_frameDurationCode;
184}
185
188{
189 return m_frameNumber;
190}
191
192uint16_t
194{
195 return DcdChannelEncodings::GetSize() + 1 + 1 + 1 + 6 + 1 + 4;
196}
197
200{
201 Buffer::Iterator i = start;
203 i.WriteU8(m_ttg);
204 i.WriteU8(m_rtg);
208 return i;
209}
210
213{
214 Buffer::Iterator i = start;
215 m_channelNr = i.ReadU8();
216 m_ttg = i.ReadU8();
217 m_rtg = i.ReadU8();
218 ReadFrom(i, m_baseStationId); // length (6) shall also be written in packet instead of hard
219 // coded, see ARP example
222 return i;
223}
224
225// ----------------------------------------------------------------------------------------------------------
226
228 : m_type(0),
229 m_length(0),
230 m_diuc(0),
231 m_fecCodeType(0)
232{
233}
234
236{
237}
238
239void
241{
242 m_type = type;
243}
244
245void
247{
248 m_length = length;
249}
250
251void
253{
254 m_diuc = diuc;
255}
256
257void
259{
260 m_fecCodeType = fecCodeType;
261}
262
263uint8_t
265{
266 return m_type;
267}
268
269uint8_t
271{
272 return m_length;
273}
274
275uint8_t
277{
278 return m_diuc;
279}
280
281uint8_t
283{
284 return m_fecCodeType;
285}
286
287uint16_t
289{
290 return 1 + 1 + 1 + 1;
291}
292
295{
296 Buffer::Iterator i = start;
297 i.WriteU8(m_type);
298 i.WriteU8(m_length);
299 i.WriteU8(m_diuc);
301 return i;
302}
303
306{
307 Buffer::Iterator i = start;
308 m_type = i.ReadU8();
309 m_length = i.ReadU8();
310 m_diuc = i.ReadU8();
311 m_fecCodeType = i.ReadU8();
312 return i;
313}
314
315// ----------------------------------------------------------------------------------------------------------
316
318
320 : m_reserved(0),
321 m_configurationChangeCount(0),
322 m_nrDlBurstProfiles(0)
323{
324}
325
327{
328}
329
330void
331Dcd::SetConfigurationChangeCount(uint8_t configurationChangeCount)
332{
333 m_configurationChangeCount = configurationChangeCount;
334}
335
336void
338{
339 m_channelEncodings = channelEncodings;
340}
341
342void
343Dcd::SetNrDlBurstProfiles(uint8_t nrDlBurstProfiles)
344{
345 m_nrDlBurstProfiles = nrDlBurstProfiles;
346}
347
348void
350{
351 m_dlBurstProfiles.push_back(dlBurstProfile);
352}
353
354uint8_t
356{
358}
359
362{
363 return m_channelEncodings;
364}
365
366std::vector<OfdmDlBurstProfile>
368{
369 return m_dlBurstProfiles;
370}
371
372uint8_t
374{
375 return m_nrDlBurstProfiles;
376}
377
378std::string
380{
381 return "DCD";
382}
383
384TypeId
386{
387 static TypeId tid =
388 TypeId("ns3::Dcd").SetParent<Header>().SetGroupName("Wimax").AddConstructor<Dcd>();
389 return tid;
390}
391
392TypeId
394{
395 return GetTypeId();
396}
397
398void
399Dcd::Print(std::ostream& os) const
400{
401 os << " configuration change count = " << (uint32_t)m_configurationChangeCount
402 << ", number of dl burst profiles = " << m_dlBurstProfiles.size();
403}
404
407{
408 uint32_t dlBurstProfilesSize = 0;
409
410 for (const auto& burstProfile : m_dlBurstProfiles)
411 {
412 dlBurstProfilesSize += burstProfile.GetSize();
413 }
414
415 return 1 + 1 + m_channelEncodings.GetSize() + dlBurstProfilesSize;
416}
417
418void
420{
421 Buffer::Iterator i = start;
425
426 for (const auto& burstProfile : m_dlBurstProfiles)
427 {
428 i = burstProfile.Write(i);
429 }
430}
431
434{
435 Buffer::Iterator i = start;
436 m_reserved = i.ReadU8();
439
440 for (uint8_t j = 0; j < m_nrDlBurstProfiles; j++)
441 {
442 OfdmDlBurstProfile burstProfile;
443 i = burstProfile.Read(i);
444 AddDlBurstProfile(burstProfile);
445 }
446
447 return i.GetDistanceFrom(start);
448}
449
450// ----------------------------------------------------------------------------------------------------------
451
453 : m_cid(),
454 m_diuc(0),
455 m_preamblePresent(0),
456 m_startTime(0)
457{
458}
459
461{
462}
463
464void
466{
467 m_cid = cid;
468}
469
470void
472{
473 m_diuc = diuc;
474}
475
476void
477OfdmDlMapIe::SetPreamblePresent(uint8_t preamblePresent)
478{
479 m_preamblePresent = preamblePresent;
480}
481
482void
483OfdmDlMapIe::SetStartTime(uint16_t startTime)
484{
485 m_startTime = startTime;
486}
487
488Cid
490{
491 return m_cid;
492}
493
494uint8_t
496{
497 return m_diuc;
498}
499
500uint8_t
502{
503 return m_preamblePresent;
504}
505
506uint16_t
508{
509 return m_startTime;
510}
511
512uint16_t
514{
515 return 2 + 1 + 1 + 2;
516}
517
520{
521 Buffer::Iterator i = start;
523 i.WriteU8(m_diuc);
526 return i;
527}
528
531{
532 Buffer::Iterator i = start;
533 m_cid = i.ReadU16();
534 m_diuc = i.ReadU8();
536 m_startTime = i.ReadU16();
537 return i;
538}
539
540// ----------------------------------------------------------------------------------------------------------
541
543
545 : m_dcdCount(0),
546 m_baseStationId(Mac48Address("00:00:00:00:00:00"))
547{
548}
549
551{
552}
553
554void
555DlMap::SetDcdCount(uint8_t dcdCount)
556{
557 m_dcdCount = dcdCount;
558}
559
560void
562{
563 m_baseStationId = baseStationId;
564}
565
566void
568{
569 m_dlMapElements.push_back(dlMapElement);
570}
571
572uint8_t
574{
575 return m_dcdCount;
576}
577
580{
581 return m_baseStationId;
582}
583
584std::list<OfdmDlMapIe>
586{
587 return m_dlMapElements;
588}
589
590std::string
592{
593 return "DL-MAP";
594}
595
596TypeId
598{
599 static TypeId tid =
600 TypeId("ns3::DlMap").SetParent<Header>().SetGroupName("Wimax").AddConstructor<DlMap>();
601 return tid;
602}
603
604TypeId
606{
607 return GetTypeId();
608}
609
610void
611DlMap::Print(std::ostream& os) const
612{
613 os << " dcd count = " << (uint32_t)m_dcdCount << ", base station id = " << m_baseStationId
614 << ", number of dl-map elements = " << m_dlMapElements.size();
615}
616
619{
620 uint32_t dlMapElementsSize = 0;
621
622 for (const auto& dlMapIe : m_dlMapElements)
623 {
624 dlMapElementsSize += dlMapIe.GetSize();
625 }
626
627 return 1 + 6 + dlMapElementsSize;
628}
629
630void
632{
633 Buffer::Iterator i = start;
636
637 for (const auto& dlMapIe : m_dlMapElements)
638 {
639 i = dlMapIe.Write(i);
640 }
641}
642
645{
646 Buffer::Iterator i = start;
647 m_dcdCount = i.ReadU8();
648 ReadFrom(i, m_baseStationId); // length (6) shall also be written in packet instead of hard
649 // coded, see ARP example
650
651 m_dlMapElements.clear(); // only for printing, otherwise it shows wrong number of elements
652
653 while (true)
654 {
655 OfdmDlMapIe dlMapIe;
656 i = dlMapIe.Read(i);
657
658 AddDlMapElement(dlMapIe);
659
660 if (dlMapIe.GetDiuc() == 14) // End of Map IE
661 {
662 break;
663 }
664 }
665 return i.GetDistanceFrom(start);
666}
667
668} // 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
uint16_t GetEirxPIrMax() const
Get EIRX IR MAX field.
uint32_t m_frequency
frequency
uint16_t GetSize() const
Get size field.
uint16_t GetBsEirp() const
Get BS EIRP field.
void SetBsEirp(uint16_t bs_eirp)
Set BS EIRP field.
void SetFrequency(uint32_t frequency)
Set frequency field.
Buffer::Iterator Write(Buffer::Iterator start) const
Write item.
Buffer::Iterator Read(Buffer::Iterator start)
Read item.
void SetEirxPIrMax(uint16_t rss_ir_max)
Set EIRX IR MAX field.
uint32_t GetFrequency() const
Get frequency function.
virtual Buffer::Iterator DoWrite(Buffer::Iterator start) const =0
Write item.
uint16_t m_eirXPIrMax
EIRX IR MAX.
virtual Buffer::Iterator DoRead(Buffer::Iterator start)=0
Read item.
uint16_t m_bsEirp
BS EIRP.
This class implements Downlink channel descriptor as described by "IEEE Standard for Local and metrop...
OfdmDcdChannelEncodings m_channelEncodings
TLV Encoded information for the overall channel.
uint8_t m_nrDlBurstProfiles
number DL purst profiles
void SetConfigurationChangeCount(uint8_t configurationChangeCount)
Set configuration change count field.
void Print(std::ostream &os) const override
void SetNrDlBurstProfiles(uint8_t nrDlBurstProfiles)
Set number DL burst profile field.
uint8_t m_reserved
changed as per the amendment 802.16e-2005
uint32_t Deserialize(Buffer::Iterator start) override
uint8_t m_configurationChangeCount
configuration change count
std::vector< OfdmDlBurstProfile > GetDlBurstProfiles() const
Get DL burst profile field.
static TypeId GetTypeId()
Get the type ID.
uint32_t GetSerializedSize() const override
OfdmDcdChannelEncodings GetChannelEncodings() const
Get channel encodings field.
std::string GetName() const
Get name field.
uint8_t GetConfigurationChangeCount() const
Get configuration change count field.
void AddDlBurstProfile(OfdmDlBurstProfile dlBurstProfile)
Add DL burst profile field.
~Dcd() override
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
void Serialize(Buffer::Iterator start) const override
uint8_t GetNrDlBurstProfiles() const
Get number DL burst profiles field.
void SetChannelEncodings(OfdmDcdChannelEncodings channelEncodings)
Set channel encodings field.
std::vector< OfdmDlBurstProfile > m_dlBurstProfiles
vector of download burst profiles
This class implements DL-MAP as described by "IEEE Standard for Local and metropolitan area networks ...
void SetDcdCount(uint8_t dcdCount)
Set DCD count field.
void Serialize(Buffer::Iterator start) const override
static TypeId GetTypeId()
Get the type ID.
void AddDlMapElement(OfdmDlMapIe dlMapElement)
Add DL Map element field.
Mac48Address GetBaseStationId() const
Get base station ID field.
std::list< OfdmDlMapIe > GetDlMapElements() const
Get DL Map elements field.
std::list< OfdmDlMapIe > m_dlMapElements
DL Map elements.
void SetBaseStationId(Mac48Address baseStationID)
Set base station ID field.
uint32_t GetSerializedSize() const override
uint8_t m_dcdCount
DCD count.
std::string GetName() const
Get name field.
void Print(std::ostream &os) const override
uint32_t Deserialize(Buffer::Iterator start) override
uint8_t GetDcdCount() const
Get DCD count field.
Mac48Address m_baseStationId
base station ID
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
~DlMap() override
Protocol header serialization and deserialization.
Definition: header.h:44
an EUI-48 address
Definition: mac48-address.h:46
This class implements the OFDM DCD channel encodings as described by "IEEE Standard for Local and met...
uint8_t GetTtg() const
Get TTG field.
uint32_t GetFrameNumber() const
Get frame number field.
uint8_t GetFrameDurationCode() const
Get frame duration code field.
uint8_t m_channelNr
channel number
uint16_t GetSize() const
Get size field.
Buffer::Iterator DoRead(Buffer::Iterator start) override
Read item.
void SetChannelNr(uint8_t channelNr)
Set channel number field.
uint8_t GetChannelNr() const
Get channel number field.
void SetTtg(uint8_t ttg)
Set TTG field.
void SetFrameDurationCode(uint8_t frameDurationCode)
Set frame duration code field.
uint8_t m_frameDurationCode
frame duration code
Mac48Address GetBaseStationId() const
Get base station ID field.
Buffer::Iterator DoWrite(Buffer::Iterator start) const override
Write item.
uint32_t m_frameNumber
frame number
void SetRtg(uint8_t rtg)
Set RTG field.
void SetFrameNumber(uint32_t frameNumber)
Set frame number field.
Mac48Address m_baseStationId
base station ID
uint8_t GetRtg() const
Get RTG field.
void SetBaseStationId(Mac48Address baseStationId)
Set base station ID field.
This class implements the OFDM Downlink burst profile descriptor as described by "IEEE Standard for L...
uint16_t GetSize() const
Buffer::Iterator Write(Buffer::Iterator start) const
Write item.
uint8_t GetFecCodeType() const
void SetFecCodeType(uint8_t fecCodeType)
Set FEC code type.
void SetLength(uint8_t length)
Set length field.
void SetType(uint8_t type)
Set type field.
uint8_t GetType() const
Get type function.
Buffer::Iterator Read(Buffer::Iterator start)
Read item.
uint8_t m_fecCodeType
FEC code type.
void SetDiuc(uint8_t diuc)
Set DIUC field.
This class implements the OFDM DL-MAP information element as described by "IEEE Standard for Local an...
void SetStartTime(uint16_t startTime)
Set start time field.
uint8_t GetDiuc() const
Get DIUC field.
void SetCid(Cid cid)
Set CID function.
uint8_t m_preamblePresent
preamble present
Cid GetCid() const
Set CID field.
uint16_t m_startTime
start time
void SetDiuc(uint8_t diuc)
Set DIUC field.
void SetPreamblePresent(uint8_t preamblePresent)
Set preamble present field.
Buffer::Iterator Write(Buffer::Iterator start) const
Write item.
uint16_t GetStartTime() const
Get start time field.
Buffer::Iterator Read(Buffer::Iterator start)
Read item.
uint8_t GetPreamblePresent() const
Get preamble present field.
uint16_t GetSize() const
Get size.
uint8_t m_diuc
DIUC.
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:932
#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.
void WriteTo(Buffer::Iterator &i, Ipv4Address ad)
Write an Ipv4Address to a Buffer.
void ReadFrom(Buffer::Iterator &i, Ipv4Address &ad)
Read an Ipv4Address from a Buffer.