tags:

views:

48

answers:

1

Hello,

I am looking to get the "Latency" field of a TCP connection. I notice windows Resource Monitor has this field, and I was wondering if there was a way I can find it. Preferrably without using WMI.

If you are unsure what field I am talking about, open Task Manager, goto the Performance tab and hit the Resource Monitor button.

Once Resource Monitor is open, expand the TCP Connections area and you will see a Latency field. Is there anyway to access this programatically?

Thanks!

A: 

I don't think you can access this information through any API. The Resource Monitor likely calculates it by seeing how long it takes for packets to be replied to.

To do this in your app, do something like this (pseudo-code):

startTime = now
socket = openSocket()
endTime = now
latency = endTime - startTime

It won't be extremely precise, but it should be pretty close to the actual network latency. However, keep in mind that Nagle's algorithm can mess with latency calculations.

Ben S
Any idea if there's a way to get what sockets or the ip that the connection is to? Problem is I need to monitor a program that can connect to 40 different IP's, and I don't know all of them.
Dave