Wireless mesh networking on Raspberry Pi using batman-adv protocol
Asked Answered
E

6

5

So I'm trying to setup a wireless mesh network using Raspberry Pi's, with the Edimax EW-7811Un WLAN Adapter and the batman-adv protocol.

I've tried following the basic setup guides from:

Unfortunately, when I get to the point where I need to ping one node from the other, I get

Destination Host Unreachable.

Running the batctl o command displays

'no batman nodes in range'

However, when running iwconfig, both nodes appear to be associated with the network I've setup, and when running iwlist wlan0 scan, the network I've setup appear as cells on both nodes.

I'm now at a loss as to how to proceed. I have read some articles on issues with ad-hoc support for Linux WLAN adapter drivers. My adapter is using the RTL8192CU driver. Could this be the cause of the issue?

P.S. I have looked at the following post, but this was no help, unfortunately.

Edit: contents of /etc/network/interfaces:

Both currently setup nodes have the same contents:

auto lo

iface lo inet loopback
iface eth0 inet dhcp

allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp

Edit: contents of /etc/wpa_supplicant/wpa_supplicant.conf for both nodes:

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

Edit: ifconfig, iwconfig, and route for both nodes:

Node 1

ifconfig

wlan0    Link encap: Ethernet  HWaddr 80:1f:02:9b:bc:6c
         inet addr:192.168.2.1  Bcast:192.168.2.255  Mask:255.255.255.0
         UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
         RX packets:0  errors:0  dropped:1  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)

iwconfig

wlan0    IEEE 802.11bg  ESSID:"pi-ad-hoc" Nickname:"<WIFI@REALTEK>"
         Mode:Ad-Hoc  Frequency:2.412 GHz  Cell: 02:11:87:A1:CD:FF
         Bit Rate:54 Mb/s   Sensitivity:0/0
         Retry:off    RTS thr:off    Fragment thr:off
         Encryption key:off
         Power Management:off
         Link Quality=2/100  Signal level=2/100  Noise level=0/100
         Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
         Tx excessive retries:0  Invalid misc:0  Missed beacon:0

route

Kernel IP routing table
Destination    Gateway        Genmask        Flags  Metric  Ref    Use  Iface
192.168.2.0    *              255.255.255.0  U      0       0        0  wlan0

Node 2

ifconfig

wlan0    Link encap:Ethernet  HWaddr 80:1f:02:da:2e:ee
         inet addr:192.168.2.3  Bcast:192.168.2.255  Mask:255.255.255.0
         UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
         RX packets:0  errors:0  dropped:0  overruns:0  frame:0
         TX packets:6  errors:0  dropped:0  overruns:0  carrier:0
         collisions:0  txqueuelen:1000
         RX bytes:0  (0.0 B)  TX bytes:0  (0.0 B)

iwconfig

wlan0    IEEE 802.11bg ESSID:"pi-ad-hoc"  Nickname:"<WIFI@REALTEK>"
         Mode:Ad-Hoc  Frequency:2.412 GHz  Cell: 02:11:87:2F:D6:FF
         Bit Rate:54 Mb/s   Sensitivity:0/0
         Retry:off  RTS thr:off  Fragment thr:off
         Encryption key:off
         Power Management:off
         Link Quality=2/100  Signal level=2/100  Noise level=0/100
         Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
         Tx excessive retries:0  Invalid misc:0  Missed beacon:0

route

Kernel IP routing table
Destination    Gateway        Genmask        Flags  Metric  Ref     Use   Iface
192.168.2.0    *              255.255.255.0  U      0       0         0   wlan0
Esquivel answered 2/5, 2014 at 22:9 Comment(7)
What is 'sudo ifconfig' telling you? Did you get a valid IP of your network?Doily
The bat0 interface is showing the follow for node 1: inet addr:192.168.2.1 Bcast:192.168.2.255 Mask 255.255.255.0 and for node 2: inet addr:192.168.2.2 Bcast:192.168.2.255 Mask 255.255.255.0 wlan0 is showing no ip address or subnet mask. But i assume that's because batman-adv is now using the virtual bat0 interface?Esquivel
As far as I read the documents you mentioned above, both wlan interfaces should have an IP address. Because batman is based on adhoc networks. Where batman is responsible for the routing from bat to bat over several nodes. So as described you should be able to ping from bat to bat after successful adhoc connection. If that doesn't work we should look deeper into the setup of the adhoc network.Doily
Any ideas on where to start? As mentioned if I execute 'batctl o' it tells me that there are no batman nodes in range, so I doubt I'd be able to ping one if it can't see them?Esquivel
could you please add/post both "/etc/network/interface" settings?Doily
I see you use wpa_supplicant. Could you also provide its config?Doily
Try first without WPA in the first place (probably not needed any ways). I don't see any bat0 interface on node 1 or node 2. I think you didn't setup batman correctly. So you need to enable wlan0 via batctl (batctl if add wlan0). This will create a bat0 interface. wlan0 interface shouldn't be configured. Only bat0 shall be used. You can set IPV4 IP addresses manually or via sudo avahi-autoipd bat0. Ifconfig should give something like: pastebin.com/jm0fWbJPTolle
D
1

I just checked your configuration with two Raspberries and the same Wifi Adapters (Edimax EW-7811Un) on Raspbian. Long story short: I get the same results as you do.

My findings are as follows

  1. Setting up one Raspberry for adhoc as described and connecting from IPad or Notebook ... works fine
  2. Creating an adhoc connection on the Notebook and let one Raspberry join ... works fine
  3. Setting up one Raspbery for accesspoint and connecting from IPad or Notebook ... works fine
  4. However when setting up two Raspberries either in adhoc mode or accesspoint mode wont connect to each other ... doesnt work!
  5. As you figured out by this source here the available modes of these adapters (rtl8192cu) are unclear.
  6. Other sources create adhoc connections easily with similar setup and other wifi adpater like described.

It pretty much seems like the adapters drivers won't allow this connection.

Please note: setting up an accesspoint with these adapters requires a special compiled hostapd: read here to find out how

Doily answered 6/5, 2014 at 18:56 Comment(0)
T
6

I can confirm, that this is an issue of the latest rtl8192cu driver. I was using an older version of that driver for edimax wlan adapters with batman working (almost) fine. But I found, that under certain circumstances (with heavy load), the connection failed. Then I upgraded to the latest version of that driver (date: September 11th 2013) but found that batman wasn't working any longer (in the exact same configuration as with the older driver). The symptoms were exactly as you described in your post.

Edit: My post was deleted, saying that I don't give an answer to the question. I disagree with that: this IS an answer to the original post. The only question in the original post was this: "My adapter is using the RTL8192CU driver. Could this be the cause of the issue?"

Again: I can confirm that using this (latest) driver causes the issue. This driver is incompatible with batman. The issue has nothing to do with the configuration file. Try to look for an older driver or -better - use a wlan adapter with a different chipset.

Tessietessier answered 28/8, 2014 at 7:58 Comment(0)
D
3

You try to setup an adhoc network. However I suggest to start with a simpler approach -- Wifi Access Point and then switch over to adhoc network.

From my point of view it is easier to connect the raspi to a wireless accesspoint. Because the accesspoint will hand over the IP adresses through DHCP. Where in adhoc mode you have to care about the IPs yourself (as far as I know).

Therefore the config for the accespoint based solution would be like

/etc/network/interfaces

auto lo

iface lo inet loopback
iface eth0 inet dhcp

allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp

(which is by the way pretty much like yours already)

and then the /etc/wpa_supplicant/wpa_supplicant.conf which connects to a WPA2 accesspoint

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
        ssid="KBBL"
        psk=af2a9daa6cadd3434ad96db48173a04acddb04e6a8c5adf52ae78ef13XXXX
        key_mgmt=WPA-PSK
        scan_ssid=1
        proto=RSN
        pairwise=CCMP
        group=CCMP
}

Please note that the psk key needs to be generated by

$wpa_passphrase "KBBL" "YOUR_KEY"

which results in something like

network={
        ssid="KBBL"
        #psk="YOUR_KEY"
        psk=29af596e046ad450eeddd6752432d5dbd26575960b9024e5cbb99e945cdafa4e
}

just copy and paste the psk

Then reboot! I sometimes have trouble when just changing the network wifi settings on the fly. While after reboot everything is fine. Also the wifi network takes some time. At my place something between 20-40secs.

Btw. I also had trouble when trying to setup wifi without encryption or WEP encryption so I suggest to use WPA2 or WPA. Please also note that the WPA configuration of the wpa_supplicant is much different from this of WPA2. So you might start using the above example for WPA2.

Doily answered 3/5, 2014 at 12:36 Comment(2)
Thanks for this. Unfortunately I don't think this will get us any further. The wlan adapters have no trouble connecting to my broadband router using the wpa_supplicant GUI. Could wpa_supplicant be the issue? Is it getting in the way or something?Esquivel
So if you tested the access point connection then we should focus on the adhoc. I was wondering if there is a general connection problem with the drivers/adapters.Doily
D
2

As wifi connections to your access point work fine. We assume drivers and hardware are fine. Now let's try to connect via -- Wifi ad-hoc.

I found here some pretty promising configuration without using wpa_supplicant. As already mentioned we have to use fixed IPs. So of course they need to be different on both raspis. Please note that I had to change "manual" to "static". Now it also works at my place (after reboot). Here it comes

/etc/network/interfaces

auto lo
iface lo inet loopback
iface eth0 inet dhcp
auto wlan0
iface wlan0 inet static
    address 192.168.2.10
    netmask 255.255.255.0
    wireless-channel 4
    wireless-essid pi-ad-hoc
    wireless-mode ad-hoc

Please note: The chosen IPs should not be in the sub net of your wired network (eth0).

Also make sure sudo ifconfig wlan0 shows the correct IP

pi@raspberrypi ~ $ sudo ifconfig wlan0
wlan0     Link encap:Ethernet  HWaddr 80:1f:02:87:77:81  
          inet addr:192.168.2.10  Bcast:192.168.2.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:53 errors:0 dropped:29 overruns:0 frame:0
          TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:6007 (5.8 KiB)  TX bytes:1042 (1.0 KiB)

and here is the sudo iwconfig wlan0

pi@raspberrypi ~ $ sudo iwconfig wlan0
wlan0     IEEE 802.11bg  ESSID:"pi-ad-hoc"  Nickname:"<WIFI@REALTEK>"
          Mode:Ad-Hoc  Frequency:2.412 GHz  Cell: 02:11:87:DF:AB:FF   
          Bit Rate:54 Mb/s   Sensitivity:0/0  
          Retry:off   RTS thr:off   Fragment thr:off
          Encryption key:off
          Power Management:off
          Link Quality=2/100  Signal level=2/100  Noise level=0/100
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:0   Missed beacon:0
Doily answered 3/5, 2014 at 15:17 Comment(11)
Ok so I followed the setup from that link, which I had already seen but thought I'd try it again, and this does not work either. When I try and ping i get 'network unreachable'. When running 'iwlist wlan0 scan' both nodes see the 'pi-ad-hoc' network as cell 01, and iwconfig shows that the adapters are associated with that network. If I execute 'route', nothing is displayed for either node.Esquivel
Sorry, I just tried it and I had to change "manual" to "static". (updated the answere above). Now it works at my place - exact same configuration as above.Doily
Ok so I've changed it from 'manual' to 'static' and it no longer says 'network unreachable' but says 'Destination Host Unreachable'.Esquivel
Hey buddy, we need some more information here :). How about your "sudo ifconfig" and "sudo iwconfig" and "sudo route" of both devices? (you did reboot after changing the settings, - right?)Doily
At least we made progress :-) -- the network is accessible. Perhaps you should put your raspberries closer together for a start. My testing distance was 80cm.Doily
Added the info above. The raspberry pi's are sitting on top of one another!! I appreciate your help so far man :) hopefully we'll get there! and yes I did reboot!Esquivel
This looks pretty much like mine. Perhaps a typo? You did notice that the second raspi has the IP 192.168.2.***3*** I guess. You may skype me : tswaehn-at-workDoily
Added you on skype :) what wlan adapters are you using?Esquivel
@user3597805 I have exactly the same problem as yours. I'm just wondering if you already figured it out?Consume
Ist all about having the correct wifi adapter together with suitable drivers.Doily
Which wifi adapter are you using?Doily
D
1

I just checked your configuration with two Raspberries and the same Wifi Adapters (Edimax EW-7811Un) on Raspbian. Long story short: I get the same results as you do.

My findings are as follows

  1. Setting up one Raspberry for adhoc as described and connecting from IPad or Notebook ... works fine
  2. Creating an adhoc connection on the Notebook and let one Raspberry join ... works fine
  3. Setting up one Raspbery for accesspoint and connecting from IPad or Notebook ... works fine
  4. However when setting up two Raspberries either in adhoc mode or accesspoint mode wont connect to each other ... doesnt work!
  5. As you figured out by this source here the available modes of these adapters (rtl8192cu) are unclear.
  6. Other sources create adhoc connections easily with similar setup and other wifi adpater like described.

It pretty much seems like the adapters drivers won't allow this connection.

Please note: setting up an accesspoint with these adapters requires a special compiled hostapd: read here to find out how

Doily answered 6/5, 2014 at 18:56 Comment(0)
N
1

I had problems with the Edimax EW-7811Un in combination with the Raspberry Pi A+ It became unresponsive after a few minutes. Apache and SSH were unreachable and ping did not connect.

The iwconfig program shows: "Power Management:off" but still, it goes into an idle mode.

I found a solution from MrEngman on the raspberry forums: http://www.raspberrypi.org/forums/viewtopic.php?f=28&t=61665

This might solve it:

Make a file 8192cu.conf in directory /etc/modprobe.d/ with the command:

    sudo nano /etc/modprobe.d/8192cu.conf

add these lines:

    # Disable power management
    options 8192cu rtw_power_mgnt=0 rtw_enusbss=0
Natant answered 3/12, 2014 at 16:49 Comment(1)
That's a very good hint although the author did not mention communication loss after some time. He wrote he cannot ru. Access point mode which is necessary for batman. The used driver for the wifi adapter is just not able to run access point mode by default. It can be compiled to do so but initially it doesn't.Doily
Q
0

I dont have anywhere to test at the moment so sorry for the lack of screenshots :(

If you are still interested and have set up several mesh networks using batman-adv and catwoman and faced similar issues (I have done mixed devices like android phones, foneras, openwrt devices, etc, etc to work together).

First thing to check when using batman-adv is the compatibility version, check on your dmesg which one is using each node when you load de batman-adv module, it should match in both or they will not see each other even with both setup propertly! (this has given me quite some headaches in the past hehe)

If the nodes still can't see each other you need to check that you dont have any issues when changing the mode to ad-hoc.

Now, once the nodes see each other remenber that batman-adv works in layer 2, batctl has a ping tool to ping on this layer even when the nodes can't see each other.

Im not really sure why you have wpa-supplicant here, mesh networks doesnt need it, to set up your mesh just chose a channel and an ESSID; all nodes should have this same parameter, then just put the wifi interfaces in ad-hoc mode and on batctl add the interfaces to the bat0 interface.

bat0 interface? thats the actual mesh interface, not wlan0. You did put an ip on the wlan0 interfaces, but that would not work, you need to give bat0 an ip and that the one the mesh will use. By memory the command would be: batctl ifadd wlan0, but check the batctl help just in case :)

If you want to share internet connection you need to follow below steps, then on the node connected to the internet create a bridge between bat0 and the interface with internet (remenber to leave wlan0 or whatever interface is using the mesh alone) and to finish go to batctl on that node and switch the gw (gateway) mode on (batctl gw on, I think). then you can run dhcp over bat0 on all the nodes and it should work just fine.

Just in case, be sure that the batman-adv module is loaded hehe

I think I have covered all sides when it comes to setting up a batman-adv mesh. If you need any doubts I will try to help :D

Best regards and hope your mesh works fine! :)

Questionable answered 4/8, 2014 at 10:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.