p4lang / switch

Consolidated switch repo (API, SAI and Nettlink)
151 stars 72 forks source link

How to use this switch model #105

Open shaharhoch opened 5 years ago

shaharhoch commented 5 years ago

Hi, I want to use this switch model as an actual switch in a network.

I have a network set-up of 3 computers A,B and C where B and C are connected to A and I want to run the switch on A and allow communication between B and C. Computer A runs a Linux OS.

have compiled and ran the code as instructed in the Readme. The code seems to run just fine with no problems. The problem is I don't seem to be able to make it an actual switch that transfers packets between computer B and C.

I assumed that in order to do that, I need to edit /bmv2/run_bm.sh and change the interfaces there fro m veth0, veth1, etc... to my actual physical interfaces. The problem is that when I do that and don't run the script tools/veth_setup.sh to create the interfaces needed for the tests, the script /bmv2/run_drivers.sh fails to run.

Can anyone explain to me how to run this as a switch on actual physical interfaces on a computer and not just run the tests? Is there anywhere with a more comprehensive explanation than the readme?

Thanks in advance.

antoninbas commented 5 years ago

You don't say what is the error you are getting. It's possible that the code assumes the existence of veth pair veth250/veth251 for the CPU port. Maybe make sure that this veth pair has been created, even if you use physical interfaces for your "front-panel" ports. Note that this code is not actively maintained anymore. If you want to run switch.p4 with the switchapi/switchsai control-stack, you're kind of stuck. But if you want to run your own P4 program with your own control-plane, it's fairly easy to connect bmv2 to physical interfaces.

shaharhoch commented 5 years ago

Yes, the error I was getting did stem from the requirement of the existence of veth250 and veth251. Once I made sure they exist the code does run without errors.

But I do still have a problem. Data is not being transferred from one interface to the other. I mean, I ping computer C form computer B (as a reminder, they are both connected through A, with physical interfaces that are used as ports for the switch application) and I don't see anything when I use Wireshark on the interface from A to C. I do see ARP messages on the interface from A to B that B is sending and I do see a lot of information written on the console of the switch application (indicating it has received some data). The problem is that the data coming from one interface is not transferred to the other.

In general, all I want is to run an implementation of a switch that supports INT (In‐band Network Telemetry). It seems that this switch application supports it.

antoninbas commented 5 years ago

I don't think the INT version supported in this repo is very up-to-date. Are you configuring the L3 tables properly? What's the control-plane that you're running for this? The easiest way to debug this would be to first understand the switch.p4 pipeline, then inspect the bmv2 logs to figure out if the table lookup results are what you would expect.

shaharhoch commented 5 years ago

Hi antoninbas, I do think my problems are with configuring the tables properly. I'm kinda new to this and I'm not really sure how to configure the tables. Plus, I can't find any documentation or examples of how to do that. I just want this switch model to work as a normal switch between two of it's input ports and support INT packets. Is there any example of how to configure the tables that I can see for that? or maybe some documentation?

Thanks.

TrishaDatta commented 5 years ago

I was wondering if you had figured out how to configure the tables? I am also trying to configure the forwarding tables of a switch that runs switch.p4

jafingerhut commented 5 years ago

@TrishaDatta Is there some reason why you want to run this switch.p4 code, that is at least 2-3 years old, and has nothing but its source code for documentation? Getting such a complex beast to forward even a single packet requires adding table entries to at least 10 different tables, if I recall correctly, and maybe even more.

If your desires for packet processing features is significantly smaller than what switch.p4 implements, you will save yourself a lot of work by using a simpler P4 program.

If your desire is to create a commercial-quality switch forwarding packets with this kind of feature set, better to find a commercially-supported and documented version of switch.p4, but those are only available for significant $$$, that I know of.

TrishaDatta commented 5 years ago

I'm trying to simulate an environment where I don't "control" all of the routers, and I wanted to install a P4 program that I didn't write on the routers that I don't "control." But you're right, it seems like it will just be easier to write a separate program that does simple forwarding. Thanks for your help!