What's new
  • 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!

Schedule full-bridge modem disconnection?

noric

Senior Member
Hello,
I've noticed that after a while (2 weeks or so) my modem's SNR drops to about 3 and web surfing becomes sluggish. I simply need to disconnect and reconnect and SNR is back to normal.
Now, I use to do this via the modem's UI. I'm wondering if I can automate this using "cru" on the router on a weekly basis.
To make this clear: what I do is not rebooting the modem, but make it disconnect and then reconnect.
Is this possible with "cru"?
Thanks.

Edit: forgot to say, I have a RT-N66U with Merlin 374.40.
 
Given that the RT-N66U doesn't have a modem you must be talking about another piece of kit that you haven't specified.

That said, I used to use a Netgear DG834GT and had the same problem as you. I was running DGTeam's custom firmware on it which let me schedule a cron job to re-sync the line once a week.

To do something similar remotely from the N66U would be tricky. You would have use cru to schedule a script which TELNETed or SSHed onto your modem and ran the appropriate command.
 
I didn't mention my modem because it's not customizable at all. I was given it by a spanish ISP. No command line is available.
What I was thinking is: what if I terminate the PPP session on the RT-N66U (given it's possible)? Will it cause the modem to drop the connection?

Edit: telnet is available on the modem, now that I'm checking.
 
"service restart_wan" is probably the command you're after, but I'm not sure it will do what you want it to.
 
You're right. It doesn't achieve what I'm after.

But your idea about the router TELNETting to the modem is interesting. I'll let you know if I can do it.
 
I think this utility (avalilable through entware) would help me: http://empty.sourceforge.net/
I could then pass to the modem the restart command. I hope I can find a command to only restart the wan and not the whole modem...

Update: see here for a more in depth syntax explanation.
 
Last edited:
I think this utility (avalilable through entware) would help me: http://empty.sourceforge.net/
I could then pass to the modem the restart command. I hope I can find a command to only restart the wan and not the whole modem...

It will be hardware dependent, but look for something like:
Code:
adslctl stop
adslctl start
or
Code:
adslctl connection --down
adslctl connection --up
 
Last edited:
Thanks, but I already tried "services restart_wan" as per ColinTaylor's suggestion. It doesn't make the modem disconnect. It just terminates the PPP session. I want the modem to drop the connection and reconnect, instead.
It will be hardware dependent, but look for something like:
Code:
adslctl stop
adslctl start
or
Code:
adslctl connection --down
adslctl connection --up

There was nothing like that but after some trial and error it seems that this does the trick:
Code:
port a1 set ActivateLine start

Now I need to pass this command from the router to the modem.
 
Ok, I've tried "empty" but I can't get it working. I use the following script:
Code:
#!/bin/sh

empty -f -i in -o out telnet 192.168.0.1
empty -w -i out -o in "Login" "my_username\n"
empty -w -i out -o in "Password" "my_password\n"
empty -s -o in "port a1 set ActivateLine start\n"

the first empty command works: it connects to the modem via telnet and the modem asks for the login name.
But if I "cat out" after the second empty command I get as output:
Code:
my_username
instead of the expected
Code:
Password:

Any hint?

Edit: here is the syntax explanation, but still I don't see where my script is wrong.
 
Last edited:
Try modifying the supplied example script?
Code:
#!/bin/sh

# emtelnet.sh v.0.4 
# telnet example for empty
# Copyright (C) 2005, 2006 Mikhail E. Zakharov
#

telnet="telnet"				# (/full/path/to/)telnet
target="localhost"			# target telnet-host
login="luser" 				# username (Change it!)
password="TopSecret"			# password (Change it!)

fifo_in="/tmp/empty.in"			# input fifo
fifo_out="/tmp/empty.out"		# output

# telnet command examples. Chose one:
telnet_cmd="$telnet -K $target"		# connect FreeBSD from FreeBSD (SRA)
#telnet_cmd="$telnet $target"		# All other OSes

# -----------------------------------------------------------------------------
tmp="/tmp/empty.tmp"			# tempfile to store result

echo "Starting empty"
empty -f -i $fifo_in -o $fifo_out -L $tmp $telnet_cmd
if [ $? = 0 ]; then
	if [ -w $fifo_in -a -r $fifo_out ]; then
		echo "Sending Login"
		empty -w -v -i $fifo_out -o $fifo_in -t 5 ogin: "$login\n"
		echo "Sending Password"
		empty -w -v -i $fifo_out -o $fifo_in -t 5 assword: "$password\n"
		echo "Sending tests"
		empty -s -o $fifo_in "echo \"-- EMPTY TEST BEGIN --\"\n"
		empty -s -o $fifo_in "uname -a\n"
		empty -s -o $fifo_in "uptime\n"
		empty -s -o $fifo_in "who am i\n"
		empty -s -o $fifo_in "echo \"-- EMPTY TEST END --\"\n"
		echo "Sending exit"
		empty -s -o $fifo_in 'exit\n'
		echo "Check results:"
		sleep 1
		cat $tmp
		rm -f $tmp
	else
		echo "Error: Can't find I/O fifos!"
		return 1
	fi
else
	echo "Error: Can't start empty in daemon mode"
	return 1
fi

echo "Done"
 
It can't do the login either...

If I manually (not with any script) try to connect this is how the output is:
Code:
Entering character mode
Escape character is '^]'.


                ,vvvdP9P???^   ,,,
              vvd###P^`^         vvvvv v
         vv#####?^                  ????####vv,
      vv####??     ,vvvdP???^  ,,,        ??##^
     v#####?    ,vvd##P?^        #?#v#vvv
   v#####?    v###P^    ,vvv,        '?#?,
  ######?   ####?^ ,vd#P?^     `???##
  #####?   v####  ,d##P^           ''
 ######   v####  ]###L                   _   _          _                  ___
 #####?   v####  ]##L                   /   / \  |\ |  |_  \/   /\   |\ |   |
 ######    ####  ]###L                  \_  \_/  | \|  |_  /\  /--\  | \|   |
 ?#####v   ####v  ]##h,            ,,
  ?#####    ?###h,  `9#hv,     ,vv###
    ######    #####L    ]###L        ,v#v'
    ?#####vv    ?9##hv,        ,,vvvv###'
       ?#####vv     `??9P\vv,   ^         vv##,
          ######                       #######L
            ??###hvv,          ,vvv#?##?????
                `????9hdhvv,

Login: my_name
Password: ********

It looks pretty standard to me. I can't understand why the script doesn't work. It looks like everything stops after the My_name input. The modem doesn't prompt for the password. Infact the scripts fails with a timeout error, because it doesn't find the "password" request.
 
I've now tried to connect from the N66U to the N66U (a telnet session inside another telnet session: it's possible), thinking that maybe something was wrong with my modem. Actually, I see the same error. :mad:
 
Finally, I got it!

First, the "empty" command does work with the N66U. When it didn't work, it was because of some leftover files that were messing with it.

About my modem, I figured out why "empty" wasn't working. Believe it or not, it was because "\n" is not recognized as new line by my modem. Infact, I've tried to input "\r\n" instead, and this does work. Why my modem uses ms-dos syntax for new line is beyond me...
 
Well done noric.

If you plan to run this through cron remember to specify absolute pathnames for files (i.e. /tmp/empty.in rather than empty.in).
 

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!
Back
Top