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 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Authors: Jahanzeb Farooq <jahanzeb.farooq@sophia.inria.fr>
7 * Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
8 * <amine.ismail@UDcast.com>
9 */
10
11#include "dl-mac-messages.h"
12
13#include "ns3/address-utils.h"
14
15#include <stdint.h>
16
17namespace ns3
18{
19
21 : m_bsEirp(0),
22 m_eirXPIrMax(0),
23 m_frequency(0)
24{
25}
26
30
31void
33{
34 m_bsEirp = bs_eirp;
35}
36
37void
38DcdChannelEncodings::SetEirxPIrMax(uint16_t eir_x_p_ir_max)
39{
40 m_eirXPIrMax = eir_x_p_ir_max;
41}
42
43void
45{
46 m_frequency = frequency;
47}
48
49uint16_t
51{
52 return m_bsEirp;
53}
54
55uint16_t
60
66
67uint16_t
69{
70 return 2 + 2 + 4;
71}
72
82
85{
86 Buffer::Iterator i = start;
87 m_bsEirp = i.ReadU16();
89 m_frequency = i.ReadU32();
90 return DoRead(i);
91}
92
93// ----------------------------------------------------------------------------------------------------------
94
96 : m_channelNr(0),
97 m_ttg(0),
98 m_rtg(0),
99 m_baseStationId(Mac48Address("00:00:00:00:00:00")),
100 m_frameDurationCode(0),
101 m_frameNumber(0)
102{
103}
104
108
109void
111{
112 m_channelNr = channelNr;
113}
114
115void
117{
118 m_ttg = ttg;
119}
120
121void
123{
124 m_rtg = rtg;
125}
126
127void
129{
130 m_baseStationId = baseStationId;
131}
132
133void
135{
136 m_frameDurationCode = frameDurationCode;
137}
138
139void
141{
142 m_frameNumber = frameNumber;
143}
144
145uint8_t
150
151uint8_t
153{
154 return m_ttg;
155}
156
157uint8_t
159{
160 return m_rtg;
161}
162
168
169uint8_t
174
180
181uint16_t
183{
184 return DcdChannelEncodings::GetSize() + 1 + 1 + 1 + 6 + 1 + 4;
185}
186
199
202{
203 Buffer::Iterator i = start;
204 m_channelNr = i.ReadU8();
205 m_ttg = i.ReadU8();
206 m_rtg = i.ReadU8();
207 ReadFrom(i, m_baseStationId); // length (6) shall also be written in packet instead of hard
208 // coded, see ARP example
211 return i;
212}
213
214// ----------------------------------------------------------------------------------------------------------
215
217 : m_type(0),
218 m_length(0),
219 m_diuc(0),
220 m_fecCodeType(0)
221{
222}
223
227
228void
230{
231 m_type = type;
232}
233
234void
236{
237 m_length = length;
238}
239
240void
242{
243 m_diuc = diuc;
244}
245
246void
248{
249 m_fecCodeType = fecCodeType;
250}
251
252uint8_t
254{
255 return m_type;
256}
257
258uint8_t
260{
261 return m_length;
262}
263
264uint8_t
266{
267 return m_diuc;
268}
269
270uint8_t
275
276uint16_t
278{
279 return 1 + 1 + 1 + 1;
280}
281
284{
285 Buffer::Iterator i = start;
286 i.WriteU8(m_type);
287 i.WriteU8(m_length);
288 i.WriteU8(m_diuc);
290 return i;
291}
292
295{
296 Buffer::Iterator i = start;
297 m_type = i.ReadU8();
298 m_length = i.ReadU8();
299 m_diuc = i.ReadU8();
300 m_fecCodeType = i.ReadU8();
301 return i;
302}
303
304// ----------------------------------------------------------------------------------------------------------
305
307
309 : m_reserved(0),
310 m_configurationChangeCount(0),
311 m_nrDlBurstProfiles(0)
312{
313}
314
316{
317}
318
319void
320Dcd::SetConfigurationChangeCount(uint8_t configurationChangeCount)
321{
322 m_configurationChangeCount = configurationChangeCount;
323}
324
325void
327{
328 m_channelEncodings = channelEncodings;
329}
330
331void
332Dcd::SetNrDlBurstProfiles(uint8_t nrDlBurstProfiles)
333{
334 m_nrDlBurstProfiles = nrDlBurstProfiles;
335}
336
337void
339{
340 m_dlBurstProfiles.push_back(dlBurstProfile);
341}
342
343uint8_t
348
351{
352 return m_channelEncodings;
353}
354
355std::vector<OfdmDlBurstProfile>
357{
358 return m_dlBurstProfiles;
359}
360
361uint8_t
363{
364 return m_nrDlBurstProfiles;
365}
366
367std::string
369{
370 return "DCD";
371}
372
373TypeId
375{
376 static TypeId tid =
377 TypeId("ns3::Dcd").SetParent<Header>().SetGroupName("Wimax").AddConstructor<Dcd>();
378 return tid;
379}
380
381TypeId
383{
384 return GetTypeId();
385}
386
387void
388Dcd::Print(std::ostream& os) const
389{
390 os << " configuration change count = " << (uint32_t)m_configurationChangeCount
391 << ", number of dl burst profiles = " << m_dlBurstProfiles.size();
392}
393
396{
397 uint32_t dlBurstProfilesSize = 0;
398
399 for (const auto& burstProfile : m_dlBurstProfiles)
400 {
401 dlBurstProfilesSize += burstProfile.GetSize();
402 }
403
404 return 1 + 1 + m_channelEncodings.GetSize() + dlBurstProfilesSize;
405}
406
407void
409{
410 Buffer::Iterator i = start;
414
415 for (const auto& burstProfile : m_dlBurstProfiles)
416 {
417 i = burstProfile.Write(i);
418 }
419}
420
423{
424 Buffer::Iterator i = start;
425 m_reserved = i.ReadU8();
428
429 for (uint8_t j = 0; j < m_nrDlBurstProfiles; j++)
430 {
431 OfdmDlBurstProfile burstProfile;
432 i = burstProfile.Read(i);
433 AddDlBurstProfile(burstProfile);
434 }
435
436 return i.GetDistanceFrom(start);
437}
438
439// ----------------------------------------------------------------------------------------------------------
440
442 : m_cid(),
443 m_diuc(0),
444 m_preamblePresent(0),
445 m_startTime(0)
446{
447}
448
452
453void
455{
456 m_cid = cid;
457}
458
459void
461{
462 m_diuc = diuc;
463}
464
465void
466OfdmDlMapIe::SetPreamblePresent(uint8_t preamblePresent)
467{
468 m_preamblePresent = preamblePresent;
469}
470
471void
472OfdmDlMapIe::SetStartTime(uint16_t startTime)
473{
474 m_startTime = startTime;
475}
476
477Cid
479{
480 return m_cid;
481}
482
483uint8_t
485{
486 return m_diuc;
487}
488
489uint8_t
494
495uint16_t
497{
498 return m_startTime;
499}
500
501uint16_t
503{
504 return 2 + 1 + 1 + 2;
505}
506
509{
510 Buffer::Iterator i = start;
512 i.WriteU8(m_diuc);
515 return i;
516}
517
520{
521 Buffer::Iterator i = start;
522 m_cid = i.ReadU16();
523 m_diuc = i.ReadU8();
525 m_startTime = i.ReadU16();
526 return i;
527}
528
529// ----------------------------------------------------------------------------------------------------------
530
532
534 : m_dcdCount(0),
535 m_baseStationId(Mac48Address("00:00:00:00:00:00"))
536{
537}
538
540{
541}
542
543void
544DlMap::SetDcdCount(uint8_t dcdCount)
545{
546 m_dcdCount = dcdCount;
547}
548
549void
551{
552 m_baseStationId = baseStationId;
553}
554
555void
557{
558 m_dlMapElements.push_back(dlMapElement);
559}
560
561uint8_t
563{
564 return m_dcdCount;
565}
566
569{
570 return m_baseStationId;
571}
572
573std::list<OfdmDlMapIe>
575{
576 return m_dlMapElements;
577}
578
579std::string
581{
582 return "DL-MAP";
583}
584
585TypeId
587{
588 static TypeId tid =
589 TypeId("ns3::DlMap").SetParent<Header>().SetGroupName("Wimax").AddConstructor<DlMap>();
590 return tid;
591}
592
593TypeId
595{
596 return GetTypeId();
597}
598
599void
600DlMap::Print(std::ostream& os) const
601{
602 os << " dcd count = " << (uint32_t)m_dcdCount << ", base station id = " << m_baseStationId
603 << ", number of dl-map elements = " << m_dlMapElements.size();
604}
605
608{
609 uint32_t dlMapElementsSize = 0;
610
611 for (const auto& dlMapIe : m_dlMapElements)
612 {
613 dlMapElementsSize += dlMapIe.GetSize();
614 }
615
616 return 1 + 6 + dlMapElementsSize;
617}
618
619void
621{
622 Buffer::Iterator i = start;
625
626 for (const auto& dlMapIe : m_dlMapElements)
627 {
628 i = dlMapIe.Write(i);
629 }
630}
631
634{
635 Buffer::Iterator i = start;
636 m_dcdCount = i.ReadU8();
637 ReadFrom(i, m_baseStationId); // length (6) shall also be written in packet instead of hard
638 // coded, see ARP example
639
640 m_dlMapElements.clear(); // only for printing, otherwise it shows wrong number of elements
641
642 while (true)
643 {
644 OfdmDlMapIe dlMapIe;
645 i = dlMapIe.Read(i);
646
647 AddDlMapElement(dlMapIe);
648
649 if (dlMapIe.GetDiuc() == 14) // End of Map IE
650 {
651 break;
652 }
653 }
654 return i.GetDistanceFrom(start);
655}
656
657} // namespace ns3
iterator in a Buffer instance
Definition buffer.h:89
void WriteU32(uint32_t data)
Definition buffer.cc:857
void WriteU8(uint8_t data)
Definition buffer.h:870
void Write(const uint8_t *buffer, uint32_t size)
Definition buffer.cc:937
void WriteU16(uint16_t data)
Definition buffer.cc:848
uint32_t ReadU32()
Definition buffer.cc:955
uint32_t GetDistanceFrom(const Iterator &o) const
Definition buffer.cc:769
uint16_t ReadU16()
Definition buffer.h:1024
Cid class.
Definition cid.h:26
uint16_t GetIdentifier() const
Definition cid.cc:34
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 forLocal and metropo...
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 forLocal and metropolitan area networks P...
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:33
an EUI-48 address
This class implements the OFDM DCD channel encodings as described by "IEEE Standard forLocal and metr...
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 Standardfor Lo...
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 forLocal and...
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:48
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1001
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition object-base.h:35
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.