Wi-Fi网络评分机制02_CompatibilityScorer

本文详细解读了一种基于RSSI、频段特性、连接历史及安全性的无线网络评分器,类似于BubbleFunScorer,算法线性且考虑了特定优先级规则。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

该评分器与BubbleFunScorer基本类似

打分算法的代码如下

private ScoredCandidate scoreCandidate(Candidate candidate) {
    int rssiSaturationThreshold = mScoringParams.getGoodRssi(candidate.getFrequency());
    int rssi = Math.min(candidate.getScanRssi(), rssiSaturationThreshold);
    int score = (rssi + RSSI_SCORE_OFFSET) * RSSI_SCORE_SLOPE_IS_4;

    if (ScanResult.is6GHz(candidate.getFrequency())) {
        score += BAND_6GHZ_AWARD_IS_40;
    } else if (ScanResult.is5GHz(candidate.getFrequency())) {
        score += BAND_5GHZ_AWARD_IS_40;
    }
    score += (int) (candidate.getLastSelectionWeight() * LAST_SELECTION_AWARD_IS_480);

    if (candidate.isCurrentNetwork()) {
        // Add both traditional awards, as would be be case with firmware roaming
        score += CURRENT_NETWORK_BOOST_IS_16 + SAME_BSSID_AWARD_IS_24;
    }

    if (!candidate.isOpenNetwork()) {
        score += SECURITY_AWARD_IS_80;
    }

    // To simulate the old strict priority rule, subtract a penalty based on
    // which nominator added the candidate.
    score -= 1000 * candidate.getNominatorId();

    // The old method breaks ties on the basis of RSSI, which we can
    // emulate easily since our score does not need to be an integer.
    double tieBreaker = candidate.getScanRssi() / 1000.0;
    return new ScoredCandidate(score + tieBreaker, 10,
                               USE_USER_CONNECT_CHOICE, candidate);
}

处理步骤如下:

rssi处理: 以GoodRssi作为基准,如果>=GoodRssi,那么分数是确定值,以防止过大的信号强度对得分产生不合理的影响;如果<GoodRssi,那么分数为(rssi+85)*4

频段奖励: 根据候选网络的频段(6GHz、5GHz等),分别添加了 BAND_6GHZ_AWARD_IS_40BAND_5GHZ_AWARD_IS_40 奖励。这是因为通常情况下,较高频段的网络(如5GHz和6GHz)具有更高的容量和性能,因此需要对它们进行奖励。5G/6G统一加40分。

最近连接奖励: 跟BubbleFunScorer的处理是一样的,只是这里的基础分LAST_SELECTION_AWARD_IS_480更大一点,是480分。

当前网络奖励: 如果是当前已连接网络,加40分(CURRENT_NETWORK_BOOST_IS_16 + SAME_BSSID_AWARD_IS_24)

安全性奖励: 如果是非开放网络,加80分(SECURITY_AWARD_IS_80)

Nominator惩罚: 跟提名器相关,暂时没有深究其原因。

tieBreaker: 为了在得分相同的情况下通过信号强度的微小差异来解决优先级,以模拟旧的严格优先级规则。不知道这个old strict priority rule是指什么,可能是以前的实现把,暂时没研究。

这个评分器的代码更为简单,计算方法几乎是线性的。

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值