zoukankan      html  css  js  c++  java
  • mininet创建简单的拓扑

    # 四个交换机每个下边挂载一个主机
    
    Linear4 = LinearTopo(k=4)
    net = Mininet(topo=Linear4)
    net.start()
    net.pingAll()
    net.stop()

     

    # single,3
    
    from mininet.topo import SingleSwitchTopo
    
    Single3 = SingleSwitchTopo(k=3)
    net = Mininet(topo=Single3)
    net.start()
    net.pingAll()
    net.stop()

     

    # tree,depth=2,fanout=2
    
    from mininet.topolib import TreeTopo
    
    Tree22 = TreeTopo(depth=2, fanout=2)
    net = Mininet(topo=Tree22)
    net.start()
    net.pingAll()
    net.stop()

     

    # create 1 switch,2 host,set hosts IP
    
    net = Mininet()
    
    # Creating nodes in the network
    c0 = net.addController()
    h0 = net.addHost('h0')
    s0 = net.addSwitch('s0')
    h1 = net.addHost('h1')
    # Creating links between nodes in network
    net.addLink(h0, s0)
    net.addLink(h1, s0)
    # configuration of IP address in interfaces
    h0.setIP('192.168.1.1', 24)
    h1.setIP('192.168.1.2', 24)
    
    net.start()
    net.pingAll()
    net.stop()

     

    # add more limits to the host
    
    from mininet.net import Mininet
    from mininet.node import CPULimitedHost
    from mininet.link import TCLink
    
    net = Mininet(host=CPULimitedHost, link=TCLink)
    # Creating nodes in the network
    c0 = net.addController()
    s0 = net.addSwitch('s0')
    h0 = net.addHost('h0')
    h1 = net.addHost('h1', cpu=0.5)
    h2 = net.addHost('h2', cpu=0.5)
    net.addLink(s0, h0, bw=10, delay='5ms',max_queue_size=1000, loss=10, use_htb=True)
    net.addLink(s0, h1)
    net.addLink(s0, h2)
    net.start()
    net.pingAll()
    net.stop()

     

    作者:天际使徒
    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须在文章页面给出原文连接,否则保留追究法律责任的权利。
  • 相关阅读:
    UVa-129
    UVa-524
    有点迷茫
    北邮之行~
    UVa-253
    心累--期末考试成绩
    UVa-220 Othello
    UVa-201 Squares
    UVA-1589 Xiangqi
    UVa-213 Message Decoding
  • 原文地址:https://www.cnblogs.com/Horizon-asd/p/12601896.html
Copyright © 2011-2022 走看看