当前位置:网站首页>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自动化测试/测试开发,走向高薪之路.
喜欢软件测试的小伙伴们,如果我的博客对你有帮助、如果你喜欢我的博客内容,请 “点赞” “评论” “收藏” 一 键三连哦!
边栏推荐
猜你喜欢
随机推荐
What are the project management tools like MS Project
内网渗透——提权
计算S=a+aa+…+aa…a
[Map and Set] LeetCode & Niu Ke exercise
最大路径和
软件测试要达到一个什么水平才能找到一份9K的工作?
【flask入门系列】Flask-SQLAlchemy的使用
MySQL的存储过程
打印任务排序 js od华为
软件测试基础接口测试-入门Jmeter,你要注意这些事
Jetpack Compose学习(8)——State及remeber
Jiuzhou Cloud was selected into the "Trusted Cloud's Latest Evaluation System and the List of Enterprises Passing the Evaluation in 2022"
数字图像隐写术之JPEG 隐写分析
类似 MS Project 的项目管理工具有哪些
leetcode-1161: Maximum in-layer element sum
【Map与Set】之LeetCode&牛客练习
Shell变量与赋值、变量运算、特殊变量
关于Redis相关内容的基础学习
软件测试工作3年了,谈谈我是如何从刚入门进阶到自动化测试的?
用户交互+格式化输出