A Discrete-Event Network Simulator
API
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{
91 return DoWrite(i);
92}
93
96{
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{
203 i.WriteU8(m_ttg);
204 i.WriteU8(m_rtg);
208 return i;
209}
210
213{
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{
297 i.WriteU8(m_type);
298 i.WriteU8(m_length);
299 i.WriteU8(m_diuc);
301 return i;
302}
303
306{
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 (std::vector<OfdmDlBurstProfile>::const_iterator iter = m_dlBurstProfiles.begin();
411 iter != m_dlBurstProfiles.end();
412 ++iter)
413 {
414 OfdmDlBurstProfile burstProfile = *iter;
415 dlBurstProfilesSize += burstProfile.GetSize();
416 }
417
418 return 1 + 1 + m_channelEncodings.GetSize() + dlBurstProfilesSize;
419}
420
421void
423{
428
429 for (std::vector<OfdmDlBurstProfile>::const_iterator iter = m_dlBurstProfiles.begin();
430 iter != m_dlBurstProfiles.end();
431 ++iter)
432 {
433 OfdmDlBurstProfile burstProfile = *iter;
434 i = burstProfile.Write(i);
435 }
436}
437
440{
442 m_reserved = i.ReadU8();
445
446 for (uint8_t j = 0; j < m_nrDlBurstProfiles; j++)
447 {
448 OfdmDlBurstProfile burstProfile;
449 i = burstProfile.Read(i);
450 AddDlBurstProfile(burstProfile);
451 }
452
453 return i.GetDistanceFrom(start);
454}
455
456// ----------------------------------------------------------------------------------------------------------
457
459 : m_cid(),
460 m_diuc(0),
461 m_preamblePresent(0),
462 m_startTime(0)
463{
464}
465
467{
468}
469
470void
472{
473 m_cid = cid;
474}
475
476void
478{
479 m_diuc = diuc;
480}
481
482void
483OfdmDlMapIe::SetPreamblePresent(uint8_t preamblePresent)
484{
485 m_preamblePresent = preamblePresent;
486}
487
488void
489OfdmDlMapIe::SetStartTime(uint16_t startTime)
490{
491 m_startTime = startTime;
492}
493
494Cid
496{
497 return m_cid;
498}
499
500uint8_t
502{
503 return m_diuc;
504}
505
506uint8_t
508{
509 return m_preamblePresent;
510}
511
512uint16_t
514{
515 return m_startTime;
516}
517
518uint16_t
520{
521 return 2 + 1 + 1 + 2;
522}
523
526{
529 i.WriteU8(m_diuc);
532 return i;
533}
534
537{
539 m_cid = i.ReadU16();
540 m_diuc = i.ReadU8();
542 m_startTime = i.ReadU16();
543 return i;
544}
545
546// ----------------------------------------------------------------------------------------------------------
547
549
551 : m_dcdCount(0),
552 m_baseStationId(Mac48Address("00:00:00:00:00:00"))
553{
554}
555
557{
558}
559
560void
561DlMap::SetDcdCount(uint8_t dcdCount)
562{
563 m_dcdCount = dcdCount;
564}
565
566void
568{
569 m_baseStationId = baseStationId;
570}
571
572void
574{
575 m_dlMapElements.push_back(dlMapElement);
576}
577
578uint8_t
580{
581 return m_dcdCount;
582}
583
586{
587 return m_baseStationId;
588}
589
590std::list<OfdmDlMapIe>
592{
593 return m_dlMapElements;
594}
595
596std::string
598{
599 return "DL-MAP";
600}
601
602TypeId
604{
605 static TypeId tid =
606 TypeId("ns3::DlMap").SetParent<Header>().SetGroupName("Wimax").AddConstructor<DlMap>();
607 return tid;
608}
609
610TypeId
612{
613 return GetTypeId();
614}
615
616void
617DlMap::Print(std::ostream& os) const
618{
619 os << " dcd count = " << (uint32_t)m_dcdCount << ", base station id = " << m_baseStationId
620 << ", number of dl-map elements = " << m_dlMapElements.size();
621}
622
625{
626 uint32_t dlMapElementsSize = 0;
627
628 for (std::list<OfdmDlMapIe>::const_iterator iter = m_dlMapElements.begin();
629 iter != m_dlMapElements.end();
630 ++iter)
631 {
632 OfdmDlMapIe dlMapIe = *iter;
633 dlMapElementsSize += dlMapIe.GetSize();
634 }
635
636 return 1 + 6 + dlMapElementsSize;
637}
638
639void
641{
645
646 for (std::list<OfdmDlMapIe>::const_iterator iter = m_dlMapElements.begin();
647 iter != m_dlMapElements.end();
648 ++iter)
649 {
650 OfdmDlMapIe dlMapIe = *iter;
651 i = dlMapIe.Write(i);
652 }
653}
654
657{
659 m_dcdCount = i.ReadU8();
660 ReadFrom(i, m_baseStationId); // length (6) shall also be written in packet instead of hard
661 // coded, see ARP example
662
663 m_dlMapElements.clear(); // only for printing, otherwise it shows wrong number of elements
664
665 while (true)
666 {
667 OfdmDlMapIe dlMapIe;
668 i = dlMapIe.Read(i);
669
670 AddDlMapElement(dlMapIe);
671
672 if (dlMapIe.GetDiuc() == 14) // End of Map IE
673 {
674 break;
675 }
676 }
677 return i.GetDistanceFrom(start);
678}
679
680} // namespace ns3
iterator in a Buffer instance
Definition: buffer.h:100
void WriteU32(uint32_t data)
Definition: buffer.cc:871
uint8_t ReadU8()
Definition: buffer.h:1027
void WriteU8(uint8_t data)
Definition: buffer.h:881
void WriteU16(uint16_t data)
Definition: buffer.cc:862
uint32_t ReadU32()
Definition: buffer.cc:969
uint32_t GetDistanceFrom(const Iterator &o) const
Definition: buffer.cc:783
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
Wrtie 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:60
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:935
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
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.
def start()
Definition: core.py:1861