Do you know about a p4lang _interpreter_ somewhere hanging around?

hihi,

so the question as in $subj$ do you know a very simple p4-16 interpreter in .c or in .java hanging around??

not a full one but a very simple like 1000-2000 loc max… the use case is to test/develop the rare/freertr

emulated (bmv2) target more easily/quicky??? if nothing exists, then whats your opinion, would it be hard

for me (i dont think sooo:) to write one aaand would it worth the effort??? :slight_smile:

even is this allowed to have one?

surely it’ll be a way too incomplete etc, just to run the

which uses just a very small subset of p4-16… i was thinking to write the emulator for the .json

files but mehhh, i find the .p4 files more fun tbh… :slight_smile:


vlad @ intel:

First of all, there can be no such thing as a “P4_16 interpreter” – at the very minimum you need to add the name of the architecture there. For example, BMv2 support P4_16/v1model and to a certain extent P4_16/PSA.

Secondarily, I do not quite understand what is that you are trying to achieve and what are you requirements. So, it is not clear to me what is that you do not like on BMv3, for example. Note also, that P4_DPDK can also be considered a P4_16/PSA(-subset) emulator, as are other targets, like P4_EBPF, etc.


me:

hmmmm so yesss P4_16/v1model for sure… not the tna* stuff, yet, nor the rest that bmv2 do, etc… :slight_smile:

ooo my idea is the following in a quick example:

 apply {
     if (ig_md.mpls0_valid == 1) {
         tbl_mpls_fib.apply();
         if ((ig_md.mpls_op_type == 1) && (ig_md.mpls1_valid == 1)) {
             tbl_mpls_fib_decap.apply();
         }
     }
 }

}

seems easily implemented in an interpreter (not a compiler like you do mostly)

then one can realtime experiment with p4lang… i’ve done this b4 for tcl(sh):

h**ps://github.com/rare-freertr/freeRtr/blob/master/src/net/freertr/user/userScript.java

this one is here to make rare/freertr a bit more cisco-alike:

h**ps://www.cisco.com/c/en/us/td/docs/ios-xml/ios/ios_tcl/command/ios-tcl-cr-book/ios-tcl-cr-c1.html

but i even written a virtual machine to be compatible with an other stuff:

h**ps://github.com/rare-freertr/freeRtr/blob/master/src/net/freertr/user/userVM.java

it’s only 1500 loc and imho turing-complete if you know that stuff… :slight_smile:

ps: i’ve just registered to the forum, but first i wanted to know if you’re

against a very incomplete p4 interpreter , not a compiler or anything…

vlad:

All the compilers for all SW targets are extremely fast. I am not quite sure what would you achieve by using an interpreter.


me:

so yesss they’re, i mean the bmv2 dataplane of ours compiles in less than a minute…

but not realtime, and one needs to boot up a full vm here to surround it with anything else…

so thats why im heavily thinking to having a p4lang interpreter, because that can save some

cpu cycles, speed up the development, etc… and it could be realtime, etc…

meee:

so the bmv2v1model dataplane of ours compiles in less than a minute,

and yet another minute to boot up the vm, aaaand some annoying copy-paste

to surround it with anything that can inject the packets, do the protocols, etc…

so yesss they’re, i mean the bmv2 target compiles in less than a minute…

meee:

hmmmm and the worst part of the story that when i do some chatty protocols

and turn on “debugging” on the bmv2 vm, then i see the bgp/ospf/etc

whereas im only interested in the mpls, mostly… so in the interpreter,

then i could have a per line hit counter, etc, and when i flood the packets,

then it’s way easier to spot where it stopped forwarding, etc…

On 6/5/23 11:47, mc36 wrote:

so the bmv2v1model dataplane of ours compiles in less than a minute,

and yet another minute to boot up the vm, aaaand some annoying copy-paste

to surround it with anything that can inject the packets, etc…

Hi @mc36mc

I am not completely sure about how to answer this but because it includes some specific information about Tofino, I would defintieyl try in their own forum.

This is a good link: Intel(r) Tofino(tm) Family, TNA, and P4Studio questions

Cheers,

hihi @ ederollora and thanks 4 your reply…

so intel forums (a contact of meee) basically redirected me here so pls pls focus on the $subj$ and pls-pls dont redirect me back to intel! (my current/ext 1/2 year of a contract at my nren is under the finalization process, sooo…:slight_smile: moreover i dont think if they wanna maintain their rights over the p4lang itself alone, anymore… :frowning: )

so clearly speaking, the question is as is, a way too incomplete p4lang interpreter (max a 1-2 thousand of a c or java code) whereeee, and if not, then does it hurts a copyleft/right rights/feelings of somebody somewhere???

ps: so we do grow a lot of dataplanes, intel/barefoot tofino1,2(3), bmv2v1model (almost copy-paste of the tofino) but dpdk.org (same api that programs these), libpcap and plain udp sockets (both use the same forwarder code&api as dpdk) and finally a fallback software router that closely follows ietf .org and rfc-editor .org not to mention the industry trends, etc…

so pls take a deep breath and try to answer me something pls… :slight_smile:

thx 4 your understandings & sorry 4 maybe being a ddos here, :wink:

pls pls just reply anything that is your first idea about the $subj$ or my 2nd paragraph in this reply… :slight_smile:

ps: yeahh i know the ****s://www.intel.com first then ***s://community.intel.com/ moreover i still can access their curriculum storage (not oauth yet…) and have a local copy most of the pdfs with and without the password/watermarks, and my kepassxc have a working entry for intel too, just that they migrated their oauth to azure a month (or two) ago so thats why im just writing emails right now… :slight_smile:

br,

cs

I have not heard of a P4 interpreter being published already, and a quick Google search did not turn up anything other than a research paper that mentioned the possibility.

There are many C interpreters available. I did not attempt to do a survey of whether any of them were implemented in 1000-2000 lines of code, but personally it would surprise me quite a bit if one could be written in that small amount of code, and similarly for P4.

hihi Profile - andyfingerhut - P4 Programming Language and thanks for picking this up! :slight_smile:

so my google is biased a way too much against the protocols we do implement and use to provide internet access here and there soo…

what keywords did you used to find the mentioned “lot of c interpreters” then i’ll download one or two and will come up with my own in java to better align the needs of our study/field of interest… :slight_smile:

ps: surely you all will find this new work in our repos as soon as we’re done with this “hack”…

thx,

cs

One of my early search results for a C interpreter found this discussion on reddit, where an early reply gives links to 14 different C interpreters: Reddit - Dive into anything

back 2 you againnnnn,

so the more im thinking about the more i like the idea…

so i mostly need to play with the very basics from start like the header definitions where we restrict ourselves to the very basics

then the tables that the api/user can fill in,

finally those tiny c/java-ish curvy-curve codes that apply themm…

should not be a big deal once u know what you neeed…

tess for the mentioned bmv2v1m code we’ll need extra features like multicasting but wont be a big deal to add this once a very basic bmv2 .p4 runs in interpreted (realtime) on the router without the need to recompile this once i change a < to >…

ps: i tried googling once again like

p4lang “interpreter” site:github/gitlab .com/.org

but only the official ebfp and realated stuff that come up 4 me, not a standalone work…

regarding the ebfp backend, we have our very own small c code doing fine on openwrts to provide mpls/vpls and do a county-wide layer2 with the help of the nearest dpdk then a tofino or two boxes…

if we replace the owrts with some custom asics like ettus rx/tx-capable ones then we do have an 3g/4g/5g already in the Browse RARE / RARE - GEANT Bitbucket repos for years now, not to mention the rest of the conditinal compilations, and the fun part is that our p4 devvie platform is the bmv2 soo the tofino stuff is only a copy-paste and some #ifdef #endif magic…

hmmm?

thx,

cs

thx sir, just started deep-checking that reddit threaddd…

nope…

“an interpreter 4 c” is not what im looking 4…

i clearly looking for a standalone p4 interpreter and not the official frontend-backend to whatever someone donates stuff for…

oooor a pretty good and simple explanation of the intermediate .json of the p4c-bmv2-ss and a strong swear-word that the format wont change in the this century or so…

so we do have a tclsh interpreter and an interpreted turing-complete vm with somewhat 40ish os calls already within the router and both seems reuseable 4 our goals but we still would stay with interpreted .p4 for the current next-goal…

tclsh-c: for {} {} → for () {} or something like this… <— yess yesss this is what not-exist yet in .p4 only if we consider multicasting this way…

and so on…

edit: and some of them are in my /nfs/linux/update.sh already as apt-get install stanza somewhereee… :slight_smile:

I don’t know if you consider this explanation of the BMv2 JSON format pretty good, or not, but it is the only one I know of: https://github.com/p4lang/behavioral-model/blob/main/docs/JSON_format.md

I don’t understand why you want a promise that someone else won’t change this format. I can say that the BMv2 JSON format has changed little or not at all in that last 2-3 years. I can promise you that if you pick a particular commit SHA of the open source p4c repo, the way it generates BMv2 JSON files will never change, not even in 10 centuries.

so if i write the interpreter 4 the json then i would not restart it randomly in every 5-10 years (and i clearly cannot tell the users that heyy go back 5-10 years to the past, to this and that commit/sha), then instead i go for the .p4 interpreter from the start or even better do the nplang.org (just take a look on their samples, a way more fun lang isn’t it? no fixed match/action stuff like in .p4 and already produce faster networking asics than intel do and a magnitude bigger the production volume of them imho…) or the already mentioned tclsh (a cisco ios compatible stuff with a lot of code hanging around, like a full tshark and so on…) or simply continue the with the .vm files (dl.nop.hu/vm.zip) instead, these already runs on the router targets (tofino included)…

once again, we see p4 a way better as any of the above so thats why i seek for a simple && standalone interpreter 4 it that surely i’ll need to heavily rework (imho i’ll only study this a little-bit) to be able to proceed with this goal of mee…

You can do a git commit log on that JSON_format.md file in that repo to judge for yourself how often it has changed, and the magnitude of the changes made at those times.

If someone comes in 6 months and adds a new feature to the BMv2 software switch that requires new data in the BMv2 JSON file to take advantage of it, very likely they would choose to add new keys to existing objects if that is possible, rather than reworking the data format from scratch. Reworking everything from scratch would cause lots of work and changes required in both the BMv2 software switch and the p4c BMv2 back end code, and it seems unlikely to me someone would want to do that for fun.

hihi &,

i dont think i would stick to a commit/hash/sha512 and it’s not the 1st time i expressed this… :frowning:

i would not living in the past nor restrict the free development of the p4lang at all nor restrict myself to it as nplang have brighter future in the real gear world imho… :frowning:

so after my quick dinner break (and some back and forth emails in between mee and mee :slight_smile: ) my tldr is the folllowing: “i’ll care about the bits and not the bits of the bits” here once again, that is;

i have to come up with 3 classes (the rest are pre-existent, lets expect this 4 now…:slight_smile: )

encHdr — an arbitrarily placeable header class above a packHolder…

tabMatchActionTable - tabMat 4 short like gnu (is) not unix…

tinyP4intPrt - that will interpret in realtime the apply{} parts and the action{}s and the standard externs right from the .p4 source…

i’ll skip the parser/deparser/etc as the tabHdr will realtime apply the modifications, header insertions/deletions to the packHolder… (sic)

and will be placed onto the packHolder when first used within a .p4 file of ours…

soo…

this way in the long run i’ll be able to interpret the bmv2v1model and the tofino123 code equally, moreover the mentioned nplang too (?)…

and afterall i dont think it’ll be that long such i planned originally, should be less than 1kloc per unit/class/.java-file if im doing this all cleverly…

and my final goal, that is if the tofino asic floods to a hairpin/recirc-port/10g-dac-copper/etc port then i’ll be able to catch these packets one by one by an emulated p4 code (on a real pizzabox :slight_smile: ) aaaaand i’ll have the per-line hit-counter, aaaaand the openjdk(clang if compiled with graalvm) will optimize this all to the hell, so even the 10g will be reachable, if not, 1g should be fine easily, and if not, the worst that will happen that a cpu core will max out to 100% and the hairpin/sdnXXX/whatever-we-name-this-port will have lost packets… :slight_smile: (khmm, the packet delivery (on the internet) is kina best effort, rfcXXX, ieee8021, a common proverb in the telco industry…:slight_smile: )

this all just to make a birthday cake to the p4 community as a whole, etc… just 4 fun & profit u know… :slight_smile:

i’ll keep you posted once the stuff is out on the wild_wild_net, but imho i should not tell u more about my plans otherwise it wont be a surprise 4 u all… :slight_smile:

thx,

cs

wut???

i hope i not typed a half a page for nothing in the past 10-15 minutesss?? :slight_smile:

"

-------- Forwarded Message --------
Subject: [P4 Programming Language] [PM] Akismet has temporarily hidden your post
Date: Thu, 08 Jun 2023 18:09:53 +0000
From: Discourse Admin P4 via P4 Programming Language notifications@p4.discoursemail.COM
Reply-To: Discourse Admin P4 via P4 Programming Language incoming+353accb9d2d1b743e6f1986183c25cac@p4.discoursemail.COM
To: ***************************

Hello,

Our automated spam filter, Akism3t, has temporarily hidden your post in Do you know about a p4lang interpreter somewhere hanging around? for review.

A staff member will review your post soon, and it should appear shortly.

We apologize for the inconvenience.

"

okkk just to quickly jump into your rabbit hole, a programmable crc8-16-32-64 generator whenn? about 2-3 years ago a team of brazilian researchers tried to commit that but Akism3t refused the try with a reason, later they gained google award of the year (PolKA is not a dance…)…
imho it’ll be a new addition to the json whereas in tofino it’s just an extern and preexists for decades as every ethernet have a crc32 when emitting the packet on line, not to mention the preabmle and the inter-frame-gap.
br,
cs

The p4lang projects are contributed to, and changes reviewed by, either (a) people volunteering their time to do so, which are very few in number, or (b) people paid as part of their job to do so. That set of people is also very few in number today, and most of them I know of are focused on projects other than p4lang/behavioral-model code, such as p4lang/p4c.

Can the size of these sets of people change? Of course. Will they? It depends on people’s choices what they do with their time and money.

same here, btw i just reverbed the quoted text to make it a bit less strange in the language… :slight_smile:

regarding the 2nd paragraph, well, im a way too old and im studying the packet forwarding stuff and the protocols to rule these a way too long to change my interest regardless if i get paid 4 to clean up the mess on the streets… :slight_smile:

tbh nowadays im the one who makes the that mess… :)))

peace,

cs

hmmmmm, here is a commit hash that u can track 4

–ofkoz it was not meeee

&&

thanks for the discussion, i just need to add another line to the vercore sh1tl0ad about the common proverbs on the wild-wild-netzzz :))

edit:

"

-------- Forwarded Message --------
Subject: [P4 Programming Language] [PM] Thanks for spending time with us
Date: Fri, 09 Jun 2023 10:07:36 +0000
From: Discourse Admin P4 via P4 Programming Language notifications@p4.discoursemail.COM
Reply-To: Discourse Admin P4 via P4 Programming Language incoming+900c052ad4f5f885cb31b57275b65bc3@p4.discoursemail.COM
To: ******************************

Hey there. We see you’ve been busy reading, which is fantastic, so we’ve promoted you up a trust level!

We’re really glad you’re spending time with us and we’d love to know more about you. Take a moment to fill out your profile, or feel free to .


"

hmmmmm i c your bots went crazy about meee like i went crazy about p4 years agoooo… should i follow it’s/her/his instructions orrrr 4 the common world peace etc i should just shift+del thissss? :)))))))))))))))))))))))

ps: i dont think i have time to actively participate here except if you specifically bounce a topic to my inbox (mentining me here imhoooo)

thx,

cs