WLAN_REALTIME_CONNECTION_QUALITY structure (wlanapi.h)

Important

Some information relates to a prerelease product which may be substantially modified before it's commercially released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

Represents the attributes that describe the quality of the connection on a given interface.

Syntax

typedef struct _WLAN_REALTIME_CONNECTION_QUALITY {
  DOT11_PHY_TYPE                             dot11PhyType;
  ULONG                                      ulLinkQuality;
  ULONG                                      ulRxRate;
  ULONG                                      ulTxRate;
  BOOL                                       bIsMLOConnection;
  ULONG                                      ulNumLinks;
  WLAN_REALTIME_CONNECTION_QUALITY_LINK_INFO linksInfo[1];
} WLAN_REALTIME_CONNECTION_QUALITY, *PWLAN_REALTIME_CONNECTION_QUALITY;

Members

dot11PhyType

A DOT11_PHY_TYPE value that indicates the physical type of the association.

ulLinkQuality

A ULONG percentage value that represents the signal quality of the connection. This member contains a value between 0 and 100. A value of 0 implies an actual RSSI signal strength of -100 dbm. A value of 100 implies an actual RSSI signal strength of -50 dbm. You can calculate the RSSI signal strength value for ulLinkQuality values between 1 and 99 using linear interpolation.

ulRxRate

Contains the receiving rate of the association.

ulTxRate

Contains the transmission rate of the association.

bIsMLOConnection

Represents whether this is a Multi-Link Operation (MLO) connection.

ulNumLinks

Number of connected links.

linksInfo[1]

A WLAN_REALTIME_CONNECTION_QUALITY_LINK_INFO of size ulNumLinks. Each element contains information about a different connected link.

Remarks

Examples

DWORD IsWLANLinkSpeedSufficient(
    GUID* interfaceGuid,
    const ULONG minRequiredLinkQuality,
    const ULONG requiredRxRate,
    const ULONG requiredTxRate,
    bool* isSufficient)
{
    wil::unique_wlan_handle clientHandle;
    DWORD maxClientVersion = 2;
    DWORD currentClientVersion = 0;
    DWORD result = WlanOpenHandle(maxClientVersion, nullptr, &currentClientVersion, &clientHandle);
    if (result != ERROR_SUCCESS) 
    {
        wprintf(L"WlanOpenHandle failed with error: %u\n", result);
        return result;
    }

    DWORD connectionQualitySize = 0;
    wil::unique_wlan_ptr<WLAN_REALTIME_CONNECTION_QUALITY> connectionQuality;
    result = WlanQueryInterface(
        clientHandle.get(), 
        interfaceGuid,
        wlan_intf_opcode_realtime_connection_quality,
        nullptr,
        &connectionQualitySize,
        wil::out_param_ptr<void**>(connectionQuality),
        nullptr);
    if (result != ERROR_SUCCESS) 
    {
        wprintf(L"WlanQueryInterface failed with error: %u\n", result);
        return result;
    }

    if (connectionQuality->ulLinkQuality < minRequiredLinkQuality || 
        connectionQuality->ulRxRate < requiredRxRate ||
        connectionQuality->ulTxRate < requiredTxRate)
    {
        *isSufficient = false;
    }
    else
    {
        *isSufficient = true;
    }
    return ERROR_SUCCESS;
}

DWORD GetCenterChannelFrequencyOfLinkWithBestRSSI(GUID* interfaceGuid, ULONG* channelFrequency)
{
    wil::unique_wlan_handle clientHandle;
    DWORD maxClientVersion = 2;
    DWORD currentClientVersion = 0;
    DWORD result = WlanOpenHandle(maxClientVersion, nullptr, &currentClientVersion, &clientHandle);
    if (result != ERROR_SUCCESS) 
    {
        wprintf(L"WlanOpenHandle failed with error: %u\n", result);
        return result;
    }

    DWORD connectionQualitySize = 0;
    wil::unique_wlan_ptr<WLAN_REALTIME_CONNECTION_QUALITY> connectionQuality;
    result = WlanQueryInterface(
        clientHandle.get(), 
        interfaceGuid,
        wlan_intf_opcode_realtime_connection_quality,
        nullptr,
        &connectionQualitySize,
        wil::out_param_ptr<void**>(connectionQuality),
        nullptr);
    if (result != ERROR_SUCCESS) 
    {
        wprintf(L"WlanQueryInterface failed with error: %u\n", result);
        return result;
    }

    auto linkWithBestRssi = std::min_element(
        connectionQuality->linksInfo,
        connectionQuality->linksInfo + connectionQuality->ulNumLinks,
        [](const WLAN_REALTIME_CONNECTION_QUALITY_LINK_INFO& lhs, const WLAN_REALTIME_CONNECTION_QUALITY_LINK_INFO& rhs) {
            return lhs.lRssi > rhs.lRssi; // `Greater than` because RSSI is negative.
        });

    *channelFrequency = linkWithBestRssi->ulChannelCenterFrequencyMhz;
    return ERROR_SUCCESS;
}

Requirements

Requirement Value
Header wlanapi.h