#!/bin/bash

#From Jason Anderson,   hw3 CPSC851 Fall 2015
#  And others
#
#  This is more for notes...


#tcpdump –s 1500 –w T.trace udp or tcp

#timeslice -S -i T.trace 2>/dev/null |head -n -15 > T.timeslice.flows

#tcptrace –l T.trace 2>/dev/null > T.tcptrace.flows


# duration: timeslice –m 3 T.trace
# total bytes: timeslice –m 3 T.trace

# up bytes: cat T.tcptrace.flows | grep ‘actual data b’ | awk ‘{s+=$4} END {print s}’

# down bytes: cat T.tcptrace.flows | grep ‘actual data b’ | awk ‘{s+=$8} END {print s}’

# up bw:  (up bytes) / duration
# down bw: (down bytes) / duration

# TCP sessions: tcptrace T.trace | wc –l

# Open TCP: tcptrace T.trace | grep –v (complete) | wc –l

# Closed TCP: tcptrace T.trace | grep (complete) | wc –l

# UDP sessions: tcpdump -r T.trace udp | awk '{print $5}' | grep -v tigernet | sort | uniq | wc -l

# dest. IPs: cat T.timeslice.flows | awk '{print $2}' | sort | uniq | wc –l


#tcpdump -r T.trace udp | awk '{print $5}' | grep -v tigernet | sort | uniq | wc -l
cat t.trace | awk '{print $5}' | grep -v tigernet | sort | uniq | wc -l

#regex="[0-9]*[.]*[0-9]* *"
#grep -o "$begin$regex$end"  : this will produce the pattern with begin and end  delimiters
#sed "s/$end//g" | sed "s/$begin//g"  : this strips off the delims


#Results of :  grep -R "awk" | grep "sed"  | more

# /Spring-2016/hw1-student-sol/mkaur/manveen/hw1/analyzehw1.sh:	echo "$file $(sed -n '1p' $file) $(sed '1d' $file | awk '{ total += $1; count++ } END {print to tal/count }') $(sort -n $file | awk '{ a[i++]=$1; } END { x=int((i+1)/2); if (x < (i+1)/2) print (a[x-1]+a[x])/2; else print a[x-1]; }') $(sed '1d' $file | awk '{total +=1; count++ } END {print sqrt(total/NF)}')" >> $3 

# /Spring-2016/hw2-sol/David/hw2-Q2.sh:usage=$(df -P / 2> /dev/null | awk '{ if( NR == 2) print $5}' | sed 's/%//' ) 

# /Spring-2016/hw2-sol/pythonSolutions/David-hw2-Q2.py:usage = getCommandOutput("df -P / 2> /dev/null | awk '{ if( NR == 2) print $5}' | sed 's/%//'") 

# /Spring-2016/hw2-sol/Austin/hw2-Q2.sh:percent_used=$(df -hl / | awk 'FNR == 2{print $5}' | cut -c 1-2)

# /Spring-2016/hw2-sol/Parker/hw2-Q2.sh:USAGE=$(/bin/df | awk '{if ($6 == "/") print $5}' | sed 's/%//')

# /Spring-2016/hw2-submissions/parker/hw2-Q2.sh:USAGE=$(/bin/df | awk '{if ($6 == "/") print $5}' | sed 's/%//')

# /Spring-2016/hw2-submissions/matthew/hw2-Q2.sh:percent_used=$(df -hl / | awk 'FNR == 2{print $5}' | cut -c 1-2)

# /Spring-2016/hw2-submissions/daniel/hw2-EXQ1.py:usage = getCommandOutput("df -P / 2> /dev/null | awk '{ if( NR == 2) print $5}' | sed 's/%//'") 

# /Spring-2016/hw2-submissions/daniel/hw2-Q2.sh:usage=$(df -P / 2> /dev/null | awk '{ if( NR == 2) print $5}' | sed 's/%//' ) 

# /bashScripts/2017/bashScripts/monitors/monitorScriptRunzhen.sh:old_recv_data=$(cat /proc/net/dev | grep $interface | sed -e "s/\(.*\)\:\(.*\)/\2/g" | awk '{prin t $1 }')

# /bashScripts/2017/bashScripts/monitors/monitorScriptRunzhen.sh:old_trans_data=$(cat /proc/net/dev | grep $interface | sed -e "s/\(.*\)\:\(.*\)/\2/g" | awk '{print $9 }')

# /bashScripts/2017/bashScripts/monitors/monitorScriptRunzhen.sh:	new_recv_data=$(cat /proc/net/dev | grep $interface | sed -e "s/\(.*\)\:\(.*\)/\2/g" | awk '{print $1 }')

# /bashScripts/2017/bashScripts/monitors/monitorScriptRunzhen.sh:	new_trans_data=$(cat /proc/net/dev | grep $interface | sed -e "s/\(.*\)\:\(.*\)/\2/g" | awk '{print $9 }')

# /bashScripts/2017/bashScripts/monitors/tecmint_monitor.sh:nameservers=$(cat /etc/resolv.conf | sed '1 d' | awk '{print $2}')




