The script every second displays the number of incoming and outgoing packets per second on the specified network interface.
Place the contents of the script into a file, for example, pps.sh and execute by specifying the name of the network interface (you can stop the execution of the script with CTRL+C):
./pps.sh ens2f0
Script content:
#!/bin/bash
if [ -z "$1" ]; then
echo usage: $0 [network-interface]
echo shows packets-per-second
exit
fi
IF=$1
while true
do
RX1=`cat /sys/class/net/$1/statistics/rx_packets`
TX1=`cat /sys/class/net/$1/statistics/tx_packets`
sleep 1
RX2=`cat /sys/class/net/$1/statistics/rx_packets`
TX2=`cat /sys/class/net/$1/statistics/tx_packets`
TXPPS=`expr $TX2 - $TX1`
RXPPS=`expr $RX2 - $RX1`
echo "TX $1: $TXPPS pkts/s RX $1: $RXPPS pkts/s"
done