# Getting Started with P4

**URL:** https://forum.p4.org/c/getting-started-with-p4/13.md

[Latest](https://forum.p4.org/latest.md) · [Categories](https://forum.p4.org/categories.md)

---

## [About the Getting Started with P4 category](https://forum.p4.org/t/about-the-getting-started-with-p4-category/43)

<div class="topic-metadata">

**Author:** [@judysnow](https://forum.p4.org/u/judysnow)\
**Replies:** 0

</div>

Q&A for Newbies Use the following paragraphs for a longer description, or to establish category guidelines or rules: Why should people use this category? What is it for? How exactly is this different than the othe…

---

## [Bm\_dev\_mgr\_remove\_port can deadlock the BMI port manager when a packet arrives during the removal](https://forum.p4.org/t/bm-dev-mgr-remove-port-can-deadlock-the-bmi-port-manager-when-a-packet-arrives-during-the-removal/1479)

<div class="topic-metadata">

**Author:** [@louis.barbier41](https://forum.p4.org/u/louis.barbier41)\
**Replies:** 0\
**Last updated:** [September 24, 2026, 12:58pm UTC](https://forum.p4.org/t/bm-dev-mgr-remove-port-can-deadlock-the-bmi-port-manager-when-a-packet-arrives-during-the-removal/1479 "2026-09-24T12:58:44Z")

</div>

Hi everyone, On a switch that receives traffic, a Thrift bm\_dev\_mgr\_remove\_port sometimes never returns. Afterward the switch forwards nothing, and every later add\_port, remove\_port call hangs too. Only a restart recov…

---

## [How to arrange multiple registers in one stage?](https://forum.p4.org/t/how-to-arrange-multiple-registers-in-one-stage/1478)

<div class="topic-metadata">

**Author:** [@LongP4](https://forum.p4.org/u/LongP4)\
**Replies:** 2\
**Last updated:** [September 16, 2026, 5:28am UTC](https://forum.p4.org/t/how-to-arrange-multiple-registers-in-one-stage/1478 "2026-09-16T05:28:44Z")

</div>

I use @stage to arrange multiple registers in one stage, but when I arrange more than 4 registers in one stage, I receive a warning, and then the extra registers are arranged into other stages. However, when I observ…

---

## [Packet drops appear after adding src\_tcam\_table.apply() in a Tofino2 P4 pipeline, even when the table is empty](https://forum.p4.org/t/packet-drops-appear-after-adding-src-tcam-table-apply-in-a-tofino2-p4-pipeline-even-when-the-table-is-empty/1464)

<div class="topic-metadata">

**Author:** [@1418915702](https://forum.p4.org/u/1418915702)\
**Replies:** 1\
**Last updated:** [May 12, 2026, 3:46am UTC](https://forum.p4.org/t/packet-drops-appear-after-adding-src-tcam-table-apply-in-a-tofino2-p4-pipeline-even-when-the-table-is-empty/1464 "2026-05-12T03:46:20Z")

</div>

Hello everyone, I am implementing a HyperLens-like ACL packet classification pipeline on Intel Tofino2 using P4 and BF-RT. I am testing the forwarding behavior with ClassBench-generated ACL rule sets and packet traces. …

---

## [Need Help Configuring Tofino1 Switch](https://forum.p4.org/t/need-help-configuring-tofino1-switch/1419)

<div class="topic-metadata">

**Author:** [@aaywjaa](https://forum.p4.org/u/aaywjaa)\
**Replies:** 9\
**Last updated:** [May 1, 2026, 3:05pm UTC](https://forum.p4.org/t/need-help-configuring-tofino1-switch/1419 "2026-05-01T15:05:36Z")

</div>

We are newcomers to the P4 field. We have a P4 switch with a Tofino1 chip, Debian 11. When deploying the environment according to the vendor’s guide manual, the official document mentions these components and dependent i…

---

## [Throughput measurement in Tofino](https://forum.p4.org/t/throughput-measurement-in-tofino/1461)

<div class="topic-metadata">

**Author:** [@1418915702](https://forum.p4.org/u/1418915702)\
**Replies:** 3\
**Last updated:** [April 12, 2026, 2:43am UTC](https://forum.p4.org/t/throughput-measurement-in-tofino/1461 "2026-04-12T02:43:19Z")

</div>

Hi, I’m currently working on evaluating the throughput of a Tofino-based switch and have a couple of questions regarding measurement approaches. My topology is shown below. 1. Built-in throughput measurement in Tofi…

---

## [Can Open P4 Studio display memory utilization for table entries, and how can I check it?](https://forum.p4.org/t/can-open-p4-studio-display-memory-utilization-for-table-entries-and-how-can-i-check-it/1459)

<div class="topic-metadata">

**Author:** [@1418915702](https://forum.p4.org/u/1418915702)\
**Replies:** 3\
**Last updated:** [March 26, 2026, 6:07pm UTC](https://forum.p4.org/t/can-open-p4-studio-display-memory-utilization-for-table-entries-and-how-can-i-check-it/1459 "2026-03-26T18:07:16Z")

</div>

I’m working with a P4 programmable switch (Intel Tofino-based) and using Open P4 Studio (SDE). I need to monitor the memory usage of my match-action tables, specifically the TCAM and SRAM utilization at the physical memo…

---

## [Unexpected digest batching and delay in BMv2](https://forum.p4.org/t/unexpected-digest-batching-and-delay-in-bmv2/1457)

<div class="topic-metadata">

**Author:** [@Ederroski](https://forum.p4.org/u/Ederroski)\
**Replies:** 2\
**Last updated:** [March 13, 2026, 12:51pm UTC](https://forum.p4.org/t/unexpected-digest-batching-and-delay-in-bmv2/1457 "2026-03-13T12:51:49Z")

</div>

I’m testing digest behavior in P4 and I’m seeing results that I don’t quite understand. For testing purposes, the digest is triggered on almost every packet and it is configured with: max\_list\_size = 1 max\_timeout…

---

## [Set up roles for multiple (and remote) controller connections in BMv2](https://forum.p4.org/t/set-up-roles-for-multiple-and-remote-controller-connections-in-bmv2/1454)

<div class="topic-metadata">

**Author:** [@a\_mora](https://forum.p4.org/u/a_mora)\
**Replies:** 12\
**Last updated:** [February 24, 2026, 8:39pm UTC](https://forum.p4.org/t/set-up-roles-for-multiple-and-remote-controller-connections-in-bmv2/1454 "2026-02-24T20:39:02Z")

</div>

While reading the P4Runtime API specification, I noticed that a data plane can have multiple controls, even outside the target. The specification states that multiple controllers with write access can be connected to the…

---

## [How to send messages to the control plane from p4 data plane and vice-versa](https://forum.p4.org/t/how-to-send-messages-to-the-control-plane-from-p4-data-plane-and-vice-versa/1452)

<div class="topic-metadata">

**Author:** [@a\_mora](https://forum.p4.org/u/a_mora)\
**Replies:** 1\
**Last updated:** [February 17, 2026, 5:57pm UTC](https://forum.p4.org/t/how-to-send-messages-to-the-control-plane-from-p4-data-plane-and-vice-versa/1452 "2026-02-17T17:57:10Z")

</div>

I was trying to find a way to allow control the plane and the data plane to communicate (for example the data plane can notify the control plane when something happens, or the control plane can insert new entries in the …

---

## [Question about the actual input byte layout for Tofino hash when using multiple fields](https://forum.p4.org/t/question-about-the-actual-input-byte-layout-for-tofino-hash-when-using-multiple-fields/1436)

<div class="topic-metadata">

**Author:** [@LongP4](https://forum.p4.org/u/LongP4)\
**Replies:** 4\
**Last updated:** [February 2, 2026, 2:27pm UTC](https://forum.p4.org/t/question-about-the-actual-input-byte-layout-for-tofino-hash-when-using-multiple-fields/1436 "2026-02-02T14:27:16Z")

</div>

Hi, I have a question about the actual input format used by the Tofino hash function when multiple fields are provided as hash inputs. As an example, during packet parsing, I place parsed header contents into the follo…

---

## [Can Tofino2 TCAM support non-contiguous wildcard encoding like 000\*1\*? How to represent it via control plane?](https://forum.p4.org/t/can-tofino2-tcam-support-non-contiguous-wildcard-encoding-like-000-1-how-to-represent-it-via-control-plane/1437)

<div class="topic-metadata">

**Author:** [@1418915702](https://forum.p4.org/u/1418915702)\
**Replies:** 1\
**Last updated:** [February 2, 2026, 3:55am UTC](https://forum.p4.org/t/can-tofino2-tcam-support-non-contiguous-wildcard-encoding-like-000-1-how-to-represent-it-via-control-plane/1437 "2026-02-02T03:55:22Z")

</div>

Hi , I have a question about TCAM matching capability on Tofino2, especially regarding non-contiguous wildcard patterns. Suppose I want to install a TCAM entry with the following bit-level match pattern: LCP = 000\*1\* …

---

## [Are registers in BMv2 initialized to zero?](https://forum.p4.org/t/are-registers-in-bmv2-initialized-to-zero/1434)

<div class="topic-metadata">

**Author:** [@a\_mora](https://forum.p4.org/u/a_mora)\
**Replies:** 2\
**Last updated:** [January 30, 2026, 7:43pm UTC](https://forum.p4.org/t/are-registers-in-bmv2-initialized-to-zero/1434 "2026-01-30T19:43:14Z")

</div>

Hi everyone, I was wondering if registers are guaranteed to be initialized to 0 when using BMv2 (specifically simple\_switch\_grpc) and, if so, whether this is also common on other targets. I looked through the P4 langua…

---

## [Why the counter does not work as expect?](https://forum.p4.org/t/why-the-counter-does-not-work-as-expect/1425)

<div class="topic-metadata">

**Author:** [@herano1999](https://forum.p4.org/u/herano1999)\
**Replies:** 5\
**Last updated:** [January 14, 2026, 9:23am UTC](https://forum.p4.org/t/why-the-counter-does-not-work-as-expect/1425 "2026-01-14T09:23:19Z")

</div>

I wrote a Tofino P4 program, and I can successfully compile it with open-p4studio. #include \<core.p4\> #if \_\_TARGET\_TOFINO\_\_ == 3 #include \<t3na.p4\> #elif \_\_TARGET\_TOFINO\_\_ == 2 #include \<t2na.p4\> #else #include \<tna.p4\> …

---

## [How to implementing ARP in BMv2 Switch](https://forum.p4.org/t/how-to-implementing-arp-in-bmv2-switch/1411)

<div class="topic-metadata">

**Author:** [@TaikiIto](https://forum.p4.org/u/TaikiIto)\
**Replies:** 7\
**Last updated:** [December 8, 2025, 7:39am UTC](https://forum.p4.org/t/how-to-implementing-arp-in-bmv2-switch/1411 "2025-12-08T07:39:33Z")

</div>

Hello,All. I would like to implement custom ARP processing using P4 on a BMv2 switch. My goal is to implement the following logic: ARP Requests: When the switch receives an ARP packet, it should broadcast (flood) it to…

---

## [P4/Tofino: Best practices for fallback metaifno matching (primary → secondary) without duplicate apply or heavy memory usage?](https://forum.p4.org/t/p4-tofino-best-practices-for-fallback-metaifno-matching-primary-secondary-without-duplicate-apply-or-heavy-memory-usage/1409)

<div class="topic-metadata">

**Author:** [@1418915702](https://forum.p4.org/u/1418915702)\
**Replies:** 3\
**Last updated:** [November 25, 2025, 6:59pm UTC](https://forum.p4.org/t/p4-tofino-best-practices-for-fallback-metaifno-matching-primary-secondary-without-duplicate-apply-or-heavy-memory-usage/1409 "2025-11-25T18:59:57Z")

</div>

Hi， I’m implementing a 3-stage packet classification on Tofino: Stage-1: IP/Proto TCAM → outputs two metaifno (primary, secondary). Stage-2: SRC port matching — use metaifno to lookup either TCAM or SRAM. Requiremen…

---

## [Clone to CPU: First packet received by the controller, other not received](https://forum.p4.org/t/clone-to-cpu-first-packet-received-by-the-controller-other-not-received/1407)

<div class="topic-metadata">

**Author:** [@louis.barbier41](https://forum.p4.org/u/louis.barbier41)\
**Replies:** 1\
**Last updated:** [November 24, 2025, 12:56pm UTC](https://forum.p4.org/t/clone-to-cpu-first-packet-received-by-the-controller-other-not-received/1407 "2025-11-24T12:56:22Z")

</div>

Hello everyone, I’m currently debugging an issue with the PacketIn mechanism in my P4Runtime controller (Python, asyncio). I implemented the same architecture as the flow-cache example: a processNotif task, an asyncio Q…

---

## [Does P4 Support a Popcount Operation on Any Target?](https://forum.p4.org/t/does-p4-support-a-popcount-operation-on-any-target/1405)

<div class="topic-metadata">

**Author:** [@1418915702](https://forum.p4.org/u/1418915702)\
**Replies:** 1\
**Last updated:** [November 18, 2025, 7:41am UTC](https://forum.p4.org/t/does-p4-support-a-popcount-operation-on-any-target/1405 "2025-11-18T07:41:30Z")

</div>

Hi， I would like to confirm whether P4 (P4\_16) support a popcount / bit-count operation in the data plane. If not, then implementing popcount manually in P4 seems like it would consume many pipeline stages — is that re…

---

## [How to embed Ghost Thread feature in P4 code](https://forum.p4.org/t/how-to-embed-ghost-thread-feature-in-p4-code/1398)

<div class="topic-metadata">

**Author:** [@herano1999](https://forum.p4.org/u/herano1999)\
**Replies:** 6\
**Last updated:** [November 13, 2025, 11:26am UTC](https://forum.p4.org/t/how-to-embed-ghost-thread-feature-in-p4-code/1398 "2025-11-13T11:26:06Z")

</div>

Hi! Recently, I’ve been struggling to implement Bolt (NSDI ‘23). It’s quite frustrating that I cannot find any reference code except sfc\_ghost.p4, sfc\_trigger.p4 (under open-p4studio/pkgsrc/switch-p4-16/p4src/shared at …

---

## [Question about the SRAM lookup process in the two-stage ALPM matching](https://forum.p4.org/t/question-about-the-sram-lookup-process-in-the-two-stage-alpm-matching/1403)

<div class="topic-metadata">

**Author:** [@1418915702](https://forum.p4.org/u/1418915702)\
**Replies:** 1\
**Last updated:** [November 13, 2025, 8:31am UTC](https://forum.p4.org/t/question-about-the-sram-lookup-process-in-the-two-stage-alpm-matching/1403 "2025-11-13T08:31:16Z")

</div>

Hello, I am studying and trying to reproduce the ALPM (Algorithmic Longest Prefix Match) example in P4 as a baseline algorithm for my research. While reading the ALPM patent, I encountered a question about how the SRAM…

---

## [Questions on SRAM Block Usage in Tofino2](https://forum.p4.org/t/questions-on-sram-block-usage-in-tofino2/1399)

<div class="topic-metadata">

**Author:** [@1418915702](https://forum.p4.org/u/1418915702)\
**Replies:** 2\
**Last updated:** [November 12, 2025, 1:00pm UTC](https://forum.p4.org/t/questions-on-sram-block-usage-in-tofino2/1399 "2025-11-12T13:00:07Z")

</div>

I am trying to understand the SRAM block usage and size allocation behavior of Match-Action Tables (MATs) on Intel Tofino2.In my experiments, I observed the following: For a MAT with only 1 entry: When Key Width = 16…

---

## [P4Controller PacketIn. Packets not arriving](https://forum.p4.org/t/p4controller-packetin-packets-not-arriving/1401)

<div class="topic-metadata">

**Author:** [@louis.barbier41](https://forum.p4.org/u/louis.barbier41)\
**Replies:** 9\
**Last updated:** [November 11, 2025, 11:53pm UTC](https://forum.p4.org/t/p4controller-packetin-packets-not-arriving/1401 "2025-11-11T23:53:47Z")

</div>

Hello, I am currently working on P4. I am implementing the following architecture: Switch swarm that populate their routing table by using a P4 controller. I don’t understand how PacketIn works as I am not receiving a…

---

## [Intel(r) Tofino(tm) Family, TNA, and P4Studio questions](https://forum.p4.org/t/intel-r-tofino-tm-family-tna-and-p4studio-questions/504)

<div class="topic-metadata">

**Author:** [@andyfingerhut](https://forum.p4.org/u/andyfingerhut)\
**Replies:** 1\
**Last updated:** [October 22, 2025, 8:56pm UTC](https://forum.p4.org/t/intel-r-tofino-tm-family-tna-and-p4studio-questions/504 "2025-10-22T20:56:48Z")

</div>

There is a fair amount of public information about Tofino available, but in general, unless someone can point you at a public source for answers, any specific questions about Tofino hardware features, Tofino Native Archi…

---

## [Unexpected Queue Depth Spikes in BMv2 (v1model) During Congestion Control](https://forum.p4.org/t/unexpected-queue-depth-spikes-in-bmv2-v1model-during-congestion-control/1391)

<div class="topic-metadata">

**Author:** [@kmftangchaoyang](https://forum.p4.org/u/kmftangchaoyang)\
**Replies:** 5\
**Last updated:** [October 22, 2025, 6:10pm UTC](https://forum.p4.org/t/unexpected-queue-depth-spikes-in-bmv2-v1model-during-congestion-control/1391 "2025-10-22T18:10:23Z")

</div>

Hi！ When I write a P4 program on BMv2 using the v1model, I need to monitor queue length information for my congestion control algorithm. I obtain this information by reading standard\_metadata.deq\_qdepth at the egress wh…

---

## [How to routing with P4](https://forum.p4.org/t/how-to-routing-with-p4/1392)

<div class="topic-metadata">

**Author:** [@TaikiIto](https://forum.p4.org/u/TaikiIto)\
**Replies:** 2\
**Last updated:** [October 21, 2025, 5:54am UTC](https://forum.p4.org/t/how-to-routing-with-p4/1392 "2025-10-21T05:54:46Z")

</div>

Hi! I’m studying INT(In-band Network Telemetry) with P4 in the university. I’m beginner in network field and programmable data plane, so I would like to know if the following thing I am trying to do is possible. Crea…

---

## [Data Consistency Issues When Using Stateful Data in P4 Programs](https://forum.p4.org/t/data-consistency-issues-when-using-stateful-data-in-p4-programs/1393)

<div class="topic-metadata">

**Author:** [@kmftangchaoyang](https://forum.p4.org/u/kmftangchaoyang)\
**Replies:** 4\
**Last updated:** [October 20, 2025, 4:54am UTC](https://forum.p4.org/t/data-consistency-issues-when-using-stateful-data-in-p4-programs/1393 "2025-10-20T04:54:39Z")

</div>

Hi, I would like to ask a question about potential data inconsistency caused by parallel packet processing. I searched the forum briefly but couldn’t find a related topic. While writing a P4 program on BMv2 (v1model), I…

---

## [How are IDs for tables, counters, meters, and actions assigned in P4 compiler output JSON files?](https://forum.p4.org/t/how-are-ids-for-tables-counters-meters-and-actions-assigned-in-p4-compiler-output-json-files/1388)

<div class="topic-metadata">

**Author:** [@farhan](https://forum.p4.org/u/farhan)\
**Replies:** 3\
**Last updated:** [September 28, 2025, 6:51pm UTC](https://forum.p4.org/t/how-are-ids-for-tables-counters-meters-and-actions-assigned-in-p4-compiler-output-json-files/1388 "2025-09-28T18:51:10Z")

</div>

Hi everyone, I’m trying to better understand how the P4 compiler assigns IDs to pipeline objects (such as tables, actions, counters, meters, etc.) when generating artifacts like: dash\_pipeline.json dash\_pipeline\_p…

---

## [How to get Socket path when using controller to get information from data plane](https://forum.p4.org/t/how-to-get-socket-path-when-using-controller-to-get-information-from-data-plane/1358)

<div class="topic-metadata">

**Author:** [@yuexin12138](https://forum.p4.org/u/yuexin12138)\
**Replies:** 5\
**Last updated:** [August 13, 2025, 9:56pm UTC](https://forum.p4.org/t/how-to-get-socket-path-when-using-controller-to-get-information-from-data-plane/1358 "2025-08-13T21:56:02Z")

</div>

Hello, I am writing a P4 program in bmv2. I would like that P4 sends this information(including throughput and flow\_id) by using digest + thrift to controller and set meter based on this digest. I have already finish t…

---

## [How to setup IPv6](https://forum.p4.org/t/how-to-setup-ipv6/1338)

<div class="topic-metadata">

**Author:** [@dpilipczuk](https://forum.p4.org/u/dpilipczuk)\
**Replies:** 1\
**Last updated:** [June 20, 2025, 6:43pm UTC](https://forum.p4.org/t/how-to-setup-ipv6/1338 "2025-06-20T18:43:43Z")

</div>

Hi! I have college project regarding p4. I need to implement ipv4 ↔ ipv6 translation, but I have trouble with setting up the environment :confused: Ideally, I want to create topology with two hosts and one switch. One …

---

## [ModuleNotFoundError: No module named 'p4' when running make run in exercises/basic](https://forum.p4.org/t/modulenotfounderror-no-module-named-p4-when-running-make-run-in-exercises-basic/1331)

<div class="topic-metadata">

**Author:** [@kacperkuczynski26](https://forum.p4.org/u/kacperkuczynski26)\
**Replies:** 1\
**Last updated:** [June 6, 2025, 4:11pm UTC](https://forum.p4.org/t/modulenotfounderror-no-module-named-p4-when-running-make-run-in-exercises-basic/1331 "2025-06-06T16:11:20Z")

</div>

Hi all, I’m working on the basic exercise from the official p4lang/tutorials repo on a clean installation of Ubuntu 24.04 in VirtualBox. I followed the setup steps including: bash git clone https://github.com/p4lang/t…

[Next page](https://forum.p4.org/c/getting-started-with-p4/13.md?page=1)
