X10 DSL2002/07/27 |
Welcome to my X10 DSL page
I have a DSL modem -- nothing surprising, who doesn't? ;-)
But mine tends to go out of sync on heavy loads, which is annoying.
The symptom is pretty simple: the modem seems to be up, all three LEDs in steady
green state, but nothing goes thru in either direction, i.e. from my point of
view there's no network connection, nothing can be ping, etc.
The solution I found is to power cycle the modem, then it syncs up again and
everything works fine for some time.
So after a while of being pissed, I got myself one of those X10 modules to
control the modem.
This is not exactly rocket science nor am I the first one to do that. This page
is merely one more resource on the net that describes this hack :-)
Update:
This page was written in mid 2002. While it was fun to play with Linux and X10, DSL modem issues are not fun by themselves so shortly after, I actually contacted my ISP rawbandwidth.com which has a great and friendly support and I really recommend them (and feel free to give me the referral credit :-))
Anyway, to make a long story short, with their help I rewired a bit the messy phone installation at my place, which did help a bit the DSL performance. But the major fix was simply to upgrade the firmware of the modem. That was a huge boost in resolving the problem. Eventually the problem disappeared forever when I moved -- only as far as two house away in the same street was enough.
So if you have serious DSL sync problems, the ideal fix involves these steps:
- Get a real ISP! One driven by technical skills, not marketing. (Of course you don't want your ISP to be too cheap nor too bad at marketing since you don't want them to die on you!)
- Get a better DSL modem and/or upgrade the firmware. If your ISP can't help you, see previous point.
- Move to a place where you can get descent DSL service (always difficult to predict -- check with DSL Reports.)
The components of the system are as follow:
Quite frankly, the X10 web site sucks. Not only they are well known spammers and they master browser popups to the point it becomes art, but browsing the site is an utterly nightmare to be able to find what you want. Their strategy of hurry-up-one-deal-every-day isn't exactly subtle either (i.e. they are always on sale and don't be fooled, their sale always ends tomorrow, but then there will another one). Besides that awful marketing approach, the products look good to me, I had no surprise with them, they are correctly documented (from a lavish Windows end-user point of view at least, not from a geek point of view), and they deliver fast.
I couldn't locate solely a FireCracker CM17A on the web site, so I got the starter kit, which comes with a LM465 module to control a lamp with a polarized 2-pin plug. Since my modem has a 3-pin plug with a ground, that wouldn't work too good, plus this module is actually a dimmer, so it is not recommended at all to control an on/off appliance. Which is why I needed the AM466. Besides, I'm actually using this lamp module (one interesting usage is simulating a presence whilst your away on vacation by having a cron job turn it on or off semi regularly). Note that the wireless receiver is yet-another switch that can control one more lamp.
Setting up the software is as easy as setting up the hardware.
There are two easy ways to control the FireCracker under Linux: FlipIt and BottleRocket. They both have up-to-date packages for Debian woody. To get the packages:
apt-get install flipit
apt-get install bottlerocket
I started my hack with FlipIt, which was working fine, and some day it stopped work at all. At first I though the FireCracker broke down, but the same exact hardware worked with BottleRocket. That kind of puzzles me. In between, sure I added the UPS which is monitored via a control port, but I was not using the same ports and anyway after a while I unplugged that port and removed the ups daemon. That still puzzles me but anyway it works so...
Then I wrote two simplistic scripts to turn the modem on or off. This way I don't have to change the master script whenever I want to switch from FlipIt to BottleRocket or adjust arguments:
and#!/bin/sh # script: x10_dsl_on.sh
LOGFILE=debug.log.txt
date >> $LOGFILE
# /usr/local/bin/flipit flip a1 on
/usr/bin/br -vvvvvvvv A1 on >> $LOGFILE
echo "modem flipped on (error $?)"
#!/bin/sh # script: x10_dsl_off.sh
LOGFILE=debug.log.txt
date >> $LOGFILE
# /usr/local/bin/flipit flip a1 off
/usr/bin/br -vvvvvvvv A1 off>> $LOGFILE
echo "modem flipped off (error $?)"
And then I have this master script that is run in a cron job. The script checks several IP's, some by numbers and some by name (which implies the DNS must be up and running too). If they all fail, then the net is down and the modem must be rebooted. There's a slight delay between the off and on. Then I know the modem will sync in about one minute.
#!/bin/sh
# vim: set expandtab tabstop=4 shiftwidth=4: #
# created: RM 20020510
# the idea here is to ping several IP/addresses and then see how many
# did actually work. Let's take for example 8 IP/names to test, and
# assume that if at least one works, then the connection is up!
#
# Note that only IP's can be used, not hostnames. Otherwise
# ping does not return the error code 1 as we expect.
# 4 direct IP's are used and 4 domain names are used. This way,
# if the connection is up but there's a problem resolving names
# we only get half hits.
# where to append log
LOGFILE=ping.log.txt
LOGBOOT=reboot.log.txt
function log()
{
if [ "$1" != "" ];
then
/usr/bin/logger -p cron.alert -t "x10dsl[$$]" "$*"
fi
}
# first, test the presence of a lock file (the pid file)
LOCK=/var/run/x10_dsl.pid
if [ -e $LOCK ]; then
exit 0
fi
# use our PID for lock
echo $$ > $LOCK
date >> $LOCK
log `date` "- testing -- pid $$"
# ping returns 0 on success, 1 if couldn't ping anything
# accumulate return values and compare to 0
nberror=0
nbok=0
# Insert your IP's here, these are made up
for i in "209.210.211.1" \
"209.212.213.2" \
"204.205.206.3" \
"198.199.200.4" \
"www.debian.org" \
"www.redhat.com" \
"www.google.com"
do
ping -c 1 -q $i > /dev/null 2>&1
if [ $? -eq 0 ]; then
nbok=$(($nbok+1))
else
log "ping $i failed with error $?"
nberror=$(($nberror+1))
fi
done
if [ $nbok -eq 0 ]; then
# no ping succeeded at all, reset the modem
# write an entry in the syslog
/usr/bin/logger -p cron.alert -t "x10dsl[$$]" \
"$nberror ping errors, rebooting modem"
# write a single entry in the reboot log file
echo `date | tr -d '\n'` " -- Reboot -- pid $$" >> $LOGBOOT
x10_dsl_off.sh | $LOGGER # >> $LOGFILE
sleep 5
x10_dsl_on.sh | $LOGGER # >> $LOGFILE
# wait 1 minute... don't stress the modem
sleep 60
log "Done -- pid $$"
else
log "Modem OK -- pid $$"
fi
# remove the lock file
rm $LOCK
|
|