Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Active scan on a WiFi NIC, including flush of old scan results - how ? Pin

Active scan on a WiFi NIC, including flush of old scan results - how ? Pin

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++adobe
7 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    amitalonm
    wrote on last edited by
    #1

    Hi, I wrote a program using VC++ that should scan for available wireless networks in the area. In my SW I use the commands OID_802_11_BSSID_LIST_SCAN and OID_802_11_BSSID_LIST. My questions are: 1. How can I Force the Wireless NIC to do ACTIVE SCAN (as contrary to PASSIVE scan) ? 2. According to tests that I did, the card does not flush the list between scans, i.e. I get for several scan a result of an AP that was on air during an old scan, but is no longer there, and new scans return's it's data as if it is still there. A code part that I used is attached - in order to illustrate which functions I am using.

    NDIS_802_11_BSSID_LIST* m_pBSSIDList;
    m_pBSSIDList = (NDIS_802_11_BSSID_LIST *) VirtualAlloc (NULL,
    sizeof (NDIS_802_11_BSSID_LIST) * NUMBEROF_BSSIDS,
    MEM_RESERVE | MEM_COMMIT,
    PAGE_READWRITE) ;

    memset (m_pBSSIDList, 0, sizeof (NDIS_802_11_BSSID_LIST) * NUMBEROF_BSSIDS);

    // Do Scan
    oidcode = OID_802_11_BSSID_LIST_SCAN;
    DeviceIoControl (m_handle,
    IOCTL_NDIS_QUERY_GLOBAL_STATS,
    &oidcode,
    sizeof(oidcode),
    (ULONG *) NULL,
    0,
    &bytesreturned,
    NULL);

    Sleep (6100); // According to the documentation the result of the scan should be valid after 6 seconds.
    // The original line was delay of 2000 mSec. find out why...
    //Sleep (2000);

    // Read scan results
    oidcode = OID_802_11_BSSID_LIST;
    if (DeviceIoControl( m_handle,
    IOCTL_NDIS_QUERY_GLOBAL_STATS,
    &oidcode,
    sizeof(oidcode),
    (ULONG *) m_pBSSIDList,
    sizeof(NDIS_802_11_BSSID_LIST) * NUMBEROF_BSSIDS,
    &bytesreturned,
    NULL) == 0)
    {
    // List failed
    return NULL;
    }
    else
    {
    return m_pBSSIDList;
    }

    If you have any idea of how can I solve my problems, or if you see that I forgot any important line- please let me know. I am open to hear about completely new ways to do this. only requirement is that I will use VC++. Thanks a lot, --Amit.

    D 1 Reply Last reply
    0
    • A amitalonm

      Hi, I wrote a program using VC++ that should scan for available wireless networks in the area. In my SW I use the commands OID_802_11_BSSID_LIST_SCAN and OID_802_11_BSSID_LIST. My questions are: 1. How can I Force the Wireless NIC to do ACTIVE SCAN (as contrary to PASSIVE scan) ? 2. According to tests that I did, the card does not flush the list between scans, i.e. I get for several scan a result of an AP that was on air during an old scan, but is no longer there, and new scans return's it's data as if it is still there. A code part that I used is attached - in order to illustrate which functions I am using.

      NDIS_802_11_BSSID_LIST* m_pBSSIDList;
      m_pBSSIDList = (NDIS_802_11_BSSID_LIST *) VirtualAlloc (NULL,
      sizeof (NDIS_802_11_BSSID_LIST) * NUMBEROF_BSSIDS,
      MEM_RESERVE | MEM_COMMIT,
      PAGE_READWRITE) ;

      memset (m_pBSSIDList, 0, sizeof (NDIS_802_11_BSSID_LIST) * NUMBEROF_BSSIDS);

      // Do Scan
      oidcode = OID_802_11_BSSID_LIST_SCAN;
      DeviceIoControl (m_handle,
      IOCTL_NDIS_QUERY_GLOBAL_STATS,
      &oidcode,
      sizeof(oidcode),
      (ULONG *) NULL,
      0,
      &bytesreturned,
      NULL);

      Sleep (6100); // According to the documentation the result of the scan should be valid after 6 seconds.
      // The original line was delay of 2000 mSec. find out why...
      //Sleep (2000);

      // Read scan results
      oidcode = OID_802_11_BSSID_LIST;
      if (DeviceIoControl( m_handle,
      IOCTL_NDIS_QUERY_GLOBAL_STATS,
      &oidcode,
      sizeof(oidcode),
      (ULONG *) m_pBSSIDList,
      sizeof(NDIS_802_11_BSSID_LIST) * NUMBEROF_BSSIDS,
      &bytesreturned,
      NULL) == 0)
      {
      // List failed
      return NULL;
      }
      else
      {
      return m_pBSSIDList;
      }

      If you have any idea of how can I solve my problems, or if you see that I forgot any important line- please let me know. I am open to hear about completely new ways to do this. only requirement is that I will use VC++. Thanks a lot, --Amit.

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      See responses here.

      "Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown

      "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

      A 1 Reply Last reply
      0
      • D David Crow

        See responses here.

        "Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown

        "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

        A Offline
        A Offline
        amitalonm
        wrote on last edited by
        #3

        Hi David, Thanks for your answer. it answered my first question, but the second question, that bothers me much more is still left unanswered. My problem is that the Wireless Card returns old scanned data, that is no longer relevant, of APs that are no longer on air. According to the text in here: http://msdn.microsoft.com/en-us/library/ms799400.aspx[^] it says that "...The miniport driver must manage its cached BSSID scan list in the following ways: * The driver must clear its BSSID scan list when set by OID_802_11_BSSID_LIST_SCAN before it starts the explicit network scan. ... " I tried my code, which uses the OID_802_11_BSSID_LIST_SCAN command, on 2 different Wireless NICs (DELL, and Intel) and both Wireless NICs did not clear the history and kept returning the result of old scanned APs that are no longer on air. Can you maybe help me here as well ? Thanks, -- Amit.

        D 1 Reply Last reply
        0
        • A amitalonm

          Hi David, Thanks for your answer. it answered my first question, but the second question, that bothers me much more is still left unanswered. My problem is that the Wireless Card returns old scanned data, that is no longer relevant, of APs that are no longer on air. According to the text in here: http://msdn.microsoft.com/en-us/library/ms799400.aspx[^] it says that "...The miniport driver must manage its cached BSSID scan list in the following ways: * The driver must clear its BSSID scan list when set by OID_802_11_BSSID_LIST_SCAN before it starts the explicit network scan. ... " I tried my code, which uses the OID_802_11_BSSID_LIST_SCAN command, on 2 different Wireless NICs (DELL, and Intel) and both Wireless NICs did not clear the history and kept returning the result of old scanned APs that are no longer on air. Can you maybe help me here as well ? Thanks, -- Amit.

          D Offline
          D Offline
          David Crow
          wrote on last edited by
          #4

          What happens if you issue the OID_802_11_BSSID_LIST commad by itself? I have no idea if that is even valid. I'm just tossing out ideas.

          "Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown

          "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

          A 1 Reply Last reply
          0
          • D David Crow

            What happens if you issue the OID_802_11_BSSID_LIST commad by itself? I have no idea if that is even valid. I'm just tossing out ideas.

            "Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown

            "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

            A Offline
            A Offline
            amitalonm
            wrote on last edited by
            #5

            I don't think that it will help. According to the documentation the Wireless card will return it's most up to date database, without flushing old information. The data may have been collected using passive scan or any other action that the card's driver was doing to collect, before the _LIST query (command) was issued.

            F 1 Reply Last reply
            0
            • A amitalonm

              I don't think that it will help. According to the documentation the Wireless card will return it's most up to date database, without flushing old information. The data may have been collected using passive scan or any other action that the card's driver was doing to collect, before the _LIST query (command) was issued.

              F Offline
              F Offline
              fibers
              wrote on last edited by
              #6

              Hi: I also got the confusion with this question, when I want collect each AP's RSSI real-time. quote: The miniport driver must manage its cached BSSID scan list in the following ways: The driver must clear its BSSID scan list when set by OID_802_11_BSSID_LIST_SCAN before it starts the explicit network scan. Because we use the OID in the upper layer of the system. The Application just pass down the OID to the under miniport driver. It seems that the driver will do the clear things for us. The actual implement of the hardware is variety, so it is unforeseen.

              A 1 Reply Last reply
              0
              • F fibers

                Hi: I also got the confusion with this question, when I want collect each AP's RSSI real-time. quote: The miniport driver must manage its cached BSSID scan list in the following ways: The driver must clear its BSSID scan list when set by OID_802_11_BSSID_LIST_SCAN before it starts the explicit network scan. Because we use the OID in the upper layer of the system. The Application just pass down the OID to the under miniport driver. It seems that the driver will do the clear things for us. The actual implement of the hardware is variety, so it is unforeseen.

                A Offline
                A Offline
                amitalonm
                wrote on last edited by
                #7

                Hi Fibers, here are my understandings about this issue: 1. The fastest promised "response time" for updated information that you can get using NDIS API will be around 6 seconds. 2. If you need faster response time then this - you need to work wuth wireless NIC's drivers. 3. In order to check yourself, you may do some tests and from time to time switch the power of the transmitting AP on/off. when you switch it off - you will know exactly when the reading of the relevant AP should vanish from the list. according to my tests, I could not make them disappear fast, i.e. the reading of the AP that is no longer on air, kept reporting as if it was on air, sometimes for about 1-2 minutes (!!!) after the AP was turned off. the rx database was not flushed and held old information. This, of course, is not what I wanted. The scan command, which should have flush the RXed AP's database, surely did not work. I think that this problem is due to incompatibility of the Wireless card's vendors with NDIS requirements. If you find any wireless card (NIC) that the NDIS SCAN command actually cleans the old data from the database, using NDIS interface, please inform me with the exact model of the wireless NIC. If you find any wireless NIC that you can access it's Firmware and control it using your code (bypass the NDIS level), and that can do it with no cost (no need to pay for information on how to do this), please update me as well with the wireless card's model and brand, and with relevant sample code. As a matter of fact, I think that in order to achieve fast response, this is that direction that you should focus on. Any help will be very much appreciated ! In second thought, please update us anyway :-) Thanks a lot and good luck. -- Amit.

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups