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.
- 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).
CHECKSUM_CRC32_MPEG2 and CHECKSUM_CRC32_ISO_HDLC in ChecksumType, with new values rather than reusing 2.
- Extend
parseChecksumType() ("crc32-mpeg2", "crc32-iso-hdlc"), getChecksumSizeInBytes() (4 bytes each) and computeChecksum().
- 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.
Type: enhancement
Component:
src/inet/common/checksum,src/inet/protocolelement/checksumVersion: INET 4.7.0 (
dfe270b21f, 2026-07-07)Summary
ChecksumTypeexposes an arbitrary subset of the CRC-32 configurationsChecksum.hsupports. Two are missing:crc32_iso_hdlc(), but no enum entry; only its byte-swapped siblingCHECKSUM_ETHERNET_FCShas one.poly=0x04c11db7 init=0xffffffff refin=false refout=false xorout=0x00000000 check=0x0376e6e7) - no named function and no enum entry, althoughgeneric_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
computeChecksum()andgetChecksumSizeInBytes()throw"Unknown checksum type"outside that set, andparseChecksumType()accepts onlyinternet,ethernet-fcs,crc32c,crc16-ibm,crc16-ccitt.(Aside: value
2is unused - was an entry removed? Reusing it would break result comparability against older.sca/.vecfiles, so new values look safer either way.)Consequence
ChecksumInserterBase.ned:25andChecksumCheckerBase.ned:25hardcode the list:so
ChecksumInserter/ChecksumCheckerand 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 handlingchecksumModedifferently from every other INET protocol.Substituting the nearest available value is not a way out:
crc32_iso_hdlcis reflected withxorout=0xffffffffandethernetFcsis 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.
Checksum.hfollowing the existingcrc32c/crc32_iso_hdlcpattern -crc32_mpeg2(), thestd::vector<uint8_t>overload, and acrc32_mpeg2_bitwise()delegating togeneric_crc32(buf, bufsize, 0x04c11db7, 0xffffffff, false, false, 0x00000000).CHECKSUM_CRC32_MPEG2andCHECKSUM_CRC32_ISO_HDLCinChecksumType, with new values rather than reusing2.parseChecksumType()("crc32-mpeg2","crc32-iso-hdlc"),getChecksumSizeInBytes()(4 bytes each) andcomputeChecksum().@enum(...)lists inChecksumInserterBase.nedandChecksumCheckerBase.ned.Check values for the test alongside
Checksum_1.test, withcrc32_iso_hdlcshown for contrast:"123456789"0x0376E6E70xCBF43926"Lorem ipsum dolor sit amet"0x1C2A18450x5F29D461Both 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.