How do i monitor network traffic on Windows from the command line; specifically the download/upload speeds and amount of data uploaded/downloaded ? Is there a script /batch for doing that ?
相关问题
- softlinks atime and mtime modification
- Get unexpanded argument from bash command line
- Include and Execute EXE in C# Command Line App
- Batch - Set variables in for loop
- Rails gem update not working (version 4.1.1 to 4.2
相关文章
- Compile and build with single command line Java (L
- How to update command line output?
- How to execute another python script from your scr
- boost:asio IPv4 address and UDP comms
- Python file keyword argument?
- Interactively merge files tracked with git and unt
- Lauch default editor (like 'webbrowser' mo
- How to print jq output sequentially
typeperf in Windows should work to get the data.
While
tshark
is really powerful if you want to have fine grained statistics (according to hosts, protocols, ...), it has the main drawback to gather statistics during the time period it is running. As such, it is only good at reporting "instant" statistics but not to report poll traffic at regular points in time to have a view of how your network traffic changes along the day, week, ...Moreover, as
tshark
makes packets capturing, there is some overhead.So, according to your needs, you might be interested in the MS Windows
net
ornetstat
commands (netstat
has option to report statistics by protocol).'net statistics [Server|workstation]'
or'netstat [-e|-s]'
are, as far as network traffic statistics are concerned, the MS Windows equivalents of Linux'ifconfig'
(or'cat /proc/net/dev'
if you prefer).Note that, as
ifconfig
do,net
ornetstat
only report amount of data since the interface has been brought up.In order to obtain traffic rates, you've got to timestamp your calls to those commands and do the computation yourself.
AFAIK, both commands are shipped with all recent MS Windows versions.
I'm updating the answer for a more complete an accurate one, using
netsh
command, and some string operations to avoid Windows 32bits integer overflow.Remember you need to run
netsh interface ip show subinterfaces
and check what is the line of your network adapter. The following batch file uses the 4th string line, that's the 1st adapter listed.It checks the speed every 10 seconds. If your upload or download speed is up to 100 MBytes per seconds, you need to repeat the loop more often (for example every 1 second).
It creates a .csv file too. Remove that last line if you don't need it.
The batch file:
Keep in touch if you need a fix.
Previous solution using a batch file, with some limitations:
I wanted to give you an easier solution, then I used my previous answer to code a fresh windows batch script that iterates every 10 seconds. It monitors download and upload bandwidth/speed in console and logs ammount of bytes transferred in a .csv file.
PS: Windows limitations are the counter resets every 4GBytes transferred and at midnight.
Old solution using task scheduller and XAMPP:
I had to monitor and log the amount of data downloaded as your case, and found it faster to run a script with the Windows task scheduller than looking for a free software that dump the usual graphics info into a file. Perhaps my homemade script works for you.
I started a local Apache/PHP server using XAMPP for Windows and run this script from command line. For example:
The
bwlog.php
script uses @phep answer suggested windows commandnetstat -e
. You can create the script file with the notepad, and the code is:Then I processed the the .csv in a spreadsheet software to calc the download speed (bandwidth) using the difference between 2 bytes values over the difference between the 2 matching time values (bytes/seconds).
Feel free to ask a fix to log the uploaded bytes. Wish it be useful.
You can use tshark with -z
<statistics>
argument. Just search Wireshark. It is open source and multiplatform.