ActiveXperts Network Component


ActiveXperts Network Component Icmp Object

ICMP/Ping is one of the most commonly used utilities on the Internet by people and programs, with untold millions of pings flashing every second back and forth between computers. The original PING utility stood for "Packet Internet Groper", and was a package of diagnostic utilities used by DARPA personnel to test the performance of the ARPANET. Almost every operating system includes a Ping program. It has become one of the most versatile and widely used diagnostic tools on the Internet.

ICMP/Ping sends a small packet of information containing an ICMP ECHO_REQUEST to a specified computer, which then sends an ECHO_REPLY packet in return.

You can use Ping to perform several useful network diagnostics, such as the following:

  • Access - You can use Ping to see if you can reach another computer. If you can't ping a site at all, but you can ping other sites, then it's a pretty good sign that your network is fine and that site is down. On the other hand, if you can't ping any site, then likely your entire network connection is down - try rebooting;
  • Time & distance. You can use Ping to determine how long it takes to bounce a packet off of another site, which tells you its distance in network terms. For example, a site hosted on your neighbor's computer next door with a different Internet service provider might go through more routers and be farther away in network distance than a site on the other side of the ocean with a direct connection to the Internet backbone. If a site seems slow, you can compare ping distances to other sites to determine whether it is the site, the network, or your system that is slow. You can also compare ping times to get an idea of which sites have the fastest network access and would be most efficient for downloading, chat, and other applications;
  • Domain IP address. You can ping either a domain name or an IP address. If you ping a domain name, it will helpfully display the corresponding IP address in the response;
  • TTL (time-to-live) - TTL prevents circular routing: the condition where an ICMP packet bounces in an infinite loop among intermediate hosts. The mechanism counts intermediate hosts along the route from source to destination.

The Network Component Icmp object enables you to add Icmp/Ping functionality to your program, and features the following:

  • Supports RFC-792;
  • Support for timeout and time-to-live (also called TTL);
  • Ping computers with error control messages;
  • Object oriented design;
  • Microsoft .NET compatible;
  • Samples for VBScript, Visual Basic, Visual C++, Visual Basic .NET, Visual C# .NET, ASP and ASP .NET

The Icmp object is part of the Network Component. Overview of all Network Component objects:

DnsServer & DnsRecord - Ftp & FtpFile - Http - Icmp - IPtoCountry - Msn - Ntp - Radius - Rsh - Scp - SFtp - Ssh - SnmpManager - SnmpTrapManager - SnmpMibBrowser - Tcp - Tftp - TraceRoute - Udp - Xen - Wake-on-LAN - Xen (Citrix)

Icmp Sample code

VBScript sample: ping a remote host

' Constants: Some Error codes 
Set icmpObj = CreateObject("AxNetwork.Icmp")
 strHost = inputbox( "Enter host", "Input", "" )
Loop until strHost <> ""
icmpObj.Ping strHost, 2000 ' Timeout 2000 ms
If( icmpObj.LastError = 0 ) Then
  WScript.Echo "Duration:" & icmpObj.LastDuration & "ms"
  Script.Echo "Error " & icmpObj.LastError
End If
WScript.Echo "Ready."

Visual Basic .NET sample: ping a remote host

' Constants: Some Error codes 
Imports AxNetwork

   Module Module1
      Sub Main()
        Dim objIcmp As IcmpClass = New Icmp
        Dim objConstants As SocketConstants = New SocketConstants
        Dim i As System.Int16
        Dim strHost As String = ""
        For i = 1 To 4
            Console.WriteLine("Pinging " & strHost & " ...")
            objIcmp.Ping(strHost, 2000)
            If (objIcmp.LastError = 0) Then
                Console.WriteLine("  Reply from " & strHost)
                Console.WriteLine("  Time=" & objIcmp.LastDuration.ToString())
            End If
       End Sub
   End Module

On, you can find a lot of Network Component samples. These samples are also part of the Network Component installation. Visit