def get_packets_per_second(trace, features):
"""
Gets the total number of packets per second along with mean, standard deviation, min, max and median
@return a 1D list that contains the packets per second
"""
packets_per_second = {}
for val in trace:
second = floor(val[0])
if second not in packets_per_second:
packets_per_second[second] = 0
packets_per_second[second] += 1
l = list(packets_per_second.values())
features.append(sum(l) / len(l))
features.append(np.std(l))
features.append(np.percentile(l, 50))
features.append(min(l))
features.append(max(l))
return l
评论列表
文章目录