开发者

Measuring "total bytes sent" from web service with nettcpbinding using perfmon

开发者 https://www.devze.com 2023-04-08 14:37 出处:网络
I have a web service (WCF) exposing both http endpoints and a tcp endpoint (using the nettcpbinding). I am trying to measure the difference in \"total bytes sent\" using the different endpoints.

I have a web service (WCF) exposing both http endpoints and a tcp endpoint (using the nettcpbinding). I am trying to measure the difference in "total bytes sent" using the different endpoints.

I have tried using perfmon and looked at the performance counter: web service > total bytes sent. However it looks like that this only measures http traffic - ca开发者_如何学运维n any of you confirm this? It doesn't look like tcp traffic increments the number.

There is also a TCP category in perfmon, but there is not a "total bytes sent". Is perfmon the wrong tool for the job?


Solved. I measured bytes received on the client by using code something similar to:

NetworkInterface[] interfaces = NetworkInterface.GetAllNetworkInterfaces();
NetworkInterface lan = null;

       foreach (NetworkInterface networkInterface in interfaces)
        {
            if (networkInterface.Name.Equals("Local Area Connection"))
            {
                lan = networkInterface;
            }
        }

        IPv4InterfaceStatistics stats = lan.GetIPv4Statistics();
        Console.WriteLine("bytes received: " + stats.BytesReceived);

Do this before and after the web service call and diff the 2 values. Obviously you need to be aware that any other traffic on the client does not interfere.

0

精彩评论

暂无评论...
验证码 换一张
取 消