c - How does netstat know the number of bytes received and sent? -


i want create simple application displays number of bytes downloaded , uploaded. noticed netstat (when using -e switch):

enter image description here

how netstat knows information, call windows api function or something?

netstat uses1 ip helper api, part of core windows networking api. running dumpbin /imports on netstat produces: (snipped brevity)

iphlpapi.dll          140007000 import address table          1400080a0 import name table                  0 time date stamp                  0 index of first forwarder reference                        a3 internalgetboundtcp6endpointtable                       a4 internalgetboundtcpendpointtable                       c2 internalgetudptablewithownermodule                       b5 internalgettcp6table2                       b9 internalgettcptable2                       b6 internalgettcp6tablewithownermodule                       bb internalgettcptablewithownermodule                       internalgetudp6tablewithownermodule                       80 getudpstatisticsex                       64 getipstatisticsex                       4d geticmpstatisticsex                       7a gettcpstatisticsex 

the last 4 ip helper functions ones you're interested in. getudpstatisticsex, getipstatisticsex, geticmpstatisticsex , gettcpstatisticsex


1this most likely answer question, completeness netstat imports queryperformancecounter might using produce output. without source code netstat, there's no way know 100% certainty.


Comments

Popular posts from this blog

matlab - error with cyclic autocorrelation function -

django - (fields.E300) Field defines a relation with model 'AbstractEmailUser' which is either not installed, or is abstract -

c# - What is a good .Net RefEdit control to use with ExcelDna? -