# Can I install rules like this？

**URL:** <https://forum.p4.org/t/can-i-install-rules-like-this/119>\
**Category:** Education Working Group\
**Created:** [September 24, 2021, 7:45am UTC](https://forum.p4.org/t/can-i-install-rules-like-this/119 "2021-09-24T07:45:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![AcmeT](https://avatars.discourse-cdn.com/v4/letter/a/f1d935/32.png) [@AcmeT](https://forum.p4.org/u/AcmeT)\
**Post date:** [September 24, 2021, 7:45am UTC](https://forum.p4.org/t/can-i-install-rules-like-this/119/1 "2021-09-24T07:45:24Z")

</div>

Hello,  
I’m a beginner of P4 and here is my question.  
I want to check the match-action table if the rule is exist when the first packet of a new flow arrives. If the rule is not there, I want to send the packet to control plane and the control plane to parse the packet then install new rules. Can P4 do this?  
Thank you

---

<div class="post-metadata">

**Author:** ![ederollora](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.p4.org/ederollora/32/21_2.png) [@ederollora](https://forum.p4.org/u/ederollora)\
**Post date:** [September 24, 2021, 8:55am UTC](https://forum.p4.org/t/can-i-install-rules-like-this/119/2 "2021-09-24T08:55:46Z")

</div>

Hi,

You should be able to do that. You can find some examples at [jafingerhut/p4-guide](https://github.com/jafingerhut/p4-guide) like [this one](https://github.com/jafingerhut/p4-guide/blob/07fd9ac5ed1610a725eb9d029d61a8ba9931e48e/ptf-tests/packetinout/packetinout.p4) or [this one](https://github.com/jafingerhut/p4-guide/blob/5dc2d80c8282f5cb01a803c46e537704bf0f3715/p4runtime/v1model-p4runtime-most-types1.p4). It is always good to search for `controller_header` in P4 programs to identify similar examples. You then need the control plane that can receive those packets and process them. I generally recommend ONOS, which has a nice tutorial [here](https://github.com/opennetworkinglab/ngsdn-tutorial) but there is a steep learning curve if you have never used it before. Else, you can try to use the Python control plane included in the [P4 tutorials](https://github.com/p4lang/tutorials). It needs some modifications, but I just searched on Github and you can find some code [here](https://github.com/kevinbird61/p4-researching) by Kevin Cyu, [here](https://github.com/demian91/Simple-P4runtime-Controller) by Belma Turkovicor [some I did](https://github.com/ederollora/NETPROC_P4Knocking) some time ago.

I hope it helps

---

<div class="post-metadata">

**Author:** ![AcmeT](https://avatars.discourse-cdn.com/v4/letter/a/f1d935/32.png) [@AcmeT](https://forum.p4.org/u/AcmeT)\
**Post date:** [September 26, 2021, 5:48am UTC](https://forum.p4.org/t/can-i-install-rules-like-this/119/3 "2021-09-26T05:48:05Z")

</div>

Thank you very much!!! I will check these for more. : )
