Click here to Skip to main content
15,893,594 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to write a program in c# which will give me network bandwidth usage per protocol like 80, 8080, 443 etc. I have written code to calculate total bytes sent and received using NetworkInterface class but I am not getting any method/class to calculate the bytes per port like 80,8080,443 etc.
Please assist in this.
Posted
Comments
Ravi Bhavnani 18-Nov-15 18:37pm    
Does this article help?

http://www.codeproject.com/Articles/4194/Packet-Capture-and-Analayzer

/ravi
Member 12150952 19-Nov-15 2:58am    
Thanks Ravi for your comment. I looked into this but it is giving packet capture details, I didn't get the details of bytes usage for each protocol. Could you please help me in understanding this?
Member 12150952 19-Nov-15 4:28am    
I am using below code to get total bytes sent and received.

IPv4InterfaceStatistics interfaceStatistic = networkInterface.GetIPv4Statistics();
double bytesSentSpeed = (double)(interfaceStatistic.BytesSent – lngBytesSend) / 1024;
double bytesReceivedSpeed = (double)(interfaceStatistic.BytesReceived – lngBtyesReceived) / 1024;


Is there any way like this to get the bytes sent and received for specific protocol/port?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900