Solved

visual studio 2010 + getting ping latency from remote computer

Posted on 2010-09-07
6
1,041 Views
Last Modified: 2012-05-10
I would like to get the ping information (latency) when I ping a remote computer.
0
Comment
Question by:mphillip85
  • 3
  • 2
6 Comments
 
LVL 19

Expert Comment

by:daveamour
ID: 33625121
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 500 total points
ID: 33625527
If you are talking about VB.NET, that MSDN article has some source code, but only for C#.  Here is the VB.NET translation:


Imports System.Net
Imports System.Net.NetworkInformation
Imports System.Text

Namespace Examples.System.Net.NetworkInformation.PingTest
	Public Class PingExample
		' args[0] can be an IPaddress or host name.
		Public Shared Sub Main(args As String())
			Dim pingSender As New Ping()
			Dim options As New PingOptions()

			' Use the default Ttl value which is 128,
			' but change the fragmentation behavior.
			options.DontFragment = True

			' Create a buffer of 32 bytes of data to be transmitted.
			Dim data As String = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
			Dim buffer As Byte() = Encoding.ASCII.GetBytes(data)
			Dim timeout As Integer = 120
			Dim reply As PingReply = pingSender.Send(args(0), timeout, buffer, options)
			If reply.Status = IPStatus.Success Then
				Console.WriteLine("Address: {0}", reply.Address.ToString())
				Console.WriteLine("RoundTrip time: {0}", reply.RoundtripTime)
				Console.WriteLine("Time to live: {0}", reply.Options.Ttl)
				Console.WriteLine("Don't fragment: {0}", reply.Options.DontFragment)
				Console.WriteLine("Buffer size: {0}", reply.Buffer.Length)
			End If
		End Sub
	End Class
End Namespace

Open in new window

0
 

Author Comment

by:mphillip85
ID: 33639407
how do i make the source (127.0.0.1) different.  I want to test a ping from a changing source and destination.  
0
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 
LVL 96

Expert Comment

by:Bob Learned
ID: 33640687
You don't have control over the source.  You would have to run the test from that machine.

The Ping class is a wrapper around the IcmpSendEcho2 command:

<DllImport("iphlpapi.dll", SetLastError:=True)> _
Friend Shared Function IcmpSendEcho2(ByVal icmpHandle As SafeCloseIcmpHandle, ByVal [Event] As SafeWaitHandle, ByVal apcRoutine As IntPtr, ByVal apcContext As IntPtr, ByVal ipAddress As UInt32, <[In]> ByVal data As SafeLocalFree, ByVal dataSize As UInt16, ByRef options As IPOptions, ByVal replyBuffer As SafeLocalFree, ByVal replySize As UInt32, ByVal timeout As UInt32) As UInt32
End Function

That function only specifies destination addresses, and not source addresses.

IcmpSendEcho2 Function
http://msdn.microsoft.com/en-us/library/aa366051(VS.85).aspx
0
 

Author Comment

by:mphillip85
ID: 33640789
what can i do to change the source.  is that a add-on for vb that will give me that flexibility?

there are utilities that you can set source and destination.  This is what my goal is.

Thanks
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 33640934
I believe that the difficulty is at the operating system level.  The assumption is that the source is already known, so it is not an argument.  There are no add-ons, or arguments that you can specify with IcmpSendEcho2 that will allow you to do that, that I know of.
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Advertise subnet not directly attached 6 47
get column names from table in vb.net 8 49
Sql server insert 13 36
Very Large data in MYSQL 7 73
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
The article explains the protocols and technology which is involved when two computers on different TCP/IP networks communicate with each other. In the diagram, a router is used to segregate two networks. The networks are 192.168.1.0/24 and 192…
After creating this article (http://www.experts-exchange.com/articles/23699/Setup-Mikrotik-routers-with-OSPF.html), I decided to make a video (no audio) to show you how to configure the routers and run some trace routes and pings between the 7 sites…
After creating this article (http://www.experts-exchange.com/articles/23699/Setup-Mikrotik-routers-with-OSPF.html), I decided to make a video (no audio) to show you how to configure the routers and run some trace routes and pings between the 7 sites…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question