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