Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am developing a tool-chain which performs automatically a network-benchmark and some security checks. As they have a very good reception, I am using two usb wifi antennas. In order to scan for and connect to open networks I have decided to use Ubuntu network managers command line interface (nmcli).

Scan for networks, sort SSIDs by signal strength and awk for unencrypted ones:

nmcli -t -f SSID,MODE,SIGNAL,SECURITY,BSSID dev wifi list iface $interface \
| sort -n -r -t: -k 3 \
| awk -F: '{ if ($2 == "Infrastructure" && $4 == "") 
        print substr($1, 2, length($1) - 2); }')

Connect to network, specifying the SSID and Access Point:

nmcli device wifi connect "$ssid" iface "$iface" bssid "$apmac" --timeout 20 

However, my timeout of 20 seconds is caught quite frequently. Checking /var/log/syslog, tells me, that although I am connecting to an unencrypted network, wpa_supplicant is called, which as far as I know should just be used in case of encrypted networks. Moreover, the ssid_scan parameter is set to 1, which means that a scan with SSID-specific probe request frames is done as an aid to find more APs. However, I specify an AP, so this test should be redundant. Last but not least, the "Association request to the driver failed" message worries me a little bit, but the WIFI connection works just fine afterwards.

21:48:12 NetworkManager[1108]: <info> Activation (wlan1) starting connection 'askUbuntu'
21:48:12 NetworkManager[1108]: <info> (wlan1): device state change: disconnected -> prepare (reason 'none') [30 40 0]
21:48:12 NetworkManager[1108]: <info> Activation (wlan1) Stage 1 of 5 (Device Prepare) scheduled...
21:48:12 NetworkManager[1108]: <info> Activation (wlan1) Stage 1 of 5 (Device Prepare) started...
21:48:12 NetworkManager[1108]: <info> Activation (wlan1) Stage 2 of 5 (Device Configure) scheduled...
21:48:12 NetworkManager[1108]: <info> Activation (wlan1) Stage 1 of 5 (Device Prepare) complete.
21:48:12 NetworkManager[1108]: <info> Activation (wlan1) Stage 2 of 5 (Device Configure) starting...
21:48:12 NetworkManager[1108]: <info> (wlan1): device state change: prepare -> config (reason 'none') [40 50 0]
21:48:12 NetworkManager[1108]: <info> Activation (wlan1/wireless): connection 'askUbuntu' requires no security.  No secrets needed.
21:48:12 NetworkManager[1108]: <info> Config: added 'ssid' value 'askUbuntu'
21:48:12 NetworkManager[1108]: <info> Config: added 'scan_ssid' value '1'
21:48:12 NetworkManager[1108]: <info> Config: added 'bssid' value '02:1a:11:ff:96:49'
21:48:12 NetworkManager[1108]: <info> Config: added 'key_mgmt' value 'NONE'
21:48:12 NetworkManager[1108]: <info> Activation (wlan1) Stage 2 of 5 (Device Configure) complete.
21:48:12 NetworkManager[1108]: <info> Config: set interface ap_scan to 1
21:48:12 NetworkManager[1108]: <info> (wlan1): supplicant interface state: inactive -> scanning
21:48:22 wpa_supplicant[1299]: wlan1: Trying to associate with 02:1a:11:ff:96:49 (SSID='askUbuntu' freq=2437 MHz)
21:48:22 wpa_supplicant[1299]: wlan1: Association request to the driver failed
21:48:22 NetworkManager[1108]: <info> (wlan1): supplicant interface state: scanning -> associating
21:48:22 kernel: [ 9205.713773] IPv6: ADDRCONF(NETDEV_CHANGE): wlan1: link becomes ready
21:48:22 wpa_supplicant[1299]: wlan1: Associated with 02:1a:11:ff:96:49
21:48:22 wpa_supplicant[1299]: wlan1: CTRL-EVENT-CONNECTED - Connection to 02:1a:11:ff:96:49 completed (auth) [id=0 id_str=]
21:48:22 NetworkManager[1108]: <info> (wlan1): supplicant interface state: associating -> completed
21:48:22 NetworkManager[1108]: <info> Activation (wlan1/wireless) Stage 2 of 5 (Device Configure) successful.  Connected to wireless network 'askUbuntu'.
21:48:22 NetworkManager[1108]: <info> Activation (wlan1) Stage 3 of 5 (IP Configure Start) scheduled.
21:48:22 NetworkManager[1108]: <info> Activation (wlan1) Stage 3 of 5 (IP Configure Start) started...
21:48:22 NetworkManager[1108]: <info> (wlan1): device state change: config -> ip-config (reason 'none') [50 70 0]
21:48:22 NetworkManager[1108]: <info> Activation (wlan1) Beginning DHCPv4 transaction (timeout in 45 seconds)
21:48:22 NetworkManager[1108]: <info> dhclient started with pid 4794
21:48:22 NetworkManager[1108]: <info> Activation (wlan1) Beginning IP6 addrconf.
21:48:22 NetworkManager[1108]: <info> Activation (wlan1) Stage 3 of 5 (IP Configure Start) complete.
21:48:22 dhclient: Internet Systems Consortium DHCP Client 4.2.4
21:48:22 dhclient: Copyright 2004-2012 Internet Systems Consortium.
21:48:22 dhclient: All rights reserved.
21:48:22 dhclient: For info, please visit https://www.isc.org/software/dhcp/
21:48:22 dhclient: 
21:48:22 NetworkManager[1108]: <info> (wlan1): DHCPv4 state changed nbi -> preinit
21:48:22 dhclient: Listening on LPF/wlan1/00:13:33:ab:ff:d2
21:48:22 dhclient: Sending on   LPF/wlan1/00:13:33:ab:ff:d2
21:48:22 dhclient: Sending on   Socket/fallback
21:48:22 dhclient: DHCPDISCOVER on wlan1 to 255.255.255.255 port 67 interval 3 (xid=0x3f3faafb)
21:48:24 avahi-daemon[1083]: Joining mDNS multicast group on interface wlan1.IPv6 with address fe80::213:33ff:feab:ffd2.
21:48:24 avahi-daemon[1083]: New relevant interface wlan1.IPv6 for mDNS.
21:48:24 avahi-daemon[1083]: Registering new address record for fe80::213:33ff:feab:ffd2 on wlan1.*.
21:48:25 dhclient: DHCPDISCOVER on wlan1 to 255.255.255.255 port 67 interval 6 (xid=0x3f3faafb)
21:48:25 dhclient: DHCPREQUEST of 192.168.43.72 on wlan1 to 255.255.255.255 port 67 (xid=0x3f3faafb)
21:48:25 dhclient: DHCPOFFER of 192.168.43.72 from 192.168.43.1
21:48:25 dhclient: DHCPACK of 192.168.43.72 from 192.168.43.1
21:48:25 dhclient: bound to 192.168.43.72 -- renewal in 1372 seconds.
21:48:25 NetworkManager[1108]: <info> (wlan1): DHCPv4 state changed preinit -> bound
21:48:25 NetworkManager[1108]: <info>   address 192.168.43.72
21:48:25 NetworkManager[1108]: <info>   prefix 24 (255.255.255.0)
21:48:25 NetworkManager[1108]: <info>   gateway 192.168.43.1
21:48:25 NetworkManager[1108]: <info>   hostname 'kearney'
21:48:25 NetworkManager[1108]: <info>   nameserver '192.168.43.1'
21:48:25 NetworkManager[1108]: <info> Activation (wlan1) Stage 5 of 5 (IPv4 Configure Commit) scheduled...
21:48:25 NetworkManager[1108]: <info> Activation (wlan1) Stage 5 of 5 (IPv4 Commit) started...
21:48:25 avahi-daemon[1083]: Joining mDNS multicast group on interface wlan1.IPv4 with address 192.168.43.72.
21:48:25 avahi-daemon[1083]: New relevant interface wlan1.IPv4 for mDNS.
21:48:25 avahi-daemon[1083]: Registering new address record for 192.168.43.72 on wlan1.IPv4.
21:48:26 NetworkManager[1108]: <info> (wlan1): device state change: ip-config -> secondaries (reason 'none') [70 90 0]
21:48:26 NetworkManager[1108]: <info> Activation (wlan1) Stage 5 of 5 (IPv4 Commit) complete.
21:48:26 NetworkManager[1108]: <info> (wlan1): device state change: secondaries -> activated (reason 'none') [90 100 0]
21:48:26 NetworkManager[1108]: <info> Writing DNS information to /sbin/resolvconf
21:48:26 dnsmasq[1682]: setting upstream servers from DBus
21:48:26 dnsmasq[1682]: using nameserver 192.168.43.1#53
21:48:26 dnsmasq[1682]: using nameserver 192.168.178.1#53
21:48:26 NetworkManager[1108]: <info> Activation (wlan1) successful, device activated.

15 seconds for a connection to an access point which is next to me seems like a HUGE overhead. How do I optimize my network manager configuration, so that connections to unencrypted wifi networks are set up as fast as possible?

share|improve this question
    
15 seconds to connect is average connect-time for Windows and Linux, secured or otherwise... is there any reason you say the connect time should be faster? –  Thomas W. Oct 14 '13 at 20:08
1  
As you can see from the logs, your system is scanning for wireless networks before it even tries to connect. I've seen wireless cards taking a lot of time scanning all channels. Most Intel cards just take a few seconds, but some other could take 10 seconds like yours seem to take. The actual time to connect to the network takes four seconds of which is three seconds for DHCP address configuration. Using static addresses would make it a single second to connect. Encryption or not, the connection time doesn't change much by the way. –  gertvdijk Oct 14 '13 at 20:10
    
@ThomasW.: My tool-chain operates in different modes, for two subtle modes the connection time (say 15 secs) is way higher than the tests (~2secs). @ gertvdijk: Is it possible to turn the channel scanning off or is it driver-related, ergo not possible to adjust? –  Oyks Livede Oct 14 '13 at 20:59

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.