Esempio n. 1
0
    def test_dns_over_tls_no_reset_packets(self):
        """ Verify there are no TCP packets with RST flags

        Steps:
            1. Enable opportunistic or strict mode
            2. Ping hosts and verify that there are TCP pkts with RST flags
        """
        # start tcpdump on device
        self._start_tcp_dump(self.dut)

        # set private DNS to opportunistic mode
        cutils.set_private_dns(self.dut, cconst.PRIVATE_DNS_MODE_OPPORTUNISTIC)

        # connect DUT to wifi network
        wutils.start_wifi_connection_scan_and_ensure_network_found(
            self.dut, self.ipv4_ipv6_network[SSID])
        wutils.wifi_connect(self.dut, self.ipv4_ipv6_network)
        for host in self.ping_hosts:
            wutils.validate_connection(self.dut, host)

        # stop tcpdump on device
        pcap_file = self._stop_tcp_dump(self.dut)

        # check that there no RST TCP packets
        self._verify_rst_packets(pcap_file)
Esempio n. 2
0
    def test_dns_over_tls_no_reset_packets(self):
        """ Verify there are no TCP packets with RST flags

        Steps:
            1. Enable opportunistic or strict mode
            2. Ping hosts and verify that there are TCP pkts with RST flags
        """
        # start tcpdump on device
        self._start_tcp_dump(self.dut)

        # set private DNS to opportunistic mode
        self.dut.droid.setPrivateDnsMode(True)
        mode = self.dut.droid.getPrivateDnsMode()
        asserts.assert_true(mode == PRIVATE_DNS_MODE_OPPORTUNISTIC,
                            "Failed to set private DNS opportunistic mode")

        # connect DUT to wifi network
        wutils.wifi_connect(self.dut, self.wifi_network_with_dns_tls)
        for host in self.ping_hosts:
            wutils.validate_connection(self.dut, host)

        # stop tcpdump on device
        pcap_file = self._stop_tcp_dump(self.dut)
        self.log.info("TCPDUMP file is: %s" % pcap_file)

        # check that there no RST TCP packets
        self._verify_rst_packets(pcap_file)
    def _bluetooth_tethering_then_disconnect(self, pan_ad, panu_ad):
        """Test bluetooth PAN tethering connection then disconnect service.

    Test basic PAN tethering connection between two devices then disconnect
    service.

    Steps:
    1. Enable data connection on PAN device
    2. Disable data connection on PANU device
    (steps 3-7: orchestrate_and_verify_pan_connection())
    3. Enable Airplane mode on PANU device. Enable Bluetooth only.
    4. Enable Bluetooth tethering on PAN Service device.
    5. Pair the PAN Service device to the PANU device.
    6. Verify that Bluetooth tethering is enabled on PAN Service device.
    7. Verify HTTP connection on PANU device.
    8. Disable Bluetooth tethering on PAN Service device.
    9. Verify no HTTP connection on PANU device.

    Args:
      pan_ad: Android device providing tethering via Bluetooth
      panu_ad: Android device receiving tethering via Bluetooth

    Expected Result:
    PANU device has internet access only with Bluetooth tethering

    Returns:
      Pass if True
      Fail if False
    """

        if not wait_for_cell_data_connection(self.log, pan_ad, True):
            self.log.error("Failed to enable data connection.")
            return False

        panu_ad.droid.telephonyToggleDataConnection(False)
        if not wait_for_cell_data_connection(self.log, panu_ad, False):
            self.log.error("Failed to disable data connection.")
            return False

        if not orchestrate_and_verify_pan_connection(pan_ad, panu_ad):
            self.log.error("Could not establish a PAN connection.")
            return False
        internet = wutils.validate_connection(panu_ad, DEFAULT_PING_URL)
        if not internet:
            self.log.error("Internet is not connected with Bluetooth")
            return False

        # disable bluetooth tethering and verify internet is not working
        internet = None
        pan_ad.droid.bluetoothPanSetBluetoothTethering(False)
        try:
            internet = wutils.validate_connection(panu_ad, DEFAULT_PING_URL)
        except Exception as e:
            self.log.error(e)
        if internet:
            self.log.error("Internet is working without Bluetooth tethering")
            return False

        return True
Esempio n. 4
0
    def test_dns_server_link_properties_strict_mode(self):
        """ Verify DNS server in the link properties when set in strict mode

        Steps:
            1. Set DNS server hostname in Private DNS settings (stict mode)
            2. Verify that DNS server set in settings is in link properties
            3. Verify for WiFi as well as LTE
        """
        # start tcpdump on device
        self._start_tcp_dump(self.dut)

        # set private DNS to strict mode
        self.dut.droid.setPrivateDnsMode(True, DNS_QUAD9)
        mode = self.dut.droid.getPrivateDnsMode()
        specifier = self.dut.droid.getPrivateDnsSpecifier()
        asserts.assert_true(
            mode == PRIVATE_DNS_MODE_STRICT and specifier == DNS_QUAD9,
            "Failed to set private DNS strict mode")

        # connect DUT to wifi network
        wutils.wifi_connect(self.dut, self.wifi_network_no_dns_tls)
        for host in self.ping_hosts:
            wutils.validate_connection(self.dut, host)

        # DNS server in link properties for wifi network
        link_prop = self.dut.droid.connectivityGetActiveLinkProperties()
        dns_servers = link_prop['DnsServers']
        wifi_dns_servers = [each for lst in dns_servers for each in lst]
        self.log.info("Link prop: %s" % wifi_dns_servers)

        # DUT is on LTE data
        wutils.reset_wifi(self.dut)
        time.sleep(1) # wait till lte network becomes active
        for host in self.ping_hosts:
            wutils.validate_connection(self.dut, host)

        # DNS server in link properties for cell network
        link_prop = self.dut.droid.connectivityGetActiveLinkProperties()
        dns_servers = link_prop['DnsServers']
        lte_dns_servers = [each for lst in dns_servers for each in lst]
        self.log.info("Link prop: %s" % lte_dns_servers)

        # stop tcpdump on device
        pcap_file = self._stop_tcp_dump(self.dut)
        self.log.info("TCPDUMP file is: %s" % pcap_file)

        # Verify DNS server in link properties
        asserts.assert_true(DNS_QUAD9 in wifi_dns_servers,
                            "Hostname not in link properties - wifi network")
        asserts.assert_true(DNS_QUAD9 in lte_dns_servers,
                            "Hostname not in link properites - cell network")
    def test_single_scan_while_pno(self):
        """Test wifi scanner single scan parallel to PNO connection.

         1. Check device have a saved network.
         2. Trigger PNO by attenuate the signal to move out of range.
         3. Start WifiScanner single scan for both band with default scan settings.
         4. Verify that scanner report single scan results.
         5. Attenuate the signal to move in range.
         6. Verify connection occurred through PNO.
        """
        self.log.info("Check connection through PNO for reference network")
        current_network = self.dut.droid.wifiGetConnectionInfo()
        self.log.info("Current network: {}".format(current_network))
        asserts.assert_true('network_id' in current_network, NETWORK_ID_ERROR)
        asserts.assert_true(current_network['network_id'] >= 0, NETWORK_ERROR)
        self.log.info("Kicking PNO for reference network")
        self.attenuators[ATTENUATOR].set_atten(90)
        time.sleep(10)  #wait for PNO to be kicked
        self.log.info("Starting single scan while PNO")
        self.wifi_scanner_single_scan(self.default_scan_setting)
        self.attenuators[ATTENUATOR].set_atten(0)
        self.log.info("Check connection through PNO for reference network")
        time.sleep(30)  #wait for connection through PNO
        current_network = self.dut.droid.wifiGetConnectionInfo()
        self.log.info("Current network: {}".format(current_network))
        asserts.assert_true('network_id' in current_network, NETWORK_ID_ERROR)
        asserts.assert_true(current_network['network_id'] >= 0, NETWORK_ERROR)
        time.sleep(10)  #wait for IP to be assigned
        asserts.assert_true(
            wutils.validate_connection(self.dut, self.ping_addr),
            "Error, No internet connection for current network")
        wutils.wifi_forget_network(self.dut,
                                   self.reference_networks[0]["2g"]["SSID"])
Esempio n. 6
0
    def test_data_usage_limit_downlink(self):
        """ Verify connectivity when data usage limit reached

        Steps:
            1. Set the data usage limit to current data usage + 10MB
            2. Download 20MB data
            3. File download stops and data limit reached
            4. Device should lose internet connectivity
            5. Verify data usage limit
        """
        # get pre mobile data usage
        total_pre = self._get_total_data_usage_for_device(cconst.TYPE_MOBILE)

        # set data usage limit to current usage limit + 10MB
        self.log.info("Setting data usage limit to %sMB" %
                      (total_pre + INC_DATA))
        self.dut.droid.connectivitySetDataUsageLimit(
            self.sub_id, str(int((total_pre + INC_DATA) * BYTE_TO_MB_ANDROID)))

        # download file through app
        http_file_download_by_chrome(self.dut,
                                     self.download_file,
                                     self.file_size,
                                     timeout=120)
        total_pst = self._get_total_data_usage_for_device(cconst.TYPE_MOBILE)

        # verify data usage
        connectivity_status = wutils.validate_connection(self.dut)
        self.dut.droid.connectivityFactoryResetNetworkPolicies(self.sub_id)
        self.log.info("Expected data usage: %s" % (total_pre + INC_DATA))
        self.log.info("Actual data usage: %s" % total_pst)
        asserts.assert_true(
            not connectivity_status,
            "Device has internet connectivity after reaching data limit")
        return total_pst - total_pre - INC_DATA < DATA_USG_ERR
Esempio n. 7
0
    def _test_private_dns_mode(self, network, dns_mode, use_tls,
                               hostname = None):
        """ Test private DNS mode """
        # connect to wifi
        wutils.reset_wifi(self.dut)
        if network:
            wutils.wifi_connect(self.dut, network)
        time.sleep(1) # wait till lte network becomes active - network = None

        # start tcpdump on the device
        self._start_tcp_dump(self.dut)

        # set private dns mode
        if dns_mode == PRIVATE_DNS_MODE_OFF:
            self.dut.droid.setPrivateDnsMode(False)
        elif hostname:
            self.dut.droid.setPrivateDnsMode(True, hostname)
        else:
            self.dut.droid.setPrivateDnsMode(True)
        mode = self.dut.droid.getPrivateDnsMode()
        asserts.assert_true(mode == dns_mode,
                            "Failed to set private DNS mode to %s" % dns_mode)

        # ping hosts should pass
        for host in self.ping_hosts:
            self.log.info("Pinging %s" % host)
            asserts.assert_true(wutils.validate_connection(self.dut, host),
                                "Failed to ping host %s" % host)

        # stop tcpdump
        pcap_file = self._stop_tcp_dump(self.dut)
        self.log.info("TCPDUMP file is: %s" % pcap_file)

        # verify DNS queries
        self._verify_dns_queries_over_tls(pcap_file, use_tls)
    def set_attn_and_validate_connection(self, attn_value, bssid):
        """Validate wifi connection status on different attenuation setting.

        Args:
            attn_value: Attenuation value for different APs signal.
            bssid: Bssid of excepted network.

        Returns:
            True if bssid of current network match, else false.
        """
        self.attenuators[0].set_atten(attn_value[0])
        self.attenuators[1].set_atten(attn_value[1])
        self.attenuators[2].set_atten(attn_value[2])
        self.dut.droid.wakeLockAcquireBright()
        self.dut.droid.wakeUpNow()
        try:
            asserts.assert_true(
                self.check_connection(bssid),
                "Device is not connected to required bssid {}".format(bssid))
            time.sleep(10)  #wait for connection to be active
            asserts.assert_true(
                wutils.validate_connection(self.dut, self.ping_addr),
                "Error, No Internet connection for current bssid {}".format(
                    bssid))
        finally:
            self.dut.droid.wifiLockRelease()
            self.dut.droid.goToSleepNow()
    def _verify_captive_portal(self, network, click_accept=ACCEPT_CONTINUE):
        """Connect to captive portal network using uicd workflow.

        Steps:
            1. Connect to captive portal network
            2. Run uicd workflow to accept connection
            3. Verify internet connectivity

        Args:
            network: captive portal network to connect to
            click_accept: Notification to select to accept captive portal
        """
        # connect to captive portal wifi network
        wutils.connect_to_wifi_network(self.dut,
                                       network,
                                       check_connectivity=False)

        # run ui automator
        uutils.wait_and_click(self.dut, text="%s" % network["SSID"])
        if uutils.has_element(self.dut, text="%s" % click_accept):
            uutils.wait_and_click(self.dut, text="%s" % click_accept)

        # wait for sometime for captive portal connection to go through
        curr_time = time.time()
        while time.time() < curr_time + TIME_OUT:
            link_prop = self.dut.droid.connectivityGetActiveLinkProperties()
            self.log.debug("Link properties %s" % link_prop)
            if link_prop and link_prop[IFACE] == WLAN:
                break
            time.sleep(2)

        # verify connectivity
        asserts.assert_true(
            wutils.validate_connection(self.dut, ping_gateway=False),
            "Failed to connect to internet. Captive portal test failed")
    def test_IPv6_RA_with_RTT(self):
        """Test if the device filters IPv6 RA packets with different re-trans time

        Steps:
          1. Get the current RA count
          2. Send 400 packets with different re-trans time
          3. Verify that RA count increased by 400
          4. Verify internet connectivity
        """
        pkt_num = 400
        rtt_list = random.sample(range(10, 10000), pkt_num)
        self.log.info("RTT List: %s" % rtt_list)

        # get mac address of the dut
        ap = self.access_points[0]
        wutils.connect_to_wifi_network(self.dut, self.wpapsk_5g)
        mac_addr = self.dut.droid.wifiGetConnectionInfo()['mac_address']
        self.log.info("mac_addr %s" % mac_addr)
        time.sleep(30)  # wait 30 sec before sending RAs

        # get the current ra count
        ra_count = self._get_icmp6intype134()

        # start tcpdump on the device
        tcpdump_pid = start_tcpdump(self.dut, self.test_name)

        # send RA with differnt re-trans time
        for rtt in rtt_list:
            ap.send_ra('wlan1', mac_addr, 0, 1, rtt=rtt)

        # stop tcpdump and pull file
        time.sleep(60)
        pcap_file = stop_tcpdump(self.dut, tcpdump_pid, self.test_name)

        # get the new RA count
        new_ra_count = self._get_icmp6intype134()
        asserts.assert_true(new_ra_count >= ra_count + pkt_num,
                            "Device did not accept all RAs")

        # verify the RA pkts RTT match
        tcpdump_rtt_list = self._get_rtt_list_from_tcpdump(pcap_file)
        asserts.assert_true(
            set(rtt_list).issubset(set(tcpdump_rtt_list)),
            "RA packets didn't match with tcpdump")

        # verify if internet connectivity works after sending RA packets
        wutils.validate_connection(self.dut)
Esempio n. 11
0
    def test_dns_server_link_properties_strict_mode(self):
        """ Verify DNS server in the link properties when set in strict mode

        Steps:
            1. Set DNS server hostname in Private DNS settings (stict mode)
            2. Verify that DNS server set in settings is in link properties
            3. Verify for WiFi as well as LTE
        """
        # start tcpdump on device
        self._start_tcp_dump(self.dut)

        # set private DNS to strict mode
        cutils.set_private_dns(
            self.dut, cconst.PRIVATE_DNS_MODE_STRICT, cconst.DNS_GOOGLE)

        # connect DUT to wifi network
        wutils.start_wifi_connection_scan_and_ensure_network_found(
            self.dut, self.ipv4_ipv6_network[SSID])
        wutils.wifi_connect(self.dut, self.ipv4_ipv6_network)
        for host in self.ping_hosts:
            wutils.validate_connection(self.dut, host)

        # DNS server in link properties for wifi network
        link_prop = self.dut.droid.connectivityGetActiveLinkProperties()
        wifi_dns_servers = link_prop['PrivateDnsServerName']
        self.log.info("Link prop: %s" % wifi_dns_servers)

        # DUT is on LTE data
        wutils.reset_wifi(self.dut)
        time.sleep(1) # wait till lte network becomes active
        for host in self.ping_hosts:
            wutils.validate_connection(self.dut, host)

        # DNS server in link properties for cell network
        link_prop = self.dut.droid.connectivityGetActiveLinkProperties()
        lte_dns_servers = link_prop['PrivateDnsServerName']
        self.log.info("Link prop: %s" % lte_dns_servers)

        # stop tcpdump on device
        pcap_file = self._stop_tcp_dump(self.dut)

        # Verify DNS server in link properties
        asserts.assert_true(cconst.DNS_GOOGLE in wifi_dns_servers,
                            "Hostname not in link properties - wifi network")
        asserts.assert_true(cconst.DNS_GOOGLE in lte_dns_servers,
                            "Hostname not in link properites - cell network")
Esempio n. 12
0
    def add_hiddenSSID_and_connect(self, hidden_network):
        """Add the hidden network and connect to it.

        Args:
            hidden_network: The hidden network config to connect to.

        """
        wutils.connect_to_wifi_network(self.dut, hidden_network, hidden=True)
        if not wutils.validate_connection(self.dut):
            raise signals.TestFailure("Fail to connect to internet on %s" %
                                      hidden_network)
Esempio n. 13
0
    def add_hiddenSSID_and_connect(self, hidden_network):
        """Add the hidden network and connect to it.

        Args:
            hidden_network: The hidden network config to connect to.

        """
        ret = self.dut.droid.wifiAddNetwork(hidden_network)
        asserts.assert_true(ret != -1, "Add network %r failed" % hidden_network)
        self.dut.droid.wifiEnableNetwork(ret, 0)
        wutils.connect_to_wifi_network(self.dut, hidden_network)
        if not wutils.validate_connection(self.dut):
            raise signals.TestFailure("Fail to connect to internet on %s" %
                                       hidden_network)
Esempio n. 14
0
    def test_wifi_tethering_data_usage_limit_downlink(self):
        """ Verify connectivity when data usage limit reached

        Steps:
            1. Set the data usage limit to current data usage + 10MB
            2. Start wifi tethering and connect a dut to the SSID
            3. Download 20MB data on tethered device
            4. File download stops and data limit reached
            5. Verify data usage limit
        """
        # connect device to wifi hotspot
        ad = self.tethered_devices[0]
        wutils.toggle_wifi_off_and_on(self.dut)
        wutils.start_wifi_tethering(self.dut,
                                    self.network[wutils.WifiEnums.SSID_KEY],
                                    self.network[wutils.WifiEnums.PWD_KEY],
                                    ttutils.WIFI_CONFIG_APBAND_2G)
        wutils.wifi_connect(ad, self.network)

        # get pre mobile data usage
        total_pre = self._get_total_data_usage_for_device(cconst.TYPE_MOBILE)

        # set data usage limit to current usage limit + 10MB
        self.log.info("Setting data usage limit to %sMB" %
                      (total_pre + INC_DATA))
        self.dut.droid.connectivitySetDataUsageLimit(
            self.sub_id, str(int((total_pre + INC_DATA) * BYTE_TO_MB_ANDROID)))

        # download file from tethered device
        http_file_download_by_chrome(ad,
                                     self.download_file,
                                     self.file_size,
                                     timeout=120)
        total_pst = self._get_total_data_usage_for_device(cconst.TYPE_MOBILE)

        # verify data usage
        connectivity_status = wutils.validate_connection(ad)
        self.dut.droid.connectivityFactoryResetNetworkPolicies(self.sub_id)
        wutils.stop_wifi_tethering(self.dut)
        self.log.info("Expected data usage: %s" % (total_pre + INC_DATA))
        self.log.info("Actual data usage: %s" % total_pst)
        asserts.assert_true(
            not connectivity_status,
            "Device has internet connectivity after reaching data limit")
        return total_pst - total_pre - INC_DATA < DATA_USG_ERR
    def test_wifi_connection_while_single_scan(self):
        """Test configuring a connection parallel to wifi scanner single scan.

         1. Start WifiScanner single scan for both band with default scan settings.
         2. Configure a connection to reference network.
         3. Verify that connection to reference network occurred.
         2. Verify that scanner report single scan results.
        """
        self.attenuators[ATTENUATOR].set_atten(0)
        data = wutils.start_wifi_single_scan(self.dut,
                                             self.default_scan_setting)
        idx = data["Index"]
        scan_rt = data["ScanElapsedRealtime"]
        self.log.info(
            "Wifi single shot scan started with index: {}".format(idx))
        asserts.assert_true(self.connect_to_reference_network(), NETWORK_ERROR)
        time.sleep(10)  #wait for connection to be active
        asserts.assert_true(
            wutils.validate_connection(self.dut, self.ping_addr),
            "Error, No internet connection for current network")
        #generating event wait time from scan setting plus leeway
        scan_time, scan_channels = wutils.get_scan_time_and_channels(
            self.wifi_chs, self.default_scan_setting, self.stime_channel)
        wait_time = int(scan_time / 1000) + self.leeway
        validity = False
        try:
            event_name = "{}{}onResults".format(EVENT_TAG, idx)
            self.log.debug("Waiting for event: {} for time {}".format(
                event_name, wait_time))
            event = self.dut.ed.pop_event(event_name, wait_time)
            self.log.debug("Event received: {}".format(event))
            results = event["data"]["Results"]
            bssids, validity = self.proces_and_valid_batch_scan_result(
                results, scan_rt, event["data"][KEY_RET],
                self.default_scan_setting)
            self.log.info("Scan number Buckets: {}\nTotal BSSID: {}".format(
                len(results), bssids))
            asserts.assert_true(
                len(results) == 1 and bssids >= 1, EMPTY_RESULT)
        except queue.Empty as error:
            raise AssertionError(
                "Event did not triggered for single scan {}".format(error))
Esempio n. 16
0
    def _test_private_dns_mode(self, ad, net, dns_mode, use_tls, hostname=None):
        """ Test private DNS mode

        Args:
            1. ad: android device object
            2. net: wifi network to connect to, LTE network if None
            3. dns_mode: private DNS mode
            4. use_tls: if True, the DNS packets should be encrypted
            5. hostname: private DNS hostname to set to
        """

        # set private dns mode
        if dns_mode:
            cutils.set_private_dns(self.dut, dns_mode, hostname)

        # connect to wifi
        if net:
            wutils.start_wifi_connection_scan_and_ensure_network_found(
                self.dut, net[SSID])
            wutils.wifi_connect(self.dut, net)

        # start tcpdump on the device
        self._start_tcp_dump(self.dut)

        # ping hosts should pass
        for host in self.ping_hosts:
            self.log.info("Pinging %s" % host)
            status = wutils.validate_connection(self.dut, host)
            asserts.assert_true(status, "Failed to ping host %s" % host)
            self.log.info("Ping successful")

        # stop tcpdump
        pcap_file = self._stop_tcp_dump(self.dut)

        # verify DNS queries
        self._verify_dns_queries_over_tls(pcap_file, use_tls)

        # reset wifi
        wutils.reset_wifi(self.dut)
    def test_wifi_connection_and_pno_while_batch_scan(self):
        """Test configuring a connection and PNO connection parallel to wifi
           scanner batch scan.

         1. Start WifiScanner batch scan with default batch scan settings.
         2. Wait for scan result event for a time depend on scan settings.
         3. Verify reported batch scan results.
         4. Configure a connection to reference network.
         5. Verify that connection to reference network occurred.
         6. Wait for scan result event for a time depend on scan settings.
         7. Verify reported batch scan results.
         8. Trigger PNO by attenuate the signal to move out of range.
         9. Wait for scan result event for a time depend on scan settings.
         10. Verify reported batch scan results.
         11. Attenuate the signal to move in range.
         12. Verify connection occurred through PNO.
        """
        self.attenuators[ATTENUATOR].set_atten(0)
        data = wutils.start_wifi_background_scan(
            self.dut, self.default_batch_scan_setting)
        idx = data["Index"]
        scan_rt = data["ScanElapsedRealtime"]
        self.log.info(
            "Wifi background scan started with index: {} rt {}".format(
                idx, scan_rt))
        #generating event wait time from scan setting plus leeway
        scan_time, scan_channels = wutils.get_scan_time_and_channels(
            self.wifi_chs, self.default_batch_scan_setting, self.stime_channel)
        #default number buckets
        number_bucket = 10
        time_cache = self.default_batch_scan_setting[
            'periodInMs'] * number_bucket  #default cache
        #add 2 seconds extra time for switch between the channel for connection scan
        #multiply cache time by two to account for scheduler changing period
        wait_time = (time_cache * 2 + scan_time) / 1000 + self.leeway + 2
        result_flag = 0
        try:
            for snumber in range(1, 7):
                event_name = "{}{}onResults".format(EVENT_TAG, idx)
                self.log.info("Waiting for event: {}".format(event_name))
                event = self.dut.ed.pop_event(event_name, wait_time)
                self.log.debug("Event onResults: {}".format(event))
                results = event["data"]["Results"]
                bssids, validity = self.proces_and_valid_batch_scan_result(
                    results, scan_rt, event["data"][KEY_RET],
                    self.default_batch_scan_setting)
                self.log.info(
                    "Scan number: {}\n Buckets: {}\n BSSID: {}".format(
                        snumber, len(results), bssids))
                asserts.assert_true(bssids >= 1,
                                    "Not able to fetch scan result")
                if snumber == 1:
                    self.log.info(
                        "Try to connect AP while waiting for event: {}".format(
                            event_name))
                    asserts.assert_true(self.connect_to_reference_network(),
                                        NETWORK_ERROR)
                    time.sleep(10)  #wait for connection to be active
                    asserts.assert_true(
                        wutils.validate_connection(self.dut, self.ping_addr),
                        "Error, No internet connection for current network")
                elif snumber == 3:
                    self.log.info("Kicking PNO for reference network")
                    self.attenuators[ATTENUATOR].set_atten(90)
                elif snumber == 4:
                    self.log.info("Bring back device for PNO connection")
                    current_network = self.dut.droid.wifiGetConnectionInfo()
                    self.log.info(
                        "Current network: {}".format(current_network))
                    asserts.assert_true('network_id' in current_network,
                                        NETWORK_ID_ERROR)
                    asserts.assert_true(
                        current_network['network_id'] == -1,
                        "Device is still connected to network  {}".format(
                            current_network[wutils.WifiEnums.SSID_KEY]))
                    self.attenuators[ATTENUATOR].set_atten(0)
                    time.sleep(
                        10
                    )  #wait for connection to take place before waiting for scan result
                elif snumber == 6:
                    self.log.info(
                        "Check connection through PNO for reference network")
                    current_network = self.dut.droid.wifiGetConnectionInfo()
                    self.log.info(
                        "Current network: {}".format(current_network))
                    asserts.assert_true('network_id' in current_network,
                                        NETWORK_ID_ERROR)
                    asserts.assert_true(current_network['network_id'] >= 0,
                                        NETWORK_ERROR)
                    time.sleep(10)  #wait for connection to be active
                    asserts.assert_true(
                        wutils.validate_connection(self.dut, self.ping_addr),
                        "Error, No internet connection for current network")
                    wutils.wifi_forget_network(
                        self.dut, self.reference_networks[0]["2g"]["SSID"])
        except queue.Empty as error:
            raise AssertionError(
                "Event did not triggered for batch scan {}".format(error))
        finally:
            self.dut.droid.wifiScannerStopBackgroundScan(idx)
            self.dut.ed.clear_all_events()