geoNetGraph.py 文件源码

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

项目:cdnsim 作者: cnplab 项目源码 文件源码
def parseIRLorigin(self, fileName, ip2as=True, as2ip=False):
        re_origin = re.compile('(\d+\.\d+\.\d+\.\d+/\d+)\t(\d+)', re.UNICODE)
        if as2ip:
            self.as2ip = dict()
        if ip2as:
            self.ip2as = SubnetTree.SubnetTree()
        F_origin = open(fileName, 'r')
        for line in iter(F_origin):
            match = re_origin.match(line)
            if match is not None:
                asNum = int(match.group(2))
                if ip2as:
                    self.ip2as[match.group(1)] = asNum
                if as2ip:
                    newNet = IPv4Network(match.group(1))
                    if newNet.prefixlen > self.smallSubnetPrefix:
                        continue
                    if asNum in self.netGraph:
                        if asNum not in self.as2ip:
                            self.as2ip[asNum] = [newNet]
                        else:
                            self.as2ip[asNum].append(newNet)
        return None
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号