Simulating slow connections with TCPMon

Posted by

Lately there have been two issues in Enonic CMS that were impossible to recreate without a slow connection. In one situation, we needed to see what happened when a download of a large binary file was stopped by the user. In our office, even downloading a 16Gb file was so quick, we were not able to stop the download before it had completed. So, a tool to simulate a slow connection was needed. We found the Apache open source utility TCPMon.

Apache TCPMon is a very simple, open source TCP Monitor written in Java.  It is no longer supported, and there are some stability issues, so it is not recommended for any heavy duty testing.  However, it is so simple to set up and get started with, so for a quick test, it is perfect.  Check out the web-page here: Apache TCPMon .

Quick start guide

After you have downloaded and unzipped the distribution, just run the .sh / .bat script to get it started (you may have to make the .sh-file executable).  You will then be presented with a configuration screen like this:

Screenshot 2014-02-28 17

The options are pretty self explanatory.  You choose a target host and port of the computer you are going to access, and map it to a listen port on your local machine.  We use Tomcat for local testing, and run it on port 8080, so I set up port 8081 to be used to access localhost:8080.  Then I add a 10 ms delay for every 1024 bytes transferred.  This will make a 1Mb file take a little more than 10 seconds on a local download, while normal web-pages still load fast enough, not to be too annoying.

And that's really it.  Direct your requests to port 8081 instead of 8080, and TCP Mon will slow down your connection, listing details of each request in a new tab: 

TCP Mon Screenshot 2014-03-26 12

TCP Mon provides quite a lot of interesting details about each request, and it is quite possible to use it for more advanced network traffic analysis, but be warned:  The heavier the use, the more likely it is to crash.  In my experience, the crashes came a little too often, but when they happened, closing the tab, by clicking the "Stop" button, and restarting the listener was all that was necessary to get going again.

Compared to more complete products like WireShark, TCP Mon is not really delivering the goods, neither in functionality nor in stability.  But it is very easy to set up and get going with, and if the problem at hand is simulation of a slow connection for some simple testing, it is more than good enough.