Auto-reconnect PPP interface

Hi:

I’m a RouterOS home user. Because I had some WRAP boards (EOL now) hanging around, I decided to use one of them to distribute internet access (and LAN) to some PCs at home instead of use a standard motherboard with lots of processing power, cooling fans here and there, no-breaks and etc. I don’t need much processing power at home and those boards can be feeded by a 12V gelcell bat durying power outages.

My connection to ISP is via 3G mobile phone network, actually using an Huawei E156 modem (similar to E220). The WRAP was modified accordingly in order to make USB avialable (on WRAPs USB is there but un-conectorized nor bios enabled by default). Untill RB have more boards (besides RB230) with USB ports on it I’ll keep WRAPs up. Seems that there will be more RB options in 2009. :smiley:

ROS is 3.17, with WEB Cache enabled and a 3G modem is the ppp interface. Sill some small problems with PPP so from time to time I need to hang-up and reconnect PPP. Until I figure what’s really going on, I’m looking for alternatives to make it automatically. And dial-on-demand is not the way to go. PPP must be 24X7X365 up.

I’m using netwatch but since its an ICMP dependent tool, sometimes ping times out due to other applications running on AP-Bridge or LAN clients (downloads, video or voice, etc). I set time out to 10000 ms but still switching the status=down sometimes and the connection still up but only busy. Then PPP disconnects and reconects and hung-up was not really necessary this time.

Then I saw around on the forum, wiki or manual an script that swicthes two LAN ports when the traffic falls below certain value (trigger) in one of them. But I’m not a software guy, I’m “analog” (e.g. RF, antennas, microwave, etc). :confused:

Can anybody help me with this? I want to base this script on the “received traffic” on PPP (speed, not volume). If “received traffic” is zero (or below some vy low value) for certain amount of time (lets say 60 seconds), then PPP must be disabled, 5 seconds pause, PPP enabled back again. If anything is received from PPP within this 60 seconds, this counter must be zeroed.

One other feature that’s desireable is: some specific modem commands must be reloaded just after re-connect and they don’t fit on PPP interface tab, not because the size but the format. I guess this (and may be others) modem after connected waits for extra commands on a virtual serial interface (USB2 in my case). Windows modem GUI probably do that (I compared the AT&V results from ROS and WIN, they’re different). They’re AT commands, like AT+CSSN, AT+CREG, AT+CNMI, etc, each one followed by a . Is there a way to send this commands direct to USB2 (I use serial-terminal USB2 on Winbox to do that manually)?

I’ll keep netwatch as my “watchdog”, firing against 2 or 3 public addresses each 10 seconds or so. Other routines will require answers from internet anyway, even when nobody’s surfing (NTP clients, etc).

Any help is apreciated.

Regards

Marcus Ramos

P.S.

  1. For those that uses 3G modems and have some strange behaviour, those modems are vy current consuming (5V @ 0.5A) and USBs sometimes have not power enough to supply them accordingly. Modem manufacturers suppose this sticks will be most of the time vy close to PCs, where power filtering or regulation are not a problem. But USB connectors fails: dirt, oxidation, fadigue etc. I had some problems with and things only became really stable when I converted my USBs in a “proprietary” solution (DB15 conn), where I send 12V trhu the USB cable and use a dedicated voltage regulator on a small PCB with a standard female USB connector to the modem on it.

  2. May be this topic subject mix scripting + RouterOS on RBs + HW info. I was in doubt where create it so … my apologies. :blush:

Can anybody help me with this? I want to base this script on the “received traffic” on PPP (speed, not volume). If “received traffic” is zero (or below some vy low value) for certain amount of time (lets say 60 seconds), then PPP must be disabled, 5 seconds pause, PPP enabled back again. If anything is received from PPP within this 60 seconds, this counter must be zeroed.

It’s easy.

/interface pppoe-client monitor pppoe-test once do={
       :if ($"idle-time" >= 60s) do={ 
                      /interface pppoe-client disable ....;
                      :delay 3s;
                      /interface pppoe-client enable ....;
       }
}

Hi mrz et al …

It’s easy.

/interface pppoe-client monitor pppoe-test once do={
:if ($“idle-time” >= 60s) do={
/interface pppoe-client disable …;
:delay 3s;
/interface pppoe-client enable …;
}
}

>

Well, this should be ok because monitor routines already have "idle-time" built in.  But "idle-time" does not means "idle-RX-time". Its not zero if any packet is sent from ROS to PPPOE/PPP interface, even if public gateway does not answer. And when interface is disabled, the "monitor" close.

My problem is: I need to start this "recconect" routine if RX traffic is zero for a 1 minute time slot.

The routines that give me separated RX and TX data are:

- \interface monitor-traffic (which delivers several separated info for TX and RX)
- \tool\traffic-monitor (which consider traffic sense and have a trigger that starts some script)

I've been trying to write a script but I still facing problems with "whiles", "elses", "timing", etc.

I came up to this point (my PPP interface is VIVO):

I'm using \tools\traffic monitor. I selected VIVO as interface, received traffic, trigger=below and trigger=64 bytes.

As soon as RX traffic is below 64 bytes, traffic monitor calls the "ppp_down" script:

```text
:local i 0
{
:set i ($i + 1)
:delay 1s;
:if (i = 60) do={
/interface disable ETH1;
:delay 3s;
/interface enable ETH1;}
}

But it’s not working.

I used ETH1 only for debug purposes.

Question about traffic monitor trigger X script = as soon as the trigger is reached, script is called and run. Script needs only disable interface IF there is no-RX-traffic FOR 60 seconds of such condition (e.g no RX traffic FOR 60 seconds … WHILE there’s no RX-traffic, DO).

Meantime, if trigger is reset (RX traffic restored within 60 seconds time slot) will the script stop? Or should I create another script to be started on “trigger above 64 bytes”, to halt the first one?

Thanks.

Marcus

The solution (for now):

{:local i 0;
{
:do {

#Define system scheduler interval = 2 seconds (ping GW each 2 seconds)

:if (once [/interface ppp-client get [find name="ppp-client1"] running] = yes) do={
/system scheduler set 0 interval=2s;
}

#Routine below was stolen from enhanced mrz netwatch-II. 15 pings not answered = ppp RX path down.

:set i ($i+1);
} while=(($i<15) && ([ping 200.xxx.yyy.zzz size=128 interval=1 count=1]=0))
:if ($i=15) do={
:log info "ppp-client1 reset";
/interface disable ppp-client1;

#Change system scheduler interval to 45 seconds, to wait for ppp dialing time + authentication + DHCP + default GW changes. System scheduler interval will be 2 seconds again on next scheduler run, if ppp-client is already up.

:if (once [/interface ppp-client get [find name="ppp-client1"] disabled] = yes) do={
/system scheduler set 0 interval=45s;
}
:delay 2s;
/interface enable ppp-client1}
}
}

Notes:

  1. 128 bytes ping because this Huawei E156 3G modem seems not like 32 bit packets very much.

  2. Still missing a script part where some modem AT commands must be re-loaded once to the modem, as soon as ppp-client is up again. I’m doing this manually, using the serial-terminal usb2. But I guess there must be a way to send this commands direct to serial usb2 port.

The commands are:

AT+CSSN=1
AT+CREG=1
AT+CGREG=1
AT+CMEE=1
AT+CNMI=2,1,2,2,0
AT+CCWA=1
AT+CLIP=1

That’s it.

Regards;

Marcus