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

Add feature: support ICMP type 13/14 timestamps #353

Merged
merged 7 commits into from
Nov 11, 2024

Conversation

gsnw-sebast
Copy link
Collaborator

This is an extension to send ICMP type 13 and receive ICMP type 14 with fping (Issue: #265).
To use it, root rights are required on the system and it can be used as follows.

  1. ./fping --icmp-timestamp 127.0.0.1
127.0.0.1 is alive (Timestamp Originate=67895434 Receive=67895434 Transmit=67895434)
  1. ./fping --icmp-timestamp -c 2 127.0.0.1 (For the output, I first partly oriented myself on hping3)
27.0.0.1 : [0], 20 bytes, 0.072 ms (0.072 avg, 0% loss)
ICMP timestamp: Originate=67951889 Receive=67951889 Transmit=67951889
ICMP timestamp RTT tsrtt=71991
127.0.0.1 : [1], 20 bytes, 0.057 ms (0.064 avg, 0% loss)
ICMP timestamp: Originate=67952890 Receive=67952890 Transmit=67952890
ICMP timestamp RTT tsrtt=56783

127.0.0.1 : xmt/rcv/%loss = 2/2/0%, min/avg/max = 0.057/0.064/0.072

Unfortunately I could not test the function under macOS and the Github Action Test under macOS is not possible.

@coveralls
Copy link

coveralls commented Oct 8, 2024

Coverage Status

coverage: 87.714% (-0.05%) from 87.762%
when pulling 3aa5894 on gsnw:icmp-13_and_14
into 6a7e7ad on schweikert:develop.

@auerswal
Copy link
Collaborator

@gsnw-sebast: Thanks for your work on this!

I have not yet found the time to do a thorough review, but the approach looks sensible. I'll try to review this pull request in a couple of weeks.

In your example output for --count=2, you compute a ICMP timestamp RTT with a higher resolution than that if the ICMP timestamps. This is based on existing fping RTT measurements, I think. IMHO this is a bit misleading, since it does not use only the ICMP timestamp data (which has a millisecond resolution). What do you think?

Then I have two high-level suggestions for consideration:

  1. Should --icmp-timestamp automatically set --ipv4 since the ICMP timestamp and timestamp reply messages are only defined for IPv4?
  2. Should the option combination --icmp-timestamp --size=N be rejected since the ICMP timestamp message has a fixed size?

@gsnw-sebast
Copy link
Collaborator Author

gsnw-sebast commented Oct 13, 2024

I'm not sure about the RTT issue myself.
I have also tried to orientate myself on hping3 here.

The formula should be TSRTT = (Transmittime - Originatetime) + (ICMP RTT - (Transmittime - Originatetime)
Here it could be that the ICMP RTT is not in this_reply line 2618

if (icmp_request_typ == 13) {
            if(ip_header_otime_ms != -1 && ip_header_rtime_ms != -1 && ip_header_ttime_ms != -1) {
                printf("ICMP timestamp: Originate=%lu Receive=%lu Transmit=%lu\n", ip_header_otime_ms, ip_header_rtime_ms, ip_header_ttime_ms);
                tsrtt = (ip_header_ttime_ms - ip_header_otime_ms) + (this_reply - (ip_header_rtime_ms - ip_header_otime_ms));
                printf("ICMP timestamp RTT tsrtt=%d\n", tsrtt);
            }
            else {
                printf("ICMP timestamp: unknown\n");
            }
        }
  1. According to my IPv6 book and the IANA page [1], ICMP Timestamp does not exist under IPv6
  2. I would have to check that, thanks for the feedback (Answer: With ICMP Timestamp there is no data area in the header. It therefore has a fixed size and format)

[1] https://www.iana.org/assignments/icmpv6-parameters/icmpv6-parameters.xhtml

@auerswal
Copy link
Collaborator

I would prefer fping not to compute an ICMP timestamp RTT. I would also prefer the ICMP timestamp values to always be in the same line as the other output for a received reply message. This could look as follows:

$ fping --icmp-timestamp -c 2 127.0.0.1
127.0.0.1 : [0], 20 bytes, 0.072 ms (0.072 avg, 0% loss), ICMP timestamp: Originate=67951889 Receive=67951889 Transmit=67951889
127.0.0.1 : [1], 20 bytes, 0.057 ms (0.064 avg, 0% loss), ICMP timestamp: Originate=67952890 Receive=67952890 Transmit=67952890

127.0.0.1 : xmt/rcv/%loss = 2/2/0%, min/avg/max = 0.057/0.064/0.072

@gsnw-sebast
Copy link
Collaborator Author

The format you suggested was also my first idea. I have therefore adapted it. Thanks for the feedback.

@gsnw-sebast
Copy link
Collaborator Author

gsnw-sebast commented Oct 13, 2024

I have changed the parameters so that --icmp-timestamp and --size may not be used at the same time.
Even if e.g. --icmp-timestamp works with e.g. --size in the appropriate size

I know the documentation is still missing

Copy link
Collaborator

@auerswal auerswal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All in all this looks promising, I think we just need to look at some of the details before merging. Thanks!

doc/fping.pod Outdated Show resolved Hide resolved
src/fping.c Show resolved Hide resolved
src/fping.c Outdated Show resolved Hide resolved
src/fping.c Outdated Show resolved Hide resolved
src/fping.c Outdated Show resolved Hide resolved
src/fping.c Outdated Show resolved Hide resolved
doc/fping.pod Outdated Show resolved Hide resolved
doc/fping.pod Show resolved Hide resolved
Copy link
Owner

@schweikert schweikert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good, thank you!

Suggestion: could you also update CHANGELOG.md?

Copy link
Collaborator

@auerswal auerswal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

@gsnw-sebast
Copy link
Collaborator Author

Suggestion: could you also update CHANGELOG.md?

Shouldn't the CHANGELOG.md be created again with release 5.3 and then the rule defined that every pull request must also contain the extension of the CHANGELOG.md?

@schweikert
Copy link
Owner

Suggestion: could you also update CHANGELOG.md?

Shouldn't the CHANGELOG.md be created again with release 5.3 and then the rule defined that every pull request must also contain the extension of the CHANGELOG.md?

Ideally yes, but you could already start with adding a line to a "Next" section maybe? We definitely need to get the habit of always also changing CHANGELOG.md instead of me guessing a good name for the change summary based on the commits.

@gsnw-sebast gsnw-sebast merged commit 0a589a7 into schweikert:develop Nov 11, 2024
7 of 9 checks passed
@gsnw-sebast gsnw-sebast deleted the icmp-13_and_14 branch November 11, 2024 11:02
@moeller0
Copy link

This is excellent! However one request, would it be possible to also add the missing 4th number, the time the type 14 packet was received in the same time format as Originate? The goal is to calculate the two OWDs:
Forward OWD: Receive - Originate
Return OWD: MISSINGLOCALRECEIVE - Transmit

and to do this MISSINGLOCALRECEIVE would be helpful, or in the hping case that can be constructed as:
Originate + tsrtt

I guess the same is possible for fping:

user@macbook src % sudo ./fping -c 1 --icmp-timestamp 9.9.9.9
Password:
9.9.9.9 : [0], 20 bytes, 40.9 ms (40.9 avg, 0% loss), ICMP timestamp: Originate=55736120 Receive=55736157 Transmit=55736157

MISSINGLOCALRECEIVE = Originate + 40.9

it is just parsing this would be easier if there was something like:
Originate=55736120 Receive=55736157 Transmit=55736157 Localreceive=55736160

@lynxthecat
Copy link

Sweet, so fping is about to support ICMP type 13/14?

@moeller0
Copy link

It does, at least the development version!

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

Successfully merging this pull request may close these issues.

6 participants