When using jmeter for load testing, sometimes it is necessary to verify the impact of network bandwidth on performance, so how to simulate different network speeds in JMeter load testing.
Limit output bandwidth to simulate different network speeds
JMeter does provide you with the option to limit the output bandwidth in order to simulate different network speeds. The bandwidth can be controlled by the following two attributes:
1、httpclient.socket.http.cps = 0
2、httpclient.socket.https.cps = 0
They are used for HTTP and HTTPS protocols respectively. The attribute defaults to zero, which means there is no limit. The acronym "cps" stands for "characters per second." When the property is set to greater than zero, the bandwidth will be limited according to your settings.
This is the formula for calculating "cps": [Kbps, also known as bit rate, refers to the transmission rate of digital signals, that is, how many thousands of bits of information are transmitted per second]
cps = (target bandwidth, converted into Kbps as a unit, then * 1024/ 8
For example: To simulate the GPRS cellular network speed (download 171 Kbits/sec), the relevant CPS value will be: 21888 (171 * 1024/8)
Here is how to limit bandwidth through these attributes :
1. Find these two lines in jmeter.properties and add these two lines to the user.properties file
httpclient.socket.http.cps = 21888
httpclient.socket.https.cps = 21888
Restart JMeter to take effect.
2. The attribute value can also be passed through the -J command parameter, as shown below:
jmeter -J httpclient.socket.http.cps = 21888 -J httpclient.socket.https.cps = 21888 -t /path/to/your/testplan.jmx