an early look at p4 for software networking

26 June 2017 2:00 PM (igalia | networking | p4 | compilers | snabb | vpp)

Happy midsummer, hackfriends!

As you know at work we have been trying to find ways to apply compilers technology to the networking space. We will compile high-level configurations into low-level network processing graphs, search algorithms into lookup routines optimized for the target data structures, packet filters into code ready to be further trace-compiled, or hash functions into parallel AVX2 code.

On one side, we try to provide fast implementations of existing "languages"; on the other side we can't help but try out new co-designed domain-specific languages that can be expressive and run fast. As an example, with pfmatch we extended pflang, the tcpdump language, with a more match-action kind of semantics. It worked fine but the embedding between pfmatch and the host language could have been more smooth; in the end the abstractions it offers don't really apply to what we have needed to build. For a long time we have been wondering if indeed there is a better domain-specific programming language to apply to the networking domain.

P4 claims to be this language, and I think it's worth a look. P4's goal is be able to define switches and other networking equipment in software, with the specific goal that they would like to be able for P4 programs to be synthesized to ASICs, or installed in the FPGA of a "Smart NIC", or compiled to CPUs. It's a wide target domain and the silicon-bakery side of things definitely constrains what is possible. Indeed P4 explicitly disclaims any ambition to be a general-purpose programming language. Still, I think they manage to achieve an admirable balance between declarative programming and transparent low-level compilability.

The best, most current intro to P4 out there is probably Vladimir Gurevich's slides from last month's P4 "developer day" in California. I think it does a good job linking the language's syntax and semantics with how they are intended to be applied to the target domain. For a more PL-friendly and abstract introduction, the P416 specification is a true delight.

Like I said, at work we build software switches and other network functions, and our target is commodity hardware. We write most of our work in Snabb, a powerful network toolkit built on LuaJIT, though we are branching out now to VPP/ as well, just to broaden the offering a bit. Generally we try to build solutions that don't have any dependencies other than a commodity Xeon server and a commodity NIC like Intel's 82599. So how could P4 help us in what we're doing?

My first thought in this regard was that if there is a library of P4 building blocks out there, that it would be really convenient to be able to incorporate a functional block written in P4 within the graph of a Snabb program. For example, if we have an IPFIX collector written in Snabb (and we do!), it would be cool to stick that in the middle of a P4 traffic conditioner.

(Immediately I run into the problem that I am straining my mind to think of a network function that we wouldn't rather just write in Snabb -- something valuable enough that we wouldn't want to "own" it and instead we would import someone else's black box into our data-plane. Maybe this interesting in-network key-value cache counts? But I digress, let's assume that something exists here.)

One question is, why bother doing P4 in software? I can understand that if you have 1Tbps ports that you definitely need custom silicon pushing your packets around. You would like to be able to program that silicon, so P4 looks to be a compelling step forward. But if your needs are satisfied with 40Gbps ports and you have chosen a software networking solution for its low cost, low lock-in, high flexibility, and sufficient performance -- well does P4 buy you something?

Right now it would seem that the answer is "no". A Cisco group wrote a custom P4 compiler to VPP, which is architecturally pretty much the same as Snabb, and they had to do some work to get the performance within a couple percent of the hand-coded application. The only win I can see is if people start building up libraries of reusable P4 components that can be linked together -- but the language itself currently doesn't support any more global composition primitive than #include (yes, it uses CPP :).

Additionally, at least as things are now, it doesn't seem that there's a library of reusable, open source P4 components out there to take advantage of. If this changes, I'll have to have another look. And of course it's worth keeping an eye on what kinds of cool things people are building :)

Thanks to Luke Gorrie for conversations leading to this blog post. All opinions and errors mine, of course!

11 responses

  1. Paul Johnson says:

    Thanks for sharing this nice resource. It's really interesting. Keep up the good work and keep updating the same.

  2. hack facebook account says:

    In touch with their friends while some have had the luck use Facebook as a way for them to reach their the facebook site.

  3. read more here says:

    That's great news for developers, P4 looks very interesting. I will try to take a look at some tutorials whenever I have the time. Programming is a great way to improve your memory, I recommended it to many people.

  4. xbox live membership says:

    Thank you

  5. run 3 says:

    Thank you for sharing this nice resource. It's really interesting. Keep up the good work and keep updating the same.

  6. best law essay writer says:

    Your ability to write is amazing. an awesome article ought to include all relevant statistics for the subject in a gentle way in order that readers can get your thought off without problems. In this text, you arranged all your thoughts in a nice way. I'm really inspired with this. I like to ship your website to get top subjects to examine. nearly have all your posts, and this one is satisfactory. this newsletter defined the thoughts in a thrilling way. keep the same first-rate in the rest of the posts, that's the nice issue I've from your articles.

  7. assignment experts says:

    This flexibility conceivably brings about cost-effectiveness, enabling systems administration organizations to purchase equipment segments specifically from unique makes, without depending on an outsider. Chip providers in their turn would prefer not to miss the prepare and put into help of P4 to remain in the game.

  8. Full Essay Help UK says:

    Software-defined networking is an engineering implying to be dynamic, reasonable, manageable, cost-effective, and adaptable, trying to be appropriate for the high-transmission capacity, dynamic nature of the present applications. SDN structures decouple organize control and sending capacities

  9. Pay Someone To Write My Essay says:

    This is a nice book to celebrate learning to read. It has a positive attitude. However, it failed to hold the interest of my 5-year-old and it's moved to the bottom of our book pile

  10. amazon gift card codes for shopping says:

    Free amazon gift cards.

  11. windows 10 updates says:

    P4 is a great software. You won't be disappointed when using it.

Leave a Reply