Tracking Bandwidth & Latency in Linux

0

I'm trying to write a simple script that can detect dips in network traffic (both bandwidth and latency in both directions) between 2 arbitrary hosts in my network over time. Is there a tool to do this?

If needed, I plan to write a couple of client/server scripts in bash to perform this testing using nc (netcat), but if a pre-existing solution captures what I'm trying to do, please let me know.

First, I'll determine how much data I can send in 1 second between my arbitrary hosts. We'll call this the "payload". Initial tests show the payload to be ~50 MB.

Then I'll execute the following:

  1. Client sends the payload to the server.
  2. When the server receives the entire payload, it will immediately respond by sending a payload to the client.
  3. When the client receives the entire payload, it will sleep for 30 seconds. Go to 1.

By doing so, I will receive the following data (bidirectional bandwidth & latency):

  1. By recording the time to execute the nc from client to server in (1), I will get the bandwidth sending data from client to server.
  2. By recording the time to execute the nc from server to client in (2), I will get the bandwidth sending data from the server to the client.
  3. Somehow I'll determine packet latency, perhaps using a monitoring tool or diff-ing the timestamps between the first packet of the payload sent from the source and the first packet of the payload received on the destination.

Michael Altfield

Posted 2016-01-29T20:51:20.977

Reputation: 413

Question was closed 2016-02-09T00:54:29.643

Answers

0

iPerf is a good tool for performance testing. Rather then write a script to monitor load the way you propose, I'd look at Nagios (and integrate PNP4Nagios which will sort out notifications for you, and provide you with graphs of performance over time.

I do wonder how practical it is to move data between hosts like this on a constant basis long term, as this wastes the bandwidth which would otherwise be available. Would you not be better monitoring real throughput of the link and correlating this with latency and packet loss to work out if you are getting what you are paying for when you need this ? (I've "slapped down" ISP's who - playing the oldest game in the ISP book - tried to insist the problem was not on their network more then once using this, especially when monitoring multiple points)

I note that while latency, packet loss and throughput are not totally dependent on each other, there is (for a link with known/contracted/expected characteristics) a correlation between these factors.

davidgo

Posted 2016-01-29T20:51:20.977

Reputation: 49 152

iperf (not to be confused with netperf) works great for testing bandwidth in nearly exactly the way I described (using arguments appropriately = time iperf -c <ip> -t 1 -r -i 30), but it does not test for latency. For testing latency without ICMP, I'm using hping -S – Michael Altfield – 2016-02-02T00:17:54.373

0

You need to check is iperf does what you need.

Based on my understanding of your questions, I think it should.

Clark Wierda

Posted 2016-01-29T20:51:20.977

Reputation: 41