Implementing a routing protocol with a customized data packet

I want to implement a routing protocol based on OSPF, with some modifications in the data packet (i.e, adding new fields for data and addresses) and perform some evaluations. Initially, this protocol is considered as a proof-of-concept for scientific research purpose.

My questions:
1- Is it feasible with p4lang ? since I am don’t have any prior knowledge.
1-1- Can p4lang be interfaced with Python (scapy lib can only manipulate packets).
2- Is it possible to evaluate the routing protocol written in p4lang in terms of: nbr of packets sent, congestion, transmission time, queuing buffer, etc.
3- I want also to verify the scalability of the routing protocol, how many nodes are possible in a network ?

Thank you

Welcome to the group!

Hi, this is should be feasible. If two routers encrypted the communication channel between them, then it would be impossible (I believe… that’s the purpose of encrypting the traffic, right?). But as long as the switch can parse the protocol, then you should not have problems. Consider that P4 is not focused on the application layer, specially if this is of variable size (for instance, HTTP). Also, some hardware targets might be limited on how many bytes can be parsed too (software targets like the bmv2 are much more flexible). So the fewer fields you parse from your custom OSPF protocol, the better. If you need additional fields with custom values, then try to insert them as close as your custom OSPF header (beginning) as possible. That would simplify the implementation.

Absolutely, check the P4 tutorial. You have plenty of examples of Python programs and the scapy library. I believe many developers have posted packet_in and packet_out examples using P4Runtime using Python (and possibly scapy) so be sure to check them. My first search showed some example like this or this one. The p4-guide is always a good reference for any example you might want to search. This one is pretty good that shows the packet_in and packet_out examples.

You would have to be a little more specific on what you mean by “evaluate”. You could, in principle, extract some information from the switch standard_metadata (I am referring to the Simple Switch target based on the bmv2). For instance, as you can observe here and also explained here, you have some interesting information like the timestamps (AFAIK this is not sync among switch, it is a rolling timestamp), queue time or the packets in the queue. Now, you can always extend the functionality of the switch framework and implement your own metadata. However, unless you are familiar with P4, bmv2 and C++, might not be a one-day task.

In terms of packets sent, I think you can use the counters, However, I believe counters cannot be read in the data plane but the control plane can query it (like the Simple switch CLI). See here for more info about counters or any other topic about P4 shown in other lectures.

I am not completely sure how to answer this question. I believe this depends on your server or laptop that uses Mininet (I believe you will use Mininet). Furthermore, I do not remember performance tests in terms of maximum nodes, but for sure there must be articles talking about it. My guess is that your computing and memory resources might be the limit, but I could be wrong, considering bmv2 was thought to be used for debugging and testing. I remember a colleague from a Spanish university complaining about using more than 16 switches following the examples of the NG-SDN tutorial (controller uses Java, so it might not be your option), since the controller could not detect some links. I think that you can test it yourself and let us know what you find. But other developers might know this, so I will see if they answer :slight_smile:

You have to know, though, that the bmv2 was never a production switch, so it will not run as such. However, you can try to use the commands shown in this website to try to improve the performance.

Good luck