Netwatch ICMP settings

Some time ago we had a thread where the various possible settings for the Netwatch ICMP probe (which are largely un- and mis- documented on Mikrotik help documentation) were discussed and partially tested, here:

I tried to put together all the info found by the forum members on that thread in a single spreadsheet, adding a couple of (needed) formulas to provide a tool to better find suitable values for the settings.

Attached:
Netwatch_ICMP.zip (17.6 KB)

As always comments, suggestions, corrections, etc. are welcome.

Have fun.

EDIT:
uploaded corrected version with lines 10 and 11 of notes corrected
uploaded another version, this time actually corrected

You’re work on this and other Mikrotik topics is very helpful – thank you.

Please check the descriptions on lines 10 and 11.

For my purpose of minimizing positive results (i.e., minimizing a “down” determination to those times when the problem is more than a moment’s loss or flap or “hiccup”), I use:

Interval: 5 minutes
Packet interval: 40ms
Packet count: 600
THR-avg: 400
THS-loss-percentage: 95

This results in a G/H ratio of 4.49%

But, I think (and I certainly could be wrong) that what it does is creates a netwatch that will only have a positive (down) condition when a link is what I would call “truly” down – i.e., something I might want to consider possibly doing something about.

There is certainly no deep analysis that went into choosing these specific numbers.

And @Josephny provides the example of why @jaclaz created a spreadsheet. @Josephny’s settings are not doing what he thinks they are. This was all discussed in the thread that @jaclaz links and his spreadsheet would allow @Josephny to set this better.

What @Josephny doing above is running an intensive ping for ~24 seconds, then waiting 4min36sec, then running again for 24 sec. Sending 2400 pings in each those 24 seconds. And assuming average latency is 400ms is pretty high. So, yes, you may not get a false positives… but what your monitoring is does a ping flood only create extremely high latency.

Since TZSP makes this easy, here is a Wireshark of @Josephny netwatch configuration, adjusted to use 1.0.0.1 (so I didn’t have to filter 8.8.8.8):

Notice the Time column above goes from 24 to 300 with the No. column changing time at 4800 (since capture only shows 1.1 traffic, 2400 pings + return is 4800 – apparently didn’t lose any, also matching WinBox that showed no loss)

Basically @Josephny is a counter-counter example of what goes wrong with guessing with ICMP netwatch values.

@Jaclaz, netwatch simple ping often easier if one does not want to understand how to tweak these setting. That’s worth mention. Also default ICMP netwatch settings kinda assume you have a pretty decent wired connection. But in most wireless cases or with janky ISPs, the threshold value almost certainly need to be adjusted.

@Amm0
Yep, sometimes you need to invoke Dukhat:
http://jdebp.info/FGA/dukhat-on-foolishness.html

The two main points I tried to make with the spreadsheet are:

  1. it makes little sense to ping at very short intervals, a tiny fraction of the minimum the two main Operating Systems in the world allow, as I see it may actually create false positives due to flooding
  2. it is pointless to have a very large script interval when all the action is concentrated into an initial burst and then nothing happens for minutes, the spreadsheet suggests 85% to 95% “occupation”

In other words, when monitoring something, “slow, steady, continuous” is better than “fast, wobbly, intermittent”.

@Josephny’s settings are almost exactly the opposite of what they should be according to the previous discussion, but if he is happy with them, it is just fine :slightly_smiling_face:.

The “simple” netwatch could be considered as !ICMP, and as such does not belong to this topic (which is about ICMP probe and not anything else), but sure, nomen est omen, “simple” is (much) simpler.

Thanks, guys.

What would be your recommended settings for an ICMP Netwatch that would:

  1. Result in a DOWN status only after 4 or 5 minutes of lack of connectivity;
  2. Not be sensitive to momentary drops/flaps;
  3. Not be sensitive to high response times;
  4. Not create a burden on the device or the connection (resulting in increased latency).

First thing you forgot requirement #5:

:wink:

Seriously now, maybe a “plain” (ICMP) netwatch is not suitable for your requirements.

Let’s put aside, for the moment, #3 (that could be obtained by fine tuning other settings), and let’s see how #1, #2 and #4 can be reached with the “main” settings.

You can have settings like:
S=300
T=4
pc=270
pi=1000
that give a ratio of 91%.

The settings will ping, one per second, for the first (roughly) 4.5 minutes, and then have some 30 seconds for timeout and threshold comparison.

Now, which loss- percent threshold are you going to set?

If you use the default 85%, it should mean that out of the total 270 packets you send at each run, 0.85*270=229 lost packets won’t trigger the down status, 230 will.

BUT the 270-230=40 packets that can go through will take 40 seconds.

These can be either “sparsely distributed” or concentrated at the beginning or end of the run, let’s see what could happen in these two extreme cases.

If we use | for a successful ping and . for a failed one, you can have:
-|-|-|-.-.-.-.-.-.-
or
-.-.-.-.-.-.–|-|-|-
in BOTH cases the netwatch will go down if the total of | is less than 40 or so.

BUT in the first case the down will be “true”, as the down is triggered after some 4 minutes with no replies to ping and currently there is no connection, in the second it will be “false”, the connection is good when the netwatch takes its decision which is reflecting the state of the connection of the 4 minutes preceding the last minute.

And since the next run will take 5 minutes, this “false” down won’t be corrected for five (long) minutes.

What you probably need - instead - is a sort of netwatch that runs every (say) 1 minute for 30-45 seconds or so and has a mechanism (needs to be scripted) to create a counter with these characteristics:

  1. each fail increases the counter by one
  2. each success resets the counter to 0
  3. when (if) the counter reaches 5, then (and only then) it is a “true” down

That is a great explanation. I’m starting to get it (:wink: – I think.

If we raise the loss-percent to 98, then 264 packets (which would take a minimum of 264 seconds) would need to fail in order for netwatch to determine a DOWN condition.

Or, extending the logic:

S=600
T=4
pc=570
pi=1000
THR-loss-percentage=98

I think that would be that a packet would be transmitted every second for 570 seconds and 559 of them would have to fail for netwatch to declare a DOWN connection.

Or, why not use a thr-loss-percentage of 100 across an S of 300 or 600 to determine what I’m calling a true-non-momentary down connection?

What am I missing here (I know it’s something)?

I don’t think 100% can be a valid threshold value, as to exceed it you would need to have 101% fails, i.e. have more fails than the packets you send.

98% (considering also the possible rounding issues with integer math) or maybe 99% sounds to me like the real maximum you can set.

I would try with:
S=300
T=4
pc=270
pi=1000
threshold loss-percent=95

And see what happens, you can always increase it by one at the time later.

The 5% of 270 is 13 or 14 so, the false trigger would happen - I believe - only rarely.

The “main” issue that I see in these settings is the very long “recovery time” needed in those (hopefully rare) cases of false positives.

Is this correct:

/tool netwatch
add comment=Netwatch-192.168.20.1 disabled=no down-script=netwatch-5-2025 host=192.168.20.1 http-codes="" interval=5m name=Netwatch-192.168.20.1 packet-count=270 \
    packet-interval=1s test-script="" thr-loss-percent=95% timeout=4s type=icmp up-script=netwatch-5-2025

Yes and no.
It looks correct but it only takes into account a few settings, remember that all the other ones will be in effect with default values.

Are they other settings that would be better off set at non-default values?

Let’s see:

1	thr-max 	fail threshold for round trip time-max (a value above thr-max is a probe fail)	1 s	
2	thr-avg 	fail threshold for round trip time-avg	100 ms	
3	thr-stdev 	fail threshold for round trip time-stdev	250 ms	
4	thr-jitter	fail threshold for round trip time-jitter	1 s	
5	thr-loss-percent	fail threshold for loss-percent	85,0%	
6	thr-loss-count	fail threshold for loss-count	4294967295	(max)

#5 you set to 95%, #6 won’t be triggered ever.
#1 to #4 may well be too low for your connection, but you need to try and see.
I have no idea how the round trip time (common to all 4) is calculated when the ping fails (and - additionally - how it may affect thr-avg and thr-stdev).

FWIW, on this one from spreadsheet:

There are 9 properties (or results) of the ICMP probe (that in the help doc are incorrectly called with prefix thr- instead of rtt- or none prefix and given in a jumbled up order), here (hopefully) corrected and re-ordered:

I did open a doc bug on it, SUP-187116. MikroTik somehow thinks they’re right in docs, or they don’t understand I’m referring the 2nd section perhaps… IDK, but been open 2 months and tried to clarify several times when they closed it (and I reopened by commenting)

Would sending them the attached image (Sherwood.jpg) help?
(or would it be counter-productive?) :thinking:

Easy to cut-and-paste. Normally MT does just fix the doc when you file an issue about it… IDK what’s going on with this one, so they did get a snarky “perhaps visual aid would help”.

Adding here also a reference to two new settings since 7.20:

Hi everyone!

I understand that it has been a year since the last message, but better late than never.

Is the current Netwatch documentation acceptable in your opinion, or are further adjustments still needed?

The ICMP variables to use in a on-up=/on-down=/on-test= are still wrong under Netwatch | RouterOS Manual.

See SUP-187116, last update was:

As the documentation is written about probe options NOT script-specific names, I have added script names in description for options - if they are different.

But there are two parts, one with “Type-specific options”, and another with the “Probe statistics/variables”. The first one is correct. But the ICMP probe variables are still not the variable names you need in a on-up=/on-down=/on-test=.

It still needs work. Specifically thr-* -> rtt-* under https://manual.mikrotik.com/docs/diagnostics-monitoring-and-troubleshooting/netwatch#icmp need renaming since the section talks about the variables.

More broadly some example on-up/on-down script likely help more. The "Quick Example" shows the easy case of simple ping, not the more rich ICMP. Similar with DNS and HTTP since there are subtleties that be helpful to see.

No, it is not understandable.

This (first result searching for Netwatch):

is seemingly correct but largely incomplete.

Read-only Argument Type Description
... ... Description
sent-count num
response-count num
loss-count num
loss-percent num
rtt-avg time
rtt-min time
rtt-max time
rtt-jitter time
rtt-stdev time
... ...

This:

has still the mess with thr- vs. rtt- prefix (or no prefix)

Property Description Notes Column 4
sent-count ICMP packets sent out OK
response-count Matching/valid ICMP packet responses received OK
thr-loss-count number of lost packets NO, this is loss-count
thr-loss-percent number of lost packets in percent NO, this is loss-percent
thr-avg mean value of round trip time (rtt-avg) NO, this is rtt-avg
thr-max max round trip time (rtt-max) NO, this is rtt-max
thr-jitter jitter ( = max - min) of round trip time (rtt-jitter) NO, this is rtt-jitter
thr-stdev standard deviation of round trip time (rtt-stdev) NO, this is rtt-stdev
<-MISSING-> min round trip time this is rtt-min
AND the ORDER of the properties is mixed up

Please refer to this:

for the order they are listed that should be kept the same for both the thr- and the rtt- ones (and IMHO since ALL thresholds have the thr- prefix, ALL the corresponding "response" items should have the rtt- one, excluding sent-count and response-count, but this is marginal)
i.e.
loss-percent -> rtt-loss-percent (because it corresponds to thr-loss-percent)
loss-count -> rtt-loss-count (because it corresponds to thr-loss-count)
sent-count -> OK as is (because there is no corresponding thr- item)
response-count ->OK as is (because there is no corresponding thr- item)