# How to clone packets to the control plane while continuing normal forwarding?

**URL:** <https://forum.p4.org/t/how-to-clone-packets-to-the-control-plane-while-continuing-normal-forwarding/1293>\
**Category:** Getting Started with P4\
**Created:** [April 7, 2025, 12:03pm UTC](https://forum.p4.org/t/how-to-clone-packets-to-the-control-plane-while-continuing-normal-forwarding/1293 "2025-04-07T12:03:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zhw20250102](https://avatars.discourse-cdn.com/v4/letter/z/a587f6/32.png) [@Zhw20250102](https://forum.p4.org/u/Zhw20250102)\
**Post date:** [April 7, 2025, 12:03pm UTC](https://forum.p4.org/t/how-to-clone-packets-to-the-control-plane-while-continuing-normal-forwarding/1293/1 "2025-04-07T12:03:55Z")

</div>

I’m new to P4 and I have a specific requirement:  
When a packet arrives at the data plane, I want to send some related information of the packet to the control plane, while still allowing the original packet to continue with its normal forwarding behavior.

From my understanding, I might be able to use **`clone_preserving_field_list`** to achieve this, possibly in combination with **`PacketIn`** and **`PacketOut`**. However, I’m a bit unclear on the exact steps and best practices for this use case.

Also, are there any official documents, examples, or tutorials that explain this scenario?

Any help would be greatly appreciated!

Thanks in advance.

---

<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:** [April 13, 2025, 3:06pm UTC](https://forum.p4.org/t/how-to-clone-packets-to-the-control-plane-while-continuing-normal-forwarding/1293/2 "2025-04-13T15:06:00Z")

</div>

Yes, cloning (aka mirroring) a packet is a good approach if you want to process the original packet “normally” (whatever that happens to mean in your P4 program), but also create a copy that you treat differently, e.g. send it to a different place, perhaps with different headers.

Here is a link to a public example P4 program that demonstrates using PacketIn from switch to controller, and PacketOut messages from controller to switch: [p4-guide/ptf-tests/packetinout at master · jafingerhut/p4-guide · GitHub](https://github.com/jafingerhut/p4-guide/tree/master/ptf-tests/packetinout)

Note: It does _not_ use any clone operations. It demonstrates the ability of a P4 program to receive a packet, and send exactly one copy of that packet to the controller via PacketIn, _without_ cloning it. So that program is not exactly what you need, but at least it demonstrates the PacketIn and PacketOut features in detail.

---

<div class="post-metadata">

**Author:** ![Zhw20250102](https://avatars.discourse-cdn.com/v4/letter/z/a587f6/32.png) [@Zhw20250102](https://forum.p4.org/u/Zhw20250102)\
**Post date:** [April 13, 2025, 3:15pm UTC](https://forum.p4.org/t/how-to-clone-packets-to-the-control-plane-while-continuing-normal-forwarding/1293/3 "2025-04-13T15:15:26Z")

</div>

Thank you very much. 😀
