p4lang / p4app

Apache License 2.0
112 stars 58 forks source link

p4app v2 #54

Closed theojepsen closed 6 years ago

theojepsen commented 6 years ago

We have received a lot of feedback about using p4app. The theme of most of the feedback is having more control over running a p4app. People are used to using Mininet, and expect the same flexibility from p4app. This was difficult with p4app's previous design, which only exposed a JSON configuration file to the user. If you wanted more functionality, you would have to hack the p4app scripts.

The new version of p4app gives you more control. Instead of writing a JSON manifest file, you write your p4app using a python script, just the way you would use mininet. p4app is now a python library that wraps-up mininet, providing helpers for compiling your P4 program and setting up the topology.

The simplest example is a switch that behaves like a wire: https://github.com/theojepsen/p4app/blob/tj/v2/examples/wire.p4app/main.py

p4app also uses P4Runtime for configuring the switch: https://github.com/theojepsen/p4app/blob/tj/v2/examples/ring.p4app/main.py#L32

Both P4-14 and P4-16 are supported: https://github.com/theojepsen/p4app/blob/tj/v2/examples/compile-only.p4app/main.py

You can run different P4 programs on different switches: https://github.com/theojepsen/p4app/blob/tj/v2/examples/two-programs.p4app/main.py#L24

You can also use P4Runtime to read counters and setup multicast groups: https://github.com/theojepsen/p4app/blob/tj/v2/examples/counter.p4app/main.py#L13 https://github.com/theojepsen/p4app/blob/tj/v2/examples/multicast.p4app/main.py#L44

theojepsen commented 6 years ago

@robertsoule-barefoot Please see the updated top-level README

antoninbas commented 6 years ago

I forgot to mention it my review, please make sure you squash your commits before merging.