Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save dmpatel151282/351c828f2eba0c39be9ccb4ef34501f0 to your computer and use it in GitHub Desktop.
Save dmpatel151282/351c828f2eba0c39be9ccb4ef34501f0 to your computer and use it in GitHub Desktop.
Ethernet:-
- Make ethernet_bw.sh file.
- Copy below code snippet in file.
#!/bin/sh
INTERVAL="1" # update interval in seconds
while true
do
R1=`cat /sys/class/net/eth0/statistics/rx_bytes`
T1=`cat /sys/class/net/eth0/statistics/tx_bytes`
sleep $INTERVAL
R2=`cat /sys/class/net/eth0/statistics/rx_bytes`
T2=`cat /sys/class/net/eth0/statistics/tx_bytes`
TBPS=`expr $T2 - $T1`
RBPS=`expr $R2 - $R1`
TKBPS=`expr $TBPS / 1024`
RKBPS=`expr $RBPS / 1024`
echo "TX eth0: $TKBPS kB/s RX eth0: $RKBPS kB/s"
done
- Push ethernet_bw.sh file to Android device through ADB and start script.
WiFi :-
- Make wifi_bw.sh file.
- Copy below code snippet in file.
#!/bin/sh
INTERVAL="1" # update interval in seconds
while true
do
R1=`cat /sys/class/net/wlan0/statistics/rx_bytes`
T1=`cat /sys/class/net/wlan0/statistics/tx_bytes`
sleep $INTERVAL
R2=`cat /sys/class/net/wlan0/statistics/rx_bytes`
T2=`cat /sys/class/net/wlan0/statistics/tx_bytes`
TBPS=`expr $T2 - $T1`
RBPS=`expr $R2 - $R1`
TKBPS=`expr $TBPS / 1024`
RKBPS=`expr $RBPS / 1024`
echo "TX eth0: $TKBPS kB/s RX eth0: $RKBPS kB/s"
done
- Push wifi_bw.sh file to Android device through ADB and start script.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment