• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 752
  • Last Modified:

How to obtain the bytes received and sent from an network interface card

Hi Experts, I want to able to capture the amount of data that is being transmitted and received based on a selected NIC card. Below are the 2 requirements that I need to fulfil:

a. To list all the network adapters found in the computer
b. Based on the selected network adapter, I need to record the amount of data that is being transmitted and received.

Please advice how to implement this solution in VB.NET 2005. Please provide a sample code snippet.
0
bpyeo
Asked:
bpyeo
1 Solution
 
Kevin CrossChief Technology OfficerCommented:
Hello bpyeo,

Something like this as an exampled (see code snippet).

Regards,

mwvisa1
Module Module1 
    Sub Main()
        Dim netAdapters() As System.Net.NetworkInformation.NetworkInterface = System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces() 
        For Each netAdapter As System.Net.NetworkInformation.NetworkInterface In netAdapters
            Console.WriteLine(netAdapter.Name) 
            If netAdapter.Name = "Local Area Connection 2" Then
                Dim netStatistics As System.Net.NetworkInformation.IPv4InterfaceStatistics = netAdapter.GetIPv4Statistics()
                Console.WriteLine(String.Format("{0} has {1} bytes received and {2} bytes sent so far.", netAdapter.Name, netStatistics.BytesReceived, netStatistics.BytesSent)) 
            End If
        Next 
        Console.ReadLine()
    End Sub 
End Module

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now