Exemplo n.º 1
0
    def build( self, **_opts ):

        subnetFactory = SubnetFactory('10.0.0.0/8')

        for n in range(RN):
            ip1,ip2 = subnetFactory.getLink()
            print "host network: ",(ip1,ip2)
            asn = 100+n
            c = str(n)
            r = self.addNode( 'r'+c, cls=LinuxRouter, ip=ip1, asn=asn )
            h = self.addHost( 'h'+c, ip=ip2, defaultRoute='via '+addrOnly(ip1))
            self.addLink( h, r, intfName2='r%s-eth1'%c, params2={ 'ip' : ip1 } )

        for n in range(RN): # can only add links when ALL of the routers are defined, hence a second loop is needed
            for m in range(n+1,RN):
                asn = 100+n
                remoteAsn = 100+m
                cm = str(m)
                cn = str(n)
                ra = 'r'+cn ; rb = 'r'+cm ; intfca = ra+'-'+rb ; intfcb = rb+'-'+ra
                ip1,ip2 = subnetFactory.getLink()
                print "adding peer", ra, rb, intfca,intfcb, ip1 , ip2 , asn, remoteAsn
                self.addLink( ra, rb, intfName1=intfca, intfName2=intfcb, params1={ 'ip' : ip1, 'asn' : asn } , params2={ 'ip' : ip2, 'asn' : remoteAsn } )
Exemplo n.º 2
0
import ipaddress # note - this requires the py2-ipaddress module!
from subnetfactory import SubnetFactory

subnetFactory = SubnetFactory('10.0.0.0/8')
print subnetFactory.request(24)
print subnetFactory.request(24)
print subnetFactory.request(30)
print subnetFactory.request(29)
print subnetFactory.request(28)
print subnetFactory.request(30)
print subnetFactory.request(30)
print subnetFactory.request(24)
print subnetFactory.request(24)
print subnetFactory.request(16)
print subnetFactory.request(24)
print subnetFactory.request(28)
print subnetFactory.request(24)
print subnetFactory.request(30)
print subnetFactory.request(30)
print subnetFactory.request(30)
print subnetFactory.request(24)
print subnetFactory.request(16)
print subnetFactory.request(16)
print subnetFactory.request(12)
print subnetFactory.request(12)
print subnetFactory.request(12)
print subnetFactory.request(12)
print subnetFactory.request(12)
print subnetFactory.request(12)
print subnetFactory.request(12)
print subnetFactory.request(12)