教辅篇(Tutorial)-- 交换机实验

创建一个自定义的topo

在~/mininet/custom中找到.py文件,里面有示例讲如何创建,非常简单.

from mininet.topo import Topo

class MyTopo( Topo ):
    "Simple topology example."

    def __init__( self ):
        "Create custom topo."

        # Initialize topology
        Topo.__init__( self )

        # Add hosts and switches
        leftHost = self.addHost( 'h1' )
        rightHost = self.addHost( 'h2' )
        leftSwitch = self.addSwitch( 's3' )
        rightSwitch = self.addSwitch( 's4' )

        # Add links
        self.addLink( leftHost, leftSwitch )
        self.addLink( leftSwitch, rightSwitch )
        self.addLink( rightSwitch, rightHost )


topos = { 'mytopo': ( lambda: MyTopo() ) }

在创建的时候,不要离开custom目录,sudo mn --custom name.py --topo mytopomytopo对应的是py文件中的类名

你可能感兴趣的:(教辅篇(Tutorial)-- 交换机实验)