# Check the packet counter on simple switch port

**URL:** <https://forum.p4.org/t/check-the-packet-counter-on-simple-switch-port/649>\
**Category:** Getting Started with P4\
**Created:** [February 18, 2023, 10:42pm UTC](https://forum.p4.org/t/check-the-packet-counter-on-simple-switch-port/649 "2023-02-18T22:42:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kspimparkar](https://avatars.discourse-cdn.com/v4/letter/k/eb8c5e/32.png) [@kspimparkar](https://forum.p4.org/u/kspimparkar)\
**Post date:** [February 18, 2023, 10:42pm UTC](https://forum.p4.org/t/check-the-packet-counter-on-simple-switch-port/649/1 "2023-02-18T22:42:37Z")

</div>

I wanted to see the packet count on the simple\_switch\_grpc switch ports. I could not find right way to do it. Please help me with getting the packet count on a specific port with p4runtime on simple switch. Thanks!

---

<div class="post-metadata">

**Author:** ![andyfingerhut](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.p4.org/andyfingerhut/32/17_2.png) [@andyfingerhut](https://forum.p4.org/u/andyfingerhut)\
**Post date:** [February 19, 2023, 4:47am UTC](https://forum.p4.org/t/check-the-packet-counter-on-simple-switch-port/649/2 "2023-02-19T04:47:52Z")

</div>

The only counters that can be accessed using the p4runtime API on a P4 program are those explicitly written into the P4 program itself. There are no port packet/byte counters “by default” in a P4 program.

If you write P4 code to maintain packet & byte counts for all packets received on a port, and/or all packets sent to a port, then you can use the p4runtime API to read those counter values, explicitly defined in your P4 code, by the name that you chose to give them.
