YouHaveaBigEgo YouHaveaBigEgo - 20 days ago 6
Bash Question

Trying to determine data throughput with my ADB shell commands

I am running some throughput tests with my phone connected, and I am trying to determine my average bandwidth. It would be some value in Mbits/sec

And I run the following commands on server side (where phone is connected on my PC) :

adb shell setprop android.telephony.apn-restore 10000000;
export PATH=/data/busybox:$PATH#;
export PATH=/data:$PATH#;
chmod 777 /data/iperf
adb shell /data/iperf -s -p 5199 -B 172.20.184.121 -u -i 1
adb shell exit
exit


where
172.20.184.121
is my device's IP.

On the client side I have this :

iperf -c 172.20.184.121 -p 5199 -u -b 300M -t 60 -i 1


Now, what I have done is, I wrote those adb shell commands above into a small .bat file and I call that bat file and tried to pipe it's output to a .txt file so that I could get the output of the actual UDP transfer. I want to see the bandwidth etc. I call my
adbcommands.bat
using a system command from my Perl script. So my script would start the batch file like this on command prompt :

start adbcommands.bat > output.txt


But I am not getting anything in my .txt file. The file is empty. As you can see the last instruction was
exit
, so the new command window which opens to run the adb shell commands will close by itself, and I was hoping when it does close, my .txt file would have the data transfer info. Nope.

So, then I tried using the
tee.exe
command like this :

start adbcommands.bat | tee output.txt


Still nothing. So now I am out of bullets and want some help. Does anybody have some idea how I could get the throughput info?




For those curious, if I didn't pipe the output to a file, and if I run the above
adbcommands.bat
file, the output looks like this :

adb shell /data/iperf -s -p 5115 -B 172.20.184.121 -u -i 1
------------------------------------------------------------
Server listening on UDP port 5115
Binding to local address 172.20.184.121
Receiving 1470 byte datagrams
UDP buffer size: 224 KByte (default)
------------------------------------------------------------
[ 3] local 172.20.184.121 port 5115 connected with 172.20.98.85 port 51948
[ ID] Interval Transfer Bandwidth Jitter Lost/Total Datagrams
[ 3] 0.0- 1.0 sec 148 KBytes 1.21 Mbits/sec 7.762 ms 38211/38314 (88%)
[ 3] 2.0- 3.0 sec 159 KBytes 1.31 Mbits/sec 5.820 ms 743/ 854 (87%)
[ 3] 3.0- 4.0 sec 159 KBytes 1.31 Mbits/sec 6.762 ms 756/ 867 (87%)
.....
.....
[ 3] 0.0-166.2 sec 54.5 MBytes 2.75 Mbits/sec 7.700 ms 4506398/4545298 (99%)


What I need is in that very last line :
2.75 Mbits/sec
. That's my throughput. I am trying to pipe to a .txt file so that my script could parse it and find that value.

Answer

According to what you describe in your question, if you run

adb shell /data/iperf -s -p 5199 -B 172.20.184.121  -u  -i 1 > output.txt

you should be able to redirect the output to the file.

Comments