Jump to content

Network Interface Info, Statistics, and Traffic


Ascend4nt
 Share

Recommended Posts

Works on 7 x64. Thanks for sharing.

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

Thanks for the tests.  Btw, my 'splash window' height calculations aren't very scientific as you've seen from my other thread. :unsure:

Link to comment
Share on other sites

Ok, fine.  I'm never happy leaving things looking halfway done.  Now I've added IP and ICMP statistics.  See 1st post. Oh, and ICMP doesn't change that often - to force an increase, do a 'ping' from the command prompt.

Link to comment
Share on other sites

The splash screen is OK this time. I tested the new version and pinged a machine, it registered the packet being sent with your UDF.

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

  • 2 weeks later...

I've update this UDF with a bunch of more information.  Network adapters and interfaces are now queryable. Arrays of information about each network interface are now returned from certain functions.  Inside the arrays are indexes which can be used to query network statistics for each network interface.

This is a pretty big change from my first version of Network Statistics (I call it version 2!), so if anyone inquires about it, I could upload the old version again.  However, I plan to split the main UDF from the example in the future.

Updates:

2013-07-02:

 Fixed: indexing, updated and enhanced output

 Changed: Various functions return arrays even if failure - this is to make XP pre-SP1 and also collection of IPv6 less troublesome. @error should still be checked on return though!

 Added: Adapter and Interface information and statistics collection

See the first post

Link to comment
Share on other sites

I'm getting an error:

C:\_Downloads\NetworkStatistics.au3 (1267) : ==> Subscript used with non-Array variable.:
ConsoleWrite("Interface #"&$i+1&" Entry Info: [0] Interface Index = " & $aNIEntryInfo[0] & ", [1] Interface Type = " & $aNIEntryInfo[1] & ", ...
ConsoleWrite("Interface #"&$i+1&" Entry Info: [0] Interface Index = " & $aNIEntryInfo^ ERROR

Br,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

UEZ, thanks.. can you insert this line after the call to _Network_InterfaceInfo() and tell me what it reports?:

ConsoleWrite("_Network_InterfaceEntryInfo return, @error = " & @error & ", @extended = " & @extended & @CRLF)

Also, is there information reported to the console from the call to _Network_IPAllAddressTable() on?  I've tested this so far in 3 different VM environments, so I was hopeful.. <_<

Link to comment
Share on other sites

Sure.

Output:

_Network_InterfaceEntryInfo return, @error = 3, @extended = 2

Br,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

That is really really peculiar.  There's nothing in the documentation for GetIfEntry that mentions ERROR_FILE_NOT_FOUND (2), and in light of what the function does it really makes no sense to give that specific error.

I also asked if you had any console output from the call to _Network_IPAllAddressTable() onwards.  It seems it must return an array if it doesn't crash until _Network_InterfaceInfo()..  does the data look valid? Perhaps adding that ConsoleWrite() debug message after a call to that function could help as well.

The only thing I can guess right now is that there's an index # that isn't matching up somewhere..

thanks again for your help

Link to comment
Share on other sites

This is the complete output:

IP [IPv4] Stats: [0]  = IP Forwarding Status: [1 = Enabled, 2 = Disabled] : 2, [1]  = Default initial time-to-live (TTL) for datagrams : 64
, [2]  = # Received Datagrams : 97579, [3]  = # Received Datagrams w/Header errors : 0, [4]  = # Received Datagrams w/Address errors : 14
, [5]  = # Forwarded Datagrams : 0, [6]  = # Received Datagrams w/Unknown Protocol : 0, [7]  = # Received Datagrams Discarded : 366
, [8]  = # Received Datagrams Delivered : 99864, [9]  = # Requested Outgoing Datagrams : 79017, [10] = # Outgoing Datagrams Discarded : 0
, [11] = # Transmitted Datagrams Discarded : 0, [12] = # Datagrams w/o Routes that were Discarded : 0, [13] = TimeOut for Reassembling Incoming Fragmented Datagrams : 60
, [14] = # Datagrams Requiring Reassembly : 0, [15] = # Datagrams Successfully Reassembled : 0, [16] = # Datagrams that Failed to be Reassembled : 0
, [17] = # Datagrams that were Fragmented Successfully : 0, [18] = # Datagrams not Fragmented, and Discarded : 0, [19] = # Fragments created (for Datagrams) : 0
, [20] = # of Interfaces : 6, [21] = # of IP addresses associated with PC : 43, [22] = # of Routes in the Routing table : 14
-----------------------------------------
IP [IPv6] Stats: [0]  = IP Forwarding Status: [1 = Enabled, 2 = Disabled] : 2, [1]  = Default initial time-to-live (TTL) for datagrams : 128
, [2]  = # Received Datagrams : 0, [3]  = # Received Datagrams w/Header errors : 0, [4]  = # Received Datagrams w/Address errors : 0
, [5]  = # Forwarded Datagrams : 0, [6]  = # Received Datagrams w/Unknown Protocol : 0, [7]  = # Received Datagrams Discarded : 111
, [8]  = # Received Datagrams Delivered : 0, [9]  = # Requested Outgoing Datagrams : 800, [10] = # Outgoing Datagrams Discarded : 0
, [11] = # Transmitted Datagrams Discarded : 0, [12] = # Datagrams w/o Routes that were Discarded : 8, [13] = TimeOut for Reassembling Incoming Fragmented Datagrams : 60
, [14] = # Datagrams Requiring Reassembly : 0, [15] = # Datagrams Successfully Reassembled : 0, [16] = # Datagrams that Failed to be Reassembled : 0
, [17] = # Datagrams that were Fragmented Successfully : 0, [18] = # Datagrams not Fragmented, and Discarded : 0, [19] = # Fragments created (for Datagrams) : 0
, [20] = # of Interfaces : 10, [21] = # of IP addresses associated with PC : 30, [22] = # of Routes in the Routing table : 13
-----------------------------------------
TCP [IPv4] Stats:[0] Rto Algorithm = 3,[1] Rto Min = 10,[2] Rto Max = 4294967295,[3] #Max Connections = 4294967295,[4] #Active Opens = 1656,[5] #Passive Opens = 17
 [6] #Failed Connection Attempts = 1508,[7] #Established Connections that were Reset = 359,[8] #Established Connections [current] = 26
 [9] #Recvd Segments = 95689,[10] #Sent Segments = 73938,[11] #Retransmitted Segments = 3735
 [12] #Receive Errors = 0,[13] #Sent Segments with Reset Flag = 2058,[14] #Connections = 87
-----------------------------------------
TCP [IPv6] Stats:[0] Rto Algorithm = 3,[1] Rto Min = 10,[2] Rto Max = 4294967295,[3] #Max Connections = 4294967295,[4] #Active Opens = 0,[5] #Passive Opens = 0
 [6] #Failed Connection Attempts = 0,[7] #Established Connections that were Reset = 0,[8] #Established Connections [current] = 0
 [9] #Recvd Segments = 0,[10] #Sent Segments = 0,[11] #Retransmitted Segments = 0
 [12] #Receive Errors = 0,[13] #Sent Segments with Reset Flag = 0,[14] #Connections = 59
-----------------------------------------
UDP [IPv4] Stats: [0] #Recvd Datagrams = 9163,[1] #Discarded Datagrams [invalid port] = 359,[2] #Erroneous Datagrams = 7
 [3] #Sent Datagrams = 4827,[4] #UDP Listener Entries = 27
-----------------------------------------
UDP [IPv6] Stats: [0] #Recvd Datagrams = 0,[1] #Discarded Datagrams [invalid port] = 111,[2] #Erroneous Datagrams = 0
 [3] #Sent Datagrams = 657,[4] #UDP Listener Entries = 7
-----------------------------------------
ICMP [IPv4] Stats: [0] = # Incoming ICMP Messages : 10, [1] = # Incoming ICMP Errors : 0, [2] = # Outgoing ICMP Messages : 13, [3] = # Outgoing ICMP Errors : 0
-----------------------------------------
ICMP [IPv6] Stats: [0] = # Incoming ICMP Messages : 0, [1] = # Incoming ICMP Errors : 0, [2] = # Outgoing ICMP Messages : 35, [3] = # Outgoing ICMP Errors : 0
-----------------------------------------
# of adapters: 5
Adapter Index #13, Name = \DEVICE\TCPIP_{F5C17D50-4BE2-4008-BA0A-76067ABE7DE2}
Adapter Index #849, Name = \DEVICE\TCPIP_{4CD51587-472C-41E3-B0FD-C92CDA50FB20}
Adapter Index #786, Name = \DEVICE\TCPIP_{B73941B0-2376-4882-B70B-76B0F0ED8209}
Adapter Index #787, Name = \DEVICE\TCPIP_{B08246C5-DAC4-4823-A0A2-BD3F077BF4CC}
Adapter Index #15, Name = \DEVICE\TCPIP_{D2D5B3E5-1958-4C19-A719-BC16A5ABB6C5}
-----------------------------------------
+ Added Interface (index #0), Intel(R) 82577LM Gigabit Network Connection
+ Added Interface (index #786), VMware Virtual Ethernet Adapter for VMnet1
+ Added Interface (index #787), VMware Virtual Ethernet Adapter for VMnet8
+ Added Interface (index #849), VirtualBox Host-Only Ethernet Adapter
+ Added Interface (index #862), Microsoft 6to4 Adapter
Interface #1: [0] Index #0, [1] Type = 6, [2] Operational Status = 1, [3] Flags = 0x000000C5, [4] Physical [MAC] Address: 88-AE-1D-B1-08-30, [5] MTU =  1500
, [6] Description: Intel(R) 82577LM Gigabit Network Connection, [7] Friendly Name: Local Area Connection, [8] Adapter/Service Name [GUID] = {F5C17D50-4BE2-4008-BA0A-76067ABE7DE2}
, [9] Max Receive Speed [Vista+] = 100000000, [10] Max Transmit Speed [Vista+] = 100000000
, [11] IPv4 Address(es): 168.185.212.21, [12] IPv6 Address(es): 
, [13] Connection Type [Vista+] = 1, [14] Tunnel Type [Vista+] = 0
_Network_InterfaceEntryInfo return, @error = 3, @extended = 2
C:\_Downloads\NetworkStatistics.au3 (1268) : ==> Subscript used with non-Array variable.:
ConsoleWrite("Interface #"&$i+1&" Entry Info: [0] Interface Index = " & $aNIEntryInfo[0] & ", [1] Interface Type = " & $aNIEntryInfo[1] & ", [2] Operational Status = " & $aNIEntryInfo[2] & ", [3] Admin Status = " & $aNIEntryInfo[3] & ", [4] Physical Address = " & $aNIEntryInfo[4] & ", [5] MTU [Max Trans. Unit] in bytes = " & $aNIEntryInfo[5] & @CRLF & ", [6] Description = " & $aNIEntryInfo[6] & ", [7] Interface Name = " & $aNIEntryInfo[7] & @CRLF & ", [8] Last change [1/100th second] = " & $aNIEntryInfo[8] & ", [9] Interface Speed [bps] = " & $aNIEntryInfo[9] & @CRLF & ", [10] # Recvd Data [in Octets] = " & $aNIEntryInfo[10] & ", [11] # Recvd Unicast Packets = " & $aNIEntryInfo[11] & ", [12] # Recvd Non-Unicast Packets = " & $aNIEntryInfo[12] & ", [13] # Recvd Packets Discarded [no error] = " & $aNIEntryInfo[13] & ", [14] # Recvd Packets Discarded [error] = " & $aNIEntryInfo[14] & ", [15] # Recvd Packets Discarded [unk. protocol] = " & $aNIEntryInfo[15] & @CRLF & ", [16] # Sent Data [in Octets] = " & $aNIEntryInfo[16] & ", [17] # Sent Unicast Packets = " & $aNIEntryInfo[17] & ", [18] # Sent Non-Unicast Packets = " & $aNIEntryInfo[18] & ", [19] # Sent Packets Discarded [no error] = " & $aNIEntryInfo[19] & ", [20] # Sent Packets Discarded [error] = " & $aNIEntryInfo[20] & @CRLF & ", [21] Transmit Queue Length [n/a] = " & $aNIEntryInfo[21] & @CRLF)
ConsoleWrite("Interface #"&$i+1&" Entry Info: [0] Interface Index = " & $aNIEntryInfo^ ERROR
->11:51:04 AutoIt3.exe ended.rc:1

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Thanks, I'm gonna review it and see if there's something askew.  I haven't seen an index # 0 yet, so that's curious..

Link to comment
Share on other sites

Okay, apparently that 0 index is wrong and should be 13.  I *believe* this is due to my checks against IPv6Index.  Could you possibly locate the line

               " If $nIPAAStSize > 108 Then    ; XP SP1+ O/S Structure?"

and change that and the whole IF-Endif to read this:

                If $nIPAAStSize > 108 Then    ; XP SP1+ O/S Structure?
                    ; If IPv6 index is different than IPv4 Index, AND non-zero, use the latter
                    $nTemp = DllStructGetData($stIP_ADAPTER_ADDRESSES, "Ipv6IfIndex")
                    If $nTemp And $nTemp <> $aIPAddrTableEntries[$nNumEntries][0] Then
                        $aIPAddrTableEntries[$nNumEntries][0] = $nTemp
                    EndIf
                EndIf

Hopefully that would fix the problem.  I'm still not even sure if its worth checking Ipv6IfIndex yet, so I may modify that in the future.  However, the above code at least tests for a 0 condition, and won't change an index if Ipv6IfIndex is 0.

Thanks!

Link to comment
Share on other sites

nice!  New version uploaded!  Thx for the help spotting the error

Edited by Ascend4nt
Link to comment
Share on other sites

I Got Eror..

When I'm Disconnect Modem..

LINE 1340

$sSplashText &=StringFormat("%45,56s", $aNIEntryInfo[6] & @CRLF
$sSplashText &=StringFormat("%45,56s", $aNIEntryInfo^ ERROR
     
Error: Subscript used with non-Array variable

Edited by setengahgila
Link to comment
Share on other sites

I Got Eror..

When I'm Disconnect Modem..

....

 

A modem?! Really? :o   I thought those were all gone by now haha..

But anyway.. to the problem.  If you disconnect or disable a network interface, the index # assigned to it will fail to work, or possibly be reassigned when the device is reenabled.  But, just to be thorough here.. could you please insert this code and let me know what it reports when you disconnect the modem:

        $aNIEntryInfo = _Network_InterfaceEntryInfo($aIPAllAddrTable[$i][0])
        If @error Then
            ConsoleWrite("_Network_InterfaceEntryInfo return, @error = " & @error & ", @extended = " & @extended & @CRLF)
            ExitLoop
        EndIf

That goes in the For $i = 0 To $nIPs - 1 loop, line 1334.  It *should* return error code ERROR_NOT_FOUND (1168), if I understand it correctly.

The only way to get around the problem of disconnected devices is to rescan for devices using _Network_IPAllAddressTable().  But before we go there, it'd be good to see what kind of error code is returned.

Thanks for your help

Link to comment
Share on other sites

Updated today - version 3 (by my reckoning)!  This is now a full fledged Network Interface Information and Statistics UDF module.

2013-07-06:

 Added: Much more Adapter Information

 Changed: Example is now separate from the UDF

 Fixed some minor issues here and there

 Changed: Global Handle to IPHLPAPI.DLL is now contained in the UDF and used to speed up function calls

 Misc. Other fixes I didn't keep track of!

See 1st post, which is now a bit more detailed

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...