出于工作需要,有时候需要模拟用户的慢网速对产品做进一步测试&优化,目前有三个软件可以模拟慢网速:Fiddler,NetLimiter,Network Delay Simulator。应该还有更多好用的软件尚待发掘。

Fiddler 免费软件。模拟网速功能比较单一(Rules --> Performance --> Simulate Modem speed),选项较少,Fiddler仅是减缓带宽并未引入包丢失(后面的Network Delay Simulator加入了包丢失模拟)。且因为浏览器并发连接数问题,会造成(Http watch 或Firebug)测试结果的瀑布图不准。所以虽然有这个功能,咱们一般不用它。fiddler的亮点在另一方面

NetLimiter 共享软件,需要自己注册。准确的说是一款网络流量控制软件,通过它,你可以直接来控制每个程序对Internet的访问以及流量分配情况。这里有前人制作的图。

Network Delay Simulator  免费软件,下载地址 。我正在使用的,三种之中功能最强大,监听Network Interface Card (NIC)和TCP/IP stack之间的网络流量,可以模拟延时、带宽甚至丢包率,更精确地模拟慢网速环境。设置也很简单方便:输入带宽,点击Save Flow即可,如果你要模拟丢包,填下丢包率便行。见图。

还有更专业的~~~~

文工具推荐中指出Fiddler的“Simulate Modem Speeds”功能(Rules->Performance-> Simulate Modem Speeds)是延时,下面具体分析其实现:

Fiddler2\Scripts\SampleRules.js中设置脚本规则

static function OnBeforeRequest(oSession: Session)

{

if (m_SimulateModem){

// Delay sends by 300ms per KB uploaded.

oSession["request-trickle-delay"] = "300";

}

static function OnBeforeResponse(oSession: Session)

{

if (m_SimulateModem){

// Delay receives by 150ms per KB downloaded.

oSession["response-trickle-delay"] = "150";

}

实现代码则在Fiddler.exe中的ServerChatter类

public bool ResendRequest()

{

....

if (this.m_session["request-trickle-delay"] != null)

{

int iMS = int.Parse(this.m_session.oFlags["request-trickle-delay"]);

this.pipeServer.TrickleSend(0x400, iMS, this.m_session.oRequest.headers.ToByteArray(true, true, this._bWasForwarded && !this.m_session.isHTTPS));

this.pipeServer.TrickleSend(0x400, iMS, this.m_session.requestBodyBytes);

}

....

Fiddler.exe中的Session类

public bool ReturnResponse(bool bKeepNTLMSockets)

{

try

{

if ((this.oRequest.pipeClient != null) && this.oRequest.pipeClient.Connected)

{

if (this.oFlags["response-trickle-delay"] != null)

{

int iMS = int.Parse(this.oFlags["response-trickle-delay"]);

this.oRequest.pipeClient.TrickleSend(0x400, iMS, this.oResponse.headers.ToByteArray(true, true));

if (this.responseBodyBytes != null)

{

this.oRequest.pipeClient.TrickleSend(0x400, iMS, this.responseBodyBytes);

}

}

可以看到它们都用到了Fiddler.exe中类Pipe的函数TrickleSend,以下是其定义:

public void TrickleSend(int iSize, int iMS, byte[] data)

{

for (int i = 0; i < data.Length; i += iSize)

{

Thread.Sleep((int) (iMS / 2));

this.Send(data, i, iSize);

Thread.Sleep((int) (iMS / 2));

}

}

由此可见Fiddler.exe在请求和发送的每KB过程中都采取了延时模拟。关于延时,Issues with Time Warner Cable service in New York中有人说道”With the modem doing some QoS, it can maintain 150-300ms latency when uploading and downloading and the line remains pretty snappy.”,BT Highway中也有类似描述。作者给出了如下解释:These speeds were derived from a simple model of the effective throughput of a modem.You can adjust these to match any other connection speed you want, so long as such speed is slower than how you're actually connected to the network, of course.The neXpert plugin for Fiddler does response-time predictions using data from Microsoft Research.

文Fiddler无法模拟浏览器并发连接数限制,开启工具栏上的"Streaming"模式可以解决,但这样就打破了规则"Simulate Modem speeds",得出来的总体时间大幅缩短,此时Fiddler不仅延时了带宽还延时了浏览器并发连接。正如作者在所说:Fiddler仅是减缓带宽并未引入包丢失。

Speed Simulator看起来比Fiddler模拟的差不多(注意:多做几次测试,找一个稳定的结果,每次选择HttpWatch的Tools->Clear Cache and All Cookied清空MSIE):

本想用同样方法测试浏览器插件IE Throttle,结果它无法在x64 Windows XP SP2上的x86 IE中打开“IE Throttle Settings”。同类型的还有Firefox Throttle。

Network Delay Simulator(简称NetSim)采用Token Bucket和Leaky_bucket算法模拟真实网络并监听网卡和Tcp/IP之间的网络流量,详见Is there any forum for Net Simulator。显然,它采用的是网络包丢失模拟。但需要注意这款免费软件从version 0.9.129开始支持x86 Windows 到Win7,关于此软件任何问题可联系Andrew。

HP推荐ShunraVE Desktop的WAN emulation,使用运行在FreeBSD上的免费Dummynet。

ToDo:

HP Loadrunner的Speed Simulation如何?MS VSTS 2010的Network Emulation又如何?

由于测不准,我们得不到准确的结果,但可以得到尽可能精确的结果。比如modem,你能确定国内中国电信、中国网通等ISP提供给终端用户的无论何时何地都是标准的速度56k吗?也许Keynote、Gomez所提供的服务,Google Analytics、Omniture、Webtrends、WebPagetest,运营监控是一种弥补措施。 【关于Fiddler其它】1. 通过WinINET设置Proxy转发给127.0.0.1:8888public bool Attach()
{
    if (!this._bIsAttached)
    {
        this.oAllConnectoids = new WinINETConnectoids();
        this.piPrior = this.oAllConnectoids.GetDefaultConnectionGatewayInfo();
        if ((this.piPrior.sHttpProxy != null) && this.piPrior.sHttpProxy.Contains(CONFIG.sFiddlerListenHostPort))
        {
            this.piPrior.sHttpProxy = null;
            this.piPrior.sHttpsProxy = null;
            this.piPrior.bUseManualProxies = false;
            this.piPrior.bAllowDirect = true;
        }
        if (CONFIG.bForwardToGateway && ((this.piPrior.sPACScriptLocation != null) || this.piPrior.bAutoDetect))
        {
            this.oAutoProxy = new WinHTTPAutoProxy(this.piPrior.bAutoDetect, this.piPrior.sPACScriptLocation);
        }
        if (CONFIG.bForwardToGateway && this.piPrior.bUseManualProxies)
        {
            this._ipepHttpGateway = Utilities.IPEndPointFromHostPortString(this.piPrior.sHttpProxy);
            this._ipepHttpsGateway = Utilities.IPEndPointFromHostPortString(this.piPrior.sHttpsProxy);
            this._ipepFtpGateway = Utilities.IPEndPointFromHostPortString(this.piPrior.sFtpProxy);
            if (this.piPrior.sHostsThatBypass != null)
            {
                this.oBypassList = new ProxyBypassList(this.piPrior.sHostsThatBypass);
                if (!this.oBypassList.HasEntries)
                {
                    this.oBypassList = null;
                }
            }
        }
        else
        {
            this._ipepFtpGateway = this._ipepHttpGateway = this._ipepHttpsGateway = null;
        }
        WinINETProxyInfo oNewInfo = new WinINETProxyInfo();
        if (CONFIG.bHookWithPAC)
        {
            oNewInfo.bAllowDirect = true;
            oNewInfo.sPACScriptLocation = "file://" + CONFIG.GetPath("Pac");
        }
        else
        {
            oNewInfo.bUseManualProxies = true;
            oNewInfo.bAllowDirect = true;
            oNewInfo.sHttpProxy = CONFIG.sFiddlerListenHostPort;
            if (CONFIG.bCaptureCONNECT)
            {
                oNewInfo.sHttpsProxy = CONFIG.sFiddlerListenHostPort;
            }
            else
            {
                oNewInfo.sHttpsProxy = this.piPrior.sHttpsProxy;
            }
            if (this.piPrior.bUseManualProxies)
            {
                oNewInfo.sFtpProxy = this.piPrior.sFtpProxy;
                oNewInfo.sSocksProxy = this.piPrior.sSocksProxy;
            }
            if (CONFIG.bCaptureFTP)
            {
                oNewInfo.sFtpProxy = CONFIG.sFiddlerListenHostPort;
            }
            oNewInfo.sHostsThatBypass = CONFIG.sHostsThatBypassFiddler;
        }
        if (this.oAllConnectoids.HookConnections(oNewInfo))
        {
            this._bIsAttached = true;
            FiddlerApplication.OnFiddlerAttach();
            this.WriteAutoProxyPACFile(true);
        }
        else
        {
            FiddlerApplication.DoNotifyUser("Failed to register Fiddler as the system proxy.", "Error");
            _setDynamicRegistryKey(false);
            return false;
        }
        _setDynamicRegistryKey(true);
    }
    return true;
} 2.DNSTimeFiddler.exe函数HTTPSTunnel.TunnelDirectly,Session.ExecuteHTTPSConnect,ServerChatter.ConnectToHost和ServerChatter.ConnectToHost中:
int num3 = Environment.get_TickCount();
iPAddress = DNSResolver.GetIPAddress(str2, true);
this.m_session.Timers.DNSTime = Environment.get_TickCount() - num3;

转载于:https://blog.51cto.com/juxing/624537

工具对比_模拟慢网速环境相关推荐

  1. 前端人员如何模拟慢网速环境

    出于工作需要,有时候需要模拟用户的慢网速对产品做进一步测试&优化,目前有三个软件可以模拟慢网速:Fiddler,NetLimiter,Network Delay Simulator.应该还有更 ...

  2. Network Delay Simulator模拟延时、带宽甚至丢包率,更精确地模拟慢网速环境

    Network Delay Simulator 免费软件,下载地址 .我正在使用的,三种之中功能最强大,监听Network Interface Card (NIC)和TCP/IP stack之间的网络 ...

  3. chrome浏览器模拟慢网速环境

    浏览器版本:65.0.3325.181(正式版本) (64 位) 按F12呼出开发人员工具

  4. 测试中如何模拟低网速状态

    遇到了什么? 在做项目时,通常容易遇到一个问题:在项目环境中拥有良好的表现,功能很酷很炫,但是在实际发布上线之后,却发现因为用户网速不理想,容易产生一些意料不到的状况,例如页面的可用性出现障碍.而且这 ...

  5. Mac/ios 模拟器 测试模拟慢网速

    原文:http://www.heyuan110.com/2015/06/16/Mac%E6%B5%8B%E8%AF%95%E6%A8%A1%E6%8B%9F%E6%85%A2%E7%BD%91%E9% ...

  6. Charles——charles代理菜单proxy总结—— 开始/暂停模拟慢网速—— stop/start throttling 和 throttling settings...

    charles 开始/暂停模拟慢网速 1.2. stop/start throttling 和 2.2 throttling settings 暂时开始慢网速,这个说实话,我自己是不常用的,也就偶尔上 ...

  7. 为什么手机网速太慢_为什么手机网速太慢

    当通信用户在日常生活中一遍又一遍发出类似抱怨的时候,他们第一个联想到的,也许是电信运营商辛苦架设的网络仍然不够好.不够快,但其实在这背后,影响手机上网速度的因素不少,面对信号糟糕的手机,你必须知道-- ...

  8. 为什么手机网速太慢_为什么手机网速很慢;为什么手机信号满格,网速却很慢?...

    其实我们看到的信号强度并不准确米凯拉 舍费尔,手机信号强度是打电话信号强度和上网信号强度的总和,所以我们经常可能遇到打电话信号很强,但是却上网非常慢和上网很快却电话信号非常差的情况,而上网信号强度我们 ...

  9. 网卡清空缓存命令_提高局域网网速方法技巧:网卡调至全速/取消缓存设置

    很多网民都很关注自己的网速,并希望把网速提高上去,以便更舒畅的上网.网速上去了,上网的心情都会好一些,工作的效率都会高一点.所以,无论是企业还是家庭个人,网速永远都不能忽视. 今天,本人收集了几个提高 ...

最新文章

  1. 64位的机器上VS2008不能使用SharePoint的workflow template
  2. Tableau必知必会之学做 饼图 和 折线图 的组合图表
  3. Java面试笔试题整理
  4. libnids校验和引起回放包不能正常捕捉
  5. 武汉大学计算机学院的李明,李明副研究员
  6. 多台Linux服务器之间互相免密登陆
  7. 作者:胡良霖(1973-),男,中国科学院计算机网络信息中心高级工程师
  8. 每日小记 2017.4.24
  9. android 调用百度地图,高德地图第三方APP进行导航
  10. UTF-8是如何编码的?
  11. 2021-09-08321. 拼接最大数 单调栈
  12. java将pdf转excel,excel转pdf,itextpdf转换excel
  13. 微信小程序的微信开发者工具的快捷键查找和设置
  14. PPT 2010如何添加背景音乐
  15. 平面束方程少一个面的原因
  16. 关于mysql的时区(下):如何设置mysql的时区
  17. 任务式对话中的自然语言理解(智能对话场景)
  18. 如何在Ubuntu 20.04 / 18.04服务器中进入救援模式或紧急模式?
  19. NGUI的动态字体dynamicFont的制作
  20. FTP登陆之后显示列表错误的解决方法

热门文章

  1. 创远家居基于江湖家居装修门户PHP系统源码
  2. 视频会议系统OpenMeetings v5.1.0源码
  3. 酱茄企业官网多端开源小程序源码 v1.0.0
  4. MPA是什么意思?一MPA简介和MPA地位
  5. Node.js DNS 模块
  6. 开源ckplayer 网页播放器, 跨平台(html5, mobile),flv, f4v, mp4, rtmp协议. webm, ogg, m3u8 !...
  7. node.js——麻将算法(四)胡牌算法的一些优化处理方案(无赖子版)
  8. C++——获取array,vector,string的元素个数
  9. SelectSort 选择排序
  10. 【今日CV 视觉论文速览】22 Nov 2018