OSX wifi debug tool - airport

OSX wifi debug tool - airport

airport analysis

Backgroud

一直以来MAC OSX系统中,在双频合一的SSID下,总是莫名的Roaming到2.4G,需要从OSX下看看Wifi的log.发现了一个好的命令行工具airport.

Usage

  1. 创建软连接
sudo ln -s /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport /usr/local/bin/airport
  1. 使用说明
Usage: airport <interface> <verb> <options>

	<interface>
	If an interface is not specified, airport will use the first AirPort interface on the system.

	<verb is one of the following:
	prefs	If specified with no key value pairs, displays a subset of AirPort preferences for
		the specified interface.

		Preferences may be configured using key=value syntax. Keys and possible values are specified below.
		Boolean settings may be configured using 'YES' and 'NO'.

		DisconnectOnLogout (Boolean)
		JoinMode (String)
			Automatic
			Preferred
			Ranked
			Recent
			Strongest
		JoinModeFallback (String)
			Prompt
			JoinOpen
			KeepLooking
			DoNothing
		RememberRecentNetworks (Boolean)
		RequireAdmin (Boolean)
		RequireAdminIBSS (Boolean)
		RequireAdminNetworkChange (Boolean)
		RequireAdminPowerToggle (Boolean)
		WoWEnabled (Boolean)

	logger	Monitor the driver's logging facility.

	sniff	If a channel number is specified, airportd will attempt to configure the interface
		to use that channel before it begins sniffing 802.11 frames. Captures files are saved to /tmp.
		Requires super user privileges.

	debug	Enable debug logging. A debug log setting may be enabled by prefixing it with a '+', and disabled
		by prefixing it with a '-'.

		AirPort Userland Debug Flags
			DriverDiscovery
			DriverEvent
			Info
			SystemConfiguration
			UserEvent
			PreferredNetworks
			AutoJoin
			IPC
			Scan
			802.1x
			Assoc
			Keychain
			RSNAuth
			WoW
			P2P
			Roam
			BTCoex
			AllUserland - Enable/Disable all userland debug flags

		AirPort Driver Common Flags
			DriverInfo
			DriverError
			DriverWPA
			DriverScan
			AllDriver - Enable/Disable all driver debug flags

		AirPort Driver Vendor Flags
			VendorAssoc
			VendorConnection
			AllVendor - Enable/Disable all vendor debug flags

		AirPort Global Flags
			LogFile - Save all AirPort logs to /var/log/wifi.log

<options> is one of the following:
	No options currently defined.

Examples:

Configuring preferences (requires admin privileges)
	sudo airport en1 prefs JoinMode=Preferred RememberRecentNetworks=NO RequireAdmin=YES

Sniffing on channel 1:
	airport en1 sniff 1


LEGACY COMMANDS:
Supported arguments:
 -c[<arg>] --channel=[<arg>]    Set arbitrary channel on the card
 -z        --disassociate       Disassociate from any network
 -I        --getinfo            Print current wireless status, e.g. signal info, BSSID, port type etc.
 -s[<arg>] --scan=[<arg>]       Perform a wireless broadcast scan.
				   Will perform a directed scan if the optional <arg> is provided
 -x        --xml                Print info as XML
 -P        --psk                Create PSK from specified pass phrase and SSID.
				   The following additional arguments must be specified with this command:
                                  --password=<arg>  Specify a WPA password
                                  --ssid=<arg>      Specify SSID when creating a PSK
 -h        --help               Show this help
  1. 示例: 修改AutoJoin模式为Preferred,减少自动Roaming
llwangdeMini:~ llwang$ sudo airport prefs
Password:
AirPort preferences for en1:

DisconnectOnLogout=NO
JoinMode=Automatic
JoinModeFallback=DoNothing
RememberRecentNetworks=YES
RequireAdminIBSS=NO
RequireAdminNetworkChange=NO
RequireAdminPowerToggle=NO
WoWEnabled=YES

llwangdeMini:~ llwang$ sudo airport prefs JoinMode=Preferred JoinModeFallback=KeepLooking
llwangdeMini:~ llwang$ sudo airport prefs
AirPort preferences for en1:

DisconnectOnLogout=NO
JoinMode=Strongest
JoinModeFallback=DoNothing
RememberRecentNetworks=YES
RequireAdminIBSS=NO
RequireAdminNetworkChange=NO
RequireAdminPowerToggle=NO
WoWEnabled=YES

llwangdeMini:~ llwang$ 
  1. 示例: 显式打开LOG来Debug Wifi
$ sudo airport debug +AllUserland
$ sudo airport debug +AllDriver
$ sudo airport debug +AllVendor
$ sudo airport logger

LOG如下:

Tue Nov  7 13:13:13: AutoJoin: <airportd[59]> BEST CONNECTED ROAM triggered
Tue Nov 7 13:13:13: Driver Event: <airportd[59]> _bsd_80211_event_callback: APPLE80211_M_ROAM_START (en1)
  1. 示例:显式连接特定bssid AP
    OSX10.5
airport --associate=XXX --bssid=YYY

OSX10.9

airport --channel=11
  1. 示例: 空口抓包信道161
airport sniff 161

Reference

airport CLI
roaming issue on OSX


2017-11-7

posted on 2017-11-07 14:36  nicephil  阅读(893)  评论(0编辑  收藏  举报

导航