Compilation of already published Articles/Ideas/Problems-Solutions which I faced or came across over the period of time. Largely a place for me to document it as note-to-self. Nothing serious. :)
Sunday, July 15, 2012
TCPMon - A Basic Tutorial
By Abdullah ChougleMon, 03/05/2012 - 09:26
TCPMon is a nice little tool for testing TCP communication between a client and server. It is an open source project, distributed under the Apache 2.0 license.
Downloading and Running TCPMon
To download TCPMon, head over to the Apache TCPMon download page and download the binary distribution.
(There’s a Google Code Project called TCPMon too, but that’s not the same one, and has fewer features)
Once downloaded and extracted, navigate to the build folder and run TCPMon by executing tcpmon.sh on Linux or tcpmon.bat on Windows. (On Linux, you’ll need to set the execute bit on the sh file before you run it). Note that your current working directory must be the build folder, else Java will report a ClassNotFoundException
TCPMon as an intermediary between clients and a single server
I found TCPMon useful when testing a webservice client I was implementing – I wanted to be certain that it’s sending the right data, and also wanted to double check the server responses in a convenient way. Here’s what you need to do:
Specify the listener properties. The listener port is any arbitrary port that you’d like TCPMon to listen to (and that any other process isn’t using). The target port is that of your webservice.
In the window that appears, you will be able to monitor connections between your client and server after setting up your client to point to TCPMon’s listening port. TCPMon forwards all requests to the target server, and you’ll be able to see the requests and responses as they occur.
Checking the "XML Format" box adds appropriate indentation to any XML in subsequent requests and responses. This can make it easier to read.
TCPMon as a proxy server (an intermediary between clients and an outbound connection of the machine hosting TCPMon)
Another functionality is the use of TCPMon as a proxy - you can set up a proxy server on your machine using it, so that all requests from another device or machine are routed through the proxy.
I found this useful when testing on mobile devices that needed to connect to a VPN network accessible from my computer, but not from the device itself.
Here’s what you need to do to set up the proxy server:
To get a mobile device connected through this proxy, you'll need to modify the proxy settings of your Wifi connection:
Now all requests from this device will be routed through the TCPMon proxy.
Note that TCPMon is useful only for simple testing of requests and responses - it fails to work on anything more than a small number of requests. You’ll need a dedicated proxy server for that.
Also, if you’re connecting to a single server, it’s best to go with the first approach of an intermediary rather than a proxy server, so that TCPMon doesn’t capture traffic you don’t need to inspect.
Sending custom requests
The “Sender” tab can be used to craft your own SOAP requests and send them. The fields under this tab are pretty self-explanatory: