A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
zigbee-group-table.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2025 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#ifndef ZIGBEE_GROUP_TABLE_H
11#define ZIGBEE_GROUP_TABLE_H
12
13#include "ns3/simple-ref-count.h"
14
15#include <bitset>
16#include <unordered_map>
17
18namespace ns3
19{
20namespace zigbee
21{
22
23/**
24 * @ingroup zigbee
25 * The Zigbee Group Table
26 * Zigbee Specification r22.1.0, Section 2.2.8.3 and 3.6.6.1
27 * The group table is a special table that is accessible by both the
28 * Zigbee NWK and APS layers. It is used to store group IDs and associated endpoints.
29 * The group table is used in GroupCasting operations (A type of multicast in Zigbee).
30 * In this implementation, the group table is represented as a map where the key is the group ID
31 * and the value is a bitset representing the endpoints associated with that group ID.
32 * Each bit in the bitset corresponds to an endpoint, where the index of the bit represents the
33 * endpoint number.
34 */
35class ZigbeeGroupTable : public SimpleRefCount<ZigbeeGroupTable>
36{
37 public:
38 /**
39 * Constructor for Zigbee group table.
40 */
42
43 /**
44 * Destructor for Zigbee group table.
45 */
47
48 /**
49 * Add a group ID and its related endpoint. If the group ID already exists,
50 * the endpoint is added to the existing group ID entry.
51 *
52 * @param groupId The group ID to add.
53 * @param endPoint The endpoint to associate with the group ID.
54 * @return True if the entry was added successfully or the endpoint is already a member of the
55 * group, false if the table is full.
56 */
57 bool AddEntry(uint16_t groupId, uint8_t endPoint);
58
59 /**
60 * Remove endpoint from a group. If the endpoint is the last one
61 * associated with the group ID, the group ID entry is removed.
62 *
63 * @param groupId The group ID of the group to remove the endpoint from.
64 * @param endPoint The endpoint to remove from the group ID.
65 * @return True if the entry was removed successfully, false if the group does not exist, or the
66 * endpoint is not a member of the group.
67 */
68 bool RemoveEntry(uint16_t groupId, uint8_t endPoint);
69
70 /**
71 * Remove the endPoint from all groups.
72 *
73 * @param endPoint The endpoint to remove from all groups. If the removed endpoint is the last
74 * one associated with the group ID, the group ID entry is also removed.
75 * @return True if the endpoint was remmoved from at least one group, false if the endpoint was
76 * not found in any group.
77 *
78 */
79 bool RemoveMembership(uint8_t endPoint);
80
81 /**
82 * Indicates whether the group ID exists in the group table.
83 *
84 * @param groupId The group ID to query.
85 * @return True if the group ID exists, false otherwise.
86 */
87 bool IsGroupMember(uint16_t groupId) const;
88
89 /**
90 * Look up the endpoints associated with a given group ID.
91 *
92 * @param groupId The group ID to look up.
93 * @param endPoints A vector to store the endpoints associated with the group ID.
94 * @return True if the group ID was found and endpoints were retrieved, false otherwise.
95 */
96 bool LookUpEndPoints(uint16_t groupId, std::vector<uint8_t>& endPoints) const;
97
98 private:
99 static constexpr int MAX_GROUP_ID_ENTRIES{256}; //!< The maximum amount of group ID
100 //!< entries allowed in the table.
101 static constexpr int MAX_ENDPOINT_ENTRIES{256}; //!< The maximum amount of endpoints
102 //!< allowed per group id entry.
103 std::unordered_map<uint16_t, std::bitset<MAX_ENDPOINT_ENTRIES>>
104 m_groupTable; //!< The group table object
105};
106
107} // namespace zigbee
108} // namespace ns3
109
110#endif /* ZIGBEE_GROUP_TABLE_H */
A template-based reference counting class.
The Zigbee Group Table Zigbee Specification r22.1.0, Section 2.2.8.3 and 3.6.6.1 The group table is a...
bool RemoveEntry(uint16_t groupId, uint8_t endPoint)
Remove endpoint from a group.
bool IsGroupMember(uint16_t groupId) const
Indicates whether the group ID exists in the group table.
std::unordered_map< uint16_t, std::bitset< MAX_ENDPOINT_ENTRIES > > m_groupTable
The group table object.
static constexpr int MAX_ENDPOINT_ENTRIES
The maximum amount of endpoints allowed per group id entry.
bool LookUpEndPoints(uint16_t groupId, std::vector< uint8_t > &endPoints) const
Look up the endpoints associated with a given group ID.
ZigbeeGroupTable()
Constructor for Zigbee group table.
bool RemoveMembership(uint8_t endPoint)
Remove the endPoint from all groups.
~ZigbeeGroupTable()
Destructor for Zigbee group table.
static constexpr int MAX_GROUP_ID_ENTRIES
The maximum amount of group ID entries allowed in the table.
bool AddEntry(uint16_t groupId, uint8_t endPoint)
Add a group ID and its related endpoint.
Every class exported by the ns3 library is enclosed in the ns3 namespace.