tags:

views:

280

answers:

6

I have an application hosting a WCF service (net.tcp) that receives and sends data. Is there a way to know how much data has been transferred since the host was started?

A: 

I would assume there would be a performance counter available for that, yes.

Check out the dozens of performance counters in PerfMon that WCF installs in your system - I'm pretty sure there's one dealing with data sent and received....

Otherwise, programmatically : no, not without extensions, I'd say.

Marc

marc_s
A: 

I do not know something from DotNet, but I am using NetLimiter that may help you

Ahmed Said
+1  A: 

I would assume the performance counters (perfmon) .NET CLR Networking\Bytes Sent and .NET CLR Networking\Bytes Received for the process instance your interested in, though I've never used them directly, they may provide the information your looking for.

Zach Bonham
A: 

There is no way to find out total bytes transferred per service 'out-of-the-box' with WCF. You would need to extend WCF to capture this information. I think a BindingElementExtension with an IMessageInterceptor would get you to the level where you could inspect individual messages flowing through the service. At that point you would just need to get the size of the message.

This project allows for compression of WCF messages, which means it gets to the same low level that you would need to reach.

AgileJon
+1  A: 

WCF has its own counters , it will help you get info you need.

for that you have to enable them

like this

<configuration>
    <system.serviceModel>
        <diagnostics performanceCounters="All" /> // use this line.
    </system.serviceModel>
</configuration>

then there are 3 types of counters per service , visble hwn service is hosted & running.

ServiceModelEndpoint 3.0.0.0 + ServiceModelOperation 3.0.0.0 + ServiceModelService 3.0.0.0

i think ServiceModelOperation 3.0.0.0 will give u bytes sent/recieved.

Ajax2020
I added the information in the configuration file but I can't seem to find the counter relative to the sent/received bytes in the performance monitor utility. Are all the counters shown there or are there more counters accessible programmatically?
Julien Poulin
Also, do you know if I will be able to get this kind of information even when the communicating services are on the same machine?
Julien Poulin
A: 

I can confirm that the .NET CLR networking counters appear to work correctly for WCF services. There is an initial bit of unmanaged network activity that you won't capture, but that will be a small percentage of the total over time. I've compared these CLR networking counters with other means and find that they line up for the client/server I'm testing.

scolestock