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)
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)