Network throughput ballpark using Ping

Can the humble ping (ICMP echo) be used to measure network throughput? There is  no good standard way to measure network throughput. Using different networking protocols and routers in the network can affect throughput considerably. I recently conducted a simple experiment to measure network throughput using ping. I implemented a simple program in C# and compared the result with dedicated applications that measure throughput.

Let us begin with the program. It uses the Ping class from the .NET framework. We ping twice, once with the default buffer size and another time with a bigger buffer size. How big the buffer size is, is determined based on the response time. If the response time is too low, we increase the buffer size till be get a sufficiently high response time. We then use the following formula to calculate the throughput:

throughput in bits per second = L21000*8 / (ts – tb)


L = buffer length

ts = response time in milliseconds with small buffer size

tb = response time in milliseconds with big buffer size

Here’s the source code.

class Program
  const int TIMEOUT = 5000;
  const uint BUFFER_SIZE = 128;
  static byte [] buffer = new byte[BUFFER_SIZE];

  public static void Main (string[] args)
    Ping ping = new Ping();
    long ts;
    long tb;
    while (true)
      PingReply reply = ping.Send(args[0], TIMEOUT);


      if (reply.Status != IPStatus.Success)
        Console.WriteLine("Cannot ping: {0}", reply.Status.ToString());

      Console.WriteLine("Round trip time: {0} ms", ts=reply.RoundtripTime);

      reply = ping.Send(args[0], TIMEOUT, buffer);

      if (reply.Status != IPStatus.Success)
        Console.WriteLine("Cannot ping: {0}", reply.Status.ToString());

      tb = reply.RoundtripTime;

      if (tb - ts <= 4)
        if (buffer.Length*2 < 65500)
          buffer = new byte[buffer.Length*2];

      Console.WriteLine("Throughput with {0} byte buffer: {1:0} b/s\r",
      buffer.Length, (double)buffer.Length*2000*8 / (tb - ts));

Here’s the output on a network between two PCs, each with a 100 megabit network card, and a switch between them.

Round trip time: 1 ms
Throughput with a 32768 byte buffer: 87381333 bits/sec

The result of throughput measured using Ixia QCHECK is shown below.

TCP Throughput: 90.09 Mbps

UDP Throughput: 38.096 Mbps

I am wondering why the UDP throughput is consistently lower than the TCP throughput in those results. I’ll leave that discovery for another post.

Do you think ping can serve as a basis for throughput measurement?


One thought on “Network throughput ballpark using Ping

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s