Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in calc icmp crc code #20

Open
DenZavg opened this issue Jun 26, 2021 · 0 comments
Open

Error in calc icmp crc code #20

DenZavg opened this issue Jun 26, 2021 · 0 comments

Comments

@DenZavg
Copy link

DenZavg commented Jun 26, 2021

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant