How to add a node and a link during runtime?




During runtime, I will add one node (h3) to the topology.


h1 can ping h2.


Add one host h3.


Add a link between s1 and h3


Before assign s1-eth3 to s1, we can see that s1 has s1-eth1 and s2-eth2. (s1-eth3 can not be seen.)

assign s1-eth3 to s1

Set the ip address for h3

h1 can ping h3.








from import Mininet

from mininet.node import Host, Node

from mininet.cli import CLI

from import TCLink, Intf

from mininet.log import setLogLevel, info

from subprocess import call


def myNetwork():


    net = Mininet()

    r1 = net.addHost('r1')

    r1.cmd('sysctl -w net.ipv4.ip_forward=1')


    h2 = net.addHost('h2', cls=Host, ip='')

    h1 = net.addHost('h1', cls=Host, ip='')


    info( '*** Add links\n')

    net.addLink(h1, r1)

    net.addLink(h2, r1)



    info( '*** Starting network\n')

    h1.cmd("ip route add default via")

    h2.cmd("ip route add default via")

    r1.cmd("ip addr add brd + dev r1-eth0")

    r1.cmd("ip addr add brd + dev r1-eth1")





if __name__ == '__main__':

    setLogLevel( 'info' )




Add one node (h3) and one link between r1 and h3


Set the ip addresses for h3 and r1.



h1 can ping h3




Dr. Chih-Heng Ke (

Department of Computer Science and Information Engineering,

National Quemoy University, Kinmen, Taiwan.