Welcome! Log In Create A New Profile

Advanced

How To: Create an 802.11n AP (Access Point) w/ Debian on a Dockstar/Pogoplug/kirkwood device

Posted by davygravy 
0. Purpose, features and assumptions:
This writeup shows how I got my Pogoplug and a TP-Link TL-WN821N V3 (or TP-Link TL-WN822n V2) to work together as a 802.11n Wireless Access Point. The steps here are reproducible (they have been tested several times), and this unit works well enough for me to use daily at my workplace as my wireless AP, day-in, day-out.

Features:
  • full 802.11n speeds (between 75-100Mbps; without having 2 separate spatial streams, I don't think we can reach the theoretical 300Mbps)
  • authenticates wireless clients using WPA-PSK
  • excellent stability (no dropped connections, no crashes)
  • functions striclty as a bridge, passing DHCP and DNS traffic straight through from your main router
  • optional: can be turned into a brouter or router, by adding iptables or ebtables
As far as these instructions go, is an Access Point, not a router, brouter or anything else (it is not OpenWRT or TomatoUSB). It simply channels network connectivity from its wired ethernet port and makes that connection available to wireless clients, once a WPA passphrase is entered. Again, you can turn it into a router or brouter by adding iptables and/or ebtables, and a few other modifications.

Assumptions:
  • that you have a working knowledge of Linux
  • you are familiar with Debian's apt-get commands and CLI basics
  • and you understand how to use an editor such as nano
If this is not the case, then you may find it challenging to carry out the steps, or to understand what is being said. You have been warned. It could brick your Pogoplug, clog your sink, flatten your tires, wreck your life, motivate you to beg others to google stuff for you, and cause you to generally be a miserable person. Well, that didn't happen to me - my access point works great, and I didn't have any problems - I'm satisfied with it. But, then again, YMMV. Good luck.



1. Required Hardware:
  • Pogoplug, Dockstar or other supported plugcomputer
  • any USB Wireless 802.11n adapter with the following Atheros chipset/chipset combos:
    • the AR7010 and/or AR9287 chipset combination, which uses the ath9k-htc driver This chipset supports 802.11n speeds w/ hostapd Here is a link, though it seems to not be totally up-to-date : http://linuxwireless.org/en/users/Drivers/ath9k_htc#ath9k_htc
      I've tested it with two different adapters that use this chipset:
      • TP-Link TL-WN821N V3
      • TP-Link TL-WN822N V2 - this unit has dual dipole antennae, and puts out an amazingly strong signal
    • the AR9170 chipset, which, in the Linux 3.x kernel uses the carl9170 driver - TP-Link TL-WN821N V2, others also; see this link for more information : http://linuxwireless.org/en/users/Drivers/carl9170
    • ... any new N-capable chipset that you can dig up new documentation on... adjust directions that follow to your situation...
  • USB flash drive (less durable, slower, smaller), or USB-SATA drive (better choice for some)
  • optional : USB-to-ethernet adapter, so you can have an extra ethernet port to play with - handy if you are experimenting w/ routes, dhcp and dns


2. Install Debian Squeeze on your Dockstar's USB drive and then upgrade your kernel to make sure you are running a 3.3.x kernel.
(Originally, I recommended debootstrapping Squeeze and then dist-upgrading that to Wheezy, but here are some inherent problems with CUPS and other essential packages.)
I did this by following Jeff's Original Directions ( http://jeff.doozan.com/debian/ ) but using shyd's installer script (see http://forum.doozan.com/read.php?2,4244,4587#msg-4587 ) to get squeeze installed. Then go to the section in the Forum where my 3.3.2 Kirkwood kernel package is provided and install that. Restart and do:
uname -a
and you should see that you are running a 3.3.2 kernel.

Ideally, you want a 3.x.x kernel, since the driver for the ath9k usb adapters works very well. Some of the pre3.0 kernels had problems w/ the driver for the chipset we want to use. You could do this w/ an older kernel and modules, but with the new kernel working so well, seems like a less efficient choice.

3. Install the required packages and utilities:
apt-get install wpasupplicant hostapd bridge-utils wireless-regdb iw wireless-tools usbutils nano psmisc crda apt-utils dialog syslog-ng

Also, you'll probably need to pull in cdra and wireless-regdb from Squeeze-Backports.

Also install the firmware-atheros package. Since this package is in non-free, you must either edit your /etc/apt/sources.list to access the non-free packages, or simply download it from here : http://ftp.us.debian.org/debian/pool/non-free/f/firmware-nonfree/firmware-atheros_0.34_all.deb and install it via dpkg -i.
wget http://ftp.us.debian.org/debian/pool/non-free/f/firmware-nonfree/firmware-atheros_0.36_all.deb
dpkg -i firmware-atheros_0.36_all.deb
(Note: this package is updated frequently, so the version number of it may have changed.)





4. Check to see that your usb hardware is properly recognized:
Plug in your ath9k wireless usb adapter, and issue:
lsusb
You should see a line similar to this:
Bus 001 Device 003: ID 0cf3:7015 Atheros Communications, Inc. TP-Link TL-WN821N v3 802.11n [Atheros AR7010+AR9287]

Also, see if the kernel is seeing it correctly and that modules loaded as expected, by issuing:
lsmod | grep ath

You should see something like:
ath9k_htc              49588  0 
mac80211              194086  1 ath9k_htc
ath9k_common            1552  1 ath9k_htc
ath9k_hw              299341  2 ath9k_htc,ath9k_common
ath                    13478  2 ath9k_htc,ath9k_hw
cfg80211              140867  3 ath9k_htc,mac80211,ath
usbcore               118711  5 ath9k_htc,usb_storage,uas,ehci_hcd


5. Configure hostapd, network/interface and other settings:

a. Create hostapd's conf file, in /etc/hostapd/hostapd.conf, and set a wpa_passphrase of your own

nano /etc/hostapd/hostapd.conf
then copy the contents below into the file. Make sure you chose a wpa_passphrase. You can change the ssid to your liking.

#   /etc/hostapd/hostapd.conf
#   authoritative information and specifics are available here:
#   http://hostap.epitest.fi/gitweb/gitweb.cgi?p=hostap.git;a=blob_plain;f=hostapd/hostapd.conf


# if you want to bridge the onboard eth0 and the wireless USB adapter's wlan0, this should work
interface=wlan0
bridge=br0


# this is the driver that must be used for ath9k and other similar chipset devices
driver=nl80211


#  yes, it says 802.11g, but the n-speeds get layered on top of it
hw_mode=g


#  this enables the 802.11n speeds and capabilities ...  You will also need to enable WMM for full HT functionality.
ieee80211n=1
wmm_enabled=1



#  self-explanatory, but not all channels may be enabled for you - check /var/log/messages for details
channel=2
#  also, make sure you survey your 2.4GHz environment, and find some uncluttered/uncrowded channels



#   adjust to fit your location
country_code=US
#   Here is the authoritative list of countries:
#   http://www.iso.org/iso/country_codes/iso_3166_code_lists/country_names_and_code_elements.htm

#   let your AP broadcast the settings that agree with the above-mentioned regulatory requirements per country
ieee80211d=1


#   adjust to fit your preference
ssid=AirDebian


#   this is how I set mine up - works perfectly for iPhone, Mac OS X (SnowLeopard) & Linux
auth_algs=3
wpa=3
wpa_passphrase=*************************
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
macaddr_acl=0


#   these have to be set in agreement w/ channel and some other values... read hostapd.conf docs
ht_capab=[HT20][SHORT-GI-20]
#                                                        ...  these can be tuned to specific capabilities per device/chipset


#  IIUC, this enables reauthentication for clients, so the passphrase doesn't have to be re-entered
eap_reauth_period=360000000
#   ... my understanding... 3600 seconds = 1 hr, so your device would have to reauthenticate if it rejoined after 1 hr
#   I have mine set quite a bit higher than 3600 seconds... so that my iPhone doesn't ask me to type in the password 
#   frequently...  


# makes the SSID visible and broadcasted
ignore_broadcast_ssid=0




#  debugging output - uncomment them to activate; issue  hostapd -d /etc/hostapd/hostapd.conf
#  to get debugging info in visible/real-time form
#logger_syslog=-1
#logger_syslog_level=2
#logger_stdout=-1
#logger_stdout_level=2

b. Disable the regular startup of hostapd via the init script in /etc/init.d/hostapd, so that it will be started up just after br0 is brought up. The easiest way do this is to move it to /.
cd /etc/init.d/
mv hostapd ../../

c. Set up your /etc/network/interfaces: Move the stock file to a backup name, and then create a new file, copying in the contents below and saving it.

cd /etc/network
mv interfaces interfaces.stock-backup
nano interfaces

You will have to adjust the contents below somewhat to fit your own network, your router's (gateway) address, and the addresses that you want to use for eth0, br0 and wlan0. The file contents below are commented, but it is assumed that you have a good working knowledge of this sort of thing.
#   /etc/network/interfaces

###  NOTE:  This setup works for my network. All of these interfaces have IPs set statically.  You
###  	      may decided to try to change that and have one or more of them set dynamically. YMMV.
###
###		      The IP ranges show are generic : change them to fit your network.
###                 In this setup,  the network's router is @ 192.168.1.1
###							eth0 is @ 192.168.1.14
###							br0 is @ 192.168.1.13



#  bring up both br0 and eth0 when booting
auto lo br0 eth0


# Loopback Interface
iface lo inet loopback


# Internet Interface
iface eth0 inet static
        address 192.168.1.14
        gateway 192.168.1.1
        network 192.168.1.0
        netmask 255.255.255.0
        broadcast 192.168.1.255

	
# Wireless Interface
iface wlan0 inet static
        address 192.168.1.15
        network 192.168.1.0
        gateway 192.168.1.1
        netmask 255.255.255.0
        broadcast 192.168.1.255


# Bridge interface: use eth0 and wlan0 
#		            bring br0 up, then add a route to reach the router/gateway, 
#					then start hostapd after a 10 second pause (let devices settle)
iface br0 inet static
	bridge_ports eth0 wlan0
	address 192.168.1.13
        network 192.168.1.0
        gateway 192.168.1.1
        netmask 255.255.255.0
        broadcast 192.168.1.255
        up /sbin/ifconfig br0 up 
        post-up /bin/sleep 10 ; /usr/sbin/hostapd -B /etc/hostapd/hostapd.conf 
 	pre-down /usr/bin/killall hostapd
        down /sbin/ifconfig br0 down

d. Edit /etc/resolv.conf to point to your nameserver (dns server). This may be optional for you - I didn't have to.

6. Reboot, wait for the green light, and test it out. Two things you should check
  • Determine that you can ssh back into your pogoplug/dockstar.
  • Using a laptop, iPhone, or other wireless client, you should also be able to connect wirelessly now, as well, using the wpa_passphrase that you entered.

7. Tune your AP's settings for its WiFi adapter for optimum performance
a. Survey your local 2.4 GHz (or if applicable, 5 GHz) environment. Use an application like iStumbler or Stumbler, accumulating samples for at least 15 minutes, as often/frequently as your software allows you to (mine allowed sampling every 10 seconds), from both inside your house and (if possible) outside. You want to know how many of the channels are occupied in your area. Determine the least-used, least-crowded channel(s). This is NOT an optional step if you want optimum performance. Once you choose a "clear channel" for yourself, edit /etc/hostapd/hostapd.conf to reflect your new channel choice.

b. Check your USB WiFi adapter's capabilities: while logged into your AP via ssh, issue the command :
iw list
and note the capabilities it lists. My TP-Link WN821N V3 lists the following:

root@AirDebian:~# iw list
Wiphy phy0
	Band 1:
		Capabilities: 0x116e
                        HT20/HT40
			SM Power Save disabled
			RX HT20 SGI
			RX HT40 SGI
			RX STBC 1-stream
			Max AMSDU length: 3839 bytes
			DSSS/CCK HT40

Since the neighborhood I live it is crowded w/ 2.4GHz traffic, I couldn't get HT40 to work well. HT20 worked great for me, and I set my ht_capab in /etc/hostapd/hostapd.conf to read like this:
ht_capab=[HT20][SHORT-GI-20][RX-STBC1]

c. Use iperf or some sort of network throughput meter to check your speed and robustness, and refine further, if necessary. I did not get great benefit out of using iperf, but rather found that booting my laptop into Mac OS X 10.6.6, and using ActivityMonitor.app to monitor the transfer speed of a 1GB file was very effective. My personal finding was that I had to decrease the txpower from 20dBm to 12dBm to get perfect stability. Otherwise my card would overheat and stop working. [it is possible that the chip in my TP-Link WN821N V3 simply needs a heat sink of some sort, but I've not tried testing that solution.]

Optional step - use only if you are having stability problems or serious overheating on the USB dongle: I fixed my stability problems by throttling by the txpower to about 60% of max, this way... in my /etc/network/interfaces, I now have the following in the br0 stanza:
(note the iwconfig wlan0 txpower 12 in the post-up line.
  
 


#  Bridge interface: use eth0 and wlan0 
#  bring br0 up, then add a route to reach the router/gateway, 
#  then start hostapd after a 10 second pause (let devices settle)
iface br0 inet static
        bridge_ports eth0 wlan0
        address 192.168.1.13
        network 192.168.1.0
        gateway 192.168.1.1
        netmask 255.255.255.0
        broadcast 192.168.1.255
        up /sbin/ifconfig br0 up
        post-up /bin/sleep 10 ; /usr/sbin/hostapd -B /etc/hostapd/hostapd.conf ; iwconfig wlan0 txpower 12
        pre-down /usr/bin/killall hostapd
        down /sbin/ifconfig br0 down


#
#





8. Finish up odds-and-ends, add packages to your liking, and for you needs.
    Take your pick from below... my own arrangement now has basic web status page that shows the following:
    hard drive space and SMART status, USB printer and ink levels, AP channel and attached clients, and running servers...
  • set /etc/hostname to something more descriptive than "debian"
  • set the root password to something other than "root"
  • set your timezone: dpkg-reconfigure tzdata
  • optional: add samba & swat, netatalk, and avahi-daemon so that your AP can function as a NAS device, in addition.
  • optional: add p910nd (non-spooling print server for USB printers) or CUPS
  • optional: add a dnsmasq, dhcp server, iptables and/or ebtables to turn it into a full-fledge router
  • optional: enable correct LED behavior by changing arcNumber in uBoot env, & adding code in /etc/rc.local script


References:
  1. http://www.mikrocontroller.net/topic/193795
  2. http://linuxwireless.org/en/users/Documentation/hostapd
  3. http://forum.ubuntuusers.de/topic/accesspoint-mit-tl-wn821n-version/2/
  4. http://www.su-root.eu/computing/turn-your-linux-computer-in-a-wireless-access-point-using-hostapd
  5. http://blogs.cs.st-andrews.ac.uk/devan/2010/07/21/how-to-build-a-802-11n-wireless-ap-with-debian/
  6. http://www.robert-heyward.com/rjh/?page_id=12
  7. https://forum.openwrt.org/viewtopic.php?id=24610
  8. http://linuxwireless.org/en/users/Documentation/iw#Getting_device_capabilities
  9. http://forums.whirlpool.net.au/archive/1310314



*********************************************
*********************************************
*********************************************
*********************************************


Original 1st post of thread:
After some tinkering on a Pogoplug E02 and a TP-Link Wn-N821 V3 card, I've managed to get this far in Wheezy: Using the 3.1.0-1-kirkwood kernel, wireless-tools, dhcp3, and other bits and pieces, it boots, creates and configures wlan0 as the wireless interface, brings up hostapd & the interface in master mode, invites my Mac Airbook to associate w/ it, and it issues a dhcp lease. I confirm that the lease is written to the lease file on the AP. Also the Mac Airbook shows the leased dhcp IP.

Unfortunately, something w/ routing is borked, I think, as I can't ping anything on the other side, from either side... seemingly no connectivity... I cannot ping the AP (neither eth0 nor wlan0) from the Airbook, nor the other way around.
NOTE/EDIT: I've found that if I connect two wireless client to the AP, I can access them from each other. I confirmed that with my iPhone and MacBook air.

iwconfig
lo        no wireless extensions.

eth0      no wireless extensions.

wlan0     IEEE 802.11bgn  Mode:Master  Frequency:2.417 GHz  Tx-Power=20 dBm   
          Retry  long limit:7   RTS thr:off   Fragment thr:off
          Power Management:off
          
mon.wlan0  IEEE 802.11bgn  Mode:Monitor  Tx-Power=20 dBm   
          Retry  long limit:7   RTS thr:off   Fragment thr:off
          Power Management:off

route
default         192.168.11.xx    0.0.0.0         UG    0      0        0 eth0
192.168.11.0    *               255.255.255.0   U     0      0        0 eth0
192.168.11.0    *               255.255.255.0   U     0      0        0 wlan0



Anybody have experience w/ this? (I've read what I could find in terms of suggestions & fixes... not seeming to see the right fix, though)

=====================================================



Edited 64 time(s). Last edit at 08/24/2012 06:35PM by davygravy.
Re: Creating an AP (Access Point) w/ Debian on a Dockstar/Pogoplug/otherkirkwood device
November 28, 2011 02:40AM
Your wireless device needs to have a satic ip like: 192.168.1.1 netmask 255.255.255.0

Your dhcp server needs the following parameters:

subnet: for example 192.168.1.0/24
gateway: that gives you internet connection; for example; 192.168.1.254
and a range to give ip's; example: 192.168.1.10 192.168.1.20.

If you don't specify domain-name-servers on the dhcp server configuration file you will need to set your local server as dns server with (for example) dnsmasq. Dnsmasq only read /etc/resolv.conf on your host and provide this info to your clients.

please check this stuff and tell me; you must have a route chain that says: destination: 0.0.0.0 gateway: 192.168.1.1 netmask 255.255.255.0 if you write 'route -n' on your mac's prompt

Good luck!
Re: Creating an AP (Access Point) w/ Debian on a Dockstar/Pogoplug/otherkirkwood device
November 28, 2011 06:51AM
On my Mac, I see this from the Network Utility: (this is from the BSD-ish Darwin toolset, not from Linux)

Routing tables

Internet:
Destination        Gateway            Flags        Refs      Use   Netif Expire
127                localhost          UCS             0        0     lo0
localhost          localhost          UH              7      816     lo0
169.254            link#4             UCS             0        0     en1
192.168.11         link#4             UC              3        0     en1
192.168.11.5       link#4             UHLWI           1        4     en1
192.168.11.16      localhost          UHS             0        0     lo0
192.168.11.255     link#4             UHLWbI          1        1     en1
224.0.0/4          lo0                UmCS            2        0     lo0
224.0.0.251        lo0                UHmW3I          0        0     lo0   3549

Internet6:
Destination        Gateway            Flags         Netif Expire
localhost          localhost          UH              lo0
fe80::%lo0         localhost          Uc              lo0
localhost          link#1             UHL             lo0
fe80::%en1         link#4             UC              en1
fe80::210:75ff:fe1 blahblahc   UHLW            en1
airmini10v.local   0:blahblah   UHL             lo0
fe80::5e59:48ff:fe 5cblahgblah  UHLW            en1
fe80::%en0         link#5             UC              en0
ff01::             localhost          Um              lo0
ff02::             localhost          UmC             lo0
ff02::             link#5             UmC             en0

=====================================================



Edited 3 time(s). Last edit at 11/28/2011 05:30PM by davygravy.
Re: Creating an AP (Access Point) w/ Debian on a Dockstar/Pogoplug/otherkirkwood device
November 28, 2011 05:05PM
???? :^/ I'm puzzled, since the routing tables shown on my AirBook do not significantly differ, whether I'm connected via an Asus RT-N16 router, or my Pogoplug AccessPoint...

I booted my Airbook into Ubuntu and ran Network Utils ... here is Linux-style routing table (rather than the BSD-ish Darwin/OS X output I first put up) - connected to the PogoPlug Access Point

Destination	Gateway	 Netmask	Interface
192.168.11.0	0.0.0.0	 255.255.255.0	eth3
169.254.0.0	0.0.0.0	 255.255.0.0	eth3
0.0.0.0	       192.168.11.5	0.0.0.0	eth3
fe80::	::	64	eth3
::	::	0	lo
::1	::	128	lo
fe80::2blahblahblah	::	128	lo
ff00::	::	8	eth3
::	::	0	lo


Now, using my Airport-ish TomatoUSB Asus router, which give a perfect connection, I see the following routing table:

Destination	Gateway	Netmask	Interface
169.254.0.0	0.0.0.0	255.255.0.0	eth3
192.168.0.0	0.0.0.0	255.255.0.0	eth3
0.0.0.0	192.168.11.5	0.0.0.0	eth3
fe80::	::	64	eth3
::	::	0	lo
::1	::	128	lo
fe80::223:4eblahblahblah	::	128	lo
ff00::	::	8	eth3
::	::	0	lo

=====================================================



Edited 1 time(s). Last edit at 11/28/2011 05:25PM by davygravy.
Re: Creating an AP (Access Point) w/ Debian on a Dockstar/Pogoplug/otherkirkwood device
November 28, 2011 07:27PM
OK, made some progress ... I can now connect to the AP w/ any wireless client, ssh into the AP ... and see other devices on the AP ... just can't "get out" of the AP's subnet to the rest of my network or to the internet...


EDIT: Now have solved a DNS problem and can wirelessly ssh into my AP via either interface's IP, and can access the internet from there (from the AP). Now just need to pass that connectivity directly along to attached wireless clients.


EDIT2: Getting closer: I just have to come up w/ a nice, clear way to use iptables to move everything back and forth between eth0 and wlan0.
Ideas, anyone?

=====================================================



Edited 4 time(s). Last edit at 11/29/2011 12:57AM by davygravy.
Re: Creating an AP (Access Point) w/ Debian on a Dockstar/Pogoplug/otherkirkwood device
November 29, 2011 08:14AM
OK!

If you want to have a router on your device you'll need to activate ip_forward. The easiest way is type on your prompt:

echo "1" > /proc/sys/net/ipv4/ip_forward

The other thing needed is activate NAT:

iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE


Everything works now... Or it should work :)
Re: Creating an AP (Access Point) w/ Debian on a Dockstar/Pogoplug/otherkirkwood device
November 29, 2011 04:09PM
bummer... hmmm...

cat /proc/sys/net/ipv4/ip_forward
1
root@AirDebian:~# iptables -vnL --line-numbers
Chain INPUT (policy ACCEPT 38 packets, 3381 bytes)
num   pkts bytes target     prot opt in     out     source               destination         

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
num   pkts bytes target     prot opt in     out     source               destination         

Chain OUTPUT (policy ACCEPT 17 packets, 1796 bytes)
num   pkts bytes target     prot opt in     out     source               destination         
root@AirDebian:~# iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE 
root@AirDebian:~# ping yahoo.com
PING yahoo.com (72.30.2.43) 56(84) bytes of data.
64 bytes from ir1.fp.vip.sk1.yahoo.com (72.30.2.43): icmp_req=1 ttl=57 time=95.0 ms
64 bytes from ir1.fp.vip.sk1.yahoo.com (72.30.2.43): icmp_req=2 ttl=57 time=96.1 ms
64 bytes from ir1.fp.vip.sk1.yahoo.com (72.30.2.43): icmp_req=3 ttl=57 time=94.3 ms
^C
--- yahoo.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2000ms
rtt min/avg/max/mdev = 94.388/95.209/96.167/0.814 ms
root@AirDebian:~# ping 192.168.11.5
PING 192.168.11.5 (192.168.11.5) 56(84) bytes of data.
From 192.168.11.15 icmp_seq=1 Destination Host Unreachable
From 192.168.11.15 icmp_seq=2 Destination Host Unreachable
From 192.168.11.15 icmp_seq=3 Destination Host Unreachable
From 192.168.11.15 icmp_seq=5 Destination Host Unreachable
From 192.168.11.15 icmp_seq=6 Destination Host Unreachable
From 192.168.11.15 icmp_seq=7 Destination Host Unreachable
From 192.168.11.15 icmp_seq=8 Destination Host Unreachable
From 192.168.11.15 icmp_seq=9 Destination Host Unreachable
From 192.168.11.15 icmp_seq=10 Destination Host Unreachable
^C
--- 192.168.11.5 ping statistics ---
12 packets transmitted, 0 received, +9 errors, 100% packet loss, time 11017ms
pipe 4
root@AirDebian:~#


unless anyone has another idea...

I think I may try ebtables and bridging...

EDIT: This looks promising: http://www.su-root.eu/computing/turn-your-linux-computer-in-a-wireless-access-point-using-hostapd

One issue is that the use of the ath9k chipset & driver w/ hostapd forces one to have to handle the br0 bridge interface in a special way, distinct and different from the other wireless cards. :^| ... still working at this... an irritating point of difference between this author's setup and mine is that he _has a built-in LCD/LED screen on his AP host_. My box doesn't. So if during the experimentation, one borks the network setup, there is no soft landing - you have to force a hard restart of the pogoplug, since your only window into it is via ethernet.


EDIT 2 : Success! at least a partial success... using the steps from the article above http://www.su-root.eu/computing/turn-your-linux-computer-in-a-wireless-access-point-using-hostapd I put script together that creates the bridge and brings it up as an interface. It is _truly_ a bridge, as the IP that my laptop receives is from my router, not from the subnet that is handled dhcp-wise on the AP. Something to be fixed is one pesky problem - when the bridge br0 interface is up, I can no longer contact the AP via ping, ssh or anything else. This certainly won't work. Maybe some routing or iptables stuff to fix still.

A clue is that just before the AP-bridge script was run, I saw a very weird IP table:
root@AirDebian:~# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.0.0     *               255.255.0.0     U     0      0        0 eth0

I think I know why this is, and i think it will be easy to fix.

EDIT3:

Not so easy, and I didn't understand after all as much as I thought I did.

Good stuff: the AP is fast, responsive and stable. What I still have to work on is some way to have access to eth0 while the bridge is up.


EDIT4:

Here is an article that has some ideas regarding how to get the br0 iface to be more useful...
http://www.linuxjournal.com/article/8172?page=0,1


If this doesn't work, I may try to truly create the bridge w/ just ebtables...

=====================================================



Edited 11 time(s). Last edit at 11/30/2011 10:54PM by davygravy.
Created an AP (Access Point) w/ Debian on a Dockstar/Pogoplug/otherkirkwood device
December 01, 2011 08:29PM
I've decided to go w/ a 2nd ethernet port ...

OK, I guess I have to surrender to hostapd, br0 and whatever else is conspiring against me. After 2 days of tinkering I cannot find a way to raise br0 (the bridge interface) and tap into it for ssh access (or other access) to the AP. The AP works great - on par w/ my RT-N16 router, in terms of connection strength, stability, etc... but I can't access the AP machine itself - just its very nice bridge interface br0... so my terms of surrender involve the purchase of a cheap $3 (USD) USB-to-Ethernet adapter.

I will use it to get access to the AP via the eth1 that it will provide (a second wired ethernet interface/port). This can be either a permanent solution, or a way into the box until I can figure a way out to access the AP via br0.

=====================================================



Edited 1 time(s). Last edit at 12/01/2011 08:42PM by davygravy.
Re: Creating an AP (Access Point) w/ Debian on a Dockstar/Pogoplug/otherkirkwood device
December 02, 2011 06:12AM
I have an AP working with Debian & hostapd with an ath9k usb card and a SINGLE ethernet port (both bridged); the hardware is NOT a plug device, but it is the same;

My configuration is:

ADSL Router: static IP -> 192.168.0.254/24
Wireless AP: static IP -> 192.168.0.254/24 with gateway: 192.168.254/24. I also edit /etc/resolv.conf to point to my wired router:

nameserver 192.168.0.254

The Wireless AP works as DHCP server (with isc-dhcp-server) and DNS forwarder (dnsmasq) while the DSL router works as internet connection and dynamic dns client.

Hostapd works great instead of my 333Mhz Via proccesor & 64MB ram; if you want I can post here my /etc/network/interfaces.

I'd recommend you that forget about DHCP and try static IP in both wireless ap (your pogo) and your router. The bacic configuration gives me this route table:

destination: gateway: netmask: interface:
192.168.0.0 192.168.0.1 255.255.255.0 br0
0.0.0.0 192.168.0.254 0.0.0.0 br0
Re: Creating an AP (Access Point) w/ Debian on a Dockstar/Pogoplug/otherkirkwood device
December 02, 2011 06:13AM
I have an AP working with Debian & hostapd with an ath9k usb card and a SINGLE ethernet port (both bridged); the hardware is NOT a plug device, but it is the same;

My configuration is:

ADSL Router: static IP -> 192.168.0.254/24
Wireless AP: static IP -> 192.168.0.254/24 with gateway: 192.168.254/24. I also edit /etc/resolv.conf to point to my wired router:

nameserver 192.168.0.254

The Wireless AP works as DHCP server (with isc-dhcp-server) and DNS forwarder (dnsmasq) while the DSL router works as internet connection and dynamic dns client.

Hostapd works great instead of my 333Mhz Via proccesor & 64MB ram; if you want I can post here my /etc/network/interfaces.

I'd recommend you that forget about DHCP and try static IP in both wireless ap (your pogo) and your router. The bacic configuration gives me this route table:

# destination: gateway: netmask: interface:
# 192.168.0.0 192.168.0.1 255.255.255.0 br0
# 0.0.0.0 192.168.0.254 0.0.0.0 br0
Re: Creating an AP (Access Point) w/ Debian on a Dockstar/Pogoplug/otherkirkwood device
December 02, 2011 06:31AM
kk ... that is very useful ... I'll try it this weekend...

thank you, pazos

and yes, could you please post your /etc/network/interfaces ?


and what commands do you use to raise the bridge? I have a script that I'd post here, but I'm going out the door to work and can't right now...

EDIT:
@ pazos: Good news for me... I decided to disregard what the documentation regarding hostapd & ath9k-usb units says, and just made standard bridge in /etc/network/interfaces... and boom, it works.

http://wiki.debian.org/BridgeNetworkConnections#Configuring_bridging_in_.2BAC8-etc.2BAC8-network.2BAC8-interfaces



I think that the only remaining problem may be making sure that br0 has a connection to the internet. The bridging function works well - my laptop and iPhone connect just as they should, and access to the internet for them is fine.

=====================================================



Edited 3 time(s). Last edit at 12/02/2011 11:05PM by davygravy.
Re: Creating an AP (Access Point) w/ Debian on a Dockstar/Pogoplug/otherkirkwood device
December 03, 2011 12:06AM
Done.

Boots, raises br0, starts hostapd, adds in necessary route for br0 to have access to internet. WPA-PSK works fine, speeds are the maximum our laptops can reach... I'm satisfied with it.

Once I get some time over the next week or 2 I'll clean up any cruft, and post reproducible steps for it.

I'd eventually like to attach a USB-sata2.5inch disk to it instead of the USB pendrive- more durable than the flash drive and can serve as NAS space, and also install p910nd on it so I can use it as a print server.

=====================================================
Re: Create an 802.11n AP (Access Point) w/ Debian on a Dockstar/Pogoplug/kirkwood device
December 03, 2011 06:44PM
CONGRATULATIONS!!! Sometimes it is better to 'Keep It Simple'

If you planned to attach usb storage why don't you get a spooling printer server like cups instead of p910nd ( that is a great piece of software for embedded devices like routers, but it lacks some exciting features of common unix printer system)

I'm working in a really interesting mod for my pink-pogo (sometimes I think it is interesting just for me :-p). It has two attached USB wireless dongles (one ath9k with hostapd & a realtek 8187 for client mode), one usb-to-rj45 interface and a 120GB hard disk to store some things. The device boots from NAND into a buildroot's like distro and it has some features like firewall (iptables & ebtables), download manager (just transmission-daemon for now). I'm currently adding a web interface to manage the device (I'm looking source code from monowall). The most basic feature of this device is getting wireless from realtek's wifi and pass throught the bridge (atheros & eth0/eth1). So far I get some basic PHP experience and both wireless interfaces (the AP and the client) can be managed via web (it is not perfect: i'm using an old fashioned way to get info about avaliable wireless conections that gives me some trouble)

Of course play is better than buy, and funnier too!
Lets go!
I did this w/ the Dockstar that I have, with a 500GB attached FreeAgent Go USB drive, and the TP-Link WN822N... the result is a very nice open-source-ish, with a very tiny physical footprint;


In terms of function, it is a Time Capsule/Wireless-NAS device & printserver, with good Apple, Windows and Linux support. Its wireless signal (at first look) seems to be about 85%-95% of the signal from my Asus RT-N16 (which was the creme-de-la-creme a year or 2 ago). True, it doesn't have a great webif, but I don't need that.

=====================================================
Re: Create an 802.11n AP (Access Point) w/ Debian on a Dockstar/Pogoplug/kirkwood device
December 14, 2011 08:56PM
pazos Wrote:
-------------------------------------------------------
> I'm currently adding
> a web interface to manage the device (I'm looking
> source code from monowall).

@pazos, it sounds very interesting! any chance you have something to share with us?

I'm using webmin, but the sw is just too much for non-tech users to navigate. I gave some of my Debian-based plugs to my relatives as gift, and they would rather have a simple interface that only allows shutdown, print spoolers, file sharing and such point-and-click stuff. I might have to learn CGI!
@bodhi

Of course I'll share the code when I have something usable & stable, but keep in mind that I have just implemented webconfig for network related tools. I'll upload files to github (just webconfig, boot-scripts and buildroot & kernel patches; all the rest is based on buildroot) when I finished some javascript related issues.

If you want a current screenshot check the attached file
Attachments:
open | download - screenshot.png (69.9 KB)
Re: How To: Create an 802.11n AP (Access Point) w/ Debian on a Dockstar/Pogoplug/kirkwood device
December 15, 2011 02:16PM
Thanks pazos! that looks really nice.
pazos, I agree w/ bodhi ... looks nice ... I realize/appreciate how much work this kind of thing is... as I made this [ https://sites.google.com/a/tds.net/unlock-your-verizon-westell-7501-wireless-g-router/ ] for a now unavailable g-router from Verizon... had to hatch up a new webif for the printer stuff ...

=====================================================
>how much work this kind of thing is?

I'm not the best person to ask for this such of things... It took me two days get a way to store all variables needed in just one config file and get a web that can do *something*...

https://sites.google.com/a/tds.net/unlock-your-verizon-westell-7501-wireless-g-router/

Um, it looks nice! very good work davygravy!!!, if you can't manage to run mini-httpd on port other than 80 you can start thinking in a *BASIC* configuration interface (AFAIK you store your custom configuration on a usb drive, no?)



Edited 2 time(s). Last edit at 12/15/2011 08:50PM by pazos.
Has anyone actually tested the wireless transfer rate of a TP-Link TL-WN821N V3 , TP-Link TL-WN822n V2 or any USB wireless adapter that is capable of being used with a pogoplug/dockstar device as an AP?

I have a TP-Link TL-WN822n V2, which I use in conjunction with a dockstar as an access point, and am unable to achieve a transfer speed above 0.5Mbps (megabits per second) when transferring between wired and wireless Windows 7 machines. When I use my standard 54Mbps wireless access point the transfer speed is approximately 26Mbps.

My hostapd.conf file is more or less identical to davygravy's: I use solely WPA2 AND CCMP encryption. My kernel is a self-compiled 3.1.5.
Clay Pidgeon (Kalli?), I get the following:

WN821n V3 : 144Mbps
WN822n V2 : 144Mbps
NetGear WNA1100 : 74Mbps

on a (psuedo) Mac Airbook with a wireless PCIe card ...

My iPhone gets about 40-50Mbps...

hth,

Davy

=====================================================



Edited 1 time(s). Last edit at 12/19/2011 11:34PM by davygravy.
davygravy Wrote:
-------------------------------------------------------
> Clay Pidgeon (Kalli?), I get the following:
>
> WN821n V3 : 144Mbps
> WN822n V2 : 144Mbps
> NetGear WNA1100 : 74Mbps
>
> on a (psuedo) Mac Airbook with a wireless PCIe
> card ...
>
> My iPhone gets about 40-50Mbps...
>
> hth,
>
> Davy

Thanks for all you work Davy; it is much appreciated.

I've managed to solve the file transfer problem: the WN822n V2 now transfers files faster than my standard 54Mps AP.
My problem was that I had not used crda to set the country_code for the WN822n V2.

crda is not an optional extra; it must be used to set the country code for ANY USB wireless adapter: otherwise the wireless adaper will not perform to its true potential.
@ Kalli Pidgeon: your question got me thinking... and I dug into some things with more scrutiny and skepticism... and it seems to have paid off (and it retaught me the lesson of not assuming things that are posted as fact on the web, even though they may sound authoritative...).


I've checked over my AP's performance with iperf [ a nice tutorial here: http://openmaniak.com/iperf.php ] , and I've discovered that it wasn't as fast as I thought... but I've made up a lot of ground in the process...

My RT-N16 (running TomatoUSB) gives me about 9-10MB/sec read and write. [ 70-80Mbps ]

Right now the best I can get from my AP is about 6-7 MB/sec read and write. I don't know if I can push it up to equal performance w/ my RT-N16/TomatoUSB router, but I'll try and post results here, showing what hostapd.conf settings gave.

My reading led me to try to disable HT40, and go with just HT20, and that _has_ panned out positively, moving me from about 2MB/sec to better than 3 times that. I'll post back here as I get more results.

=================================================

An essential step in getting one's AP to perform well is to do a very thorough and detailed survey of the wireless signal environment surrounding one's house/office/workplace. Not having an accurate profile of the number and channel-locations of cells near you can result in abysmal performance, perhaps leading one to think "these home-brewed AP's just don't work. " Actually, that is what I was suspecting... but after digging, I now know that they actually work just fine, but can be hampered (or even rendered nonfunctional) by stray signals/interference or traffic on the same channel as you are trying to occupy

I was shocked to see just how much chatter and traffic there was in the 2.4GHz band around our neighborhood. I counted 21 cells around us, mostly on channels 1, 4, 6 and 9. The only unoccupied channels are 2, 5, 7 and 10.

To profile the 2.4GHz environment surrounding our home, I did the following. I started up iStumbler on my (psuedo) Mac AirBook, and slowly walked around the house (outside), making sure I had it set to remember stations for an hour, and to scan every 10 seconds. Then I let the program run for another 20 minutes, with it just sitting in an upstairs room.

Choosing a channel that has __no__ traffic makes a huge difference.


====================================================

I also found that running the chip/USB adapter at full power (default) seems to allow it to become unstable and suddenly stop working. My theory is that it is overheating - I notice the crash and dropout when I'm testing it w/ 1GB files. If I cut the power back to 50% to 70%, these drop outs seem to stop completely and the card is much stabler.

magic incantation is...
iwconfig wlan0 txpower 14
for instance, to set it to 70% or 14/20 dBm. I currently have mine set at 50%, but this covers my house well, and gives me a decent signal outside on the porch, on the patio or at the picnic table in the back yard.

This may vary by manufacturer - perhaps some makers put a good heatsink on their units - it is my guess that TP-Link didn't expect users to use them as AP interfaces... but I don't know for sure.

=====================================================



Edited 5 time(s). Last edit at 12/22/2011 11:50PM by davygravy.
Finally found the sweet spot - the right settings so that my AP's performance is at least close to that of my Asus RT-N16 ... phew. I've changed the How-To to reflect my findings and fixes for some problems w/ speed and performance.


One thing that I've found in particular is that one really needs to check real-world transfer rates, in addition to the rates that are given by iw and other commands. Below are the rates that the iw command-line tool yields:
root@AirDebian:~# iw dev wlan0 station dump
Station 00:23:xx:xx:xx:xx (on wlan0)
	inactive time:	10 ms
	rx bytes:	834586
	rx packets:	6603
	tx bytes:	7086858
	tx packets:	6828
	tx retries:	0
	tx failed:	0
	signal:  	-55 dBm
	signal avg:	-55 dBm
	tx bitrate:	130.0 MBit/s MCS 15
Station 00:16:cf:xx:xx:xx (on wlan0)
	inactive time:	10150 ms
	rx bytes:	16775237
	rx packets:	192204
	tx bytes:	1223896351
	tx packets:	812640
	tx retries:	0
	tx failed:	0
	signal:  	-56 dBm
	signal avg:	-64 dBm
	tx bitrate:	39.0 MBit/s MCS 4
The first rate of 130MBits/sec is from my MacBook Air... and the second is from a g-device, my iPhone. While it is nice to see these rates, it is better to actually experience them, by doing transfers of large files. Such transfers give me about 85MBits/sec, typically, on the Airbook.

=====================================================



Edited 1 time(s). Last edit at 12/23/2011 12:56AM by davygravy.
@davygravy, just wanted to say THANK YOU! for posting this tutorial. I followed the Dec 23-11 version of the tutorial and can confirm that it works with a Pogoplug V2 (Pink) and the TP-Link TL-WN821N V2.

Also, two quick questions:

1. Any tips for adding a second wifi adapter to use in client mode? I'd like to have my Pogostick connect to my gateway router wirelessly.

2. What exactly is a (psuedo) Mac AirBook? I'm assuming it's a hackintosh of some sort...?



Edited 1 time(s). Last edit at 12/23/2011 09:18AM by MediaMind.
Hi mediamind

Yes you should be able to use a second USB stick as a client. Just thinking out loud here, not sure what the best choice as chipset would be, I'd definitely go with 802.11n to minimize lag/latency. You'll have to set up a new section in /etc/network/interfaces that passes along the passphrase to you wireless network. Definitely post back with your results, as someone will no doubt find it interesting.

Btw, I'm not sure whether it will simplify or complicate things to have the same chipset in your 2nd USB stick. If they are different, you may have to do something w/ udev in order to make sure the correct one gets mapped to AP usage.

Let's us know how you solution takes shape.


And yes, my little laptop that could is a Dell Mini 10v triple-boot, w/ 6 cell battery and a wireless n pcie card. Works like a charm.

=====================================================
Another footnote to add in to this How-To...

There is an interesting article here: http://forum.ubuntuusers.de/topic/accesspoint-mit-tl-wn821n-version/
After applying what little German I know to it, and using Google Translator to fill in the rest, it seems others have had some difficulty w/ the overheating problem also...

Three solutions now seem to exist:

1. Turn the txpower down (may reduce the range) - my idea
2. set ath9k_htc nohwcrypt=1 (may reduce transfer speed by 20-30%)
3. apply heat sink to chip

Actually, this article only mentions #2 and #3, but I've confirmed that #1 help somewhat...


... but ... today I decided to do an apt-get upgrade on my Wheezy install, and in pulled in a number of new packages... hostapd among them... and I've been running at full txpower for 24 hours, transferring about 150GB of files, back and forth and no hiccups... I'll keep stress-testiing it a bit more.

==========================

OK, now w/ 2 weeks of testing, and nary a hiccup... this is now my main wireless AP at home and at work.

=====================================================



Edited 2 time(s). Last edit at 01/08/2012 07:27PM by davygravy.
Great guide davygravy!

I am having trouble reproducing this now thou

I am unable to have the dist-upgrade go right. Every thing seems to work ok, but the system never comes backup. I do not own a serial cable yet so all the information i have is that it installes the 3.2.0-1-kirkwood and then when it reboots the led never lights and only the ethernet blinks. I am just wondering if you are having any issues with it as i see there are problems with the 3.2 and up kernels when you guys go to compile them.



Edited 1 time(s). Last edit at 02/12/2012 12:52PM by leapole.
Yes, there is a problem w/ the Wheezy kernel that is in testing. It will not boot on many/most kirkwood machines.

You may want to try to install Squeeze as the original, and then use my kernel here: http://forum.doozan.com/read.php?2,6578 towards the bottom I have links up for a 3.1.9 kernel I am running on one of my two AP's.

=====================================================



Edited 1 time(s). Last edit at 02/12/2012 02:26PM by davygravy.
Thank You for the Info - I am going to stop trying to get wheezy to boot for now.

I have installed your kernel 3.1.9. It works and everything boots but It does not see my tl-link 722n wifi chipset. I have installed the firmware-atheros and everything looks great in the lsusb and lsmod | grep ath but it dos not pick up my wifi cards.

I have tried many different combination and have been searching this board for the last week. I have re-installed my 3 pogoplugs at least 50 times this week.

I can get everything to work with gorgones heavy kernel but atk9 and the linux 2.6 kernel does not support putting the atk9 driver into AP mode.

Again thank you davygravy for the help
Author:

Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: