Iwconfig

This is a module to work with the iwconfig command. Although iwconfig can be used to configure as well as query wireless interfaces, in this case I’ll just be using it to get information.

IwconfigEnum

A holder of constants so that users of this code will have a reference for the names used in the regular expressions.

IwconfigEnum : essid
IwconfigEnum : mac_protocol
IwconfigEnum : mode
IwconfigEnum : frequency
IwconfigEnum : access_point
IwconfigEnum : bit_rate
IwconfigEnum : tx_power
IwconfigEnum : link_quality
IwconfigEnum : signal_level
IwconfigEnum : rx_invalid_nwid
IwconfigEnum : rx_invalid_crypt
IwconfigEnum : rx_invalid_frag
IwconfigEnum : tx_excessive_retries
IwconfigEnum : invalid_misc
IwconfigEnum : missed_beacons

IwconfigExpressions

The IwconfigExpressions holds the compiled regular expressions to tokenize the output of the iwconfig command.

IwconfigExpressions.essid
return:compiled regular expression to match the essid
IwconfigExpressions.mac_protocol
return:regex to match protocol (requires self.interface to be set)
IwconfigExpressions.mode
return:compiled regex to match the mode (e.g. Managed)
IwconfigExpressions.frequency
return:compiled regex to get the frequency
IwconfigExpressions.access_point
return:compiled regex to get the access point
IwconfigExpressions.bit_rate
return:expression to get the bit rate
IwconfigExpressions.tx_power
return:compiled regex to match the tx-power
IwconfigExpressions.link_quality
return:compiled regular expression to get the link quality
IwconfigExpressions.signal_level
return:compiled regex to get the signal level
IwconfigExpressions.rx_invalid_nwid
return:compiled regex to get count of invalid nwid
IwconfigExpressions.rx_invalid_crypt
return:compiled regex to get count of un-decryptable packets
IwconfigExpressions.rx_invalid_frag
return:compiled regex to get count of invalid packet fragments
IwconfigExpressions.tx_excessive_retries
return:compiled regex to get count of packets hardware failed to deliver
IwconfigExpressions.invalid_misc
return:compiled regex to get count of packets lost for misc reasons
IwconfigExpressions.missed_beacons
return:compiled regex to get count of beacons from Cell or AP missed

IwconfigQuery

Notes

According to the current (December 13, 2013) Ubuntu 13.10 man-page:

  • ESSID identifies cells that are part of the same virtual network (all APs with the same ESSID)

  • Access Point is the specific AP within the virtual network that the node is associated with

  • mode can be one of:

    • Ad-Hoc (only one cell, no AP)
    • Managed (node cat connect to many APS (allows roaming))
    • Master (node acts as syncronization master or Access Point)
    • Repeater (forwards packets to other wireless nodes)
    • Secondary (acts as backup master/repeater)
    • Monitor (passively monitor all packets on the frequency (not associated with a cell))
  • Bit Rate is the speed at which bits are transmitted (user speed lower due to congestion and overhead)

  • RTS Threshold - threshold for handshake to make sure channel is clear (helps with congestion )

  • fragmentation splits IP packet into smaller fragments to help with interference

  • Rx invalid nwid is count of packets with different ESSID. Detects adjacent network on the same frequency.

  • Tx excessive retries is the number of packets not delivered.

  • Invalid misc is the number of packets lost for other wireless operations

  • Missed beacon is number of periodic beacons from the AP missed. Usually indicates out of range.

The Model and API

BaseClass <|-- IwconfigQuery
IwconfigQuery o- IwconfigExpressions

IwconfigQuery(connection[, interface, ...]) Queries iwconfig for information
IwconfigQuery.event_timer An EventTimer to track intervals between calling iwconfig
IwconfigQuery.output Output of the iwconfig command, refreshed after self.interval second intervals
IwconfigQuery.command
return:command to send to connection to query iwconfig
IwconfigQuery.essid
return:the essid from the iwconfig command
IwconfigQuery.mac_protocol
return:the MAC protocol
IwconfigQuery.mode
return:the mode
IwconfigQuery.frequency
return:current frequency
IwconfigQuery.access_point
return:MAC address of associated AP
IwconfigQuery.bit_rate
return:bit-rate
IwconfigQuery.tx_power
return:the TX-power for the node
IwconfigQuery.link_quality
return:link-quality perceived by driver
IwconfigQuery.signal_level
return:signal level (RSSI)
IwconfigQuery.rx_invalid_nwid
return:count of packets with SSID’s not matching current cell
IwconfigQuery.rx_invalid_crypt
return:count of packets not unencryptable
IwconfigQuery.rx_invalid_frag
return:count of packets whose fragments couldn’t be re-assembled
IwconfigQuery.tx_excessive_retries
return:count of packets not successfully transmitted
IwconfigQuery.invalid_misc
return:count of invalid packets (received only?)
IwconfigQuery.missed_beacons
return:count of beacons not received
IwconfigQuery.__call__() Calls the iwconfig command and returns the output
IwconfigQuery.__str__()
return:output of iwconfig command un-parsed
IwconfigQuery.check_errors(stderr) Checks for known errors
IwconfigQuery.close() Closes the event timer

Responsibilities

  • maintains the expressions needed to parse the output of the iwconfig command
  • issue command to connection
  • returns requested values from the iwconfig output

Collaborators

  • Connections