What's new

Dual WAN latency based Failover

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

Colanta

Occasional Visitor
Hello,

Currently i have a problem with my main isp (300/10), where its connection node on my town, while working (0.2/10), gives an insane high latency (300ms+) to Google DNS Server, pretty away from the normal (20ms).

I'm looking to add a parameter to the falldown configuration, to be ping not responding or higher than XXX, but i really do not know if it is possible to do this in an User Script/WatchDog (haven't found it on source yet?) mod.

Any Ideas? or something already posted and done elsewhere?

Thank You

PD. Sorry for my English
 
Last edited by a moderator:
Hello,

Currently i have a problem with my main isp (300/10), where its connection node on my town, while working (0.2/10), gives an insane high latency (300ms+) to Google DNS Server, pretty away from the normal (20ms).

I'm looking to add a parameter to the falldown configuration, to be ping not responding or higher than XXX, but i really do not know if it is possible to do this in an User Script/WatchDog (haven't found it on source yet?) mod.

Any Ideas? or something already posted and done elsewhere?

Thank You

PD. Sorry for my English

I've found what i guess is the code responsible for checking the dual wan connectivity by ping, i've done a small (dirty) patch just to try on the next node failure:

Code:
int do_ping_detect(int wan_unit, const char *target)
{
	FILE *fp;
	char cmd[512];
	int count, ret = -1, validLatency;
	float latency = -1;
	int debug = nvram_get_int("ping_debug");

	/* can be default target, if necesary *//*
	if (!target)
		target = nvram_safe_get("ping_target");
	*/

	/* Check for valid domain to avoid shell escaping */
	if (!is_valid_domainname(target))
		return -1;
	if (debug)
		_dprintf("%s: %s %s\n", __FUNCTION__, "check", target);

	snprintf(cmd, sizeof(cmd), "ping -c1 -w2 -s32 %s -Mdont '%s' 2>/dev/null",
		 nvram_get_int("ttl_spoof_enable") ? "" : "-t128", target);
	if ((fp = popen(cmd, "r")) != NULL) {
		while (fgets(cmd, sizeof(cmd), fp) != NULL) {
			if (sscanf(cmd, "%*s %*s transmitted, %d %*s received", &count) == 1) {
				ret = (count > 0);
				if (debug)
					_dprintf("%s: %s %s\n", __FUNCTION__, target, ret ? "ret: ok" : "ret: fail");
			} else if (sscanf(cmd, "rtt %*s = %f/%*s ms", &latency) == 1){
			    //TODO: Get '100' from an NVRAM Value
				validLatency = (latency < 100);
				if (debug)
				    _dprintf("%s: %s %s\n", __FUNCTION__, target, validLatency ? "latency: ok" : "latency: fail");
				break;
			}
		}
		pclose(fp);
	}

	return ret && validPing;
}
 

Similar threads

Latest threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!

Staff online

Top