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?
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
I do not know something from DotNet, but I am using NetLimiter that may help you
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.
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.
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.
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.