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?

Apple app store favorites

I did’nt imagine I would find a device so much fun. An Apple iPod Touch 4 I bought last year has turned into one of my favorite time wasters, my daughters love it too. It is also a wonderful productivity tool. My old Windows Mobile smartphone has seen its usage plummet, except occasionally as a GPS or for tethering my PC to the Web.

I have listed below some of my favorite Game and non-Game apps. It is hard to place them in any particular order, so I have just ordered them alphabetically. I have also mentioned the price I purchased the app for, if it wasn’t free.


Angry Birds (99c)

This game is at the first position of the Top 25 list for several months now, it deserves its ranking.

Cat Physics

This a recent one for me, I grabbed it for its price (free) but already like it a lot.

Cover Orange

This is another favorite of mine and of my daughters.

Cut the Rope (99c)

My daughters love this one.

Fruit Ninja (99c)

I don’t find myself playing it much, but it is so good that I had to buy it. I am crazy for fruits and it makes my mouth water.

PES 2010 (99c)

I am not much of a football fan, my elder daughter is. I bought this game during the holidays for its price, but it keeps my daughter entertained, that makes it good enough for me.

Pocket Frogs

I have to admit, I am addicted to this game, it is my topmost time wasters. I am at only 13% of the achievements, which means I will be wasting quite a lot of my time over this one.

Talking Tomcat

This one is a favorite with my younger daughter. She loves poking the cat, talking or laughing at it, hear it repeat all of it back at her, you get the idea…


Documents To Go (9.99)

A convenient tool to view and (sparingly) edit documents, spreadsheets and presentations (Premium edition only) . I have not been able to project presentations using a dock connector to VGA adapter.


Makes it a breeze to get files into and out of the device. Requires an internet connection though.


Social networking is quietly taking over from other means of communications, particularly email. Facebook is leading the charge and this app is a must have.

Free Graphing Calculator

Free graphing calculator for the Math buff. It has a full-features scientific calculator, 2D graphing functionality, a reference section with math formulas, and some other niceties tucked away, such as a triangle solver and a polynomial solver.


Helps to get things nicely aligned, like a square ceiling light fixture aligned to the walls around it.


Book reader with PDF viewing support.

iHandy Level

If you do any kind of work around the house that requires a perfectly horizontal or vertical surface, and you don’t have a level, this is a decent replacement.


Forward your flight and hotel booking confirmation to and a trip is created, all information is conveniently synced to the app on the device.


A place to store those pesky passwords and PIN codes.


Read your Kindle books on the device. Nothing fancy, just as it should be.

Merriam Webster

Nice free dictionary. You need to be online to use some features such as voice search and audio pronunciation.

Network Ping Lite

For the geek. It also has a simple telnet console.


News reader. Makes sharing to Facebook a breeze.


It was good for voice, now it also does video.


Listens to a song and identifies it for you.


iCal does not have task lists, this app fits the bill.

.NET volatile keyword

I discuss the volatile keyword in this post with respect to the .NET CLR. C and C++ have different semantics for the volatile keyword. Using volatile to guarantee atomicity is not recommended. In fact, exactly for that reason .NET restricts the use of volatile to the following types:

  • Any reference type.
  • Any pointer type (in an unsafe context).
  • The types sbyte, byte, short, ushort, int, uint, char, float, bool.
  • An enum type with an enum base type of byte, sbyte, short, ushort, int, or uint.

I recently encountered a situation where I found volatile useful. I have a state attribute that is being changed concurrently by several threads. If I read that value at some point while another thread has just changed it, without volatile, I may read a value that is stale because it is held in a CPU register or cache. By using volatile I force that value to be read from memory before being checked. Any write to that attribute is also immediately written to memory.

Any variable not declared as volatile can also be written to memory using Thread.VolatileWrite and read using Thread.VolatileRead.

Auto scrolling to the end of a Gtk.NodeView

Here is how you add an item to a NodeView and auto-scroll right to it. I’ll assume you have read this tutorial and are not a total newcomer to NodeView. Using the example from the tutorial, here is how you auto-scroll to the item just added:

MyTreeNode node = new MyTreeNode ("The Beatles", "Yesterday");
view.ScrollToCell(new TreePath(new int[] {_n-1}), null, false, 0, 0);

Here, _n is the number of rows you have in the NodeStore. It can be a private attribute that should be incremented by 1 when a new row is added, and decremented when a row is removed.

That’s all there is to it!

On GTK# and InvokeRequired

Most user interface code is not thread safe. If multiple threads change UI components, unexpected things may happen. .NET Windows Forms programmers are familiar with the InvokeRequired property present in all controls. It is common to find code of the following kind in callback methods:

private void MyCallback()
  if (!InvokeRequired)
     // do something useful
    Invoke(new MethodInvoker(delegate
      // Anonymous delegate
      // Things to do in the UI thread

In GTK# this works slightly differently. To queue work to the UI thread use the static method Add from the Idle class in the GLib namespace. Here’s some example code.

private void MyCallback()
  GLib.Idle.Add(new IdleHandler(MyHandler));
private bool MyHandler()
  // do something useful
  return false; // return true if the idle handler must be called again

GTK# 2 has another method that can be used with anonymous delegates, Gtk.Application.Invoke. Its usage is described in the article Responsive Applications.

Favorite discourses from I Am That

Here are some of my favorite discourses from the book I Am That by Nisargadatta Maharaj. A pdf can be found here.

Q: How do I get at it? (the realization of who am I)

M:  You need not get at it, for you are it. It will get at you, if you give it a chance. Let go your attachment to the unreal and the real will swiftly and smoothly step into its own. Stop imagining yourself being or doing this or that and the realisation that you are the source and heart of all will dawn upon you. With this will come great love which is not choice or predilection, nor attachment, but a power which makes all things love-worthy and lovable.

Q:   I am engaged in the study of philosophy, sociology and education. I think more mental development is needed before I can dream of self-realisation. Am I on the right track?

M:  To earn a livelihood some specialised knowledge is needed. General knowledge develops the mind, no doubt. But if you are going to spend your life in amassing knowledge, you build a wall round yourself. To go beyond the mind, a well- furnished mind is not needed.

Q:   If the shape of things is mere appearance, what are they in reality?

M:  In reality there is only perception. The perceiver and the perceived are conceptual, the fact of perceiving is actual.

Q:   Where does the Absolute come in?

M:  The Absolute is the birthplace of Perceiving. It makes perception possible.

But too much analysis leads you nowhere. There is in you the core of being which is beyond analysis, beyond the mind. You can know it in action only. Express it in daily life and its light will grow ever brighter.

The legitimate function of the mind is to tell you what is not. But if you want positive knowledge, you must go beyond the mind.

Next Windows will support ARM SoCs

A while  back I wrote about MeeGo and how it mainly seemed like a push against Android and ARM, at least in openness. In mid 2010 Intel announced Atom SoCs (codenamed Oak Trail) targeting Android and MeeGo, besides Windows 7. Now, we come full circle with Microsoft announcing that its core Windows OS will support ARM SoCs from Nvidia and others, besides SoCs from Intel. That is a fairly important move considering how mobile computing has come of age. Note that Windows Mobile / Phone already does support such architectures, so this may hint at a future unification of Windows. I hope Nokia doesn’t get lost between Symbian and MeeGo.