#!/usr/bin/python

"""
This is a simple example that demonstrates multiple links
between nodes.
"""

from mininet.cli import CLI
from mininet.log import setLogLevel
from mininet.net import Mininet
from mininet.topo import Topo
from mininet.link import TCLink, TCIntf, Link


def runMultiLink():
    "Create and run multiple link network"
    topo = simpleMultiLinkTopo( n=2 )
    net = Mininet( topo=topo )
    net.start()
    CLI( net )
    net.stop()

class simpleMultiLinkTopo( Topo ):
    "Simple topology with multiple links"

    def __init__( self, n, **kwargs ):
        Topo.__init__( self, **kwargs )

    <% hostInfo.map(function(host) {  -%>
    <%- host.name %> = self.addHost('<%- host.name %>')
    <% }) -%>

    <% switchInfo.map(function(entry) { -%>
    <%- entry.name %> = self.addSwitch('<%- entry.name %>')
    <% }) -%>

    <% nodeLink_listInfo.map(function(entry) { -%>
    self.addLink(<%- entry.src_name %>,<%- entry.dst_name %>,intf=TCIntf, params1 = { 'bw': <%- entry.Bandwidth_Mbps%> , 'delay' : '<%- entry.Delay_ms%>ms' , 'loss' : <%- entry.Loss%>}, params2 = { 'bw': <%- entry.Bandwidth_Mbps%> , 'delay' : '<%- entry.Delay_ms%>ms' , 'loss' : <%- entry.Loss%>})
    <% }) -%>

if __name__ == '__main__':
    setLogLevel( 'info' )
    runMultiLink()
