fiddler弱网测试

1、模拟弱网环境

打开Fiddler,Rules->Performance->勾选 Simulate Modem Speeds,勾选之后访问网站会发现网络慢了很多

2、Fiddler弱网的原理

Rules—>Cutomize Rules打开CustomRules.js 文档

在文件中搜索关键字,m_SimulateModem

// Cause Fiddler to delay HTTP traffic to simulate typical 56k modem conditions
    public static RulesOption("Simulate &Modem Speeds", "Per&formance")
    var m_SimulateModem: boolean = false;
if (m_SimulateModem) {
            // Delay sends by 300ms per KB uploaded.
            oSession["request-trickle-delay"] = "300";
            // Delay receives by 150ms per KB downloaded.
            oSession["response-trickle-delay"] = "150";
        }

让我们来分析一下这几行代码:

首先来判断m_SimulateModem是否为true,也就是是否设置了弱网模式。

如果为弱网模式。则分析代码

oSession[“request-trickle-delay”] = “300”; 注释的也很明白,Delay sends by 300ms per KB uploaded.上传1KB需要300ms,

转化一下上传速度:1Kb/0.3s = 10/3(KB/s),也就是 3.33kb/s ,到达2G网络标准。

如果你想设置上传的速度为50KB/s,你则需要设置Delay 时间为 20ms

同样的方法,也可以限制上传的速度,调整oSession[“response-trickle-delay”]即可。

网络 上行 下载
2G 2.7K 9.6K
3G 1.8M 7.2M
4G 50M 100M
所以得出:2G网络配置
if (m_SimulateModem) {
            // Delay sends by 300ms per KB uploaded.
            oSession["request-trickle-delay"] = "300";
            // Delay receives by 150ms per KB downloaded.
            oSession["response-trickle-delay"] = "150";
        }

3G 网络配置,3G 应该是2G网络估值的1000倍速率,也就是上行和下载除去1000

if (m_SimulateModem) {
          // Delay sends by 300ms per KB uploaded.
          oSession["request-trickle-delay"] = "0.3";
          // Delay receives by 150ms per KB downloaded.
          oSession["response-trickle-delay"] = "0.15";
      }

4G网络配置,上行为3G的25倍,下载为15倍,放开延迟即可

posted @ 2022-03-21 23:51  我是小菜鸡丫丫  阅读(147)  评论(0编辑  收藏  举报