Hello everyone,
I was wondering if it is possible to add a custom header for INT in between a UDP header and the payload after that and then parse that header in some subsequent destination. If yes, how would you do it? Cause, to parse it later, wouldn’t it be required to store some upcoming protocol identifier in the UDP header? But as far as I know, there are only four fields in the UDP header: source port, destination port, UDP length, and the UDP checksum. There are no protocol identifiers in UDP. So, how can one pull this off, if it’s even possible? How would you go about writing the code?
What I was thinking is that there is an ID field (Identification) in the IPv4 header preceding the UDP header, which I haven’t found to be very useful yet for most day-to-day purposes. I was thinking I could store a custom value in that ID field of IPv4 to parse the custom header after the UDP header. What do you think about it? I am open to any other suggestions as well.
header ipv4_t {
bit<4> version; // Version (4 for IPv4)
bit<4> hdr_len; // Header length in 32b words
bit<8> tos; // Type of Service
bit<16> length; // Packet length in 32b words
bit<16> id; // Identification
bit<3> flags; // Flags
bit<13> offset; // Fragment offset
bit<8> ttl; // Time to live
bit<8> protocol; // Next protocol
bit<16> hdr_chk; // Header checksum
IPv4Addr src; // Source address
IPv4Addr dst; // Destination address
}
Hoping to hear from you soon. Thanks in advance.
Regards,