Weird (wireless) connectivity issue [SOLVED]

Questions about WIFI networks and devices
Forum rules
Before you post please read this

Weird (wireless) connectivity issue [SOLVED]

Postby 5oak on Tue Nov 08, 2011 3:32 am

Hi all,

I have been experiencing a very weird (at least imo) connectivity issue on my home network the past few weeks and I can't seem to get rid of it. Hope you guys can help out. Here it goes (pardon my lingo if it's not 100% correct).

My setup: LMDE server ('tower') and LMDE client ('thinkpad'). I use tower mainly as a music server (mpd/gmpc) and bittorrent server (rtorrent), not that it really matters. In between there's a linksys router, which is running a dhcp server (ip addresses are bound to mac-addresses). tower has 192.168.1.101, thinkpad has 192.168.1.102. The network configuration is the same on both machines. Subnetmask is 255.255.255.0, gateway (linksys router) is 192.168.1.1 and DNS ip addresses are also the same (can't remember those). There's no firewall involved, both are clean LMDE installs. So there's nothing too fancy, I think...

Now usually everyting's fine (which means I can reach and access tower from thinkpad without any problems). However, when I suspend thinkpad (for a longer time, at least an hour or so), tower becomes unreachable, which means I can't even ping tower from thinkpad (I get 'host unreachable'). ssh gives 'no route to host'. I can ping the gateway and otherwise the connection on both machines is perfectly fine (I can browse the interwebs, etc.). The curious part is though, that as soon as I ping thinkpad from tower everything is OK again (! yes, I've tried this multiple times). Now I don't want to get up every time I want to access tower to ping thinkpad first after a suspended period, so any help would be greatly appreciated. Of course, I've done my share of googling but this one's obviously out of my reach.

I honestly don't know if this issue is wireless specific. Unfortunately, I can't use cables where I live. Maybe this post should be moved to 'Networking'.

Naturally, in case more (specific) information is needed, I'd be more than willing to provide it.

Best regards,

Stijn
Last edited by 5oak on Thu Nov 24, 2011 9:38 am, edited 3 times in total.
User avatar
5oak
Level 1
Level 1
 
Posts: 31
Joined: Fri Jan 25, 2008 4:39 pm

Linux Mint is funded by ads and donations.
 

Re: Weird (wireless) connectivity issue

Postby Oscar799 on Tue Nov 08, 2011 10:16 am

Please don't cross post
Duplicate post deleted
Image
"Don't fix it if it ain't broken,don't break it if you can't fix it" Husse
Registered Linux User #511789
User avatar
Oscar799
Level 18
Level 18
 
Posts: 8813
Joined: Tue Aug 11, 2009 9:21 am
Location: United Kingdom

Re: Weird (wireless) connectivity issue

Postby 5oak on Tue Nov 08, 2011 10:20 am

Oscar799 wrote:Please don't cross post
Duplicate post deleted


Yeah I figured this is not specific to LMDE since I had the same issue on Ubuntu (10.04). Let's see where this goes then...
User avatar
5oak
Level 1
Level 1
 
Posts: 31
Joined: Fri Jan 25, 2008 4:39 pm

Re: Weird (wireless) connectivity issue

Postby Anakinholland on Tue Nov 08, 2011 7:30 pm

This is a REALLY awkward situation! If any, I would expect problems on the laptop, not the server!?

No expert, but educated guess would be the router is at fault here, causing havoc with a bad routing-table (initiated by the laptop shutting down?) or something like that...

As you've already troubleshooted the situation, you could circumvent this problem by creating a tiny script on the server and run it every x seconds while it's in runlevel 2 to 5 (multiuser with or without GUI), which will automatically start at boot.

Create a script somewhere on the system, say /opt/pinglaptop.sh, with the following content:
Code: Select all
#!/bin/sh

while true
do
   ping -c 1 192.168.1.102
   sleep 10
done


create a file in /etc/init.d, say pinglaptop, with the following content:
Code: Select all
#!/bin/sh

PATH=/bin:/usr/bin:/sbin:/usr/sbin
DAEMON=/opt/pinglaptop.sh
DESC="Ping laptop to keep connection open"
NAME="pinglaptop"
PIDFILE=/var/run/pinglaptop.pid

test -x ${DAEMON} || exit 0

case "$1" in
  start)   log_daemon_msg "Starting" "$NAME"
         ${DAEMON} &
         ps -ef | grep ${DAEMON} | grep -v grep |awk '{ print $2 }' > "${PIDFILE}"
         log_end_msg $?
         ;;
  stop)      log_daemon_msg "Stopping" "$NAME"
         kill `cat ${PIDFILE}`
         rm -f $PIDFILE
         log_end_msg $?
         ;;
  restart)   ${0} stop
         sleep 3
         ${0} start
         ;;
  *)      log_success_msg "Usage: ${0} {start|stop|restart}"
         exit 1
esac         ;;

exit 0


give the files execution-rights:
Code: Select all
chmod +x /etc/init.d/pinglaptop /opt/pinglaptop.sh


Now create a couple of links to that last script:

Code: Select all
ln -s /etc/init.d/pinglaptop /etc/rc2.d/S99pinglaptop
ln -s /etc/init.d/pinglaptop /etc/rc3.d/S99pinglaptop
ln -s /etc/init.d/pinglaptop /etc/rc4.d/S99pinglaptop
ln -s /etc/init.d/pinglaptop /etc/rc5.d/S99pinglaptop
ln -s /etc/init.d/pinglaptop /etc/rc0.d/K00pinglaptop
ln -s /etc/init.d/pinglaptop /etc/rc1.d/K00pinglaptop
ln -s /etc/init.d/pinglaptop /etc/rc6.d/K00pinglaptop


Due to the letters S with digits 99, or letter K with digits 00, it will either run the script last in line with the parameter start when it enters runlevel 2 to 5, or first in line with the parameter stop when it enters runlevel 0 (shutdown), 6 (reboot) or 1 (single user mode). Why they didn't just call the parameter kill, I do not know ^^

Regards,

Anakin
Please Edit your initial post title and add [SOLVED] once your question is resolved.
User avatar
Anakinholland
Level 3
Level 3
 
Posts: 145
Joined: Sun Oct 30, 2011 8:09 am

Re: Weird (wireless) connectivity issue

Postby 5oak on Wed Nov 09, 2011 1:11 pm

Thanks a lot Anakin! :) Even though I would've liked to find out what the source of the problem is, your suggestion/solution is a really good one and I will learn something by applying it 'cause some parts of it really are jibberish to me! :D

I had already thought of just letting the server keep pinging my laptop (at intervals of a couple of seconds, -i) but that just seems silly... :shock:

I'm gonna try this and let all of us know how it worked out later.

Best regards,

Stijn
User avatar
5oak
Level 1
Level 1
 
Posts: 31
Joined: Fri Jan 25, 2008 4:39 pm

Re: Weird (wireless) connectivity issue

Postby 5oak on Mon Nov 14, 2011 2:10 pm

OK, this has completely solved my connectivity issues. Thnx again, Anakin! :)
User avatar
5oak
Level 1
Level 1
 
Posts: 31
Joined: Fri Jan 25, 2008 4:39 pm

Re: Weird (wireless) connectivity issue

Postby Anakinholland on Mon Nov 14, 2011 3:50 pm

5oak wrote:Thanks a lot Anakin! :) Even though I would've liked to find out what the source of the problem is, your suggestion/solution is a really good one and I will learn something by applying it 'cause some parts of it really are jibberish to me! :D

If you can tell what seems jibberish, maybe we can explain? :)

5oak wrote:I had already thought of just letting the server keep pinging my laptop (at intervals of a couple of seconds, -i) but that just seems silly... :shock:

Same solution, however it would require you to restart the ping manually after a reboot of the server :wink:

5oak wrote:OK, this has completely solved my connectivity issues. Thnx again, Anakin! :)

Sweet!

Glad to have been of help :)
Please Edit your initial post title and add [SOLVED] once your question is resolved.
User avatar
Anakinholland
Level 3
Level 3
 
Posts: 145
Joined: Sun Oct 30, 2011 8:09 am

Re: Weird (wireless) connectivity issue [solved]

Postby 5oak on Fri Nov 18, 2011 9:48 am

Anakinholland wrote:If you can tell what seems jibberish, maybe we can explain? :)


Well, since you ask for it, let me give some examples :wink: :

- "while true" --> (while what is true?)

- why the 'do' and 'sleep 10' parts?

- don't let me start on the file in /etc/init.d :D

Anakinholland wrote:Same solution, however it would require you to restart the ping manually after a reboot of the server :wink:


Actually, I managed to do this automatically bij running the following command on startup:
Code: Select all
sh -c "ping -i 2 192.168.1.102"


5oak wrote:Sweet!


Damnit, turned out your suggestion couldn't terminate the bug after all. I know why, too: the problem occurs when my laptop has been in suspended mode, turned off or is when it's rebooted. So the problem doesn't occur when the server suspends, is turned off or rebooted. Seems like I terminated it eventually by applying the pinging workaround I described above.
User avatar
5oak
Level 1
Level 1
 
Posts: 31
Joined: Fri Jan 25, 2008 4:39 pm

Re: Weird (wireless) connectivity issue [solved]

Postby Anakinholland on Sat Nov 19, 2011 6:56 am

5oak wrote:Well, since you ask for it, let me give some examples :wink: :

- "while true" --> (while what is true?)

- why the 'do' and 'sleep 10' parts?

- don't let me start on the file in /etc/init.d :D

ad 1 & 2) while is a statement, part of the bash-shell. It uses a condition to determine whether or not it should 'do' something or not. The condition could be that the day is before noon

Code: Select all
[ `date +%H%M` -lt 1200 ]

or that the number of files in the current directory is more than 10

Code: Select all
[ `ls | wc -l` -gt 10 ]

Those two condition will render a false condition at 12.01 PM and at 10 or less files, making the loop stop.

If however you want something to run indefinitely (until you kill it, or press Ctrl+C) you will need something that will always be true. So you could use

Code: Select all
[ 1 = 1 ]

or

Code: Select all
[ `uname` = "Linux" ]

but it's far easier to just write down the word "true". It's not some sort of logic, it's how the programmer decided it should work.

More examples can be found here.

As with the condition "true", the programmer decided that whatever needs doing needs to be located between the words "do" and "done". After every cycle (ie. reaching the word "done") it will check if the condition is still true. If it is, it will enter the next cycle. If it isn't, it will stop the cycle there and continue downwards.

For us there is no reason why, it just needs to be done, else the loop will not function. The same goes for the if-statement. if needs a condition and when it is met, "then" do A, "else" do B, and end the statement with the word "fi". This also goes for the case-statement. It tests a condition to a list of predefined option, and ends with the word "esac".

Regarding "sleep 10", you don't need to have the server ping you laptop ALL the time, so why not reserve resources and only do it once every 10 seconds? :) More information can be found using the command

Code: Select all
man sleep

You created this situation yourself using the parameter "-i 2" on ping, I just did it differently, putting the script in charge instead of the ping-command.

ad 3) the file in /etc/init.d is there to jumpstart our own script. All the files in that directory are run by the very first process that is started at boot: init

You can look it up using "ps -ef":

root 1 0 0 10:19 ? 00:00:00 /sbin/init

For that script I just picked another file that was already there, and altered it. :)

"start" will start the script, make note of its Process ID (PID) and jolt a line of logging in the syslog file (located in /var/log).
"stop" will kill the script, using the PID which was noted during "start", and jolt a line of logging in the syslog file (located in /var/log).
"restart" will perform a "stop", wait for 3 seconds, and then "start" again.
Any other parameter used with that script will result in an error telling the user what command/parameter he should be using.

5oak wrote:Damnit, turned out your suggestion couldn't terminate the bug after all. I know why, too: the problem occurs when my laptop has been in suspended mode, turned off or is when it's rebooted. So the problem doesn't occur when the server suspends, is turned off or rebooted. Seems like I terminated it eventually by applying the pinging workaround I described above.

I don't get that, as my setup (although overly extensive, I agree) should do exactly the same as yours :) Ah well, don't want to discuss that any further to be honest, I'm glad you got your problem solved! :D
Please Edit your initial post title and add [SOLVED] once your question is resolved.
User avatar
Anakinholland
Level 3
Level 3
 
Posts: 145
Joined: Sun Oct 30, 2011 8:09 am

Linux Mint is funded by ads and donations.
 

Return to Wireless

Who is online

Users browsing this forum: No registered users and 2 guests