A Discrete-Event Network Simulator
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
18namespace ns3
19{
20
21NS_LOG_COMPONENT_DEFINE("ZigbeeHelper");
22
24{
25 NS_LOG_FUNCTION(this);
26 m_stackFactory.SetTypeId("ns3::zigbee::ZigbeeStack");
27 m_nwkLayerOnly = false;
28}
29
30void
32{
33 NS_LOG_FUNCTION(this);
34 m_stackFactory.Set(n1, v1);
35}
36
39{
40 NS_LOG_FUNCTION(this);
41
42 zigbee::ZigbeeStackContainer zigbeeStackContainer;
43
44 for (uint32_t i = 0; i < c.GetN(); ++i)
45 {
46 Ptr<NetDevice> device = c.Get(i);
47
48 NS_ASSERT_MSG(device, "NetDevice not found in the node " << i);
49
50 NS_LOG_LOGIC("Installing Zigbee on node " << device->GetNode()->GetId());
51
53
55 {
56 zigbeeStack->SetOnlyNwkLayer();
57 }
58
59 zigbeeStackContainer.Add(zigbeeStack);
60 device->GetNode()->AggregateObject(zigbeeStack);
61 zigbeeStack->SetNetDevice(device);
62 }
63 return zigbeeStackContainer;
64}
65
66void
71
72} // namespace ns3
Hold a value for an Attribute.
Definition attribute.h:59
holds a vector of ns3::NetDevice pointers
uint32_t GetN() const
Get the number of Ptr<NetDevice> stored in this container.
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
Ptr< Object > Create() const
Create an Object instance of the configured TypeId.
void Set(const std::string &name, const AttributeValue &value, Args &&... args)
Set an attribute to be set during construction.
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
Smart pointer class similar to boost::intrusive_ptr.
zigbee::ZigbeeStackContainer Install(NetDeviceContainer c)
Install the Zigbee stack on top of an existing LrWpanNetDevice.
void SetNwkLayerOnly()
If this is set, the helper will only create Zigbee stacks that contain only the NWK layer.
ObjectFactory m_stackFactory
Zigbee stack object factory.
bool m_nwkLayerOnly
Flag indicating that only the NWK layer is present.
void SetDeviceAttribute(std::string n1, const AttributeValue &v1)
Set an attribute on each ns3::ZigbeeStack created by ZigbeeHelper::Install.
Holds a vector of ns3::ZigbeeStack pointers.
void Add(ZigbeeStackContainer other)
Append the contents of another ZigbeeStackContainer to the end of this container.
Zigbee protocol stack to device interface.
#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
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition log.h:271
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Every class exported by the ns3 library is enclosed in the ns3 namespace.