A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
Loading...
Searching...
No Matches
zigbee-helper.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2023 Tokushima University, Japan
3
*
4
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Author:
7
* Alberto Gallegos Ramonet <alramonet@is.tokushima-u.ac.jp>
8
*/
9
10
#include "
zigbee-helper.h
"
11
12
#include "ns3/log.h"
13
#include "ns3/names.h"
14
#include "ns3/net-device.h"
15
#include "ns3/node.h"
16
#include "ns3/zigbee-stack.h"
17
18
namespace
ns3
19
{
20
21
NS_LOG_COMPONENT_DEFINE
(
"ZigbeeHelper"
);
22
23
ZigbeeHelper::ZigbeeHelper
()
24
{
25
NS_LOG_FUNCTION
(
this
);
26
m_stackFactory
.
SetTypeId
(
"ns3::zigbee::ZigbeeStack"
);
27
}
28
29
void
30
ZigbeeHelper::SetDeviceAttribute
(std::string
n1
,
const
AttributeValue
&
v1
)
31
{
32
NS_LOG_FUNCTION
(
this
);
33
m_stackFactory
.
Set
(
n1
,
v1
);
34
}
35
36
zigbee::ZigbeeStackContainer
37
ZigbeeHelper::Install
(
const
NetDeviceContainer
c
)
38
{
39
NS_LOG_FUNCTION
(
this
);
40
41
zigbee::ZigbeeStackContainer
zigbeeStackContainer
;
42
43
for
(
uint32_t
i
= 0;
i
<
c
.GetN(); ++
i
)
44
{
45
Ptr<NetDevice>
device =
c
.Get(
i
);
46
47
NS_ASSERT_MSG
(device,
"NetDevice not found in the node "
<<
i
);
48
49
NS_LOG_LOGIC
(
"Installing Zigbee on node "
<< device->GetNode()->GetId());
50
51
Ptr<zigbee::ZigbeeStack>
zigbeeStack
=
m_stackFactory
.
Create
<
zigbee::ZigbeeStack
>();
52
zigbeeStackContainer
.Add(
zigbeeStack
);
53
device->GetNode()->AggregateObject(
zigbeeStack
);
54
zigbeeStack
->SetNetDevice(device);
55
}
56
return
zigbeeStackContainer
;
57
}
58
59
}
// namespace ns3
ns3::AttributeValue
Hold a value for an Attribute.
Definition
attribute.h:59
ns3::NetDeviceContainer
holds a vector of ns3::NetDevice pointers
Definition
net-device-container.h:32
ns3::ObjectFactory::Create
Ptr< Object > Create() const
Create an Object instance of the configured TypeId.
Definition
object-factory.cc:82
ns3::ObjectFactory::Set
void Set(const std::string &name, const AttributeValue &value, Args &&... args)
Set an attribute to be set during construction.
Definition
object-factory.h:213
ns3::ObjectFactory::SetTypeId
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
Definition
object-factory.cc:31
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition
ptr.h:66
ns3::ZigbeeHelper::ZigbeeHelper
ZigbeeHelper()
Definition
zigbee-helper.cc:23
ns3::ZigbeeHelper::Install
zigbee::ZigbeeStackContainer Install(NetDeviceContainer c)
Install the Zigbee stack on top of an existing LrWpanNetDevice.
Definition
zigbee-helper.cc:37
ns3::ZigbeeHelper::m_stackFactory
ObjectFactory m_stackFactory
Zigbee stack object factory.
Definition
zigbee-helper.h:80
ns3::ZigbeeHelper::SetDeviceAttribute
void SetDeviceAttribute(std::string n1, const AttributeValue &v1)
Set an attribute on each ns3::ZigbeeStack created by ZigbeeHelper::Install.
Definition
zigbee-helper.cc:30
ns3::zigbee::ZigbeeStackContainer
Holds a vector of ns3::ZigbeeStack pointers.
Definition
zigbee-stack-container.h:37
ns3::zigbee::ZigbeeStack
Zigbee protocol stack to device interface.
Definition
zigbee-stack.h:46
uint32_t
NS_ASSERT_MSG
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Definition
assert.h:75
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition
log.h:191
NS_LOG_LOGIC
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition
log.h:271
NS_LOG_FUNCTION
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Definition
log-macros-enabled.h:229
ns3::Create
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Definition
ptr.h:436
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
zigbee-helper.h
src
zigbee
helper
zigbee-helper.cc
Generated on Mon Dec 15 2025 15:22:12 for ns-3 by
1.9.8