I attempted to answer on Zulip just now; copy-pasting the response here:
Here is an educated guess-- I don't think there are examples or
documentation around this.
Packets are stored in instances of WifiMacQueue, which are subclasses of
the Queue class found in src/network/utils. New transmissions and frames
awaiting acknowledgment (i.e. possible retransmissions) are all stored
in these queues. The base class Queue has trace sources for Enqueue,
Dequeue, Drop. There will be five such queues for each net device (one
for the DCF frames like beacons, and four for the four different AC
categories). Therefore, if you hook the traces of all five of these
queues, and monitor their enqueue, dequeue, and drop traces, you could
monitor the buffer occupancy by monitoring when the aggregate counts are
zero or non-zero.
In an 802.11be multi-link device, there will be replication of the above
for each link.
The config paths are
"/NodeList/[i]/DeviceList/[i]/$ns3::WifiNetDevice/Mac/Txop/Queue"
"/NodeList/[i]/DeviceList/[i]/$ns3::WifiNetDevice/Mac/BE_Txop/Queue"
"/NodeList/[i]/DeviceList/[i]/$ns3::WifiNetDevice/Mac/BK_Txop/Queue"
"/NodeList/[i]/DeviceList/[i]/$ns3::WifiNetDevice/Mac/VO_Txop/Queue"
"/NodeList/[i]/DeviceList/[i]/$ns3::WifiNetDevice/Mac/VI_Txop/Queue"
I think it would be helpful to you and others if we made this less
complicated and directly provided a buffer occupancy trace.