RESETTING THE COUNTERS
Lets say you want to reset all of the counters to 0.
Given this, we need this:
# ifconfig eth0 RC packets:12341234 errors: 0 dropped:0 overruns:0 frame:0 TX packets:61123 errors:0 dropped:0 overruns:0 carrier:2 collisions: 0 txqueuelen:1000 RX bytes: 1234123412 (1.8 GB) TX bytes: 86012341234 (86.0 MB)
You want this:
# ifconfig eth0 RC packets:0 errors: 0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions: 0 txqueuelen:1000 RX bytes: 0 (0.0 B) TX bytes: 0 (0.0 MB)
– have ethtool: apt-get install ethtool
– Have a physical connection to the device:
If you only have a network connection to a device this will be impossible, unless you have another means of connection to the device such as via
There are 2 situations, one in which you can reset the counters and one in which you cant.
The current way to reset the counters is to just disable the driver and then renable it. Not all drivers can be disables. Here are the 2 situations.
Lets find out if your in 1st or 2nd situation.
Look at the counters and identify the interface name:
In this case its eth0, lets get the driver name:
# ethtool -i eth0 driver: e1000e
Here the driver name showed me the interface is e1000e (this is an Intel driver)
We will run “# modprobe -D DRIVERNAME” and based on the output find out if you can reset them or not.
# modprobe -D e1000e insmod /lib/modules/18.104.22.168-vanillaice/kernel/drivers/pps/pps_core.ko insmod /lib/modules/22.214.171.124-vanillaice/kernel/drivers/ptp/ptp.ko insmod /lib/modules/126.96.36.199-vanillaice/kernel/drivers/net/ethernet/intel/e1000e/e1000e.ko
The above output shows that the driver is dependent on other drivers, and mainly it doesnt say that its kernel built-in driver. Thus this is situation 1 and you can reset the counters.
Another example of situation 1 is very similar output, but take the Atheros atl1c driver on my PC (the driver in this case is also not kernel built-in).
# modprobe -D atl1c insmod /lib/modules/3.13.5-vanillaice/kernel/drivers/net/ethernet/atheros/atl1c/atl1c.ko
The above is also module driver (even though it doesnt list any dependencies but only lists it self). Thus this falls into the case that you can reset the counters.
Below is the other type of output from modprobe -D
# modprobe -D e1000e modprobe: module e1000e is builtin
The above is situation 2, the driver is kernel-built in. Thus you cant reset the counters
Here is the summary of both cases:
…1… DRIVER MODULE
If your driver is not kernel-built in but it is a module that is added in via “insmod” or “modprobe”. Therefore you can see it with “lsmod”.
First run ifconfig to get the interface name:
Now run ethtool to get the driver name (or however you want to get the driver name). Lets imagine its eth0.
# ethtool -i eth0
In this case lets pretend the driver name DRIVERNAME. Now check that the driver is not a kernel built-in driver with modprobe.
# modprobe -D DRIVERNAME
If it doesnt say “kernel built-in” then you can proceed with resetting the counters (By first removing/disabling the driver). If it says the driver is “kernel built-in” then you cannot proceed with resetting the counters (read …2… below).
Remove the driver (This doesnt really remove the driver, it just disables it):
# modprobe -r DRIVERNAME
At this point if you were sshed/telneted in or connected via network protocol, you will lose connection and you will need to reconnect physically to the PC/device via console or physical acccess (keyboard/monitor)
Now you can enable the driver:
# modprobe DRIVERNAME
Now look at the counters they should be all 0:
…2… DRIVER IS KERNEL BUILT-IN
If your drive is kernel built-in, then there is no way currently to reset the driver. As you cant turn off the driver and reenable it. Currently that is the only way to reset those counters.
Why cant we reset drivers that are kernel built-in? Check out this link
- ” module built-in the kernel: in this case there is no way to reset the counters (of course without rebooting the system) if the particular network module driver has not a way to reset them using some code written inside the driver. From what I have seen in the source code of the modules I had used, none of them had such a software hook. But there might be other modules that offer this functionality just that I have not personally seen it on the common NIC drivers I have used.”