Generate multiple paths with equal cost


In order to study multipath transmission, I sometimes need to generate multiple paths with equal cost for my research. I use the following example to show how to generate 2 multipath with equal cost (3) in the mininet script.



H1 -----s1---s2----s3-----h2

      |       |



In this example, two paths (h1-s1-s2-s3-h2, h1-s1-s4-s3-h2) exist. Each path consists of 3 switches.


[mininet script]



from import Mininet

from mininet.node import Controller, RemoteController, UserSwitch

from mininet.cli import CLI

from mininet.log import setLogLevel

from import Link, TCLink, Intf


def topology():

    "Create a network."

    net = Mininet( controller=RemoteController, link=TCLink )

    print "*** Creating nodes"

    h1 = net.addHost( 'h1')

    h2 = net.addHost( 'h2')

    SwitchList = []

    # set n to different numbers, you can set that each path to contain n switches

    n = 3

    for x in range(1, n*2-2+1):




    c0 = net.addController( 'c0', controller=RemoteController, ip='', port=6633 )


    print "*** Creating links"

    linkBW = {'bw':100}

    net.addLink(h1, SwitchList[0], cls=TCLink, **linkBW)

    net.addLink(h2, SwitchList[n-1], cls=TCLink, **linkBW)

    for i in range(n*2-2):

     if i==(n-1):

       net.addLink(SwitchList[0], SwitchList[i+1], cls=TCLink, **linkBW) 

     elif i!=(n-1) and i!=(n*2-2-1):

        net.addLink(SwitchList[i], SwitchList[i+1], cls=TCLink, **linkBW)


        net.addLink(SwitchList[i], SwitchList[n-1], cls=TCLink, **linkBW)


    print "*** Starting network"


    for sw in SwitchList:



    #using the static arp, the hosts don't need to run arp protocol. Speed up the emulation.

    h1.cmd('arp -s '+ h2.IP()+' '+h2.MAC())

    h1.cmdPrint('arp -n')

    h2.cmd('arp -s '+h1.IP()+' '+h1.MAC())

    h2.cmdPrint('arp -n')


    #print "*** Running CLI"

    CLI( net )


    print "*** Stopping network"



if __name__ == '__main__':

    setLogLevel( 'info' )





Dr. Chih-Heng Ke (

Department of Computer Science and Information Engineering,

National Quemoy University, Kinmen, Taiwan.