Skip to content

ChecksumType is missing two CRC-32 configurations that Checksum.h can already compute #1177

Description

@torokati44

Type: enhancement
Component: src/inet/common/checksum, src/inet/protocolelement/checksum
Version: INET 4.7.0 (dfe270b21f, 2026-07-07)

Summary

ChecksumType exposes an arbitrary subset of the CRC-32 configurations Checksum.h supports. Two are missing:

  • CRC-32/ISO-HDLC - has a named function, crc32_iso_hdlc(), but no enum entry; only its byte-swapped sibling CHECKSUM_ETHERNET_FCS has one.
  • CRC-32/MPEG-2 (poly=0x04c11db7 init=0xffffffff refin=false refout=false xorout=0x00000000 check=0x0376e6e7) - no named function and no enum entry, although generic_crc32() computes it correctly today.

Since the enum is the only way into the checksum module machinery, a protocol using either one cannot use that machinery at all.

Current state

enum ChecksumType
{
    CHECKSUM_TYPE_UNDEFINED = -1;
    CHECKSUM_INTERNET = 1;
    CHECKSUM_CRC16_IBM = 3;
    CHECKSUM_CRC16_CCITT = 4;
    CHECKSUM_ETHERNET_FCS = 5;
    CHECKSUM_CRC32C = 6;
}

computeChecksum() and getChecksumSizeInBytes() throw "Unknown checksum type" outside that set, and parseChecksumType() accepts only internet, ethernet-fcs, crc32c, crc16-ibm, crc16-ccitt.

(Aside: value 2 is unused - was an entry removed? Reusing it would break result comparability against older .sca/.vec files, so new values look safer either way.)

Consequence

ChecksumInserterBase.ned:25 and ChecksumCheckerBase.ned:25 hardcode the list:

string checksumType @enum("internet","ethernet-fcs","crc32c","crc16-ibm","crc16-ccitt") = default("ethernet-fcs");

so ChecksumInserter / ChecksumChecker and everything built on them are unavailable to such a protocol, which then has to hand-roll its trailer chunk, serializer and checker, and ends up handling checksumMode differently from every other INET protocol.

Substituting the nearest available value is not a way out: crc32_iso_hdlc is reflected with xorout=0xffffffff and ethernetFcs is that byte-swapped, so either puts wrong bytes on the wire - silently, since the same wrong function on both ends still validates.

Suggested fix

Only the surface is missing; the arithmetic exists.

  1. Named wrappers in Checksum.h following the existing crc32c / crc32_iso_hdlc pattern - crc32_mpeg2(), the std::vector<uint8_t> overload, and a crc32_mpeg2_bitwise() delegating to generic_crc32(buf, bufsize, 0x04c11db7, 0xffffffff, false, false, 0x00000000).
  2. CHECKSUM_CRC32_MPEG2 and CHECKSUM_CRC32_ISO_HDLC in ChecksumType, with new values rather than reusing 2.
  3. Extend parseChecksumType() ("crc32-mpeg2", "crc32-iso-hdlc"), getChecksumSizeInBytes() (4 bytes each) and computeChecksum().
  4. Extend the @enum(...) lists in ChecksumInserterBase.ned and ChecksumCheckerBase.ned.

Check values for the test alongside Checksum_1.test, with crc32_iso_hdlc shown for contrast:

Message CRC-32/MPEG-2 CRC-32/ISO-HDLC
"123456789" 0x0376E6E7 0xCBF43926
"Lorem ipsum dolor sit amet" 0x1C2A1845 0x5F29D461

Both first-row values are the published CRC RevEng check values, so the configurations are identifiable independently of any implementation. The second row reuses the string already in Checksum_1.test.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions