Why No RPi Wifi ?

As mentioned in the last post the Raspberry Pi I have been using to control Squirty the RepRap suddenly decided to stop connecting to my home network. It would work with a different wifi dongle, but not with the one I have been using for the last year or so. The “broken” dongle was able to connect to the network without any problems when connected to my windows desktop, so I was quite mystified as to what happened.

My usual approach when encountering problems like this is to try a few random solutions, type error messages into google, read, generate some theories about what might be going wrong, try some more things, then mope. I think this is the least effective possible approach, but somehow I do it anyway. If you spend all your time generating theories and trying solutions it is easy to become frustrated and to overlook something important, so I started this post with the intention that I was not going to solve my wifi troubles, instead I would just try to document and properly understand the problem. Unfortunately at some point I accidentally fixed the problem without really knowing how I did it. Although the solution is not as satisfying as I would like because I don’t know what caused the problem in the first place, I found the process of documenting everything I was doing in the post quite helpful. Therefore I’m keeping the rest of the post as I originally wrote it in case it is useful to anyone else or in case someone has a better idea of what went wrong in the first place

So here’s what I documented as I “solved” the problem.

The raspberry pi controlling Squirty (I’ll call it RaspRepRap) should connect to my home wireless network. Here’s the layout of the network…

Layout of my home network. There is one main router connected to the internet and one secondary router with DHCP switched off which gives better wifi coverage. Compimus Prime is the desktop I use for tinkering. It is named for its superiority over my other desktop "Compy"  which is almost 10 years old now.
Layout of my home network. There is one main router connected to the internet and one secondary router with DHCP switched off which gives better wifi coverage. Compimus Prime is the desktop I use for tinkering. It is named for its superiority over my other desktop “Compy” which is almost 10 years old now.

…and here is how the wifi dongle and Squirty are connected in. Even though the raspberry pi has two ethernet ports they can only provide wimpy amounts of power which is why I need the powered hub.
How the RepRap and Wifi dongle connect into the raspberry pi
How the RepRap and Wifi dongle connect into the raspberry pi

To show the problem I’ve plugged the wifi into Router B by ethernet with the troublesome adapter (TP Link TL-WN722N, I’ll call it Dongle X) attached to the USB hub but without Squirty plugged in. I can then log in using SSH. Here’s what I see when I type ifconfig…

RaspRepRap with both Dongle X and ethernet connection

pi@raspreprap ~ $ ifconfig
eth0 Link encap:Ethernet HWaddr b8:27:eb:fb:ba:4f
inet addr:192.168.0.110 Bcast:192.168.0.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:562 errors:0 dropped:0 overruns:0 frame:0
TX packets:783 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:42614 (41.6 KiB) TX bytes:96212 (93.9 KiB)

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)

wlan0 Link encap:Ethernet HWaddr 90:f6:52:e7:4f:a5
inet addr:192.168.0.109 Bcast:192.168.0.255 Mask:255.255.255.0
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)

…and when I type iwconfig


pi@raspreprap ~ $ iwconfig
wlan0 IEEE 802.11bgn ESSID:off/any
Mode:Managed Access Point: Not-Associated Tx-Power=20 dBm
Retry long limit:7 RTS thr:off Fragment thr:off
Power Management:off

lo no wireless extensions.

eth0 no wireless extensions.

Interestingly ifconfig shows that the wifi adapter has an IP address, but iwconfig shows that it is not associated with a wireless network. When I check the main router admin page I see that RaspRepRap is on the DHCP client list twice, once as 192.168.0.110 (eth0) and once as 192.168.109. I can ping 192.168.0.109 from my main computer. I can also connect to 192.168.0.109 using PUTTY. This is quite embarrassing – it seems like it is working after all? What happens if I unplug the ethernet and just try to connect via wifi?

With just the wifi adapter plugged in I can no longer ping 192.168.0.109 – it says destination host unreachable. It seems like the problem doesn’t occur if there is an ethernet connection when the wifi adapter is plugged in. This is irritating as it means I’m going to have to plug RaspRepRap into a monitor to see what is happening when the problem occurs.

Before I faff with plugging in monitor etc. I’m going to try the configuration where the Pi is plugged into both ethernet and wifi but using the dongle that still works (TL-WN727N, Dongle Y).

Here’s the ifconfig output when connecting using SSH to 192.168.0.110

RaspRepRap with both Dongle Y and ethernet connection

pi@raspreprap ~ $ ifconfig
eth0 Link encap:Ethernet HWaddr b8:27:eb:fb:ba:4f
inet addr:192.168.0.110 Bcast:192.168.0.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:175 errors:0 dropped:0 overruns:0 frame:0
TX packets:76 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:19458 (19.0 KiB) TX bytes:8961 (8.7 KiB)

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)

wlan0 Link encap:Ethernet HWaddr 90:f6:52:cb:01:a0
inet addr:192.168.0.109 Bcast:192.168.0.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:361 errors:0 dropped:0 overruns:0 frame:0
TX packets:83 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:85366 (83.3 KiB) TX bytes:13935 (13.6 KiB)

Here’s the iwconfig output

pi@raspreprap ~ $ iwconfig
wlan0 IEEE 802.11bgn ESSID:"NewSnuf"
Mode:Managed Frequency:2.472 GHz Access Point: 00:26:5A:CB:DB:11
Bit Rate=54 Mb/s Tx-Power=20 dBm
Retry long limit:7 RTS thr:off Fragment thr:off
Power Management:on
Link Quality=61/70 Signal level=-49 dBm
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:59 Invalid misc:15 Missed beacon:0

lo no wireless extensions.

eth0 no wireless extensions.

Here’s a comparison of the outputs
ComparisonTable

A few things that are interesting about this

  • Most important difference is that even though Dongle X has an IP address it does not have an associated ESSID
  • They both get given the same IP address even though I have an address reservation enabled for 192.168.0.109 for Dongle Y and nothing for Dongle X
  • The ifconfig for Dongle X shows 0 bytes received and transmitted even though there is an ip address. I took this snapshot before I tried to ping & putty the 192.168.0.109 address

The fact that there are no bytes received or transmitted while using Dongle X makes me wonder why I am able to ping that address and also putty into it. I tried Dongle X again in combination with the ethernet connection to Router B. I checked that iwconfig and ifconfig had the same output as before, then pinged the .109 address from my computer. I got a reply. Checking ifconfig again .109 still shows 0 bytes transmitted/received. I used putty to establish SSH connection to .109. It worked but still no bytes transmitted/received according to ifconfig. This makes me think that there is some alternative route being found to .109 using the ethernet connection at .110. I did a tracert to .109 but it just shows a single hop.

I’m not going to plug the Pi into a monitor after all – I think I can continue to diagnose the problem using SSH (easier because I can type this on the same keyboard).

I’m puzzled by this ability to ping .109 when the connection appears to not be receiving or transmitting any packets. To try and understand what’s going on I’m going to clear the logs for both Router A and Router B and then see what happens when I boot up the Pi plugged into ethernet Router B and with wifi Dongle X.

Router A output

Index Time Type Level Log Content
5 Oct 25 13:06:25 DHCP INFO DHCPS:Send ACK to 192.168.0.110
4 Oct 25 13:06:25 DHCP INFO DHCPS:Recv REQUEST from B8:27:EB:FB:BA:4F
3 Oct 25 13:06:25 DHCP INFO DHCPS:Send OFFER with ip 192.168.0.110
2 Oct 25 13:06:25 DHCP INFO DHCPS:Recv DISCOVER from B8:27:EB:FB:BA:4F
1 Oct 25 13:05:29 OTHER INFO User clear system log.

Router B output

Priority Time Message
[INFO] Thu Apr 29 09:00:50 2004 Log viewed by IP address 192.168.0.106
[INFO] Thu Apr 29 09:00:50 2004 Log cleared by IP address 192.168.0.106

Nothing about 192.168.0.109. Then I tried pinging .109 again, but this time it is unreachable. Huh? Did I imagine the ping working before? I SSH in to .110 and check ifconfig etc. Everything looks the same except now there is no ip address for wlan0 when I type ifconfig

wlan0 Link encap:Ethernet HWaddr 90:f6:52:e7:4f:a5
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)

The only thing I did differently was to clear the router logs first. I now feel suspicious about this .109 address generally. I’m going to clear the address reservation for Dongle Y to .109 from Router A. For Router B DHCP is switched off, but I noticed that when I switch DHCP on there are stored address reservations there too for Dongle Y’s MAC address (.109) and RaspRepRap’s ethernet port (.110). I will get rid of both sets. I’ll also reboot both routers.

After rebooting both routers and restarting RaspRepRap I find that:

  • Router A has allocated IP addresses to both RaspRepRap’s ethernet port (.110) and to Dongle X (.100)
  • Logging in to RaspRepRap using SSH to .110 works
  • Ifconfig shows that wlan0 has IP address 192.168.0.100
  • Iwconfig shows that wlan0 is now associated with the ESSID NewSnuf

…in other words everything seems to be working fine now. Damn. I think I have fixed the problem but I don’t know why. Just to check that everything is working OK now I am going to add address reservations for RaspRepRap in Router A and then try to connect using wifi only.

And it works. Hmm. My best theory for what was going wrong is that there was some setting gummed up in either Router A or Router B (highly technical description) and that by rebooting the routers I have degummed it. I’m sure I have rebooted Router A quite recently, so it seems more likely it was something to do with Router B.

What, if anything, can I learn from this exercise?

  1. Documenting the problem is a good way to solve it!
  2. Specifically I found that the temptation to try something repeatedly to see if it “works this time” disappeared when I could just scroll back up and see what I’d already tried
  3. Routers are mysterious beasts
  4. Rebooting all my routers should be an early step on any future network troubleshooting

Leave a Reply

Your email address will not be published. Required fields are marked *