point-source / dart_ping

Multi-platform network ping utility for Dart
30 stars 13 forks source link

TTL and time are inverted #35

Closed giulitu95 closed 1 year ago

giulitu95 commented 1 year ago

On Windows platforms, whenever I ping a certain address, in the corresponding PingResponse Object the values inside the ttl and time properties are inverted. I think the problem is in the following lines of code:

https://github.com/point-source/dart_ping/blob/734a9d4655ab8bd16a37e3fc8417b07b907c612f/dart_ping/lib/src/models/ping_parser.dart#L70-L76

Note that while in Unix systems the information order in the standard output is respectively: seq, ttl and time. I.e.:

64 bytes from 192.168.1.1: icmp_seq_1 ttl=64 time=5.3 ms

in windows systems the output is printed differently. I.e.:

Reply from 192.168.1.1: bytes=32 time=9ms TTL=64

Note that:

  1. The sequence number is not present. As a consequence, in property seq, I cannot find the right value.
  2. The time is printed before the TTL value. Since in line 74 and 75, the TTL and time properties are assigned respectively with the third and fourth matching values, it happens that I will find the ttl value inside the time property and the time value inside the ttl property.