Fiddler capture tool use: weak network environment simulation speed the testing process (reproduced)

Transfer from: http: //www.51testing.com/html/80/n-3726980.html

Fiddler capture tool use: Weak speed network environment simulation testing process

Posted: 2018-6-06 11:46 Author: west of people Source: 51Testing network editing software testing

Font: Tai  Zhong  Small  |  Previous  |  Next  | I want to contribute  | Recommended tags:  software testing tool  Fiddler  capture tool

   A: Why do weak network test ?
  The actual customer site network may be unstable or low speed, poor network environment can lead to some bug, user experience and even some services are not available. The company's internal network is usually relatively smooth R & D environment, it is difficult to reproduce this bug. To solve this problem, we need to create a weak network environment for testing, reproduce and fix the problem.
   Two: how to simulate the harsh network environment?
  This article only fiddler , for example, the other to be understood that no specific studies.
   Three: Fiddler how weak analog network?
  Fiddler is an HTTP debugging proxy that can record all your computers and the Internet HTTP communications between the Fiddler also allows you to inspect all HTTP traffic, set breakpoints, and modifying all the "in and out" of data (refer to Cookie / HTML / JS / CSS files, etc.).
  To simulate the harsh network environment, simple, more intuitive, only drawback is that it supports those services use HTTP to communicate and interact using Fiddler.
  Fiddler open, the case where the default Rules -> Performances -> Simulate Modem Speeds state is unchecked, the network is normal. After this option is selected (analog optical cat network speed), speed will become very slow, open a web page to load for a long time. This realization of the weak network effect.
   Set up
  If you want to know the specific value (upload and download) speed, you can use a tool speedtest, speed is simple, there are a lot of online tutorials.
  http://www.speedtest.net/ site is in English, should be the foreign version, access is slower. And Windows systems only supports Windows10 download the client, I use Windows7 using the chrome browser extensions have to be installed Speedtest FQ, it is not recommended. Http://www.speedtest.cn/ site visit is recommended, and speed generate results quickly is in Chinese. Support phone client APP download.
   Four: the principle of speed limit
  Fiddler speed network is implemented in a delayed manner, network latency network speed * = number of bytes transferred.
  Click Rules - Customize Rules (shortcut Ctrl + R) to open the Fiddler ScriptEditor, or directly opening the right side of the home page to sign FiddlerScript.
  image.png
  After opening the file, Ctrl + F to find m_SimulateModem flag, you can see the following code:
  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"; }
  Description Note: values ​​represent request-trickle-delay is a delay in how many milliseconds per KB of data to be uploaded; response-trickle-delay data corresponding to each of the KB of how many milliseconds may be delayed download. For example, you want to simulate the upload speed network 100KBps, that delay is upload 1KB / 100KBps = 0.01s = 100ms, then changed to 100.
  When checked Simulate Modem Speeds, request-trickle-delay and response-trickle-delay will be set if their speed is quite fast, then the value can be approximately calculated here after opening the analog and upload download bandwidth, and upload default settings such as delay of 300ms download delay is 150ms, you can calculate the approximate analog bandwidth:
  Upload bandwidth = (1 * 8/1000) /0.300 ≈ 0.027Mbps
  Download bandwidth = (1 * 8/1000) /0.150 ≈ 0.053Mbps
  The resulting bandwidth of the actual circumstances there may be errors, subject to various external factors would not be so precise.
  Thus upload download bandwidth is twice, that is, the smaller the delay, the greater the bandwidth. Bandwidth and latency is inversely proportional herein.
   Five: adjust the network environment parameters
  Fiddler default Simulate Modem Speeds speed is too slow, but the speed limit parameters can be adjusted, if need to modify the configuration file can be a little faster Fiddler2ScriptsCustomRules.js. (Should modifications do not forget to back up the original file) can be found in the reference example fiddler official website http://www.fiddlerbook.com/Fiddler/dev/ScriptSamples.asp.
  Here are two simple ways to modify the script, you can select one.
  method 1
  Find if (m_SimulateModem) statement, modify the code. The following script implements a random delay amount is set so that the network bandwidth is not constant at a low value, but will be within a certain range of random jitter:
  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,50); // Delay receives by 150ms per KB downloaded. oSession["response-trickle-delay"] = ""+randInt(1,50);}
   Method 2
  Click fiddlerScript onBeforeRequest found in the code, here we define what to do before sending the request. Add the following code delay can be achieved:
  oSession [ "request-trickle-delay"] = "3000"; // request phase delay of 3 seconds oSession [ "response-trickle-delay"] = "3000"; // response phase delay of 3 seconds
   Add code
  Is selected from one of the above two methods, save the configuration file (Ctrl + S) modified or cleared buffer (Rules -> Performances -> Disable Caching), check again Rules -> Performances -> Simulate Modem Speeds for speed. Note: After each time you edit and save the configuration file, Simulate Modem Speeds option will be canceled, please re-check.
  限速完毕一定要取消勾选,不然会影响上网。像第二种方法由于请求和响应都延迟3秒,会导致访问网页很慢。
 

Guess you like

Origin www.cnblogs.com/yuany66/p/11229245.html