5
Please someone explain me in simple terms how to use usbmon to track the amount of data transferred from pendrive ?
5
Please someone explain me in simple terms how to use usbmon to track the amount of data transferred from pendrive ?
3
usbmon.txt and usbmon.txt Examples gives a clear explanation about usbmon or usbdump.
You have to find which bus connected to your device. For that open your terminal and type:
cat /sys/kernel/debug/usb/devices
It will give you an output similar to:
T: Bus=03 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 2 Spd=12 MxCh= 0
D: Ver= 1.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 8 #Cfgs= 1
P: Vendor=0557 ProdID=2004 Rev= 1.00
S: Manufacturer=ATEN
S: Product=UC100KM V2.00
In the above sample output, T has Bus with its ID. So, Bus id is 03.
or
To see Bus ID you can also use lsusb , open terminal & type:
lsusb
It will give you an output similar to:
Bus 003 Device 002: ID 0557:2004 ATEN UC100KM V2.00
Which means Bus ID 003.
You now know that the USB gets connected to BUS ID 003. Then in terminal type:
cat /sys/kernel/debug/usb/usbmon/3u > /tmp/1.mon.out
In the above command, you are monitoring the data transmission happening in Bus ID 03. If you want to monitor the data transmission at all Buses, then type:
cat /sys/kernel/debug/usb/usbmon/0u > /tmp/1.mon.out
Which will scan until the transmission goes to the end. If you want to interrupt then use CTRL+C.
To understand the output read: The usbmon: USB monitoring framework
2
Find the bus number your device is on (see shekar's answer). Then on the raw /dev/usbmonX, use pipemeter (or pipebench) to measure throughput, or dump it to a file and visualize its growth with speedometer..f.e. for device on bus number 2:
# next three commands are equivalent - use any one
# pipemeter /dev/usbmon2 > /dev/null
# pipemeter < /dev/usbmon2 > /dev/null
# cat /dev/usbmon2 | pipemeter > /dev/null
# in 1st terminal
# cat /dev/usbmon2 > /tmp/usbdump
# in 2nd terminal
# speedometer /tmp/usbdump
The formatted text output from the /sys/kernel/debug/usb/usbmon/Xu files produces overhead for small amounts of traffic but seems to truncate bigger data blocks, so the raw usbmon device should give you more exact figures.
2
Install wireshark than easiest way is to:
sudo modprobe usbmon
sudo wireshark
usbmon{Bus nr form lsusb} fe: usbmon1
Cleaner way is to add rule for usbmon for your user, than you can use it (and wireshark) without root privileges
But that file 1.mon.out is showing very weird output , how to use that output to calculate the data transferred in Bytes ? – user3529205 – 2014-04-18T13:37:58.820
http://pastebin.com/b6U7Je7h – user3529205 – 2014-04-18T13:41:31.553
@user3529205 Found it. Please look at 2nd link in my answer. – shekhar – 2014-04-18T13:52:00.120
still i think there is no way to find the size of packet file ? – user3529205 – 2014-04-18T14:02:11.980
do u think www.mjmwired.net/kernel/Documentation/usb/usbmon.txt#163 i what i need ? – user3529205 – 2014-04-18T14:03:30.043
@user3529205 yes , its explaining the output. – shekhar – 2014-04-18T14:24:59.890
please can you point out in line 1-5 of pastebin link what would be the length field ? actually after " Number of isochronous frame descriptors and descriptors themselves" and before " < > = " signs there are two numbers – user3529205 – 2014-04-18T14:27:34.507