peer.py 文件源码

python
阅读 47 收藏 0 点赞 0 评论 0

项目:swift 作者: nsg-ethz 项目源码 文件源码
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')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号