Questions about simple_switch

Hello,

I have started the simple_switch on an ubuntu server with the command (sudo simple_switch_grpc -i 0@enp0s25 app.json (where app.json is the json got from the compilation of p4 program from p4c)).

The interface that I am using is enp0s25 (which is physical ethernet on the server) I have loaded the ICMP program from p4pi on the switch (p4pi/arp_icmp.p4 at master · p4lang/p4pi · GitHub).

I am trying to have a physical wlan (AP) also attached to this switch at port 1 and connect my laptop to it and ping the enp0s25 from my laptop. Do you think such a setting would be possible? How do I assign IP addresses to enp0s25 from the switch? If I run DHCP from my server to assign an IP to my laptop - how to communicate this information to my switch and make it aware that such an address is reachable from WLAN?

If you add more options when you start siple_switch_grpc, e.g. simple_switch_grpc -i 0@enp0s25 -i 1@wlan app.json, then it should start with port 1 sending packets to and receiving packets from port wlan.

By default, any interface configuration done via Linux on interfaces has NO EFFECT on the behavior of your P4 program. You could configure your P4 program tables so that its view of IPv4, IPv6, and Ethernet address configuration has no resemblance to the configuration of the interfaces done by Linux. It is up to you and any control plane software you write for your P4 program to make its address configuration what you want.

@andyfingerhut thanks for your reply. Like you mentioned I was trying to use P4runtime shell to assign IP addresses to one of my interface bound to the switch. However I cannot seem to find any clear instructions on how to do so. If you could help me point to command that would enable me to do so/let me know if it possible to do it with p4rt shell or I should use something else please let me know. I am thankful for all the help

There are no P4 APIs that “assign an IPv4 address to an interface”, partly because it is possible to write P4 programs that do not use IPv4 addresses at all. It is intended to be a protocol-independent programming language, and while most useful P4 programs use IPv4 headers and addresses, they need not.

There are APIs for adding entries to tables that you define in your P4 program. If those have IPv4 addresses as keys or action parameters, then it is up to you and your control plane software to know whether those IPv4 addresses are “assigned to a local port”, or not. For example, some IPv4 addresses in a P4 program might be IPv4 addresses of other devices in the network, e.g. in a routing table.

Hello @kspimparkar

I am also currently experimenting with using an ubuntu physical machine as a p4 switch and connecting two windows ports via enp2s0 and enp4s0 physical network ports. But the strange thing is that the two hosts cannot communicate with each other. Do you guarantee that the two sides can communicate with each other?Actually, I’m asking for your advice, because I feel that you have achieved the function of implementing a software switch on a physical machine

The configuration commands are as follows:

sudo simple_switch --interface 0@enp2s0 --interface 1@enp4s0 test.bmv2/test.json &
table_add ipv4_match to_port_action 10.10.0.0/16 => 0
table_add ipv4_match to_port_action 11.11.0.0/16 => 1

Do you handle arp requests appropriate ? Are your packets actually received by the switch ? Do your tables match ? The bmv2 log (if enabled during compiliation) should give you information whether packets are received and wether they match on your tables

I also attached physical interfaces some time ago, so it definitely works when you handle all network related things correctly (arp, possible checksum updates etc)

1 Like

Thank you for your reply.
I was able to capture interest packets at the physical interface, but not at the veth on the bmv2 software switch.
I listed the configuration commands I used as follows:

sudo simple_switch --interface 0@enp2s0 --interface 1@enp4s0 test.bmv2/test.json &
table_add ipv4_match to_port_action 10.10.0.0/16 => 0
table_add ipv4_match to_port_action 11.11.0.0/16 => 1

I think these configurations are inadequate
Could you tell me how you configured it?Be very grateful

What should
table_add ipv4_match to_port_action 10.10.0.0/16 => 0
table_add ipv4_match to_port_action 11.11.0.0/16 => 1

do?

As far as I see, this table does not exist in your P4 program (you said you use p4pi/arp_icmp.p4 at master · p4lang/p4pi · GitHub)

Your P4 program only handles ARP and ICMP traffic. Is this the kind of traffic that you send?

What does your BMv2 log say?

I’m sorry I didn’t make that clear. I referred to this example https://opennetworking.org/news-and-events/blog/getting-started-with-p4/.

Here is to add the forwarding port corresponding to the forwarding IP address.
But when I bind physical port with bmv2 through
sudo simple_switch --interface 0@enp2s0 --interface 1@enp4s0 test.bmv2/test.json &
I want the host connected to enp2s working on network segment 11.11.0.0 to communicate with the host connected to enp4s working on network segment 10.10.0.0.
Currently being plagued by this problem, it seems that no packages are reaching the bmv2 software switch.
Similar questions were asked::https://forum.p4.org/t/how-to-implement-softwared-p4-switch-in-pc-or-general-server-to-achieve-better-performance/698/4?u=jyt