Routing the Packets

So I want some help regarding that suppose,
If we are implementing the basic forwading program given in exercise it works like if we send the packet with custom source and destination address it just forwards it from source → destination defined in packets.

But what if I want to forward some packets arriving at my ethernet port 1 and want to send it to ethernet port2 what should I do because the packets arriving on ethernet port 1 will have destination address of my machine so it will not forward to port 2 {correct me if I am wrong}.

sudo simple_switch -i 0@eth0 -i 1@eth1 basic.json --log-console

Does the tunneling or source routing program given in the tutorials help?

The packet that arrives at your ethernet port 1 should only be addressed to ethernet port 1 on layer-2.
If the IP dst address is the address of ethernet port 1, then there is no need to “route” the packet, as it has reached its final destination.

If i understand you correctly, you want to implement IP routing (layer-3).
Therefore, you will forward the packet according to its IP dst address in your P4 program.
What your program does, depends on your program.

So you would need a MAT that matches on the IP dst address (if you want to do IP routing) and has an entry set that forwards the packet through ethernet port 2 (in your case, thats egress port 1).

Hey thanks for the answer