from scapy.all import *
pkts = rdpcap("lalalao2.pcap")
#time slice de t em segundos : 10 minutos
t = 600
somaMin = pkts[0].time + t
valores=[]
for p in pkts:
if p<=somaMin:
valores.append(p)
else:
primslice =valores
f=open("time1.txt",'w')
f.writelines(primslice)
valores=[]
valores.append(p)
somaMin=p.time + t
The above code opens a network dump file (PCAP) and creates vectors containing time slices of t seconds. I would like each slice time to be written to a different text file: time1, time2, ... The problem is that I do not know how many slices I have, because it depends on the capture. Is it possible?