def send_fake_update(p, peer_ip, ts, rib, encoding, socket):
# if it is an advertisement
if rib is not None:
# Make the second part of the v_mac (the part where the as-path is encoded)
v_mac = ''
deep = 1
aspath = ''
for asn in rib.rib[p]:
if deep in encoding.mapping:
depth_value = encoding.mapping[deep].get_mapping_string(asn)
v_mac += ''+depth_value
deep += 1
aspath += str(asn)+' '
aspath = aspath[:-1]
v_mac = string.ljust(v_mac, encoding.max_bytes, '0')
socket.send(peer_ip+'|'+p+'|'+str(ts)+'|'+aspath+'|'+v_mac+'\n')
else: # If it is a withdrawal
socket.send(peer_ip+'|'+p+'|'+str(ts)+'\n')
评论列表
文章目录