Friday, October 25, 2013

Add components to mininet on fly

Add a new controller, switch, two hosts

mininet> py net.addController('c2', IP="127.0.0.2", port=6633)

mininet> py net.addSwitch('s2')
mininet> py s2.start([c2])

mininet> py net.addHost('h4')
mininet> py net.addLink(s2, net.get('h4'))
mininet> py s2.attach('s2-eth1')
mininet> py net.get('h4').cmd('ifconfig h4-eth0 10.4')

mininet> py net.addHost('h5')
mininet> py net.addLink(s2, net.get('h5'))
mininet> py s2.attach('s2-eth2')
mininet> py net.get('h5').cmd('ifconfig h5-eth0 10.5')

2 comments:

  1. I would add:
    py net.get('h4').setIP('10.4')
    py net.get('h5').setIP('10.5')

    This allows the pingall command to work. Pingall fails for me without those additions.

    ReplyDelete
  2. Hi, thanks for the code. When I run the "py net.addController('c2', IP="127.0.0.2", port=6633)" command to add the second controller, I receive the " 'list' object is not callable". Do you know what would be the issue?

    Thanks

    ReplyDelete