Date: Sun, 4 Apr 1999 11:00:41 +1000 (EST) From: Rowan Crowe <rowan@sensation.net.au> To: freebsd-isp@freebsd.org Subject: Re: pppd redial script Message-ID: <Pine.BSF.4.01.9904041045280.13153-100000@velvet.sensation.net.au> In-Reply-To: <19990404081048.A1776@caamora.com.au>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, 4 Apr 1999, jonathan michaels wrote:
> On Sat, Apr 03, 1999 at 08:45:49PM +1000, Rowan Crowe wrote:
> > Hi all,
> >
> > This is a redial script I wrote the other night, which redials after the
> > link drops out but backs off exponentially if redial attempts keep
> > failing. (In Australia, we pay 25c per call, so if the other end is
> > answering but there's some sort of PPP problem, constant redials could end
> > up costing $$$). Redial delay is capped at 300 seconds maximum.
> >
> > Basically the delays for repeated failed attempts will go something like:
> > 5, 15, 45, 135, 300, 300, 300...
> >
> > Once the link has been up more than 10 minutes, it is considered "stable"
> > and the redial delay is reset to 5 seconds when it next drops.
> >
> > I'd be interested in any comments. Feel free to use it yourselves. To run
> > it in the background use '&' on the commandline. (the info messages could
> > probably be >>'d to a log file).
>
> one thing that would make ths really usefull, more than an
> exponential backoff is a determinable cuttof point, that is a
> point at which teh script 'times out' so to speak and stops
> trying.
That would be easy to do, simply have a counter which is incremented each
drop, if it exceeds a preset value then break. The counter is reset to
zero or 1 at the same time the delay is reset to 5 seconds (when the link
has been up longer than 10 mins).
> just a thought, for us not free local call types outside of usa
> telephone thinking/billing areas.
Certainly, although in my situation (client's machines etc) an unattended
redial is almost essential. :)
Here are the additions, but they are NOT tested. I've also added in a
couple of speaker noises as an indication of the link going down, and also
each redial attempt.
#!/bin/sh
delay1=5
retry_count=0
while :
do
stime=`date "+%s"`
echo "l8acal1n0l8aca">/dev/speaker
/usr/sbin/pppd -detach connect '/usr/bin/chat -v -f /etc/ppp/ppp-sens.scr' /dev/cuaa0 115200 deflate 15 bsdcomp 15 203.20.114.194: lcp-echo-interval 30 lcp-echo-failure 2
etime=`date "+%s"`
retry_count=`expr ${retry_count} + 1`
connectedtime=`expr ${etime} - ${stime}`
echo "time connected=${connectedtime} seconds"
if [ "`expr ${connectedtime} \< 600`" = "1" ]; then
delay1=`expr ${delay1} \* 3`
echo "delay now ${delay1} seconds"
if [ "`expr ${delay1} \> 300`" = "1" ]; then
echo "capping delay at 300 seconds"
delay1=300
fi
fi
if [ "`expr ${connectedtime} \> 600`" = "1" ]; then
echo "resetting delay to 5 seconds"
delay1=5
echo "resetting retry count to 0"
retry_count=0
fi
if [ "`expr ${retry_count} \> 20`" = "1" ]; then
echo "WARNING! retry count exceeded! exiting..."
exit 1
fi
echo "o3l32an0an0an0l8an0an0an0l32an0an0a" > /dev/speaker
echo "l1n0o3l32an0an0an0l8an0an0an0l32an0an0a" > /dev/speaker
echo "sleeping ${delay1} seconds"
sleep ${delay1}
done
--
Rowan Crowe Sensation Internet Services, Melbourne Aust
fidonet: 3:635/728 +61-3-9388-9260
http://www.rowan.sensation.net.au/ http://www.sensation.net.au/
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-isp" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.01.9904041045280.13153-100000>
