# Is there any way to get the queue depth information of different priority queues?

**URL:** <https://forum.p4.org/t/is-there-any-way-to-get-the-queue-depth-information-of-different-priority-queues/770>\
**Category:** Getting Started with P4\
**Created:** [May 8, 2023, 6:10am UTC](https://forum.p4.org/t/is-there-any-way-to-get-the-queue-depth-information-of-different-priority-queues/770 "2023-05-08T06:10:14Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tuananh01](https://avatars.discourse-cdn.com/v4/letter/t/e5b9ba/32.png) [@tuananh01](https://forum.p4.org/u/tuananh01)\
**Post date:** [May 8, 2023, 6:10am UTC](https://forum.p4.org/t/is-there-any-way-to-get-the-queue-depth-information-of-different-priority-queues/770/1 "2023-05-08T06:10:14Z")

</div>

Hello everyone,

This is a shorter version of: [Queue depth of different priority queues - Getting Started with P4 - P4 Programming Language](https://forum.p4.org/t/queue-depth-of-different-priority-queues/769)

My topology:  
 ![topology](https://us1.discourse-cdn.com/flex019/uploads/p4/original/1X/65cd1130b419c8dc7c07b2528f78188248d5a50b.png)

From h1 & h2, I send 10 packets from each host to h3, 1 second interval between packets. h1 has higher priority than h2.  
I use iperf to send UDP flow from h5 to h4 to create congestion

```auto
iperf -c 10.0.2.5 -u -b 3M -t 10 -i 1

```

I implement 8 priority queues on MRI exercise and use multiple swtrace\_X tables and add\_swtrace\_X actions for each qid. There’s no difference between tables and actions.

```auto
if (hdr.mri.isValid()) {
          hdr.ipv4.tos = (bit<8>)standard_metadata.qid;
          if (hdr.ipv4.tos == 0x7) {
              swtrace_7.apply();
          }
          else if (hdr.ipv4.tos == 0x6) {
              swtrace_6.apply();
          }
          else if (hdr.ipv4.tos == 0x5) {
              swtrace_5.apply();
          }
          else if (hdr.ipv4.tos == 0x4) {
              swtrace_4.apply();
          }
...and so on

```

On switch 1, I configured:

```auto
set_queue_depth 20 4 7
set_queue_rate 1 4 7

set_queue_depth 20 4 6
set_queue_rate 1 4 6

set_queue_depth 20 4 5
set_queue_rate 1 4 5

set_queue_depth 20 4 4
set_queue_rate 1 4 4

set_queue_depth 20 4 3
set_queue_rate 1 4 3

set_queue_depth 20 4 2
set_queue_rate 1 4 2

set_queue_depth 20 4 1
set_queue_rate 1 4 1

set_queue_depth 20 4 0
set_queue_rate 1 4 0

```

Result from h3:  
I received all 20 packets  
Packet from h1

![image](https://us1.discourse-cdn.com/flex019/uploads/p4/original/1X/f191ee9e1b2a666f3acd418e8c24c7442a2bc679.png)  
Packet from h2  
 ![image](https://us1.discourse-cdn.com/flex019/uploads/p4/original/1X/53d60e9eda357a69d150273b9f216c8c2d6b1ac7.png)

The queue depth of h1 and h2 is always up to 20 which I think they should be smaller than that and also be different from each other, because when I checked the tos value they’re in different priority queues.  
Is there anything wrong with my approach?
