def post_data():
global global_cnt
global global_src_ip
global global_dst_ip
global global_proto
try:
post = request.json
except IndexError:
pass
# overall received packets
global_cnt += 1
data = loads(post)
# src ip distribution
if data[u'ip_src'] in global_src_ip.keys():
global_src_ip[data[u'ip_src']] += 1
else:
global_src_ip[data[u'ip_src']] = 1
# dst ip distribution
if data[u'ip_dst'] in global_dst_ip.keys():
global_dst_ip[data[u'ip_dst']] += 1
else:
global_dst_ip[data[u'ip_dst']] = 1
# proto distribution
if data[u'protocol'] in global_proto.keys():
global_proto[data[u'protocol']] += 1
else:
global_proto[data[u'protocol']] = 1
评论列表
文章目录