Skip to content

Instantly share code, notes, and snippets.

@songritk
Created July 8, 2016 02:42
Show Gist options
  • Save songritk/c463625221288c9929ecbaf90aaeaa57 to your computer and use it in GitHub Desktop.
Save songritk/c463625221288c9929ecbaf90aaeaa57 to your computer and use it in GitHub Desktop.
แปลง ข้อมูลจาก tshark
#!/bin/bash
FILENAME=$1
DIR=./utils
if [ $# -eq 0 ]
then
echo "./stat-linux.sh <pcap>"
exit
fi
tshark -Tfields -e wlan_radio.data_rate -e frame.len -Y'wlan.fc.type ==0' -r $FILENAME |awk '{print ($1*10**6),($2*8)}' > mgmt.txt
tshark -Tfields -e wlan_radio.data_rate -e frame.len -Y'wlan.fc.type==1' -r $FILENAME |awk '{print ($1*10**6),($2*8)}' > ctl.txt
tshark -z'proto,colinfo,radiotap.dbm_antsignal,radiotap.dbm_antsignal' -z 'proto,colinfo,wlan_radio.data_rate,wlan_radio.data_rate' -z'proto,colinfo,wlan.duration,wlan.duration' -Y'wlan.fc.type==2' -Y'udp' -r $FILENAME|sed 's/Len=//g' |awk '{print $7,$11,$14,$17,$20}' > udp.txt
tshark -z 'proto,colinfo,radiotap.dbm_antsignal,radiotap.dbm_antsignal' -z 'proto,colinfo,wlan_radio.data_rate,wlan_radio.data_rate' -z 'proto,colinfo,wlan.duration,wlan.duration' -Y'wlan.fc.type==2' -Y'icmp' -r $FILENAME|sed 's/Len=//g' |awk '{ print $7,$16,$19}' > icmp.txt
tshark -z 'proto,colinfo,radiotap.dbm_antsignal,radiotap.dbm_antsignal' -z 'proto,colinfo,wlan_radio.data_rate,wlan_radio.data_rate' -z 'proto,colinfo,wlan.duration,wlan.duration' -Y'wlan.fc.type==2' -Y'icmp.type == 8' -r $FILENAME|sed 's/Len=//g' |awk '{ print $7,$16,$19,$22}' > icmp-req.txt
tshark -z 'proto,colinfo,radiotap.dbm_antsignal,radiotap.dbm_antsignal' -z 'proto,colinfo,wlan_radio.data_rate,wlan_radio.data_rate' -z 'proto,colinfo,wlan.duration,wlan.duration' -Y'wlan.fc.type==2' -Y'icmp.type == 0' -r $FILENAME|sed 's/Len=//g' |awk '{ print $7,$16,$19}' > icmp-reply.txt
mgmtstat=`Rscript $DIR/stat.R mgmt.txt`
ctlstat=`Rscript $DIR/stat.R ctl.txt`
udpstat=`Rscript $DIR/stat.R udp.txt`
icmp=`Rscript $DIR/stat.R icmp.txt`
icmpstat_req=`Rscript $DIR/stat.R icmp-req.txt`
icmpstat_reply=`Rscript $DIR/stat.R icmp-reply.txt`
echo $mgmtstat \| $ctlstat \| $udpstat \| $icmp \| $icmpstat_req \| $icmpstat_reply
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment