A while back I had written some wifi scanning code. I have re-synced with ns-3-dev and uploaded the code here, in case it is useful to someone:
http://code.nsnam.org/gjc/ns-3-wifi-scanning/
Caveats:
1- The code is experimental;
2- The active scanning is pessimistic, i.e. scanning takes longer time than real world, because it assumes all channels are busy with traffic and always spends 50 ms in each channel (real world cards are smarter and spend just a few ms if they do not sense any traffic in that channel). In any case, it works, in spite of being rudimentary.
3- The code has not been reviewed yet by Mathieu, the WiFi maintainer, although I hope he will consider it ;-)
4- I don't have a lot of time to maintain the code, so it would be wonderful if someone could pick it up. Maybe I might develop something more on top of this, or maybe not, I am not sure yet...
Further things to implement:
1- Switching channels should consume between 1 and 5 ms (hardware limitations) [1];
2- Probing a "free" channel should require a delay of only 1-2 ms (aka "minimum channel time"), and 10 to 27 ms (aka "maximum channel time") for busy channels [1];
3- Due to inter-channel interference, additional channels may erroneously appear busy and thus cause additional scanning delays (has to spend maximum channel time, instead of minimum, for additional channels), so without the inter-channel interference model mentioned by Mathieu scanning delays might be too optimistic;
4- The scanning machinery should somehow record the "signal quality" of the received ProbeResponses, and report it back to the client, so that the client can choose the best AP based on signal strength;
5- The final piece of the puzzle would be to implement a MobilityManager kind of object, attached to the node, which would select the best AP at all times. Right now NS 3 has very rudimentary mobility management. An experiment I have made: place two APs on the same channel, same SSID, spaced by 100 meters; move a STA to the space in the middle of the two APs; the STA starts receiving beacons from both APs, and it keeps associating to one and other AP, constantly flip-flopping its association between the two APs.
[1]
Murray, D.
Dixon, M.
Koziniec, T., "Scanning Delays in 802.11 Networks", NGMAST '07. (
http://ieeexplore.ieee.org/xpls/abs_all.jsp?arnumber=4343430)
--
Gustavo J. A. M. Carneiro
INESC Porto, Telecommunications and Multimedia Unit
"The universe is always one step beyond logic." -- Frank Herbert