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!
I'm assuming that the Resource monitor looks at the Round Trip Time (RTT) for a given TCP table entry. This gives a reasonable indication of overall network delay.
There is an API you can use to access these statistics, namely GetPerTcpConnectionEStats. This allows you to retrieve plenty of stats about a specific TCP connection.
You basically get the list of tcp connections first using GetTcpTable, then find the row you want, and pass it to GetPerTcpConnectionEStats, with the TcpConnectionEstatsPath as the EstatsType parameter, so that you should get a TCP_ESTATS_PATH_ROD_v0 structure.
This structure has a number of RTT stats in it, the most useful of which is probably the SumRtt and CountRtt members, which you could use to get an average RTT calculation for that particular TCP table row.
Note that these functions only exist in Vista and above, but then so does the Resource Monitor, so I reckon that's ok.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With