def get_inter_arrival_time(trace, in_trace, out_trace, features):
"""
For both the complete trace, the trace only containing incoming and the trace only containing outcoming packets,
we calculate the inter-arrival time.
Next, we add the max, mean, standard deviation and third quartile as features.
@param in_trace contains all the incoming packets and nothing else
@param out_trace contains all the outcoming packets and nothing else
"""
complete_inter_arrival_time = inter_packet_time(trace)
in_inter_arrival_time = inter_packet_time(in_trace)
out_inter_arrival_time = inter_packet_time(out_trace)
inter_arrival_times = [complete_inter_arrival_time, in_inter_arrival_time, out_inter_arrival_time]
for time in inter_arrival_times:
if len(time) == 0:
features.extend([0, 0, 0, 0])
else:
features.append(max(time))
features.append(sum(time) / len(time))
features.append(np.std(time))
features.append(np.percentile(time, 75))
评论列表
文章目录