17#include "ns3/packet.h"
18#include "ns3/simulator.h"
19#include "ns3/zigbee-profiles.h"
34 .SetGroupName(
"Zigbee")
98 "Error, in ZDO the profile must be 0");
99 NS_ABORT_MSG_IF(params.m_dstEndPoint != 0,
"Error, in ZDO the endpoint must be 0");
106 switch (params.m_clusterId)
119 switch (params.m_clusterId)
149 nwkAddrRequestCmd.
SetRequestType(
static_cast<uint8_t
>(params.m_requestType));
151 zdpFrame->AddHeader(nwkAddrRequestCmd);
165 m_aps->ApsdeDataRequest(apsdeParams, zdpFrame);
177 nwkAddrResponseCmd.
SetTsn(params.m_tsn);
178 nwkAddrResponseCmd.
SetStatus(
static_cast<uint8_t
>(params.m_status));
181 zdpFrame->AddHeader(nwkAddrResponseCmd);
195 m_aps->ApsdeDataRequest(apsdeParams, zdpFrame);
205 asdu->RemoveHeader(requestCmd);
210 bool isBroadcast = dataParams.
m_dstAddr16 ==
"FF:FF" ||
221 bool matchFound =
false;
223 if (
m_nwk->GetIeeeAddress() == requestedIeeeAddr)
226 matchedNwkAddr =
m_nwk->GetNetworkAddress();
229 else if (
m_nwk->GetNwkAddrByIeeeAddr(requestedIeeeAddr, matchedNwkAddr))
289 asdu->RemoveHeader(responseCmd);
This class can contain 16 bit addresses.
virtual void DoInitialize()
Initialize() implementation.
Object()
Caller graph was not generated because of its size.
virtual void DoDispose()
Destructor implementation.
Smart pointer class similar to boost::intrusive_ptr.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Implements the NWK_addr_req command See Zigbee Specification r22.1.0, Section 2.4....
void SetRequestType(uint8_t type)
Set the request type, either single device or extended response.
void SetTsn(uint8_t tsn)
Set the transaction sequence number.
uint8_t GetTsn() const
Get the transaction sequence number.
uint8_t GetRequestType() const
Get the request type previously set for the network address request.
void SetIeeeAddress(Mac64Address ieeeAddress)
Set the IEEE address used as base for the network address request.
void SetStartIndex(uint8_t index)
Set the start index.
Mac64Address GetIeeeAddress()
Get the IEEE address set for the network address request.
NWK_addr_rsp Command Frame See Zigbee Specification Section 2.4.4.2.1, Figure 2-64.
Mac16Address GetNwkAddrRemoteDev()
Get the network address of the remote device.
void SetTsn(uint8_t tsn)
Set the transaction sequence number of the NWK_addr_rsp command.
void SetIeeeAddrRemoteDev(Mac64Address ieeeAddrRemoteDev)
Set the IEEE address of the remote device.
void SetStatus(uint8_t status)
Set the status of the NWK_addr_rsp command.
Mac64Address GetIeeeAddrRemoteDev()
Get the IEEE address of the remote device.
void SetNwkAddrRemoteDev(Mac16Address nwkAddrRemoteDev)
Set the network address of the remote device.
uint8_t GetStatus() const
Get the status of the NWK_addr_rsp command.
Callback< void, NwkAddrRespIndParams > ZdoNwkAddrRspIndCallback
This callback is called after a ASDU has successfully received and APS push it to deliver it to the n...
void HandleNwkAddrRequest(Ptr< Packet > asdu, ApsdeDataIndicationParams dataParams)
Effect on Receipt (NWK_addr_req) See Zigbee Specification 2017, Section 2.4.3.1.1.
Ptr< ZigbeeNwk > m_nwk
Pointer to the Zigbee Network Layer (NWK) object.
Ptr< ZigbeeNwk > GetNwk() const
Get the underlying APS used by the current Zigbee ZDO.
ZdoNwkAddrRspIndCallback m_zdoNwkAddrRspIndCallback
This callback is used to to notify the result of a NWK_addr_req request in the ZDO to the Application...
void NwkAddrRequest(NwkAddrRequestParams params)
This function is used to send a Network Address (16-bit address)Request to a remote device when the I...
void ApsDataIndication(ApsdeDataIndicationParams params, Ptr< Packet > p)
This function is called when the Zigbee Stack receives an APSDE-DATA.indication with destination endp...
SequenceNumber8 m_tsn
The transaction sequence number.
void NotifyConstructionCompleted() override
Notifier called once the ObjectBase is fully constructed.
void SetAps(Ptr< ZigbeeAps > aps)
Set the underlying APS to use in this Zigbee ZDO.
void SetNwk(Ptr< ZigbeeNwk > nwk)
Set the underlying NWK to use in this Zigbee ZDO.
void DoInitialize() override
Initialize() implementation.
Ptr< ZigbeeAps > GetAps() const
Get the underlying APS used by the current Zigbee ZDO.
void SetZdoNwkAddrRspIndCallback(ZdoNwkAddrRspIndCallback c)
Set the indication callback to be called when a response (NWK_addr_rsp) to an NWK_addr_req is receive...
void NwkAddrResponse(NwkAddrResponseParams params)
This function is used to send a Network Address (16-bit address) Response to a remote device in reply...
static TypeId GetTypeId()
Get the TypeId of ZigbeeZdo class.
Ptr< ZigbeeAps > m_aps
Pointer to the Zigbee Application Support Sub-layer (APS) object.
void HandleNwkAddrResponse(Ptr< Packet > asdu, ApsdeDataIndicationParams dataParams)
Effect on Receipt (NWK_addr_rsp) See Zigbee Specification 2017, Section 2.4.4.2.1.
void DoDispose() override
Destructor implementation.
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
NwkAddrRequestType
Zigbee Device Profile (ZDP) enumeration of request types for NWK_addr_req command.
@ EXTENDED_RESPONSE
Request type for an extended response, not currently supported.
@ SINGLE_DEVICE_RESPONSE
Request type for a single device response.
@ DST_ADDR16_DST_ENDPOINT_PRESENT
16-bit destination address and destination endpoint present.
@ NWK_ADDR_REQ
Network Address Request command (Optional).
@ NWK_ADDR_RSP
Network Address Response command (Mandatory).
ZdpStatus
Zigbee Device Profile (ZDP) enumeration of status codes.
@ DEVICE_NOT_FOUND
The device with the specified IEEE address was not found in the network.
@ SUCCESS
The request was successful.
@ INV_REQUESTTYPE
The request type is invalid or not supported.
@ ZDP_PROFILE
Zigbee Device Profile (ZDP).
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Zigbee Specification r22.1.0, Section 2.2.4.1.3 APSDE-DATA.indications params.
Mac16Address m_dstAddr16
The destination 16-bit address.
Mac16Address m_srcAddress16
The 16-bit address.
Zigbee Specification r22.1.0, Section 2.2.4.1.1 APSDE-DATA.request params.
uint16_t m_profileId
The application profile ID.
uint16_t m_clusterId
The application cluster ID.
Mac16Address m_dstAddr16
The destination 16-bit address.
uint8_t m_txOptions
Transmission options.
uint8_t m_srcEndPoint
The source endpoint.
uint32_t m_asduLength
The ASDU length.
bool m_useAlias
Indicates if alias is used in this transmission.
ApsDstAddressMode m_dstAddrMode
Destination address mode.
uint8_t m_dstEndPoint
The destination endpoint.
uint8_t m_radius
Radius (Number of hops this message travels).
ZDO Network Address Request Parameters.
ZDO Network Address Response Indication Parameters.
Mac16Address m_nwkAddrRemoteDev
The network address (16-bit address) of the remote device matching the request.
Mac64Address m_ieeeAddrRemoteDev
The IEEE address (64-bit address) of the remote device matching the request.
ZdpStatus m_status
The status of the NWK_addr_req being responded to.
ZDO Network Address Response Parameters.
uint8_t m_tsn
The transaction sequence number, must match the one used in the corresponding NWK_addr_req.
Mac16Address m_nwkAddrRemoteDev
The network address (16-bit address) of the remote device matching the request.
Mac16Address m_dstAddr
The destination of the response (the device that issued the NWK_addr_req).
ZdpStatus m_status
The status of the NWK_addr_req being responded to.
Mac64Address m_ieeeAddrRemoteDev
The IEEE address (64-bit address) of the remote device matching the request.