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

feat(icmp) support DoNotFragment + Size #633

Open
wants to merge 17 commits into
base: master
Choose a base branch
from

Conversation

antoinekh
Copy link

Summary

It's really a network-related need.
We use Gatus for temporary tests and we need to do MTU validation.

This pull request adds 2 capabilities to ICMP:

  • Ability to set the DoNotFragement bit
  • Ability to configure the size

This will my issue #506

Example of configuration with these options:

  - name: 10.35.206.132_df
    group: static
    url: "icmp://10.35.206.132"
    interval: 3s
    conditions:
      - "[CONNECTED] == true"
    client:
      timeout: 1s
      df: true
      size: 3500

Checklist

  • [X ] Tested and/or added tests to validate that the changes work as intended, if applicable.
  • [X ] Updated documentation in README.md, if applicable.

@antoinekh antoinekh changed the title feat(size) support DoNotFragment + Size feat(icmp) support DoNotFragment + Size Dec 4, 2023
README.md Outdated
@@ -38,6 +38,7 @@ Have any feedback or questions? [Create a discussion](https://github.com/TwiN/ga


## Table of Contents
- [Table of Contents](#table-of-contents)
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
- [Table of Contents](#table-of-contents)

README.md Outdated


### Conditions
Here are some examples of conditions you can use:

| Condition | Description | Passing values | Failing values |
|:---------------------------------|:----------------------------------------------------|:---------------------------|------------------|
| :------------------------------- | :-------------------------------------------------- | :------------------------- | ---------------- |
Copy link
Owner

Choose a reason for hiding this comment

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

Could you revert this & other similar changes?

client/config.go Outdated
Comment on lines 57 to 58
// Df set for the client
Df bool `yaml:"df"`
Copy link
Owner

Choose a reason for hiding this comment

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

What does Df mean? DoFragment?
Could you clarify that in the comment?

@antoinekh
Copy link
Author

Ah that's my markdown auto format in my vscode, I'll revert.
And add info on the Df bit
I’ll take explanation for this good https://stackoverflow.com/questions/45953716/when-to-set-dont-fragment-flag-in-ip-header

@antoinekh
Copy link
Author

Should be better now.
Let me know if you need more informations.

I'm not sure if this is really a feature that should be added to Gatus, but it doesn't cost much to add it.

q:q! Outdated
Copy link
Owner

Choose a reason for hiding this comment

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

looks like this file has been added by accident?

Copy link
Author

Choose a reason for hiding this comment

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

My bad, fixed !

README.md Outdated
Comment on lines 353 to 354
| `client.df` | Option to set the DoNotFragement bit for ICMP packet | `false` |
| `client.size` | Size of the ICMP packet | `25` |
Copy link
Owner

Choose a reason for hiding this comment

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

I'In hindsight, maybe this should be under icmp, i.e.

client:
  icmp:
    df: true
    size: 25

What do you think?

Copy link
Author

Choose a reason for hiding this comment

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

It's done, as you said, it makes more sense that way

client/config.go Outdated Show resolved Hide resolved
client/config.go Outdated
// Size of the packet
Size int `yaml:"size"`
type ICMPConfig struct {
DF bool `yaml:"df"` // Don't Fragment flag used for the ICMP client
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
DF bool `yaml:"df"` // Don't Fragment flag used for the ICMP client
DF bool `yaml:"df"` // Don't Fragment flag used for the ICMP client

client/config.go Outdated
c.Icmp = &Icmp{
Df: false,
c.ICMPConfig = &ICMPConfig{
DF: false,
Size: 25,
Copy link
Owner

Choose a reason for hiding this comment

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

Based on what I just looked at, the current default value is 25 (on my machine, at least 🤣)

image

Side note, I also see that there's a comment on L112 that may no longer be valid - it says // limit for pro-ping, below 25 it's not working.

Copy link
Author

Choose a reason for hiding this comment

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

I've set this configuration because it's the only way I've found to make it work.
But maybe I'm missing something in Go.

I did the tests by validating with network captures:

  • A classic linux ping can have a data of 0.
  • If I don't specify a Size or defaultSize by default the Size is 24.
    So you are right I can remove defaultSize = 24

But then, If I don't specifiy anything in icmp in my yaml file, the ping is not working.

That's why I put this code with the Size in it.

        // If Icmp is nil, let's initialize it with default values
        c.ICMPConfig = &ICMPConfig{
            DF:   false,
            Size: 24,
        }

But maybe this is not the good way to initialise it.

If I test with a Size <24 it doesn't work either.
I notice that this limitation exists in other tools that use pro-bing
For example
https://github.com/SuperQ/smokeping_prober
Packetdata size in bytes. Default 56 (Range: 24 - 65535)

That's why I put

    if c.ICMPConfig != nil {
        // limit for pro-ping, below 24 it's not working
        if c.ICMPConfig.Size < 24 {
            c.ICMPConfig.Size = 24
        }

And my mistake: the limit is 24, not 25.

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.

None yet

2 participants