# How to debug wireless host AP mode



## ralphbsz (Feb 18, 2014)

I'm using my FreeBSD server as a wireless AP, using an atheros 9285 card.  The system has two antennas, connected to the two ports of the card, which are mounted about 10 feet apart (using coax extension cables, at two different levels of the house, hidden in plastic tube inside of walls).  We're are in an extremely radio-quiet area (the nearest house is 1/2 mile away); I've used both channels 2 and 6 in 11g mode.  Clients are two Macs, one Dell Windows laptop, and one iPad.  This has worked OK for a while, but has always had issues.  The main issue is that the AP regularly goes into a mode where it complains continously about "ath0: stuck beacon; resetting (bmiss count 4)", at which point wireless service to the house is somewhere between intermittent and non-existing.  The only fix I know is to reboot (bringing the interface down and up doesn't help).  The bintval setting of the device has been increased to 300 ms, no effect.

Recently, this has become much worse.  Today, the storm of "stuck beacon" occurred twice already, each time with a reboot.  Right now, ping times from a Mac about 10 feet from one of the antennas fluctuate between 3ms and 5000ms, with 20% packet loss (that is with excellent signal strength).  The iPad has lost connection multiple times.

The real question is this: I have no idea what is causing it , and I have no idea how to debug it.  I don't know of any tools that allow me to show on the server (on the machine that is the AP) what connections it sees, what the error rates are, or what the noise level on the antenna is.  All I can see is to use "arp -a" to see which clients are (or were recently) connected.  I can change configurations (like switch between channels, move antennas, disconnect one of the two antennas), but with no feedback from the system, that's unlikely to be productive.

What debugging tools exist for host AP mode?


----------



## SirDice (Feb 18, 2014)

ralphbsz said:
			
		

> What debugging tools exist for host AP mode?


Run hostapd(8) with -d or -dd. See the hostapd(8) man page.

On what version of FreeBSD? A newer release may have improved drivers.


----------



## ondra_knezour (Feb 18, 2014)

The 9287 driver has been reported as improved, so may be upgrade or at least test with actual live cd is worth of try?


----------



## ralphbsz (Feb 18, 2014)

Never used `hostapd`, since we don't need authentication on our wireless (we're physically secure).  I'll install it tonight, set up -d or the debugging options in the config file, and see what I find.

Still running 9.0.  Upgrading to 9.2 is on my to-do list, but that's a huge project (I'll have to spend a day doing it).  I'll also see whether I can find a Ath9287-based card quickly; swapping that into the system is much less work than an OS upgrade, and might make a good short-term fix until I find time to do the OS upgrade.


----------



## ralphbsz (Feb 24, 2014)

Update: No news.  An Ath9287-based card has been ordered, but isn't here yet.  I made the problem partially go away, by switching the two antennas around (connecting antenna A to port B on the card).  And by instituting a new rule in our household: no network-intensive iPad usage (like watching videos) while a Mac is also running on the wireless.  This is a little inconvenient (Mac users sometimes have to get banished to sit near a wired network outlet if the rest of the family wants to watch a movie on the sofa), but the "stuck beacon" problem has become manageable now.

I also compiled `athstats` from the tools directory.  It shows fascinating statistics, which are hard to understand.  One fascinating tidbit from it: It seems the ath driver uses the two antennas highly asymmetrically, and nearly only receives on one antenna, and then transmits on the other one.  Since they are separated by about 15 feet, this is an interesting choice.  But no smoking gun.

I tried running `hostapd -d`, but it doesn't show anything interesting.  That's probably because I use no security at all on our wireless network (we are fortunately able to rely on physical security: the only people who can get to within 1/4 mile are our neighbors), and `hostapd` is mostly an authentication and security server.

More news after the Ath9287 card is installed, and the kernel upgraded to 9.2.


----------



## ralphbsz (Mar 6, 2014)

Update:


			
				ondra_knezour said:
			
		

> The 9287 driver has been reported as improved, so may be upgrade or at least test with actual live cd is worth of try?


9287-based card showed up a few days ago.  Swapped it in.  Did not upgrade FreeBSD itself.  Since then, most problems have gone away.  Signal strength is still not optimal everywhere in the house, and the two antennas are in widely spaced different locations, but fixing that will require a day of installing conduit.  Speed is good enough to function (a few Mbit/s), but way less than it should be.  But since it basically functions, this is a back burner issue.

There is one weirdness: athstats reports the following usage for the two antennas:

```
Antenna profile:
[0] tx  5544062 rx    67802
[1] tx        0 rx  5449198
```
Which, if true, would seem to indicate that it always transmits on the antenna that it doesn't receive on.  But since the two antennas are physically spaced far apart, that makes little sense, since each device will have much better connectivity to one antenna or the other.


----------

