nsg-ethz / p4-utils

Extension to Mininet that makes P4 networks easier to build
GNU General Public License v2.0
175 stars 65 forks source link

How to clone packets more than once back to back? #55

Closed Master-COLLiDER closed 1 year ago

Master-COLLiDER commented 1 year ago

Can we not use clone3 twice to clone packet two times and send it to controller?

When I use clone3 twice then only second clone is reached the controller and the sniff function calls the recv_msg_cpu once.

here is my controller code to sniff packet from cpu port the recv_msg_cpu() function is used to handle the packets

def run_cpu_port_loop(self):
        cpu_port_intf = str(self.topo.get_cpu_port_intf(self.sw_name).replace("eth0", "eth1"))
        sniff(iface=cpu_port_intf, prn=self.recv_msg_cpu)

also in the p4 code

if(send_to_all.apply().hit){
    meta.CLONE_ETHER_TYPE = DELETE_MC_ETHER_TYPE;
    clone3(CloneType.I2E, 100, meta);
}
meta.CLONE_ETHER_TYPE = CACHE_ETHER_TYPE;
clone3(CloneType.I2E, 100, meta);

And rest I am handling in control egress

edgar-costa commented 1 year ago

Hi,

You can only create one copy of the packet. In order to create more clones you need to somehow do that in your P4 code logic. To clone more than one packet, you will need to trigger another cloning when the cloned packet is processed again at the egress.

Master-COLLiDER commented 1 year ago

You can only create one copy of the packet. In order to create more clones you need to somehow do that in your P4 code logic. To clone more than one packet, you will need to trigger another cloning when the cloned packet is processed again at the egress.

Thank your @edgar-costa. I have understood now. I will try CloneType.E2E in egress.