当前位置:网站首页>Fiddler captures packets to simulate weak network environment testing
Fiddler captures packets to simulate weak network environment testing
2022-07-31 01:49:00 【Love to eat caraway】

现在的Android软件,Basically there will be network requests,有些APPWhen frequent data transmission is required, the stability of network requests and the compatibility under special network conditions are required,However, it is difficult for us to simulate the situation of weak network and poor network when we test,Today, I will share with you a dry article to simulate a weak network situation.
正文
第一步:下载抓包软件fiddler
官网:http://www.telerik.com/fiddler
这是PC端的软件,Our process for simulating a weak network environment is roughly:手机APPProxy to ours using a web proxypc上,Then all network requests go throughpc,这个时候我们就可以通过fiddlerto limit the network,So as to achieve the purpose of simulating a weak network environment.
这就是Fiddler的主界面了:

第二步:设置fiddler
fiddlerAlso need to set up need to set up,Find the headTools功能,Then click on the first functionOptions,会弹出一个界面:

找到Connections,把port改为8888,At this time, you can use our mobile phone proxy to the computer.

第三步:Set up an Android device proxy
打开我们的手机,进入wifi设置,The thing to note here is that the Android device is connectedwifiMust be with oursPCIt is the same network to set up successfully.Available on most Android deviceswifiSet proxy in settings,However, it cannot be ruled out that a small number of devices are limited by the system.We need to know before setting up the proxyPC的ip地址,可以通过系统cmd命令,然后ipconfig获取,如下:

Then you can set up a proxy on your phone,This is my phonewifiInterface for setting up the proxy:

设置后之后,All network requests on the phone are proxied toFiddlerThen you can view it:

第四步:Set network restrictions
回到我们的fiddler中来,在工具栏中找到Rules,From the name it is obvious what this function is for.再到Rules列表中找到Customize Rules,At this point, something similar to a text editor will pop up:

used in this text editorCtrl+FUse the search function to search for keywords:simulate,The following code snippet can be found:
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";
}

The rest of this code is left alone,你只需要知道request-trickle-delayIt represents the delay time of your network request,response-trickle-delayIt represents the delay time of network response,单位都是毫秒,It is given by default here300毫秒和150毫秒,所以,只需要修改这2This value can simulate network delay and weak network environment,For example, the above can be modified2个值为:2000和2000,Represents network request latency2秒,网络响应延迟2秒:
if (m_SimulateModem) {
// Delay sends by 300ms per KB uploaded.
oSession["request-trickle-delay"] = "2000";
// Delay receives by 150ms per KB downloaded.
oSession["response-trickle-delay"] = "2000";
}
Remember to press after making changesCtrl+S保存.
第五步:开启网络延迟
Then you can turn on the network delay,还是我们的Rules功能中,找到Performance,Then one can be seen in the sub-optionsSimulate Modems Speeds,选中它,大功告成,Network latency is turned on,Turn off network delay if needed,再次点击即可.
第六步:Expand weak network rules
Probably we don't want a consistently weak network environment in our testing,Rather, it is a randomly strong and weak network,This is more appropriate to our real situation,Then we can modify the above code as :
static function randInt(min, max) {
return Math.round(Math.random()*(max-min)+min);
}
if (m_SimulateModem) {
// Delay sends by 300ms per KB uploaded.
oSession["request-trickle-delay"] = ""+randInt(1,2000);
// Delay receives by 150ms per KB downloaded.
oSession["response-trickle-delay"] = ""+randInt(1,2000);
}
这里的randInt(1,2000)应该很好理解,代表1-2000中的一个随机整数,In this way, there will be occasional delays and occasional good network conditions
现在我邀请你进入我们的软件测试学习交流群:【746506216】,备注“入群”, 大家可以一起探讨交流软件测试,共同学习软件测试技术、面试等软件测试方方面面,还会有免费直播课,收获更多测试技巧,我们一起进阶Python自动化测试/测试开发,走向高薪之路.
喜欢软件测试的小伙伴们,如果我的博客对你有帮助、如果你喜欢我的博客内容,请 “点赞” “评论” “收藏” 一 键三连哦!
边栏推荐
- prometheus 监控概述
- 软件测试工作3年了,谈谈我是如何从刚入门进阶到自动化测试的?
- pycharm重命名后无法运行(报错: can‘t open file......No such file or directory)
- VSCode插件:嵌套注释
- 程序员转正述职报告/总结
- C language _ structure pointer array function voting system
- Can an inexperienced college graduate switch to software testing?my real case
- 打印任务排序 js od华为
- 充电效果模拟
- What does a software test report contain?
猜你喜欢

pycharm重命名后无法运行(报错: can‘t open file......No such file or directory)

关于Redis相关内容的基础学习

Arbitrum 专访 | L2 Summer, 脱颖而出的 Arbitrum 为开发者带来了什么?

934. The Shortest Bridge

Centos 7.9安装PostgreSQL14.4步骤

最高月薪20K?平均薪资近万...在华为子公司工作是什么体验?

MySQL (6)

基于FPGA的售货机

MySQL的分页你还在使劲的limit?

Crypto Life, a day in the life of a Web3 project partner
随机推荐
加密生活,Web3 项目合伙人的一天
Fiddler抓包模拟弱网络环境测试
cudaMemcpy学习笔记
什么是理想的大学生活?
两个有序数组间相加和的Topk问题
C语言小程序 -- 常见经典练习题
勾股数元组 od js
12 pictures take you to fully understand service current limit, circuit breaker, downgrade, and avalanche
最大路径和
九州云入选“可信云最新评估体系及2022年通过评估企业名单”
最高月薪20K?平均薪资近万...在华为子公司工作是什么体验?
CV-Model【3】:MobileNet v2
Set the browser scrollbar style
Google官方控件ShapeableImageView使用
有没有可以做副业可以日入300元方法?
C language _ structure pointer array function voting system
C language applet -- common classic practice questions
prometheus 监控概述
How to expose Prometheus metrics in go programs
力扣刷题之爬楼梯(7/30)