A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
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 "mac-messages.h"
12
13#include "wimax-tlv.h"
14
15#include "ns3/address-utils.h"
16#include "ns3/log.h"
17#include "ns3/uinteger.h"
18
19namespace ns3
20{
21
22NS_LOG_COMPONENT_DEFINE("MACMESSAGES");
23
24NS_OBJECT_ENSURE_REGISTERED(ManagementMessageType);
25
30
32 : m_type(type)
33{
34}
35
39
40void
42{
43 m_type = type;
44}
45
46uint8_t
48{
49 return m_type;
50}
51
52std::string
54{
55 return "Management Message Type";
56}
57
60{
61 static TypeId tid = TypeId("ns3::ManagementMessageType")
63 .SetGroupName("Wimax")
64 .AddConstructor<ManagementMessageType>();
65 return tid;
66}
67
73
74void
75ManagementMessageType::Print(std::ostream& os) const
76{
77 os << " management message type = " << (uint32_t)m_type;
78}
79
82{
83 return 1;
84}
85
86void
92
95{
96 Buffer::Iterator i = start;
97 m_type = i.ReadU8();
98 return i.GetDistanceFrom(start);
99}
100
101// ---------------------------------------------------------------------
102
104
106 : m_reserved(0),
107 m_reqDlBurstProfile(0),
108 m_macAddress(Mac48Address("00:00:00:00:00:00")),
109 m_rangingAnomalies(0)
110{
111}
112
114{
115}
116
117void
118RngReq::SetReqDlBurstProfile(uint8_t reqDlBurstProfile)
119{
120 m_reqDlBurstProfile = reqDlBurstProfile;
121}
122
123void
125{
126 m_macAddress = macAddress;
127}
128
129void
130RngReq::SetRangingAnomalies(uint8_t rangingAnomalies)
131{
132 m_rangingAnomalies = rangingAnomalies;
133}
134
135uint8_t
140
143{
144 return m_macAddress;
145}
146
147uint8_t
152
153std::string
155{
156 return "RNG-REQ";
157}
158
159TypeId
161{
162 static TypeId tid =
163 TypeId("ns3::RngReq").SetParent<Header>().SetGroupName("Wimax").AddConstructor<RngReq>();
164 return tid;
165}
166
167TypeId
169{
170 return GetTypeId();
171}
172
173void
174RngReq::Print(std::ostream& os) const
175{
176 os << " requested dl burst profile = " << (uint32_t)m_reqDlBurstProfile
177 << ", mac address = " << m_macAddress
178 << ", ranging anomalies = " << (uint32_t)m_rangingAnomalies;
179}
180
181void
183{
184 NS_LOG_DEBUG(" requested dl burst profile = "
185 << (uint32_t)m_reqDlBurstProfile << ", mac address = " << m_macAddress
186 << ", ranging anomalies = " << (uint32_t)m_rangingAnomalies);
187}
188
191{
192 return 1 + 1 + 6 + 1;
193}
194
195void
204
207{
208 Buffer::Iterator i = start;
209 m_reserved = i.ReadU8();
213
214 return i.GetDistanceFrom(start);
215}
216
217// ---------------------------------------------------------------------
218
220
222 : m_reserved(0),
223 m_timingAdjust(0),
224 m_powerLevelAdjust(0),
225 m_offsetFreqAdjust(0),
226 m_rangStatus(0),
227 m_dlFreqOverride(0),
228 m_ulChnlIdOverride(0),
229 m_dlOperBurstProfile(0),
230 m_macAddress(Mac48Address("00:00:00:00:00:00")),
231 m_basicCid(),
232 m_primaryCid(),
233 m_aasBdcastPermission(0),
234 m_frameNumber(0),
235 m_initRangOppNumber(0),
236 m_rangSubchnl(0)
237{
238}
239
241{
242}
243
244void
246{
247 m_timingAdjust = timingAdjust;
248}
249
250void
251RngRsp::SetPowerLevelAdjust(uint8_t powerLevelAdjust)
252{
253 m_powerLevelAdjust = powerLevelAdjust;
254}
255
256void
258{
259 m_offsetFreqAdjust = offsetFreqAdjust;
260}
261
262void
263RngRsp::SetRangStatus(uint8_t rangStatus)
264{
265 m_rangStatus = rangStatus;
266}
267
268void
270{
271 m_dlFreqOverride = dlFreqOverride;
272}
273
274void
275RngRsp::SetUlChnlIdOverride(uint8_t ulChnlIdOverride)
276{
277 m_ulChnlIdOverride = ulChnlIdOverride;
278}
279
280void
281RngRsp::SetDlOperBurstProfile(uint16_t dlOperBurstProfile)
282{
283 m_dlOperBurstProfile = dlOperBurstProfile;
284}
285
286void
288{
289 m_macAddress = macAddress;
290}
291
292void
294{
295 m_basicCid = basicCid;
296}
297
298void
300{
301 m_primaryCid = primaryCid;
302}
303
304void
305RngRsp::SetAasBdcastPermission(uint8_t aasBdcastPermission)
306{
307 m_aasBdcastPermission = aasBdcastPermission;
308}
309
310void
312{
313 m_frameNumber = frameNumber;
314}
315
316void
317RngRsp::SetInitRangOppNumber(uint8_t initRangOppNumber)
318{
319 m_initRangOppNumber = initRangOppNumber;
320}
321
322void
323RngRsp::SetRangSubchnl(uint8_t rangSubchnl)
324{
325 m_rangSubchnl = rangSubchnl;
326}
327
330{
331 return m_timingAdjust;
332}
333
334uint8_t
339
345
346uint8_t
348{
349 return m_rangStatus;
350}
351
354{
355 return m_dlFreqOverride;
356}
357
358uint8_t
363
364uint16_t
369
372{
373 return m_macAddress;
374}
375
376Cid
378{
379 return m_basicCid;
380}
381
382Cid
384{
385 return m_primaryCid;
386}
387
388uint8_t
393
396{
397 return m_frameNumber;
398}
399
400uint8_t
405
406uint8_t
408{
409 return m_rangSubchnl;
410}
411
412std::string
414{
415 return "RNG-RSP";
416}
417
418TypeId
420{
421 static TypeId tid =
422 TypeId("ns3::RngRsp").SetParent<Header>().SetGroupName("Wimax").AddConstructor<RngRsp>();
423 return tid;
424}
425
426TypeId
428{
429 return GetTypeId();
430}
431
432void
433RngRsp::Print(std::ostream& os) const
434{
435 os << " timing adjust = " << m_timingAdjust
436 << ", power level adjust = " << (uint32_t)m_powerLevelAdjust
437 << ", offset freq adjust = " << m_offsetFreqAdjust
438 << ", ranging status = " << (uint32_t)m_rangStatus
439 << ", dl freq override = " << m_dlFreqOverride
440 << ", ul channel id override = " << (uint32_t)m_ulChnlIdOverride
441 << ", dl operational burst profile = " << (uint32_t)m_dlOperBurstProfile
442 << ", mac address = " << m_macAddress << ", basic cid = " << m_basicCid
443 << ", primary management cid = " << m_primaryCid
444 << ", aas broadcast permission = " << (uint32_t)m_aasBdcastPermission
445 << ", frame number = " << m_frameNumber
446 << ", initial ranging opportunity number = " << (uint32_t)m_initRangOppNumber
447 << ", ranging subchannel = " << (uint32_t)m_rangSubchnl;
448}
449
452{
453 return 1 + 4 + 1 + 4 + 1 + 4 + 1 + 2 + 6 + 2 + 2 + 1 + 4 + 1 + 1;
454}
455
456void
476
479{
480 Buffer::Iterator i = start;
481 m_reserved = i.ReadU8();
485 m_rangStatus = i.ReadU8();
489 ReadFrom(i, m_macAddress); // length (6) shall also be written in packet instead of hard coded,
490 // see ARP example
491 m_basicCid = i.ReadU16();
492 m_primaryCid = i.ReadU16();
496 m_rangSubchnl = i.ReadU8();
497
498 return i.GetDistanceFrom(start);
499}
500
501// ---------------------------------------------------------------------
502
504
506 : m_transactionId(0),
507 m_sfid(0),
508 m_cid(),
509 m_serviceFlow(ServiceFlow::SF_DIRECTION_DOWN)
510{
511}
512
518
520{
521}
522
523void
524DsaReq::SetTransactionId(uint16_t transactionId)
525{
526 m_transactionId = transactionId;
527}
528
529uint16_t
531{
532 return m_transactionId;
533}
534
535void
537{
538 m_sfid = sfid;
539}
540
543{
544 return m_sfid;
545}
546
547void
549{
550 m_cid = cid;
551}
552
553Cid
555{
556 return m_cid;
557}
558
559std::string
561{
562 return "DSA-REQ";
563}
564
565TypeId
567{
568 static TypeId tid =
569 TypeId("ns3::DsaReq").SetParent<Header>().SetGroupName("Wimax").AddConstructor<DsaReq>();
570 return tid;
571}
572
573TypeId
575{
576 return GetTypeId();
577}
578
579void
580DsaReq::Print(std::ostream& os) const
581{
582 os << " transaction id = " << (uint32_t)m_transactionId << ", m_sfid = " << m_sfid
583 << ", cid = " << m_cid;
584}
585
588{
589 Tlv t = m_serviceFlow.ToTlv();
590 uint32_t size = 2 + t.GetSerializedSize();
591 return size;
592}
593
594void
596{
597 Buffer::Iterator i = start;
599 Tlv t = m_serviceFlow.ToTlv();
600 t.Serialize(i);
601}
602
605{
606 Buffer::Iterator i = start;
608 Tlv tlv;
609 uint32_t size = tlv.Deserialize(i);
611 return size + 2;
612}
613
616{
617 return m_serviceFlow;
618}
619
620void
625
626// ---------------------------------------------------------------------
627
629
631 : m_transactionId(0),
632 m_confirmationCode(0),
633 m_sfid(0),
634 m_cid()
635{
636}
637
639{
640}
641
642void
643DsaRsp::SetTransactionId(uint16_t transactionId)
644{
645 m_transactionId = transactionId;
646}
647
648uint16_t
650{
651 return m_transactionId;
652}
653
656{
657 return m_serviceFlow;
658}
659
660void
665
666void
667DsaRsp::SetConfirmationCode(uint16_t confirmationCode)
668{
669 m_confirmationCode = confirmationCode;
670}
671
672uint16_t
677
678void
680{
681 m_sfid = sfid;
682}
683
686{
687 return m_sfid;
688}
689
690void
692{
693 m_cid = cid;
694}
695
696Cid
698{
699 return m_cid;
700}
701
702std::string
704{
705 return "DSA-RSP";
706}
707
708TypeId
710{
711 static TypeId tid =
712 TypeId("ns3::DsaRsp").SetParent<Header>().SetGroupName("Wimax").AddConstructor<DsaRsp>();
713 return tid;
714}
715
716TypeId
718{
719 return GetTypeId();
720}
721
722void
723DsaRsp::Print(std::ostream& os) const
724{
725 os << " transaction id = " << (uint32_t)m_transactionId
726 << ", confirmation code = " << (uint32_t)m_confirmationCode << ", m_sfid = " << m_sfid
727 << ", cid = " << m_cid;
728}
729
732{
733 return 2 + 1 + m_serviceFlow.ToTlv().GetSerializedSize();
734}
735
736void
745
748{
749 Buffer::Iterator i = start;
750
753 Tlv tlv;
754 uint32_t size = tlv.Deserialize(i);
756 return size + 3;
757}
758
759// ---------------------------------------------------------------------
760
762
764 : m_transactionId(0),
765 m_confirmationCode(0)
766{
767}
768
770{
771}
772
773void
774DsaAck::SetTransactionId(uint16_t transactionId)
775{
776 m_transactionId = transactionId;
777}
778
779uint16_t
781{
782 return m_transactionId;
783}
784
785void
786DsaAck::SetConfirmationCode(uint16_t confirmationCode)
787{
788 m_confirmationCode = confirmationCode;
789}
790
791uint16_t
796
797std::string
799{
800 return "DSA-ACK";
801}
802
803TypeId
805{
806 static TypeId tid =
807 TypeId("ns3::DsaAck").SetParent<Header>().SetGroupName("Wimax").AddConstructor<DsaAck>();
808 return tid;
809}
810
811TypeId
813{
814 return GetTypeId();
815}
816
817void
818DsaAck::Print(std::ostream& os) const
819{
820 os << " transaction id = " << (uint32_t)m_transactionId
821 << ", confirmation code = " << (uint32_t)m_confirmationCode;
822}
823
826{
827 return 2 + 1;
828}
829
830void
837
840{
841 Buffer::Iterator i = start;
844
845 return i.GetDistanceFrom(start);
846}
847
848} // 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 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
This class implements the DSA-ACK message described by "IEEE Standard forLocal and metropolitan area ...
uint32_t Deserialize(Buffer::Iterator start) override
void SetConfirmationCode(uint16_t confirmationCode)
Set confirmation code field.
void SetTransactionId(uint16_t transactionId)
Set transaction ID field.
static TypeId GetTypeId()
Get the type ID.
uint16_t m_transactionId
transaction ID
void Serialize(Buffer::Iterator start) const override
uint32_t GetSerializedSize() const override
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
uint16_t GetTransactionId() const
Get transaction ID field.
uint16_t GetConfirmationCode() const
Get confirmation code field.
void Print(std::ostream &os) const override
~DsaAck() override
std::string GetName() const
Get name field.
uint8_t m_confirmationCode
confirmation code
This class implements the DSA-REQ message described by "IEEE Standard forLocal and metropolitan area ...
Cid GetCid() const
~DsaReq() override
uint32_t Deserialize(Buffer::Iterator start) override
uint32_t GetSfid() const
void SetTransactionId(uint16_t transactionId)
set the transaction ID
ServiceFlow GetServiceFlow() const
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
Cid m_cid
CID.
std::string GetName() const
void Print(std::ostream &os) const override
uint16_t GetTransactionId() const
static TypeId GetTypeId()
Get the type ID.
uint32_t GetSerializedSize() const override
ServiceFlow m_serviceFlow
service flow
void Serialize(Buffer::Iterator start) const override
void SetServiceFlow(ServiceFlow sf)
specify a service flow to be requested by this message
uint32_t m_sfid
SFID.
void SetSfid(uint32_t sfid)
set the service flow identifier
void SetCid(Cid cid)
set the connection identifier
uint16_t m_transactionId
transaction ID
This class implements the DSA-RSP message described by "IEEE Standard forLocal and metropolitan area ...
void SetConfirmationCode(uint16_t confirmationCode)
set the confirmation code
static TypeId GetTypeId()
Get the type ID.
uint32_t m_sfid
SFID.
uint32_t GetSerializedSize() const override
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
~DsaRsp() override
Cid GetCid() const
ServiceFlow m_serviceFlow
service flow
ServiceFlow GetServiceFlow() const
std::string GetName() const
void Serialize(Buffer::Iterator start) const override
void SetSfid(uint32_t sfid)
set the service flow identifier
uint16_t GetTransactionId() const
uint16_t m_transactionId
transaction ID
void SetServiceFlow(ServiceFlow sf)
specify a service flow to be requested by this message
uint32_t GetSfid() const
void SetTransactionId(uint16_t transactionId)
set the transaction ID
Cid m_cid
CID.
uint16_t GetConfirmationCode() const
uint8_t m_confirmationCode
confirmation code
uint32_t Deserialize(Buffer::Iterator start) override
void Print(std::ostream &os) const override
void SetCid(Cid cid)
set the connection identifier
Protocol header serialization and deserialization.
Definition header.h:33
an EUI-48 address
Mac Management messages Section 6.3.2.3 MAC Management messages page 42, Table 14 page 43.
static TypeId GetTypeId()
Get the type ID.
uint32_t GetSerializedSize() const override
uint32_t Deserialize(Buffer::Iterator start) override
void Print(std::ostream &os) const override
std::string GetName() const
void Serialize(Buffer::Iterator start) const override
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
uint8_t GetType() const
Get type field.
void SetType(uint8_t type)
Set type field.
This class implements the ranging request message described by "IEEE Standard forLocal and metropolit...
uint8_t m_rangingAnomalies
ranging anomalies
~RngReq() override
void SetReqDlBurstProfile(uint8_t reqDlBurstProfile)
Set request DL burst profile field.
uint32_t Deserialize(Buffer::Iterator start) override
void Serialize(Buffer::Iterator start) const override
uint8_t GetReqDlBurstProfile() const
Get request DL burst profile field.
void SetRangingAnomalies(uint8_t rangingAnomalies)
Set ranging anomalies field.
uint8_t m_reserved
changed as per the amendment 802.16e-2005
void SetMacAddress(Mac48Address macAddress)
Set MAC address field.
uint32_t GetSerializedSize() const override
uint8_t GetRangingAnomalies() const
Get ranging anomalies field.
std::string GetName() const
Get name field.
uint8_t m_reqDlBurstProfile
request DL burst profile
void PrintDebug() const
Print debug function.
void Print(std::ostream &os) const override
Mac48Address GetMacAddress() const
Get MAC address field.
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
static TypeId GetTypeId()
Get the type ID.
Mac48Address m_macAddress
MAC address.
This class implements the ranging response message described by "IEEE Standard forLocal and metropoli...
uint32_t Deserialize(Buffer::Iterator start) override
void SetMacAddress(Mac48Address macAddress)
set the MAC address
Mac48Address m_macAddress
MAC address.
uint16_t m_dlOperBurstProfile
This parameter is sent in response to the RNG-REQ Requested Downlink Burst Profile parameter.
Mac48Address GetMacAddress() const
uint32_t GetTimingAdjust() const
Cid m_primaryCid
primary CID
void SetUlChnlIdOverride(uint8_t ulChnlIdOverride)
set the identifier of the uplink channel with which the SS is to redo initial ranging
Cid GetPrimaryCid() const
uint8_t GetRangSubchnl() const
void Print(std::ostream &os) const override
uint32_t GetSerializedSize() const override
uint8_t m_aasBdcastPermission
AAS broadcast permission.
uint8_t m_rangStatus
range status.
void SetBasicCid(Cid basicCid)
set basic CID.
uint8_t GetPowerLevelAdjust() const
uint32_t m_dlFreqOverride
Center frequency, in kHz, of new downlink channel where the SS should redo initial ranging.
uint8_t GetRangStatus() const
uint32_t GetOffsetFreqAdjust() const
void Serialize(Buffer::Iterator start) const override
void SetAasBdcastPermission(uint8_t aasBdcastPermission)
set AAS broadcast permission.
void SetDlOperBurstProfile(uint16_t dlOperBurstProfile)
set the DL oper burst profile
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
uint16_t GetDlOperBurstProfile() const
void SetPrimaryCid(Cid primaryCid)
set primary CID.
uint8_t m_initRangOppNumber
Initial Ranging opportunity (1–255) in which the associated RNG_REQ message was detected by the BS.
uint8_t GetUlChnlIdOverride() const
void SetRangSubchnl(uint8_t rangSubchnl)
set range sub channel.
~RngRsp() override
uint8_t m_rangSubchnl
Used to indicate the OFDM subchannel reference that was used to transmit the initial ranging message ...
uint32_t GetDlFreqOverride() const
void SetPowerLevelAdjust(uint8_t powerLevelAdjust)
set the relative change in transmission power level that the SS should make in order that transmissio...
void SetInitRangOppNumber(uint8_t initRangOppNumber)
set initial range opp number.
void SetTimingAdjust(uint32_t timingAdjust)
set the Tx timing offset adjustment (signed 32-bit).
uint8_t m_ulChnlIdOverride
Licensed bands: The identifier of the uplink channel with which the SS is to redo initial ranging (no...
uint8_t m_powerLevelAdjust
Specifies the relative change in transmission power level that the SS is to make in order that transm...
void SetFrameNumber(uint32_t frameNumber)
set frame number.
Cid GetBasicCid() const
void SetDlFreqOverride(uint32_t dlFreqOverride)
set the Center frequency, in kHz, of new downlink channel where the SS should redo initial ranging.
std::string GetName() const
void SetOffsetFreqAdjust(uint32_t offsetFreqAdjust)
set the relative change in transmission frequency that the SS should take in order to better match th...
uint32_t GetFrameNumber() const
uint8_t m_reserved
changed as per the amendment 802.16e-2005
uint32_t m_offsetFreqAdjust
Specifies the relative change in transmission frequency that the SS is to make in order to better mat...
Cid m_basicCid
basic CID
void SetRangStatus(uint8_t rangStatus)
set the range status.
uint32_t m_timingAdjust
Tx timing offset adjustment (signed 32-bit).
uint8_t GetInitRangOppNumber() const
uint32_t m_frameNumber
Frame number where the associated RNG_REQ message was detected by the BS.
uint8_t GetAasBdcastPermission() const
static TypeId GetTypeId()
Register this type.
This class implements service flows as described by the IEEE-802.16 standard.
Tlv ToTlv() const
creates a TLV from this service flow
This class implements the Type-Len-Value structure channel encodings as described by "IEEEStandard fo...
Definition wimax-tlv.h:76
uint32_t GetSerializedSize() const override
Definition wimax-tlv.cc:91
void Serialize(Buffer::Iterator start) const override
Definition wimax-tlv.cc:115
uint32_t Deserialize(Buffer::Iterator start) override
Definition wimax-tlv.cc:135
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_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition log.h:257
#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.