Question about extra commands in topology.json in the tutorials

I noticed that in most topology.json files, commands about gw and arp have been added, such as:

    "hosts": {
        "h1": {"ip": "", "mac": "08:00:00:00:01:01",
               "commands":["route add default gw dev eth0",
                           "arp -i eth0 -s 08:00:00:00:01:00"]},
        "h2": {"ip": "", "mac": "08:00:00:00:02:02",
               "commands":["route add default gw dev eth0",
                           "arp -i eth0 -s 08:00:00:00:02:00"]}

Are they necessary? When I try to customize the topology, do I have to define them at the same time?

Thanks. Cheers!

I do not know the answer already, but wanted to make a suggestion, since there is at least one person now working to actively improve the tutorials documentation and code (Github user id Abhinavcode13 (Abhinav kumar) · GitHub ). I will let them know about this question to see if they know the answer, or can find out.

If you are willing to try experimenting a bit, I’d recommend trying to take a working exercise that has commands like this, ensure that it works as described in the current README directions for that exercise, then remove those commands and try to run the exercise again, and see if anything behaves differently. If things break when you remove them, you have some pretty strong evidence that they are doing something that enables the exercise to work. Determining exactly what they are doing that is helpful might require more thinking, reading of documentation, experiments, etc.

If you or someone else comes to any good conclusions about (a) whether they are needed, and if yes, (b) why they are needed, please consider adding some notes to the README for the exercise that explains what you have learned.

I made a brief test in basic topology.json. When I removed the extra commands containing gw and arp, the pingall command showed 100% packet loss.


I got the correct feedback when I tried to use scapy for contracting and receiving packages. However, the sender of scapy displays a warning:

WARNING: more No route found (no default route?)

Judging from the results, I think these extra commands are needed.

Of course, it may be possible to integrate them into python for automation.

Thanks. Cheers!

I thank you testing this out, @Nagisa.

Thank you, Abhinav! He added this new section to the README docs for the first exercise. Hopefully it will help answer your questions, and those of anyone else trying out the exercises in the future: tutorials/exercises/basic/ at master · p4lang/tutorials · GitHub

Thank you for your continuous attention to this issue. :grinning:

1 Like