Skip to content

Error in calc icmp crc code #20

Description

@DenZavg

Hi.
If this library is executed on arduino, then an error often occurs in the checksum calculation function( _checksum ).
In this place:
...
sum += *time + *(time + 1);
...
If the sum of two 16-bit numbers is more than the 16-bit number can hold, then the most significant bits of the sum are lost.
This line should be replaced with:

sum += *time;
sum += *(time + 1);

Then the sum of the 32 bit and 16 bit number is stored in a 32 bit number.
Or not use time in the icmp packet constructor:

ICMPEcho :: ICMPEcho (uint8_t type, uint16_t _id, uint16_t _seq, uint8_t * _payload): seq (_seq), id (_id), time (0)

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions