IWTAN user reference
IWTAN user reference
What is IWTAN
IWTAN stands for IWTAN: Wireless Topology ANalyzer. It is a Free Software, GPLv3'd library written in C with the main purpose of analyzing IEEE 802.11 wireless traffic and creating a easily-browsable data structure representing an infrastructure wireless network topology.
Wireless networks basically consists of a number of stations (clients of the net) and a number of access points. Each station is associated to an access point and uses the net sending data from and receiving by that access point.
Wireless stations and Access points can be identified by their MAC address, that should be worldwide unique. Wireless stations usually also have an IPv4 and/or IPv6 address, while access points don't (they work in layer 2).
A single AP and the stations associated to it form a BSS (Basic Service Set), identified by a single MAC address (the BSS Id). One or several wireless-interconnected BSSs form a DS (Distribution system). A DS connected to a wider net, such as the internet, forms an ESS (Extended Service Set), identified by the ESS Id, a string usually broadcasted by the access points. IWTAN is thought to analyze the traffic of one or more BSSs.
How does IWTAN work
IWTAN processes packets obtained by a pcap capture, extracting useful data about the network topology. A typical usage of IWTAN may be a program capturing data using libpcap and passing them to IWTAN in order to update the topology.
An IWTAN topology is a set of associations between stations and their AP. IWTAN also stores data about both the stations (such as the MAC address, the IP address, the time it was last seen) and the APs (such as the MAC address, the BSS id, the ESS id, the data rate, the signal strength). These data can be retrieved by the user using simple functions.
From different kind of packets, IWTAN can extract different kind of information. The type of analyzed data does not depend on IWTAN. The library just process any (significant) kind of packets and searches for interesting information. It is a task of the user to pass IWTAN interesting packets, making the wireless adapter capture frames as low-level as possible, as we'll see.
Stations and access points send to each other IEEE 802.11 Radiotap Header frames. This frames contain 802.11 WLAN frames, that may contain Wireless Management frames or Wireless Data frame. Wireless data frame contain regular traffic, such as IP packets. Most of the wireless adapter drivers, even in monitor mode, don't capture the Radiotap headers but just the WLAN frame, witch discards much interesting data. In the scheme you can see what kind of data can be extracted by different kinds of packets.
What data from what frames/packages type
Let's have some examples.
  1. IWTAN is given a Radiotap header frame. This frame is received by the access point (let's call it AP) and contains an IP packet from a host (H) in the internet to a station (STA) in the BSS. From such a kind of packet IWTAN can extract much useful information.
    • From the radiotap header we know some physical data like the signal strength, the data rate, the channel frequency.
    • The WLAN frame tells us some layer-2 data like the source (AP) and destination (STA) MAC address. This frame also tells us if the packet is sent from an access point to a station or vice-versa. In this way we can add a station and an access point to out topology.
    • The layer 3 (IP) packets tells us another information: the STA IP address. We can also obtain the H IP address, but we just don't care because it is outside the BSS and not part of the topology.
  2. Now let's assume the packet given to IWTAN is still radiotap-level but is now a beacon frame by the AP to broadcast its ESS id. We are now talking about a WLAN management frame instead of a data frame (so it does not contain an IP packet). From this kinds of packet we can obtain:
    • The same physical data from the radiotap header;
    • The ESS id from the management frame.
  3. Anyway, as said before, some wireless adapter drivers discard by default the radiotap header and gives to IWTAN just the WLAN frame. IWTAN can process this kinds of frames, but obviously cannot obtain physical data from them. So let's assume that IWTAN is given the same WLAN frame of the example above (an IP packet from a Host H to a station STA through an access point AP), without the Radiotap header. Analyzing this package, IWTAN can tell that there is an access point and a station, but don't know the signal strength.
How to use IWTAN
IWTAN provides some structures, one function to update the context, several data browsing functions, and some utility function.
Both the updating and browsing function use a context, witch is a data structure that contains all data obtained while processing packets. The number of different contexts created by an application is mostly like to be one, but several may exist. Several context may be useful, for example, if the program is centralized but obtain packets from geographically distant capture devices that the user want to keep separated.
Note that, when compiling a program using this library, you have to include both iwtan_data.h and iwtan_analyze.h, and, when compiling, link them against other libraries like (at least) libiw and libpthread with a gcc command like:
gcc iwtan_data.c iwtan_analyze.c PROGRAM.c -liw -lpthread -o OUTPUT
where PROGRAM.c is the file(s) containing the program code, and the other options link the libiw, and libpthread libraries.
An example program
An example program is provided in iwtan_example.c. What it does is simply capturing any kind of packet with libpcap from a capture file or a device and process them with IWTAN. The program terminates when a SIGINT (CTRL-X) signal is received and prints some data by the context, before freeing it.
To invoke it for reading by a capture device, type:
./iwtan_example -d ETHN where ETHN is the capture device.
To invoke it for reading by a packet capture file, type:
./iwtan_example -f FILENAME.pcap
Data structures
The data structures needed by the user, defined in iwtan_data.h are:
Context and refreshing functions
Browsing functions
Data utility functions
Notes about performance and portability
IWTAN applications are thought to be silent, witch means that its analyze over a network may not be seen, at network level, by anyone. What a regular PCAP application does is just capture flying packets, without interfering with the network transmissions. In this way, for example, the network performance is not affected.
IWTAN is thread-safe: access to write and read from a context are mutual excluded using a pthread lock. So there may be two concurrent threads, one calling the iwtan_refreshData() function, and the other calling any data-reading function, such as iwtan_get_all_APs(), keeping the data structure integrity.
IWTAN is portable and should run on any POSIX-compatible platform.
The memory used by this library is very small and there should not be memory leakage. Running a benchmark on a normal computer (1.66MHz Intel Centrino with a DDR RAM) resulted that IWTAN can process up to 120 packets per millisecond. Monitoring any packet flying over a regular wireless network, the CPU usage will be about 0.1% and the allocated context data structures will never be greater then some Kb.
Bug submission
Any problem can be submitted to my e-mail address: cornolti-at-cli-dot-unipi-dot-it.
For any bug about wrong extracted data, memory leakage, bad package data interpretation, and everything regarding packets processing, please attach a pcap capture of the packet(s) causing the bug.
Copyright
Copyright (C) 2008 Marco Cornolti

IWTAN (IWTAN: Wireless Topology ANalyzer) is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.

IWTAN is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with IWTAN; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.