IndySockets / Indy

Indy - Internet Direct
https://www.indyproject.org
434 stars 147 forks source link

icmp echo request and response automatically adds 8 bytes to the payload with a tick count #498

Open SeanSolberg opened 10 months ago

SeanSolberg commented 10 months ago

We are unable to use the ICMP client component for our task because we need to be able to do a ping (ICMP Request and Response) with a data payload of 1 bytes However, internal to the the IdICMPClient class within the PrepareEchoRequestIPv4(const ABuffer: String); method, it will include an 8 byte value that comes from the tick counter. This means if we pass in a buffer of 1 character, then the data payload that is actually sent is 9 bytes.

This internal mechanism should allow us to build the actual payload instead of forcing 8 bytes plus the bytes from the string characters. Further, because nothing internal to this class is virtual, we cannot override this behavior easily with a descendant class. Also, there should be a method to do a ping with a binary array of data payload and not a string that then internally must be converted to the array of bytes payload.

rlebeau commented 10 months ago

The tick counter is put in the payload to help calculate a value for the ReplyStatus.MsRoundTripTime property when the echo response comes back. I suppose the internal FStartTime member could be used for that purpose instead.

Allowing users to send a binary payload instead of a string payload is a good idea, especially since it doesn't appear the client returns that response data back to the caller anyway.

SeanSolberg commented 10 months ago

rlebeau, thanks for your comments. We just re-wrote it internally to do what we needed to do.

rlebeau commented 10 months ago

I updated TIdIcmpClient to support TIdBytes for user-defined data. I have not removed the tick counter from the ICMP payload yet, though.