This document describes how to modify your system in order to get devices using the RTL8192cu wireless driver to be able to communicate among one another in IEEE 802.11 Ad Hoc networks.
First, you're going to need static IP addresses. So decide on the range and subnet of the addresses you would like to use. This document will use the range 192.168.2.11-15 for 5 nodes.
Next you'll need to gather your nodes and gather all of their ifconfig information. Simply run ifconfig to get the information. It should look something like the following:
pi@raspberrypi:~ $ ifconfig
eth0 Link encap:Ethernet HWaddr b8:27:eb:60:4e:8d
inet addr:192.168.3.7 Bcast:192.168.3.255 Mask:255.255.255.0
inet6 addr: fe80::ac1d:b639:17ad:7c74/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:18296 errors:0 dropped:0 overruns:0 frame:0
TX packets:7746 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1532275 (1.4 MiB) TX bytes:2424669 (2.3 MiB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:29520 errors:0 dropped:0 overruns:0 frame:0
TX packets:29520 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1
RX bytes:2802804 (2.6 MiB) TX bytes:2802804 (2.6 MiB)
wlan0 Link encap:Ethernet HWaddr 3c:33:00:4f:f4:70
inet addr:192.168.2.14 Bcast:192.168.2.255 Mask:255.255.255.0
inet6 addr: fe80::d801:9bbf:456d:a704/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:7 errors:0 dropped:6 overruns:0 frame:0
TX packets:43843 errors:0 dropped:12 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:812 (812.0 B) TX bytes:0 (0.0 B)We're going to be using the interface wlan0 so we really only need the information from that section.
Make sure you get that output for each of your nodes and copy it to a safe location.
ARP stands for address resolution protocol. It helps convert the 4-byte IP address into a devices hardware or MAC address.
For some reason the rtl8192cu driver can't get past this networking step so we help it out by adding manual ARP entries.
Run arp -an to look at the current ARP table
pi@raspberrypi:~ $ arp -an
? (192.168.2.15) at 3c:33:00:50:00:82 [ether] PERM on wlan0
? (192.168.3.1) at 44:8a:5b:9f:ca:96 [ether] on eth0
? (192.168.1.1) at <incomplete> on wlan0Notice that this ARP table contains an entry for 192.168.2.15 This is just one of the nodes that we wish to connect to. We want to add all of our nodes on the network to this ARP table. You can do so with the following command
arp -s _ipaddr_ _hwaddr_
Use the HWaddr from the ifconfig on each node in your network. Make sure that you don't mix up the IPs and their corresponding HW addresses from node to node or else it will result in communication errors. Make sure you perform these steps on every single node as well to complete the ARP tables.
After every node that you wish to communicate in the adhoc network has the ARP table completed you should be able to ping/SSH over the ad hoc network
pi@raspberrypi:~ $ ping 192.168.2.15
PING 192.168.2.15 (192.168.2.15) 56(84) bytes of data.
64 bytes from 192.168.2.15: icmp_seq=1 ttl=64 time=1.76 ms
64 bytes from 192.168.2.15: icmp_seq=2 ttl=64 time=1.00 ms
64 bytes from 192.168.2.15: icmp_seq=3 ttl=64 time=1.04 ms
64 bytes from 192.168.2.15: icmp_seq=4 ttl=64 time=1.65 ms
^C
--- 192.168.2.15 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3004ms
rtt min/avg/max/mdev = 1.003/1.366/1.765/0.347 ms