How to Implement Network Simulation in JMeter

Reading Time: 2 minutes

Hi Folks,
In this blog, we will discuss How to implement Network Simulation in JMeter

Why Network Simulation is needed?

  • Day by day, mobile traffic over desktop traffic is growing, and there is a need to focus on mobile users for performance testing
  • Mobile web traffic comprises users with different connection speeds.
  • It is very important to perform load testing on mobile apps with different connection speeds

How to Simulate Network Speed?

1. Open file located in /bin folder of JMeter

2. Search for the keyword “cps”

3. If we are searching using “cps” then we will get two properties:
a) httpclient.socket.http.cps=0
b) httpclient.socket.https.cps=0
then remove “#” to enable the properties

a) The first property simulates the speed when we use HTTP method (protocol)
b) The second property is used to simulate the speed for HTTPS method

4. Calculate the value using the below formula or use CPS Calculator
CPS = RB * 128
CPS = Characters per second
RB = Required Bandwidth, The input value of the required bandwidth should be in kbps

5. Save and close the file


If we want to simulate 500 kbps speed for our test then the calculation will be:
=> cps = 500 x 128
=> cps = 64000
after that, we need to set
Hence JMeter will send the data with the speed of 64000 characters per second and we will achieve 500kbps network bandwidth

How to set bandwidth using the command line option?

To set the speed in the non-GUI mode, use the below command:
jmeter -J httpclient.socket.http.cps=<calculated value> -n -t <path of .jmx> -l <path of .jtl>

Points to remember:

1. Check the testing environment network bandwidth before simulating the speed. Because JMeter can only simulate the bandwidth equal to or less than the testing environment network bandwidth
2. Use RB (Required Bandwidth) value in kbps for CPS calculation
3. In a distributed mode, we can set a different bandwidth for each remote engine by specifying our desired ‘cps’ value in the file to run the test cases

So, In this way, we can simulate the network using JMeter

I hope you enjoyed it and it helped you!! stay connected for interesting blogs.

References :

Written by 

I am curious about to learn new technologies. I have good understanding of performance testing concepts.