How to Test Applications Under Poor Network Conditions with Bean Network Tester

What happens when the application we’re testing suddenly encounters poor network conditions? Limited download/upload speeds, a sudden loss of connection, blocked connections, high ping and jitter, or something else? Will the famous “It works on my machine” still hold true? We can find it out with Bean Network Tester, a free and open-source network condition simulator for Windows and Linux.

Author: Dominik Babiarz, https://www.linkedin.com/in/dominik-babiarz-7728111a6/

What Can a Bean Network Tester Do? + Download

The program is available for download from GitHub. For Windows, download the .zip or .msi file, and for Linux, download the .tar.gz archive. For the local packet capture, the program needs to be run with administrator privileges. The tool can be operated entirely through the GUI or CLI (for integration with CI/CD pipelines).

With Bean Network Tester, we can simulate packet loss, packet corruption, packet duplication, burst packet loss, high ping, jitter, and latency spikes. We can also limit download/upload speeds and much more! :-) On top of that, the program includes a connection list, additional networking tools, and a mini firewall.

Simulating Poor Network Conditions: Quick Start

After launching the program for the first time, we’ll see a huge number of options. If we just want to quickly test our application, then the “Profiles” section offers a list of predefined profiles such as “4G”, “3G”, “Poor Wi-Fi”, and so on. The profiles are sorted from the “best” network conditions to the “worst” one.

To quickly test our application, we can follow these steps:

  1. In “Profiles”, select ”LTE/4G” (at the top, next to the program name, the “Preview” section will show which network parameters will be applied to the connections).
  2. In “Process”, enter the name of our application, in my case, “myapp.exe”.
  3. Click the “Start” button.
How to Test Applications Under Poor Network Conditions with Bean Network Tester
(click on the figure to enlarge)

This way, our application will run under the selected network conditions. There are tons of profiles to choose from, and we can also create our own profiles. Profiles are saved in
C:\Users\<username>\AppData\Local\BeanNetworkTester in a file called bean_network_tester_profiles.json, so we can easily share them with other team members if needed.

Important: If we do NOT specify a target, the program will affect all network traffic.

Simulating API Connection Problems

Bean Network Tester allows us to adjust various network conditions in real time, without stopping the program. If we scroll down to the “Destination Targeting” section, we’ll find an interesting option that lets us target both an IP address AND specific ports. Because I had previously entered “myapp.exe” in the “Process” field, after filling in the IP and port fields, I’ll be targeting connections made by myapp.exe to IP address 192.168.1.55 on ports 654 or 562.

I could also change the jitter parameter (variation in network latency) or another parameter, such as “Corrupt” (packet corruption), or something else. The possibilities are quite huge! This way, we can simulate problems with specific IP addresses and ports (for example, external APIs). After changing the parameters, we need to click the “Apply Changes” button.

How to Test Applications Under Poor Network Conditions with Bean Network Tester
(click on the figure to enlarge)

Pro tip: If we DON’T specify an application name in the “Process” field, we can target all network traffic to specific IP addresses and/or ports.

Pro tip 2: There’s a “Search” input field at the top of the program, so if we’re looking for a specific setting, we can easily find it.

What Should We Test in Application Network Communication?

With Bean Network Tester, we can simulate various interesting test scenarios:

  • “LAN Mode” (Traffic to Modify) → We can simulate a LAN-only environment, with no external network connections. What happens if our app CAN’T connect to external APIs or other online services?
  • “Blocking (Firewall)” → What if we will simulate a situation, where a specific service is unavailable because the connection to it is blocked?
  • Another interesting scenario is testing with IPv4-only or IPv6-only traffic, depending on what we’re testing.
  • How will our application behave if we limit its “Download” and “Upload” speeds? Will it still be usable?
  • The program also lets us reset specific TCP connections, configure a percentage chance of random connection resets, or drop TCP SYN packets. I won’t go too deep into the networking details here, but I encourage you to experiment! Another interesting test is triggering a TCP reset or another type of connection failure while uploading a file or working on something online.

Of course, there are many more scenarios we can simulate. It all depends on what we’re testing.

Pro tip: “in very simple words”, think of TCP as sending a registered letter – there’s an established connection, delivery confirmation, and mechanisms to ensure data arrives correctly. UDP, on the other hand, is more like dropping a letter into a mailbox – maybe it arrives, maybe it doesn’t. Who knows?

Automating Application Network Testing with Test Scenarios

Another interesting feature of the program is its support for scenarios. Bean Network Tester comes with several built-in scenarios, and we can also create our own. We can load scenarios into the program using the “Load Scenario…” button (at the very bottom).

How to Test Applications Under Poor Network Conditions with Bean Network Tester
(click on the figure to enlarge)

Scenarios are stored in .json format. If we open the BeanNetworkTester\_internal\scenarios\failing-dns.json file, we’ll see the following format:

{
  "loop": true,
  "steps": [
    { "at": 0,  "settings": { "dst_port": "53", "latency": 10, "jitter": 5 } },
    { "at": 15, "settings": { "loss": 25, "latency": 200, "jitter": 200 } },
    { "at": 35, "settings": { "loss": 60, "latency": 750, "jitter": 500 } },
    { "at": 55, "settings": { "loss": 100 } },
    { "at": 68, "settings": { "loss": 10, "latency": 100, "jitter": 80 } },
    { "at": 85, "settings": { "loss": 0, "latency": 10, "jitter": 5 } }
  ]
}

At “x” seconds into the simulation, apply the specified “y” network parameters. For example, if we also wanted to limit download/upload speeds in the settings, we could modify the first step of the scenario like this:

{ “at”: 0, “settings”: { “dst_port”: “53”, “latency”: 10, “jitter”: 5, “down”: 1024, “up”: 256} },

This way, we can create ready-to-use test scenarios and run them before each new application release.

Pro tip: This scenario also affects TCP traffic. If we want to target only UDP traffic, we need to change this in the “Traffic to Modify” section of the program. Scenarios themselves do NOT support changing TCP/UDP filtering.

Automating Network Testing in CI/CD + CLI

In addition to automating tests with scenarios, we can also use the CLI to simulate various poor network conditions or run predefined scenarios. On Windows:

BeanNetworkTester.exe --scenario _internal\scenarios\congested-vpn.json --target myapp.exe

and Linux:

sudo ~/Downloads/BeanNetworkTester-v1.0.0-linux-x64/BeanNetworkTester/BeanNetworkTester --scenario_internal/scenarios/congested-vpn.json --target myapp
How to Test Applications Under Poor Network Conditions with Bean Network Tester
(click on the figure to enlarge)

Very important: By default, the program does NOT stop automatically, there is no time limit. The same applies when using a scenario with loop: true. When working with RDP or CI/CD pipelines, I strongly recommend avoiding loop: true and I advise using the –duration <seconds> parameter to set a time limit. You can read more about the available CLI flags here.

Pro tip: If you’re lazy like me, there’s no need to write CLI commands manually. In the “Statistics” tab, you’ll find a “Copy CLI Command” option. Just configure the parameters, start the simulation, stop it, and copy the generated command.

Monitoring Network Connections and Other Tools

Another interesting feature is the “Connections” tab, where we can view network connections established while the program is running (after clicking the “Start”). We can also export connections to CSV file and filter them by various fields.

For example, if we want to see how much data our app sends over an hour, we can run a session with –duration 3600 or enter 3600 in the “Run Time” field in the GUI, then find our app in the “Connections” tab.

How to Test Applications Under Poor Network Conditions with Bean Network Tester
(click on the figure to enlarge)

Some features I haven’t mentioned before include the “Seed” option for reproducing test conditions, the “Events” tab for marking when errors occur and exporting event data, and plenty of other tools and settings that I encourage you to explore on your own! :-)

Another interesting feature is the “Tools” → “Adapters” section, where we can view our network configuration, as well as “Tools” → “Port Check”, which lets us check whether specific ports are available or in use.

How to Test Applications Under Poor Network Conditions with Bean Network Tester
(click on the figure to enlarge)

Summary

Testing applications under different network conditions is a much broader topic than we can cover in this article, so I encourage you to experiment with the tool and see how your application behaves under poor network conditions. You can read more about Bean Network Tester here

About The Author

Dominik Babiarz (DonislawDev) – QA, Indie Game Developer, creator of open source tools for QA and system administrators. You can find him on GitHub
and on his Blog

Be the first to comment

Leave a Reply

Your email address will not be published.


*


This site uses Akismet to reduce spam. Learn how your comment data is processed.