How define the arp header in the P4 program

Hi @Lululouisa ,

I also believe you should add the exact output of your program and hopefully the content of your project in Github (or something like similar) so we can assess how to find the issue :slight_smile:

I had some code around using ARP and I copy-pastedm some parts from my program so it might be useful to you:

header arp_t {
    bit<16> hrd; // Hardware Type
    bit<16> pro; // Protocol Type
    bit<8> hln; // Hardware Address Length
    bit<8> pln; // Protocol Address Length
    bit<16> op;  // Opcode
    macAddr_t sha; // Sender Hardware Address
    ip4Addr_t spa; // Sender Protocol Address
    macAddr_t tha; // Target Hardware Address
    ip4Addr_t tpa; // Target Protocol Address
}

parser MyParser(packet_in packet,
                out headers hdr,
                inout metadata meta,
                inout standard_metadata_t standard_metadata) {

    state start {
        packet.extract(hdr.ethernet);
        transition select(hdr.ethernet.etherType) {
            TYPE_ARP:  parse_arp;
            TYPE_IPV4: parse_ipv4;
            default: accept;
        }
    }

    state parse_arp {
        packet.extract(hdr.arp);
        transition accept;
    }

    ( . . . )
}

struct headers {
    ethernet_t    ethernet;
    arp_t         arp;
    ( . . . )
}

# Other parts of the P4 program are omitted

Cheers

1 Like