14#include "ns3/packet.h"
15#include "ns3/simulator.h"
30 .SetGroupName(
"Zigbee")
32 .AddAttribute(
"ApsNonMemberRadius",
33 "The value to be used for the NonmemberRadius parameter"
34 " when using NWK layer multicast",
116 NS_LOG_WARN(
"Security is not currently supported");
130 switch (params.m_dstAddrMode)
135 NS_ABORT_MSG(
"Binded destination groupcast not supported");
160 NS_LOG_WARN(
"Extended address mode not supported");
194 nwkParams.
m_radius = params.m_radius;
200 std::vector<DstBindingEntry> dstEntries;
204 for (
const auto& dst : dstEntries)
210 NS_LOG_WARN(
"Bound destination found but 64bit destination not supported");
216 nwkParams.
m_dstAddr = dst.GetDstAddr16();
220 p->AddHeader(apsHeader);
268 nwkParams.
m_radius = params.m_radius;
273 if (params.m_dstAddr16 ==
"FF:FF" || params.m_dstAddr16 ==
"FF:FD" ||
274 params.m_dstAddr16 ==
"FF:FC" || params.m_dstAddr16 ==
"FF:FB")
285 if (params.m_useAlias)
311 nwkParams.
m_dstAddr = params.m_dstAddr16;
314 asdu->AddHeader(apsHeader);
356 nwkParams.
m_radius = params.m_radius;
360 nwkParams.
m_dstAddr = params.m_dstAddr16;
363 asdu->AddHeader(apsHeader);
372 confirmParams.
m_srcAddr = params.m_srcAddr;
384 if ((params.m_srcEndPoint < 0x01 || params.m_srcEndPoint > 0xfe) ||
385 (params.m_dstEndPoint < 0x01))
395 SrcBindingEntry srcEntry(params.m_srcAddr, params.m_srcEndPoint, params.m_clusterId);
448 if (!
m_apsGroupTable->AddEntry(params.m_groupAddress.ConvertToInt(), params.m_endPoint))
469 if (!
m_apsGroupTable->RemoveEntry(params.m_groupAddress.ConvertToInt(), params.m_endPoint))
522 nsdu->RemoveHeader(apsHeader);
534 NS_LOG_WARN(
"Extended Header (Fragmentation) not supported");
540 if (params.m_securityUse)
580 indicationParams.
asduLength = nsdu->GetSize();
610 std::vector<uint8_t> endPoints;
614 for (
const auto& endPoint : endPoints)
This class can contain 16 bit addresses.
virtual void DoInitialize()
Initialize() implementation.
virtual void DoDispose()
Destructor implementation.
Smart pointer class similar to boost::intrusive_ptr.
static Time Now()
Return the current simulation virtual time.
static EventId ScheduleNow(FUNC f, Ts &&... args)
Schedule an event to expire Now.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Hold an unsigned integer type.
Binding Table entry: Destination portion of the table.
void SetDstAddrMode(ApsDstAddressModeBind mode)
Set the destination address mode of the destination binding entry.
void SetDstEndPoint(uint8_t endPoint)
Set the destination endppoint to the destination binding entry.
void SetDstAddr16(Mac16Address address)
Set the destination 16-bit address of the destination binding entry.
Binding Table entry: Source portion of the table.
Zigbee Specification r22.1.0, Section 2.2.3 Class that implements the Zigbee Specification Applicatio...
void ApsmeBindRequest(ApsmeBindRequestParams params)
Zigbee Specification r22.1.0, Section 2.2.4.3.1 APSME-BIND.request Bind a source entry to one or more...
void NldeDataIndication(NldeDataIndicationParams params, Ptr< Packet > nsdu)
Zigbee Specification r22.1.0, Section 3.2.1.3 NLDE-DATA.indication Used to report to the APS the rece...
ApsmeAddGroupConfirmCallback m_apsmeAddGroupConfirmCallback
This callback is used to to notify the result of endpoint addition request in the APS to the Applicat...
void SetApsmeUnbindConfirmCallback(ApsmeUnbindConfirmCallback c)
Set the callback as part of the interconnections between the APS and the next layer or service (typic...
SequenceNumber8 m_apsCounter
The sequence number used in packet Tx with APS headers.
void SetApsdeDataConfirmCallback(ApsdeDataConfirmCallback c)
Set the callback as part of the interconnections between the APS and the next layer or service (typic...
void SetApsmeBindConfirmCallback(ApsmeBindConfirmCallback c)
Set the callback as part of the interconnections between the APS and the next layer or service (typic...
Ptr< ZigbeeGroupTable > m_apsGroupTable
The group table used by this Zigbee APS.
ZigbeeAps()
Default constructor.
void DoInitialize() override
Initialize() implementation.
Ptr< ZigbeeNwk > m_nwk
The underlying Zigbee NWK connected to this Zigbee APS.
void SendDataWithBindingTable(ApsdeDataRequestParams params, Ptr< Packet > asdu)
Send a Groupcast or IEEE address destination from a list of destination in the binding table.
void SetApsmeRemoveGroupConfirmCallback(ApsmeRemoveGroupConfirmCallback c)
Set the callback as part of the interconnections between the APS and the next layer or service (typic...
ApsmeRemoveGroupConfirmCallback m_apsmeRemoveGroupConfirmCallback
This callback is used to to notify the result of a endpoint removal request in the APS to the Applica...
void ReceiveData(const ZigbeeApsHeader &apsHeader, const NldeDataIndicationParams ¶ms, Ptr< Packet > nsdu)
Zigbee Specification r22.1.0, Section 2.2.8.4.2 Reception and Rejection of data from the NWK.
ApsdeDataConfirmCallback m_apsdeDataConfirmCallback
This callback is used to to notify the results of a data transmission request to the Application fram...
void SetGroupTable(Ptr< ZigbeeGroupTable > groupTable)
Get the group table used by this Zigbee APS.
void SetApsdeDataIndicationCallback(ApsdeDataIndicationCallback c)
Set the callback as part of the interconnections between the APS and the next layer or service (typic...
static TypeId GetTypeId()
Get the type ID.
ApsdeDataIndicationCallback m_apsdeDataIndicationCallback
This callback is used to to notify the reception of data to the Application framework (AF).
void SendDataUcstBcst(ApsdeDataRequestParams params, Ptr< Packet > asdu)
Send a regular UCST or BCST data transmission to a known 16-bit address destination.
void DoDispose() override
Destructor implementation.
ApsmeBindConfirmCallback m_apsmeBindConfirmCallback
This callback is used to to notify the result of a binding request in the APS to the Application fram...
void SetApsmeRemoveAllGroupsConfirmCallback(ApsmeRemoveAllGroupsConfirmCallback c)
Set the callback as part of the interconnections between the APS and the next layer or service (typic...
void ApsmeUnbindRequest(ApsmeBindRequestParams params)
Zigbee Specification r22.1.0, Section 2.2.4.3.3 APSME-BIND.request Unbind a destination entry from a ...
void NotifyConstructionCompleted() override
Notifier called once the ObjectBase is fully constructed.
void ApsmeRemoveGroupRequest(ApsmeGroupRequestParams params)
Zigbee Specification r22.1.0, Section 2.2.4.5.3 APSME-REMOVE-GROUP.request Request that group members...
uint8_t m_apsNonMemberRadius
The APS non-member radius, used to limit the number of hops for non-member multicast group devices wh...
ApsmeRemoveAllGroupsConfirmCallback m_apsmeRemoveAllGroupsConfirmCallback
This callback is used to to notify the result of a endpoint removal request in the APS to the Applica...
void ApsmeAddGroupRequest(ApsmeGroupRequestParams params)
Zigbee Specification r22.1.0, Section 2.2.4.5.1 APSME-ADD-GROUP.request Request that group membership...
void ApsmeRemoveAllGroupsRequest(uint8_t endPoint)
Zigbee Specification r22.1.0, Section 2.2.4.5.5 APSME-REMOVE-ALL-GROUPS.request Remove membership in ...
void SetApsmeAddGroupConfirmCallback(ApsmeAddGroupConfirmCallback c)
Set the callback as part of the interconnections between the APS and the next layer or service (typic...
void SendDataGroup(ApsdeDataRequestParams params, Ptr< Packet > asdu)
Send a Groupcast to a group address destination.
Ptr< ZigbeeNwk > GetNwk() const
Get the underlying NWK used by the current Zigbee APS.
BindingTable m_apsBindingTable
The binding table used by this Zigbee APS.
void ApsdeDataRequest(ApsdeDataRequestParams params, Ptr< Packet > asdu)
Zigbee Specification r22.1.0, Section 2.2.4.1.1 APSDE-DATA.request Request the transmission of data t...
void SetNwk(Ptr< ZigbeeNwk > nwk)
Set the underlying NWK to use in this Zigbee APS.
ApsmeUnbindConfirmCallback m_apsmeUnbindConfirmCallback
This callback is used to to notify the result of a unbinding request in the APS to the Application fr...
void NldeDataConfirm(NldeDataConfirmParams params)
Zigbee Specification r22.1.0, Section 3.2.1.2 NLDE-DATA.confirm Used to report to the APS the transmi...
Helper class used to craft the transmission options bitmap used by the APSDE-DATA....
bool GetBit(int pos) const
Get the value of the bit at the position indicated.
bool IsSecurityEnabled() const
Show if the security enable bit of the Tx options is present.
void SetUseNwkKey(bool enable)
Set the use network key bit of the TX options.
bool IsIncludeExtendedNonce() const
Show if the include extended nonce bit of the Tx options is present.
uint8_t m_txOptions
the bitmap representing the Tx options
uint8_t GetTxOptions() const
Get the complete bitmap containing the Tx options.
void SetAckRequired(bool enable)
Set the Acknowledgement required bit of the Tx options.
void SetIncludeExtendedNonce(bool enable)
Set the include extended nonce bit of the Tx options.
void SetFragmentationPermitted(bool enable)
Set the fragmentation bit of the Tx options.
void SetSecurityEnabled(bool enable)
Set the security enable bit of the TX options.
ZigbeeApsTxOptions(uint8_t value=0)
The constructor of the Tx options class.
bool IsUseNwkKey() const
Show if the use network key bit of the Tx options is present.
void SetBit(int pos, bool value)
Set a bit value into a position in the uint8_t representint the Tx options.
bool IsAckRequired() const
Show if the ACK bit of the Tx options is present.
bool IsFragmentationPermitted() const
Show if the fragmentation permitted bit of the Tx options is present.
void NldeDataRequest(NldeDataRequestParams params, Ptr< Packet > packet)
Zigbee Specification r22.1.0, Section 3.2.1.1 NLDE-DATA.request Request to transfer a NSDU.
Ptr< const AttributeChecker > MakeUintegerChecker()
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Callback< R, Args... > MakeNullCallback()
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
#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_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Callback< void, ApsmeGroupConfirmParams > ApsmeRemoveGroupConfirmCallback
This callback is called to confirm a successfully removal of a group address and or endPoint from the...
Callback< void, ApsmeBindConfirmParams > ApsmeBindConfirmCallback
This callback is called to confirm a successfully addition of a destination into the binding table.
Callback< void, ApsdeDataConfirmParams > ApsdeDataConfirmCallback
This callback is called to confirm a successfully transmission of an ASDU.
Callback< void, ApsmeRemoveAllGroupsConfirmParams > ApsmeRemoveAllGroupsConfirmCallback
This callback is called to confirm a successfully removal of an endpoint from all the the groups.
Callback< void, ApsmeBindConfirmParams > ApsmeUnbindConfirmCallback
This callback is called to confirm a successfully unbind request performed into the binding table.
Callback< void, ApsmeGroupConfirmParams > ApsmeAddGroupConfirmCallback
This callback is called to confirm a successfully addition of a group address and or endPoint into th...
Callback< void, ApsdeDataIndicationParams, Ptr< Packet > > ApsdeDataIndicationCallback
This callback is called after a ASDU has successfully received and APS push it to deliver it to the n...
@ ILLEGAL_REQUEST
Illegal request.
@ NO_SHORT_ADDRESS
No short address present.
@ INVALID_GROUP
Invalid group.
@ INVALID_BINDING
Invalid binding.
@ NOT_SUPPORTED
Not supported in APS.
@ TABLE_FULL
Binding table or group table is full.
@ SECURITY_FAIL
Security failed.
@ NO_BOUND_DEVICE
No bound device.
@ DEFRAG_UNSUPPORTED
Defragmentation is not supported.
@ SUCCESS
A request has been executed successfully.
@ INVALID_PARAMETER
A parameter value was invalid or out of range.
@ GROUP_ADDR_DST_ENDPOINT_NOT_PRESENT
Group address or 16-bit destination address present but destination endpoint not present.
@ DST_ADDR16_DST_ENDPOINT_PRESENT
16-bit destination address and destination endpoint present.
@ DST_ADDR_AND_DST_ENDPOINT_NOT_PRESENT
Destination address and destination endpoint not present.
@ DST_ADDR64_DST_ENDPOINT_PRESENT
64-bit destination address and destination endpoint present.
@ SRC_ADDR16_SRC_ENDPOINT_PRESENT
16-bit source address and source endpoint present
@ UNSECURED
Unsecured status.
@ ENABLE_ROUTE_DISCOVERY
Enable route discovery.
@ MCST
Multicast Address mode.
@ UCST_BCST
Unicast or Broadcast address mode.
@ GROUP_ADDR_DST_ENDPOINT_NOT_PRESENT
@ DST_ADDR64_DST_ENDPOINT_PRESENT
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Zigbee Specification r22.1.0, Section 2.2.4.1.2 APSDE-DATA.confirm params.
Mac16Address m_dstAddr16
The destination 16-bit address.
uint8_t m_srcEndPoint
The source endpoint.
ApsDstAddressMode m_dstAddrMode
Destination address mode.
uint8_t m_dstEndPoint
The destination endpoint.
Time m_txTime
The transmission timestamp.
Mac64Address m_dstAddr64
The destination IEEE address (64-bit address).
ApsStatus m_status
The confirmation status.
Zigbee Specification r22.1.0, Section 2.2.4.1.3 APSDE-DATA.indications params.
Time m_rxTime
The reception timestamp.
Mac16Address m_dstAddr16
The destination 16-bit address.
uint8_t m_dstEndPoint
The destination endpoint.
uint8_t asduLength
The size of the the ASDU packet.
uint8_t m_srcEndpoint
The application source endpoint.
ApsSrcAddressMode m_srcAddrMode
The source address mode.
ApsDstAddressMode m_dstAddrMode
The destination address mode.
ApsStatus m_status
The data indication status.
uint8_t m_linkQuality
The link quality indication value.
Mac16Address m_srcAddress16
The 16-bit address.
uint16_t m_clusterId
The application cluster ID.
ApsSecurityStatus m_securityStatus
Security status.
uint16_t m_profileId
The application profile ID.
Zigbee Specification r22.1.0, Section 2.2.4.1.1 APSDE-DATA.request params.
Zigbee Specification r22.1.0, Sections 2.2.4.3.2 and 2.2.4.3.4 APSME-BIND.confirm and APSME-UNBIND....
ApsDstAddressModeBind m_dstAddrMode
Destination address mode.
uint16_t m_clusterId
The application cluster ID.
ApsStatus m_status
The status of the bind request.
uint8_t m_srcEndPoint
The application source endpoint.
Mac64Address m_srcAddr
The application source address.
Mac16Address m_dstAddr16
The destination 16-bit address.
Mac64Address m_dstAddr64
The destination 64-bit address.
uint8_t m_dstEndPoint
The application destination endpoint.
Zigbee Specification r22.1.0, Sections 2.2.4.3.1 and 2.2.4.3.3 APSME-BIND.request and APSME-UNBIND....
Zigbee Specification r22.1.0, Section 2.2.4.5.2 and 2.2.4.5.4 APSME-ADD-GROUP.confirm and APSME-REMOV...
ApsStatus m_status
The status of the add group request.
uint8_t m_endPoint
The endpoint to which the given group is being added.
Mac16Address m_groupAddress
The group address being added.
Zigbee Specification r22.1.0, Section 2.2.4.5.1 and 2.2.4.5.3 APSME-ADD-GROUP.request and APSME-REMOV...
Zigbee Specification r22.1.0, Section 2.2.4.5.6 APSME-REMOVE-ALL-GROUPS.request params.
uint8_t m_endPoint
The endpoint from which all groups are being removed.
ApsStatus m_status
The status of the remove all groups request.
NLDE-DATA.confirm params.
NLDE-DATA.indication params.
NLDE-DATA.request params.
uint8_t m_nonMemberRadius
Distance in hops that a multicast frame will be relayed by nodes not a member of the group.
SequenceNumber8 m_aliasSeqNumber
The sequence number used by this NSDU (ignored if useAlias = false).
Mac16Address m_dstAddr
The destination address.
bool m_securityEnable
Enable NWK layer security for the current frame.
bool m_useAlias
Indicates if next higher layer use an alias for the current frame.
Mac16Address m_aliasSrcAddr
The source address to be used by this NSDU (ignored ifuseAlias = false).
uint8_t m_radius
Distance in hops that the frame is allowed to travel through the network.
AddressMode m_dstAddrMode
Destination address mode.
uint8_t m_discoverRoute
0x01 Enable Route Discovery | 0x00: Suppress Route discovery