Is there some error in my json file?

One of the simplest route forwarding:
h1 <-> s1 <-> h2
My json file is as follows:

{
    "hosts": {
        "h1": {"ip": "10.0.1.1/24", "mac": "08:00:00:00:01:11",
               "commands":["route add default gw 10.0.1.10 dev eth0",
                           "arp -i eth0 -s 10.0.1.10 08:00:00:00:01:00"]},
        "h2": {"ip": "10.0.1.2/24", "mac": "08:00:00:00:01:22",
               "commands":["route add default gw 10.0.1.10 dev eth0",
                           "arp -i eth0 -s 10.0.1.10 08:00:00:00:01:00"]}
   
    },
    "switches": {
        "s1": { "cli_input" : "s1-commands.txt" }
    },
    "links": [
        ["h1", "s1-p1"], ["h2", "s1-p2"]
    ]
}

My txt file is as follows:

table_add ipv4_lpm ipv4_forward 10.0.1.1/32 => 08:00:00:00:01:11 1
table_add ipv4_lpm ipv4_forward 10.0.1.2/32 => 08:00:00:00:01:22 2

My code is copied from tutorials/basic/solution.

And now h1 and h2 cannot establish a connection

I went to do a packet capture analysis on h1’s network port and found that it was the arp protocol that was not responding. But the default route is configured in h1, why is it not taking effect? Do I need to do any setting?

I do not know the root cause of the issue, but if you have determined that ARP packets are not getting through to the host, note that ARP packets are NOT IPv4 packets, i.e. IPv4 packets have Ethertype 0x0800, and ARP packets have a different Ethertype, and do not have IPv4 headers. So perhaps there are some table entries and/or P4 forwarding code that is handling ARP packets that you have disrupted somehow?

In general, if the basic exercise, unmodified, is working for you, analyze the first packet for which it behaves differently than your modified exercise, and try to figure out why that first differently-processed packet is processed differently. Yes, this can be a time-consuming process, but can also be a very enlightening one once you track down the root cause of the different behavior.

I read the switch log file s1.log and did find that the switch received the arp packet but dropped it based on the default action. I looked through the code in the tutorial tutotials/ecn and found that a situation similar to my network topology exists.

{
    "hosts": {
        "h1": {"ip": "10.0.1.1/31", "mac": "08:00:00:00:01:01",
               "commands":["route add default gw 10.0.1.0 dev eth0",
                           "arp -i eth0 -s 10.0.1.0 08:00:00:00:01:00"]},
        "h11": {"ip": "10.0.1.11/31", "mac": "08:00:00:00:01:11",
                "commands":["route add default gw 10.0.1.10 dev eth0",
                            "arp -i eth0 -s 10.0.1.10 08:00:00:00:01:00"]},
        "h2": {"ip": "10.0.2.2/31", "mac": "08:00:00:00:02:02",
               "commands":["route add default gw 10.0.2.3 dev eth0",
                           "arp -i eth0 -s 10.0.2.3 08:00:00:00:02:00"]},
        "h22": {"ip": "10.0.2.22/31", "mac": "08:00:00:00:02:22",
                "commands":["route add default gw 10.0.2.23 dev eth0",
                            "arp -i eth0 -s 10.0.2.23 08:00:00:00:02:00"]},
        "h3": {"ip": "10.0.3.3/31", "mac": "08:00:00:00:03:03",
               "commands":["route add default gw 10.0.3.2 dev eth0",
                           "arp -i eth0 -s 10.0.3.2 08:00:00:00:03:00"]}
    },
    "switches": {
        "s1": { "runtime_json" : "s1-runtime.json" },
        "s2": { "runtime_json" : "s2-runtime.json" },
        "s3": { "runtime_json" : "s3-runtime.json" }
    },
    "links": [
        ["h1", "s1-p2"], ["h11", "s1-p1"], ["s1-p3", "s2-p3", "0", 0.5], ["s1-p4", "s3-p2"],
        ["s3-p3", "s2-p4"], ["h2", "s2-p2"], ["h22", "s2-p1"], ["h3", "s3-p1"]
    ]
}

Note the h1 and h11 hosts here, they are both connected to switch s1, unlike my network topology they are divided in different subnets so that to can be forwarded directly based on the host’s default route without going through the arp protocol.
But when I use the virtual machine given in this link p4-learning, I can achieve my situation and I can’t figure out where is the problem?