Hi all, about the ARP flows, I am wondering how to define the header and parser part.
According to papers/parser.p4 at master · p4lang/papers · GitHub, maybe I can directly use header arp_rarp_t and parser_arp_rarp. However, when I define them in my p4 program, there is undefined error about arp_rarp_ipv4. Therefore, what should I define the parameters in the header field and parser field for the arp flow.
Thank you.
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
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
Hi @ederollora ,
thank you for sharing your code about ARP to me. It is really helpful for me.
I didn’t push my program to GitHub, so I didn’t share my program when I asked the question this time. I would synchronize program next time and share them at the Forum so that we can understand my questions better.
Thank you!
Louisa
Hi @DavideS ,
thank you for response. And I am sorry that I didn’t share you exact error and program to describe my question. I would synchronize the program and questions next time.
@ederollora inspires me with his solution. My question is solved now.
Thank you!
Louisa