0

Raspberry Pi, wireless dongle, hostapd
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Re: Raspberry Pi, wireless dongle, hostapd

by gadjetnut on Sat Oct 11, 2014 11:58 am

I have my Raspbery Pi working as an access point but now I would like for it to scan for available SSID's. I am using the following code:

Code: Select all | TOGGLE FULL SIZE
#!/usr/bin/python

### We import the scapy module into our program here
from scapy.all import *

#we define a list calles aps to store all APs we detect
aps = []

#The following function is a packet handler that will check each packet as it  $
#is passed by the sniffer. If the packet has an 802.11 layer and the type is 0
#which is a management frame and subtype 0. If the AP's address is not already $
# the aps list then add it to the list and print it.
def PacketHandler(pkt) :
        if pkt.haslayer(Dot11) :
                if pkt.type == 0 and pkt.subtype == 8 :
                        if pkt.addr2 not in aps :
                                aps.append(pkt.addr2)
                                print "Found BSSID %s and SSID %s " %(pkt.addr2$


In order for this to work the WIFI module needs to be in monitor mode.

The following command are meant to put the wifi interface into monitor mode:

Code: Select all | TOGGLE FULL SIZE
sudo ifconfig wlan0 down
sudo iwconfig wlan0 mode Monitor
sudo ifconfig wlan0 up


However I get the following error:

Error for wireless request "Set Mode" (8B06) :
SET failed on device wlan0 ; Invalid argument.

Any idea how to put the the Adafruit wifi module into monitor mode?

I am using:

https://www.adafruit.com/products/814

gadjetnut
 
Posts: 9
Joined: Thu Jul 25, 2013 10:20 pm

Re: Raspberry Pi, wireless dongle, hostapd

by adafruit_support_mike on Sun Oct 12, 2014 6:59 pm

The rtl8192cu chipset included in a standard Raspbian distro only supports a limited subset of what the chip can do.

The standard driver (from Realtek) had major stability problems when running the RasPi.. it would drop 30% to 80% of all incoming packets.. so the Raspbian developers wrote a streamlined driver that worked well as a client and host, but didn't do anything more than was absolutely necessary in those two roles.

The stability problems in the Realtek driver seem to have been isolated to a power-saving feature getting triggered incorrectly when the device is connected to a RasPi. The RasPi USB ports are limited to a total of 140mA current, and the wifi dongle can see that as a sign that the computer has gone to sleep. The driver puts the dongle into low-power mode, but then the next incoming data packet wakes it up again. Then the driver puts it back to sleep, the next packet wakes it again, etc.

You can download and compile your own version of the Realtek driver from their website. The overall instructions are the same as for installing a fresh version of `hostapd` here:

https://learn.adafruit.com/setting-up-a ... ng-hostapd

but you compile the driver too. All the relevant code is contained in the same bundle.

To avoid the power-down problems, you can use the workaround at the end of the general wifi tutorial:

https://learn.adafruit.com/adafruits-ra ... -configure

adafruit_support_mike
 
Posts: 59205
Joined: Thu Feb 11, 2010 2:51 pm

Re: Raspberry Pi, wireless dongle, hostapd

by dmanman on Wed Oct 22, 2014 5:38 am

What is the correct ftp to download the file?

dmanman
 
Posts: 2
Joined: Wed Oct 22, 2014 5:37 am

Re: Raspberry Pi, wireless dongle, hostapd

by dmanman on Wed Oct 22, 2014 5:39 am

What is the correct ftp address to download the fix?

dmanman
 
Posts: 2
Joined: Wed Oct 22, 2014 5:37 am

Re: Raspberry Pi, wireless dongle, hostapd

by adafruit_support_mike on Thu Oct 23, 2014 11:20 pm

The Realtek downloads page is here:

http://152.104.125.41/downloads/downloa ... loads=true

You want the Unix drivers for the 8192cu series, located about halfway down the page.

adafruit_support_mike
 
Posts: 59205
Joined: Thu Feb 11, 2010 2:51 pm

Re: Raspberry Pi, wireless dongle, hostapd

by fmdr on Mon Oct 27, 2014 3:37 pm

Hi, I'm following, like all of you i guess, the adafruit manual but i get stuck in this step:

https://learn.adafruit.com/setting-up-a ... l-software

then i followed the instructions that sk00tr shared

viewtopic.php?f=19&t=47716#p240781

I got the drivers from the website, copy them in the sdcard and follow the instructions, all works fine. Then, I try the so called "First test!" running the command

sudo /usr/sbin/hostapd /etc/hostapd/hostapd.conf

and get an error. I took a screenshot you can see here

http://es.tinypic.com/view.php?pic=30v194o&s=8

Do I have to change the hostapd.conf driver field? If I do so, I'm told the driver is invalid/unknown

Thanks in advance
Attachments
Sin título.jpg
Sin título.jpg (150.79 KiB) Viewed 2107 times

fmdr
 
Posts: 1
Joined: Mon Oct 27, 2014 3:21 pm

Re: Raspberry Pi, wireless dongle, hostapd

by adafruit2 on Mon Dec 08, 2014 9:49 pm

heya, just a note that i've updated the tutorial and tested it with a fresh copy of Raspbian 9/9/2014 and our RTL wifi dongles and it works much better now.

adafruit2
Site Admin
 
Posts: 18711
Joined: Fri Mar 11, 2005 7:36 pm

Re: Raspberry Pi, wireless dongle, hostapd

by dvdroest on Fri Mar 06, 2015 6:38 pm

Hi,

I am getting the same issue as Powershift had, and am using the same product: https://www.adafruit.com/products/1030 WiFi USB stick and followed the Wireless Access point tutorial from your site.

When I run: sudo /usr/sbin/hostapd /etc/hostapd/hostapd.conf I get:
Configuration file: /etc/hostapd/hostapd.conf
drv->ifindex=3
l2_sock_recv==l2_sock_xmit=0x0x1168638
ioctl[SIOCSIWMODE]: Invalid argument
Could not set interface to mode(3)!
Could not set interface to master mode!
rtl871xdrv driver initialization failed.

Also after getting the latest hostapd version from realtek as posted before in this thread.

When I run: dmesg | grep usb I see:
[ 3.529072] usb 1-1.2: new high-speed USB device number 4 using dwc_otg
[ 3.769093] usb 1-1.2: New USB device found, idVendor=148f, idProduct=7601
[ 3.778266] usb 1-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 3.787836] usb 1-1.2: Product: 802.11 n WLAN

And my config for /etc/hostapd/hostapd.conf:
interface=ra0
driver=rtl871xdrv
ssid=RaspiDue
hw_mode=g
channel=6
macaddr_acl=0
auth_algs=1
#ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=something
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP

Please note that I have the new Raspberry Pi 2 on Raspbian with kernel version 3.18.
The device did not even show up in the beginning when running ifconfig, I had to install the custom made driver from: http://www.raspberrypi.org/forums/viewt ... &start=175 (the one for kernel 3.18.7-v7+ (for Raspberry Pi 2).).

This also causes the device to show up as ra0 instead of wlan0, no clue why that is, or if that matters.

I have also tried to install the latest drivers from realtek as listed earlier in this thread but that one always ends with:
make ARCH=armv7l CROSS_COMPILE= -C /lib/modules/3.18.7-v7+/build M=/tmp/RTL8188C_8192C_USB_linux_v4.0.2_9000.20130911/driver/rtl8188C_8192C_usb_linux_v4.0.2_9000.20130911 modules
make[1]: *** /lib/modules/3.18.7-v7+/build: No such file or directory. Stop.
Makefile:584: recipe for target 'modules' failed

Any ideas what I can still try?

Thanks in advance!

dvdroest
 
Posts: 6
Joined: Fri Mar 06, 2015 6:21 pm

Re: Raspberry Pi, wireless dongle, hostapd

by adafruit_support_mike on Sun Mar 08, 2015 6:02 am

Let's check the basics. What do you get from `ifconfig -a`?

adafruit_support_mike
 
Posts: 59205
Joined: Thu Feb 11, 2010 2:51 pm

Re: Raspberry Pi, wireless dongle, hostapd

by dvdroest on Sun Mar 08, 2015 11:15 am

Hey Mike,

The output of that is:

pi@raspberrypi ~ $ ifconfig -a
eth0 Link encap:Ethernet HWaddr b8:27:eb:07:16:e0
inet addr:192.168.178.51 Bcast:192.168.178.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1771 errors:0 dropped:1 overruns:0 frame:0
TX packets:77 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:92823 (90.6 KiB) TX bytes:11678 (11.4 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:8 errors:0 dropped:0 overruns:0 frame:0
TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1104 (1.0 KiB) TX bytes:1104 (1.0 KiB)

ra0 Link encap:Ethernet HWaddr ac:a2:13:1b:5b:bb
inet addr:10.5.5.1 Bcast:10.5.5.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:7070 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:1583927 (1.5 MiB) TX bytes:0 (0.0 B)

Thanks for helping out!

dvdroest
 
Posts: 6
Joined: Fri Mar 06, 2015 6:21 pm

Re: Raspberry Pi, wireless dongle, hostapd

by adafruit_support_mike on Sun Mar 08, 2015 10:06 pm

Hunh.. apparently the OS has decided to rename the port.

You should be able to get everything to work by replacing 'wlan0' with 'ra0'.

adafruit_support_mike
 
Posts: 59205
Joined: Thu Feb 11, 2010 2:51 pm

Re: Raspberry Pi, wireless dongle, hostapd

by dvdroest on Mon Mar 09, 2015 2:45 am

I actually already did that before...

But now I did give the opposite a go:

I added: ACTION=="add", SUBSYSTEM=="net", ATTR{type}=="1", KERNEL=="ra*", NAME="wlan0"
to: /etc/udev/rules.d/70-persistent-net.rules

And then changed back the ra0 references in /etc/hostapd/hostapd.conf and /etc/network/interfaces to wlan0

Now if I do: ifconfig -a I get:
eth0 Link encap:Ethernet HWaddr b8:27:eb:07:16:e0
inet addr:192.168.178.51 Bcast:192.168.178.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:295 errors:0 dropped:0 overruns:0 frame:0
TX packets:98 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:19065 (18.6 KiB) TX bytes:13210 (12.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:8 errors:0 dropped:0 overruns:0 frame:0
TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1104 (1.0 KiB) TX bytes:1104 (1.0 KiB)

wlan0 Link encap:Ethernet HWaddr ac:a2:13:1b:5b:bb
inet addr:10.5.5.1 Bcast:10.5.5.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:21989 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:4821729 (4.5 MiB) TX bytes:0 (0.0 B)

And when I do: sudo /usr/sbin/hostapd /etc/hostapd/hostapd.conf I get:
Configuration file: /etc/hostapd/hostapd.conf
drv->ifindex=3
l2_sock_recv==l2_sock_xmit=0x0x19b3638
ioctl[SIOCSIWMODE]: Invalid argument
Could not set interface to mode(3)!
Could not set interface to master mode!
rtl871xdrv driver initialization failed.

my hostapd.conf:
interface=wlan0
driver=rtl871xdrv
ssid=RaspiDue
hw_mode=g
channel=6
macaddr_acl=0
auth_algs=1
#ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=something
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP

Any more ideas?

dvdroest
 
Posts: 6
Joined: Fri Mar 06, 2015 6:21 pm

Re: Raspberry Pi, wireless dongle, hostapd

by adafruit_support_mike on Wed Mar 11, 2015 2:57 am

Do you have a non-v2 RasPi you can try?

I'm starting to suspect the new v2 driver, or maybe the kernel.

adafruit_support_mike
 
Posts: 59205
Joined: Thu Feb 11, 2010 2:51 pm

Re: Raspberry Pi, wireless dongle, hostapd

by dvdroest on Wed Mar 11, 2015 4:05 am

Hi Mike,

Unfortunately I do not....
Could you maybe see if it works on one of your Raspi 2's?

dvdroest
 
Posts: 6
Joined: Fri Mar 06, 2015 6:21 pm

Re: Raspberry Pi, wireless dongle, hostapd

by adafruit2 on Thu Mar 12, 2015 4:31 pm

Hiya, we have a new package that fixes a lot of stuff and doesnt require any configuration really. Please try it out on a fresh Raspbian image. connect Ethernet and WiFi first then, at the console or over Ethernet ssh:

curl -sLS https://apt.adafruit.com/add | sudo bash
sudo apt-get install adafruit-ap

adafruit2
Site Admin
 
Posts: 18711
Joined: Fri Mar 11, 2005 7:36 pm

Please be positive and constructive with your questions and comments.