A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
zigbee-nwk-fields.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2024 Tokushima University, Japan
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Alberto Gallegos Ramonet <alramonet@is.tokushima-u.ac.jp>
7 *
8 */
9
10#include "zigbee-nwk-fields.h"
11
12#include "ns3/log.h"
13
14namespace ns3
15{
16namespace zigbee
17{
18
19NS_LOG_COMPONENT_DEFINE("ZigbeeNwkFields");
20
30
35
36uint8_t
38{
39 uint8_t capability;
40
41 capability = m_alternatePanCoord & (0x01); // Bits 0
42 capability |= ((m_deviceType & 0x01) << 1); // Bit 1
43 capability |= ((m_powerSource & 0x01) << 2); // Bit 2
44 capability |= ((m_receiverOnWhenIdle & 0x01) << 3); // Bit 3
45 // Bit 4-5 (Reserved)
46 capability |= ((m_securityCapability & 0x01) << 6); // Bit 6
47 capability |= ((m_allocateAddr & 0x01) << 7); // Bit 7
48
49 return capability;
50}
51
52bool
57
63
69
70bool
75
76bool
81
82void
84{
85 m_alternatePanCoord = (capability) & (0x01); // Bit 0
86 m_deviceType = static_cast<MacDeviceType>((capability >> 1) & (0x01)); // Bit 1
87 m_powerSource = static_cast<PowerSource>((capability >> 2) & (0x01)); // Bit 2
88 m_receiverOnWhenIdle = (capability >> 3) & (0x01); // Bit 3
89 // Bit 4-5 (Reserved)
90 m_securityCapability = (capability >> 6) & (0x01); // Bit 6
91 m_allocateAddr = (capability >> 7) & (0x01); // Bit 7
92}
93
94void
99
100void
102{
103 m_powerSource = powerSource;
104}
105
106void
111
112void
117
121
123{
124 SetSuperframe(bitmap);
125}
126
127void
129{
130 m_sspecBcnOrder = (superFrmSpec) & (0x0F); // Bits 0-3
131 m_sspecSprFrmOrder = (superFrmSpec >> 4) & (0x0F); // Bits 4-7
132
133 m_sspecPanCoor = (superFrmSpec >> 14) & (0x01); // Bit 14
134 m_sspecAssocPermit = (superFrmSpec >> 15) & (0x01); // Bit 15
135}
136
137uint8_t
142
143uint8_t
148
149bool
154
155bool
160
161} // namespace zigbee
162} // namespace ns3
uint8_t GetCapability() const
Used to obtain the complete capability information bit map.
PowerSource GetPowerSource() const
This field will be set to the value of lowest-order bit of the PowerSource parameter passed to the NL...
void SetCapability(uint8_t capability)
Set the Capability Information bit map.
bool m_alternatePanCoord
(Bit 0) The alternate PAN coordinator bit field.
void SetPowerSource(PowerSource powerSource)
Set the power source bit for the capability information field.
bool m_receiverOnWhenIdle
(Bit 3) The receiver on when idle bit field.
PowerSource m_powerSource
(Bit 2) The power source bits field.
MacDeviceType GetDeviceType() const
This field will have a value of ROUTER if the joining device is a Zigbee router.
bool IsReceiverOnWhenIdle() const
This field will be set to the value of the lowest-order bit of the RxOnWhenIdle parameter passed to t...
bool IsAlternatePanCoord() const
This field will always have a value of false in implementations of this specification.
void SetDeviceType(MacDeviceType devType)
Set the device type bit for the capability information field.
void SetAllocateAddrOn(bool value)
Set the Allocate Addr On for the capability information field.
bool m_securityCapability
(Bit 6) The security capability bit field.
MacDeviceType m_deviceType
(Bit 1) The device type bit field.
void SetReceiverOnWhenIdle(bool value)
Set the Receiver On When Idle bit for the capability information field.
bool IsAllocateAddrOn() const
This field will have a value of true in implementations of this specification, indicating that the jo...
bool m_allocateAddr
(Bit 7) The allocate address bit field.
bool IsPanCoor() const
Check if the PAN Coordinator bit is enabled.
bool IsAssocPermit() const
Check if the Association Permit bit is enabled.
uint8_t GetFrameOrder() const
Get the Superframe Specification Frame Order field.
uint8_t GetBeaconOrder() const
Get the Superframe Specification Beacon Order field.
void SetSuperframe(uint16_t superFrm)
Set the whole Superframe Specification Information field.
uint8_t m_sspecSprFrmOrder
Superframe Specification field Superframe Order (Bit 4-7)
bool m_sspecAssocPermit
Superframe Specification field Association Permit (Bit 15)
bool m_sspecPanCoor
Superframe Specification field PAN Coordinator (Bit 14)
uint8_t m_sspecBcnOrder
Superframe Specification field Beacon Order (Bit 0-3)
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
PowerSource
The power source capabilities.
MacDeviceType
The device Type Zigbee Specification r22.1.0 (Table 3-62 or Table 3-63)
@ OTHER_POWER_SOURCE
Other power source.
@ ROUTER
Router device.
Every class exported by the ns3 library is enclosed in the ns3 namespace.