How to calculate the CRC32 for BF2 RDMA?

I got a pcap file as bellow:


I want to know how to get the same CRC value like BF2. I change ipv4 DSCP/ECN, TTL , cksm, UDP cksm, BTH Rev to all ‘1’ and cut the mac header. then I put the 44Byte data into verilog generated by OutputLogic.com » CRC Generator but I didn’t get the same result as pcap. Should I change the bit order? now I do it like [44*7-1:0]. Should I change each byte from [7:0] to [0:7] and then calculate the crc?

And should I do a XOR after the CRC cal ? The pcap can be downloaded in this link https://ihepbox.ihep.ac.cn/ihepbox/index.php/s/aLe4FT7sGnhcLdJ

Hi There ,

No need to change Ethernet headers fields. If you want to understand the function calculating Invariant CRC, I suggest to go to IB spec

The Invariant CRC calculation depends on the presence of the Global Routing Header.

5.2.14 INVARIANT CRC
Invariant CRC (ICRC) covers the fields that do not change in packet from
source to destination. ICRC is only in IBA packets, and is not present in
Raw Packets. Which fields are covered in the ICRC is dependent on the
presence of the GRH.
The detailed definition of the Invariant CRC is in Section 7.8.1 on page
219.

7.8.1 INVARIANT CRC (ICRC) - 4 BYTES
Specifies a Cyclic Redundancy Code covering all the fields of the Packet
which are invariant from end to end through all switches and routers on
the network. This field is present in all IBA packets but is NOT present in
Raw Packets because for raw packets it is not known which fields will be
invariant. The CRC calculation is re-started with each packet in the message.
Which header fields that are included depends on whether the
Global Routing Header is present because the router may modify additional
header fields.
C7-47: The ICRC field shall be present in all IBA transport packets.
C7-48: The ICRC field shall be calculated as specified in Section 7.8.1,
“Invariant CRC (ICRC) - 4 Bytes,” on page 219.
If the packet is local to the subnet (the Global Routing Header is not
present), then the ICRC calculation is as follows:
• With no GRH, the ICRC includes:
• Local Routing Header: except for the VL.
• Base Transport Header: except for the Resv8a field
• Extension Transport Headers (if present),
• Packet Payload (if present),
• With no GRH, the ICRC excludes: (these fields are replaced with 1s
for the ICRC calculation)

Local Routing Header: VL,
• Base Transport Header: Resv8a.
If the packet is routed between subnets, so the Global route header is
present, the ICRC calculation is as follows:
• With a GRH, the ICRC includes:
• Global Routing Header: Version, Payload length, Next Header,
Source IPV6 address, and Destination IPV6 address
• Base Transport Header, except for the Resv8a field,
• Extension Transport Headers (if present),
• Packet Payload (if present).
• With a GRH, the ICRC excludes: (these fields are replaced with 1’s
for the CRC calculation)
• Local Routing Header, all fields,
• Global Routing Header: Flow label, Traffic Class, and Hop Limit
fields.
• Base Transport Header: Resv8a.
All fields in the packet. including those excluded from the Invariant CRC,
are protected by the Variant CRC described in the next section.
The polynomial used is the same CRC-32 used by Ethernet -
0x04C11DB7. The procedure for the calculation is:

  1. The initial value of the CRC-32 calculation is 0xFFFFFFFF.
  2. The CRC calculation is done in big endian byte order with the least
    significant bit of the most significant byte being the first bits in the
    CRC calculation.
  3. The bit sequence from the calculation is complemented and the
    result is the ICRC.
  4. The resulting bits are sent in order from the bit representing the coefficient
    of the highest term of the remainder polynomial. The least significant
    bit, most significant byte first ordering of the packet does not
    apply to the ICRC field.
    The CRC always starts with LRH:LVer bit 0, whether GRH is present or
    not.

Thanks
Samer