3 from scapy.all import *
5 def somefilter(pcapfile):
7 for p in PcapReader(pcapfile):
12 if (src,dst) in flows:
17 for flow,cnt in flows.items():
19 print 'tshark -r '+pcapfile+' -w "flow_'+flow[0]+'_'+flow[1]+'.pcap" -F pcap ' \
20 + '\'ip.src == '+flow[0]+' and ip.dst == '+flow[1]+'\''
21 print 'tshark -n -r "flow_'+flow[0]+'_'+flow[1]+'.pcap" -Eheader=y -Eseparator=, -Equote=d -Tfields '\
22 + '-e frame.number -e _ws.col.Time -e ip.src -e ip.dst -e _ws.col.Protocol -e frame.len '\
23 + '-e _ws.col.Info -e _ws.col.dscp -e _ws.col.ipid -e _ws.col.cs -e _ws.col.srcport '\
24 + '-e _ws.col.dstport -e _ws.col.proto > flow_'+flow[0]+'_'+flow[1]+'.csv'
27 if __name__ == "__main__":
28 somefilter("team15_ex22.pcap")