I want to create a network with 2 hosts connected to each other via 3 links (each link belonging to a different network)
_________10.0.0.0/31 network________________
| |
H1+---------10.0.1.0/31 network----------------+H2
| ________10.0.2.0/31 network----------------|
I followed the solution given in the mininet mailing list to try and add the links.
self.addLink( 'h1', s1, params1={'ip':'10.3/8'} )
While the hosts do get 3 interfaces only one of the interfaces gets assigned the default IP 10.0.0.1/8 I dug through the source code and the way I did it should work but I don't understand why mine doesn't
from mininet.topo import Topo
from mininet.link import TCLink, Link
from mininet.net import Mininet
class MyTopo( Topo ):
"Simple topology example."
def __init__( self ):
"Create custom topo."
# Initialize topology
Topo.__init__( self )
# Add hosts and switches
lH = self.addHost( 'h1' )
rH = self.addHost( 'h2')
# Add links
self.addLink(lH, rH, bw = 10, delay='50ms', params1={ 'ip' : '10.0.0.1/31' }, params2={ 'ip' : '10.0.0.2/31' })
self.addLink(lH, rH, bw = 1, delay='200ms', params1={ 'ip' : '10.1.0.1/31' }, params2={ 'ip' : '10.1.0.2/31' })
self.addLink(lH,rH, bw = 0.1, delay='500ms', params1={ 'ip' : '10.2.0.1/31' }, params2={ 'ip' : '10.2.0.2/31' })
topos = { 'mytopo': ( lambda: MyTopo() ) }
I just needed to pass intf=TCIntf
to the addLink()
function and pass the appropriate arguments
self.addLink(lH, rH, intf=TCIntf, params1={'delay':'50ms', 'bw' : 10, 'ip' : '10.0.0.1/24' }