Mark Eschbach

Software Developer && System Analyst

Measuring TCP/IP Flow

Techniques for measuring application usage of TCP/IP bandwidth

Ever wondered what the bandwidth usage was for a TCP/IP connection? I have. Wondering how to prove my hypothesis on deployment architecture bandwidth has lead me to formalize my search. The research is to capture a single TCP/IP stream between two networked hosts containing a discrete stream.

Some applications, such as web browsers like Firefox, Chrome, and Safari, support proxying. I would imagine for those you could enable some form logging to calculate the total. That is the theory for those, however I have yet to do so.

Another possible solution is to use a virtual machine. If you were to boot up a virtual machine and use an operatoring system sush as Linux or FreeBSD you could capture the bandwidth usage on the virtual network interfaces. The drawbacks to this approach is there is other traffic which will be counted, including ARP, DHCP, DNS, and other infrastructure protocols. In theory this would be less than a physical machine (especially one with mDNS peers on it).

For a simple single port service you could use a reverse proxy. A reverse proxy listens for connections, then initiates a connection to a predefined host. While copying the data from the client stream to the proxied stream you could count the number of bytes.

Network Caliper

I needed an application to track the bandwidth usage on the TCP/IP layer of SSH. SSH is bidirectional pipe unsolicited data being pushed through. In order to addres this problem I wrote a simple node service. The node service establishes a local service socket and waits for a connection. Once a client connects the service establishes a connection to a remote TCP/IP service and copies all traffice in both directions. I choose node.js because it provdies some stream pumping operations with minimal effort and tracks the bytes itself.

The project has been posted at github:meschbach/network-calipers.