A Discrete-Event Network Simulator
API
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
28namespace ns3 {
29
31 : m_bsEirp (0),
32 m_eirXPIrMax (0),
33 m_frequency (0)
34{
35}
36
38{
39}
40
41void
43{
44 m_bsEirp = bs_eirp;
45}
46
47void
48DcdChannelEncodings::SetEirxPIrMax (uint16_t eir_x_p_ir_max)
49{
50 m_eirXPIrMax = eir_x_p_ir_max;
51}
52
53void
55{
56 m_frequency = frequency;
57}
58
59uint16_t
61{
62 return m_bsEirp;
63}
64
65uint16_t
67{
68 return m_eirXPIrMax;
69}
70
73{
74 return m_frequency;
75}
76
77uint16_t
79{
80 return 2 + 2 + 4;
81}
82
85{
90 return DoWrite (i);
91}
92
95{
97 m_bsEirp = i.ReadU16 ();
98 m_eirXPIrMax = i.ReadU16 ();
99 m_frequency = i.ReadU32 ();
100 return DoRead (i);
101}
102
103// ----------------------------------------------------------------------------------------------------------
104
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
116{
117}
118
119void
121{
122 m_channelNr = channelNr;
123}
124
125void
127{
128 m_ttg = ttg;
129}
130
131void
133{
134 m_rtg = rtg;
135}
136
137void
139{
140 m_baseStationId = baseStationId;
141}
142
143void
145{
146 m_frameDurationCode = frameDurationCode;
147}
148
149void
151{
152 m_frameNumber = frameNumber;
153}
154
155uint8_t
157{
158 return m_channelNr;
159}
160
161uint8_t
163{
164 return m_ttg;
165}
166
167uint8_t
169{
170 return m_rtg;
171}
172
175{
176 return m_baseStationId;
177}
178
179uint8_t
181{
182 return m_frameDurationCode;
183}
184
187{
188 return m_frameNumber;
189}
190
191uint16_t
193{
194 return DcdChannelEncodings::GetSize () + 1 + 1 + 1 + 6 + 1 + 4;
195}
196
199{
202 i.WriteU8 (m_ttg);
203 i.WriteU8 (m_rtg);
207 return i;
208}
209
212{
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
219 m_frameNumber = i.ReadU32 ();
220 return i;
221}
222
223// ----------------------------------------------------------------------------------------------------------
224
226 : m_type (0),
227 m_length (0),
228 m_diuc (0),
229 m_fecCodeType (0)
230{
231}
232
234{
235}
236
237void
239{
240 m_type = type;
241}
242
243void
245{
246 m_length = length;
247}
248
249void
251{
252 m_diuc = diuc;
253}
254
255void
257{
258 m_fecCodeType = fecCodeType;
259}
260
261uint8_t
263{
264 return m_type;
265}
266
267uint8_t
269{
270 return m_length;
271}
272
273uint8_t
275{
276 return m_diuc;
277}
278
279uint8_t
281{
282 return m_fecCodeType;
283}
284
285uint16_t
287{
288 return 1 + 1 + 1 + 1;
289}
290
293{
295 i.WriteU8 (m_type);
296 i.WriteU8 (m_length);
297 i.WriteU8 (m_diuc);
299 return i;
300}
301
304{
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
316
318 : m_reserved (0),
319 m_configurationChangeCount (0),
320 m_nrDlBurstProfiles (0)
321{
322}
323
325{
326}
327
328void
329Dcd::SetConfigurationChangeCount (uint8_t configurationChangeCount)
330{
331 m_configurationChangeCount = configurationChangeCount;
332}
333
334void
336{
337 m_channelEncodings = channelEncodings;
338}
339
340void
341Dcd::SetNrDlBurstProfiles (uint8_t nrDlBurstProfiles)
342{
343 m_nrDlBurstProfiles = nrDlBurstProfiles;
344}
345
346void
348{
349 m_dlBurstProfiles.push_back (dlBurstProfile);
350}
351
352uint8_t
354{
356}
357
360{
361 return m_channelEncodings;
362}
363
364std::vector<OfdmDlBurstProfile>
366{
367 return m_dlBurstProfiles;
368}
369
370uint8_t
372{
373 return m_nrDlBurstProfiles;
374}
375
376std::string
377Dcd::GetName (void) const
378{
379 return "DCD";
380}
381
382TypeId
384{
385 static TypeId tid = TypeId ("ns3::Dcd")
386 .SetParent<Header> ()
387 .SetGroupName("Wimax")
388 .AddConstructor<Dcd> ()
389 ;
390 return tid;
391}
392
393TypeId
395{
396 return GetTypeId ();
397}
398
399void
400Dcd::Print (std::ostream &os) const
401{
402 os << " configuration change count = "
404 << ", number of dl burst profiles = " << m_dlBurstProfiles.size ();
405}
406
409{
410 uint32_t dlBurstProfilesSize = 0;
411
412 for (std::vector<OfdmDlBurstProfile>::const_iterator iter =
413 m_dlBurstProfiles.begin (); iter != m_dlBurstProfiles.end (); ++iter)
414 {
415 OfdmDlBurstProfile burstProfile = *iter;
416 dlBurstProfilesSize += burstProfile.GetSize ();
417 }
418
419 return 1 + 1 + m_channelEncodings.GetSize () + dlBurstProfilesSize;
420}
421
422void
424{
429
430 for (std::vector<OfdmDlBurstProfile>::const_iterator iter =
431 m_dlBurstProfiles.begin (); iter != m_dlBurstProfiles.end (); ++iter)
432 {
433 OfdmDlBurstProfile burstProfile = *iter;
434 i = burstProfile.Write (i);
435 }
436}
437
440{
442 m_reserved = i.ReadU8 ();
444 i = m_channelEncodings.Read (i);
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
597DlMap::GetName (void) const
598{
599 return "DL-MAP";
600}
601
602TypeId
604{
605 static TypeId tid = TypeId ("ns3::DlMap")
606 .SetParent<Header> ()
607 .SetGroupName("Wimax")
608 .AddConstructor<DlMap> ()
609 ;
610 return tid;
611}
612
613TypeId
615{
616 return GetTypeId ();
617}
618
619void
620DlMap::Print (std::ostream &os) const
621{
622 os << " dcd count = " << (uint32_t) m_dcdCount << ", base station id = "
623 << m_baseStationId << ", number of dl-map elements = "
624 << m_dlMapElements.size ();
625}
626
629{
630 uint32_t dlMapElementsSize = 0;
631
632 for (std::list<OfdmDlMapIe>::const_iterator iter = m_dlMapElements.begin (); iter
633 != m_dlMapElements.end (); ++iter)
634 {
635 OfdmDlMapIe dlMapIe = *iter;
636 dlMapElementsSize += dlMapIe.GetSize ();
637 }
638
639 return 1 + 6 + dlMapElementsSize;
640}
641
642void
644{
648
649 for (std::list<OfdmDlMapIe>::const_iterator iter = m_dlMapElements.begin (); iter
650 != m_dlMapElements.end (); ++iter)
651 {
652 OfdmDlMapIe dlMapIe = *iter;
653 i = dlMapIe.Write (i);
654 }
655}
656
659{
661 m_dcdCount = i.ReadU8 ();
662 ReadFrom (i, m_baseStationId); // length (6) shall also be written in packet instead of hard coded, see ARP example
663
664 m_dlMapElements.clear (); // only for printing, otherwise it shows wrong number of elements
665
666 while (true)
667 {
668 OfdmDlMapIe dlMapIe;
669 i = dlMapIe.Read (i);
670
671 AddDlMapElement (dlMapIe);
672
673 if (dlMapIe.GetDiuc () == 14) // End of Map IE
674 {
675 break;
676 }
677 }
678 return i.GetDistanceFrom (start);
679}
680
681} // namespace ns3
682
iterator in a Buffer instance
Definition: buffer.h:99
void WriteU32(uint32_t data)
Definition: buffer.cc:879
void WriteU8(uint8_t data)
Definition: buffer.h:869
void WriteU16(uint16_t data)
Definition: buffer.cc:871
uint16_t ReadU16(void)
Definition: buffer.h:1029
uint8_t ReadU8(void)
Definition: buffer.h:1021
uint32_t GetDistanceFrom(Iterator const &o) const
Definition: buffer.cc:788
uint32_t ReadU32(void)
Definition: buffer.cc:973
Cid class.
Definition: cid.h:38
uint16_t GetIdentifier(void) const
Definition: cid.cc:45
uint32_t m_frequency
frequency
uint16_t GetBsEirp(void) 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.
uint32_t GetFrequency(void) const
Get frequency function.
Buffer::Iterator Read(Buffer::Iterator start)
Read item.
void SetEirxPIrMax(uint16_t rss_ir_max)
Set EIRX IR MAX field.
uint16_t GetEirxPIrMax(void) const
Get EIRX IR MAX field.
virtual ~DcdChannelEncodings(void)
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 GetSize(void) const
Get size field.
uint16_t m_bsEirp
BS EIRP.
This class implements Downlink channel descriptor as described by "IEEE Standard for Local and metrop...
static TypeId GetTypeId(void)
Get the type ID.
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 SetNrDlBurstProfiles(uint8_t nrDlBurstProfiles)
Set number DL burst profile field.
uint8_t m_reserved
changed as per the amendment 802.16e-2005
void Print(std::ostream &os) const
uint8_t m_configurationChangeCount
configuration change count
void AddDlBurstProfile(OfdmDlBurstProfile dlBurstProfile)
Add DL burst profile field.
uint32_t GetSerializedSize(void) const
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
void Serialize(Buffer::Iterator start) const
uint8_t GetNrDlBurstProfiles(void) const
Get number DL burst profiles field.
OfdmDcdChannelEncodings GetChannelEncodings(void) const
Get channel encodings field.
uint32_t Deserialize(Buffer::Iterator start)
uint8_t GetConfigurationChangeCount(void) const
Get configuration change count field.
std::vector< OfdmDlBurstProfile > GetDlBurstProfiles(void) const
Get DL burst profile field.
virtual ~Dcd(void)
void SetChannelEncodings(OfdmDcdChannelEncodings channelEncodings)
Set channel encodings field.
std::string GetName(void) const
Get name 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 AddDlMapElement(OfdmDlMapIe dlMapElement)
Add DL Map element field.
uint32_t Deserialize(Buffer::Iterator start)
std::list< OfdmDlMapIe > m_dlMapElements
DL Map elements.
Mac48Address GetBaseStationId(void) const
Get base station ID field.
uint32_t GetSerializedSize(void) const
void SetBaseStationId(Mac48Address baseStationID)
Set base station ID field.
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
uint8_t m_dcdCount
DCD count.
static TypeId GetTypeId(void)
Get the type ID.
virtual ~DlMap(void)
std::list< OfdmDlMapIe > GetDlMapElements(void) const
Get DL Map elements field.
std::string GetName(void) const
Get name field.
Mac48Address m_baseStationId
base station ID
uint8_t GetDcdCount(void) const
Get DCD count field.
void Serialize(Buffer::Iterator start) const
void Print(std::ostream &os) const
Protocol header serialization and deserialization.
Definition: header.h:43
an EUI-48 address
Definition: mac48-address.h:44
This class implements the OFDM DCD channel encodings as described by "IEEE Standard for Local and met...
virtual Buffer::Iterator DoWrite(Buffer::Iterator start) const
Write item.
uint32_t GetFrameNumber(void) const
Get frame number field.
uint8_t m_channelNr
channel number
Mac48Address GetBaseStationId(void) const
Get base station ID field.
void SetChannelNr(uint8_t channelNr)
Set channel number field.
void SetTtg(uint8_t ttg)
Set TTG field.
uint8_t GetFrameDurationCode(void) const
Get frame duration code field.
void SetFrameDurationCode(uint8_t frameDurationCode)
Set frame duration code field.
uint8_t m_frameDurationCode
frame duration code
uint8_t GetRtg(void) const
Get RTG field.
uint32_t m_frameNumber
frame number
void SetRtg(uint8_t rtg)
Set RTG field.
uint16_t GetSize(void) const
Get size field.
void SetFrameNumber(uint32_t frameNumber)
Set frame number field.
Mac48Address m_baseStationId
base station ID
uint8_t GetTtg(void) const
Get TTG field.
virtual Buffer::Iterator DoRead(Buffer::Iterator start)
Read item.
uint8_t GetChannelNr(void) const
Get channel number 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...
uint8_t GetType(void) const
Get type function.
Buffer::Iterator Write(Buffer::Iterator start) const
Write item.
uint8_t GetFecCodeType(void) 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 GetDiuc(void) const
Buffer::Iterator Read(Buffer::Iterator start)
Read item.
uint8_t m_fecCodeType
FEC code type.
uint8_t GetLength(void) const
void SetDiuc(uint8_t diuc)
Set DIUC field.
uint16_t GetSize(void) const
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.
void SetCid(Cid cid)
Set CID function.
uint8_t m_preamblePresent
preamble present
uint16_t GetSize(void) const
Get size.
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.
uint8_t GetPreamblePresent(void) const
Get preamble present field.
Cid GetCid(void) const
Set CID field.
uint8_t GetDiuc(void) const
Get DIUC field.
Buffer::Iterator Read(Buffer::Iterator start)
Read item.
uint16_t GetStartTime(void) const
Get start time field.
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:922
#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:1853