Skip to content

Automatic Checksum Re-Calcs #36

Closed

Description

@ImVexed

Hello,

I'm facing an issue with determining whether a packet's checksums need recalculation after modifications. Currently, the only options are:

  • Manually triggering recalculation in every code path where the packet changes, which becomes repetitive and error-prone with complex logic.
  • Always recalculating all checksums before serialization, which incurs unnecessary performance overhead.

Is there a way to implement automatic checksum recalculation, similar to libraries like PyPacker? For example, by tracking field modifications and recalculating only the affected layer's checksum when changes occur?

Activity

  1. shellrow commented on Aug 2, 2025

    @shellrow
    Owner

    Thanks for opening this issue — it’s a valid concern and something I’ve been thinking about as well.

    As a first step, I’ve implemented automatic checksum calculation for packet builders. That means when you call .build(), the checksum is computed automatically, ensuring correctness without requiring manual intervention.

    ed2bc2c

    As for tracking field changes and triggering automatic recalculation directly within the packet structs — that would require some internal mutation tracking. I’m still evaluating whether that’s a direction I want to pursue, or if we’ll continue recommending the use of builders for safe and reliable packet construction.

  2. shellrow commented on Nov 9, 2025

    @shellrow
    Owner

    Implemented in v0.24.0
    All mutable packet types now support optional automatic checksum recomputation.

    You can enable it per packet using:

    packet.enable_auto_checksum();

    or leave it in manual mode (default).
    The library tracks dirty state internally and recomputes only when necessary.

    https://github.com/shellrow/nex/releases/tag/v0.24.0

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions