示例,要创建一个3个交换机8个主机的拓扑,如下图:

可以用如下python代码创建上述拓扑,并指定ip:

from mininet.topo import Topo

class MyTopo( Topo ):
def __init__( self ):
"Create custom topo." # Initialize topology
Topo.__init__( self ) # Add hosts and switches
leftHost1 = self.addHost( 'h1', ip='10.0.0.1' )
leftHost2 = self.addHost( 'h2', ip='10.0.0.2' )
leftHost3 = self.addHost( 'h3', ip='10.0.1.1' )
leftHost4 = self.addHost( 'h4', ip='10.0.1.2' ) leftSwitch = self.addSwitch( 's1' )
middleSwitch = self.addSwitch( 's2' )
rightSwitch = self.addSwitch( 's3' ) rightHost1 = self.addHost( 'h5', ip='10.0.11.1' )
rightHost2 = self.addHost( 'h6', ip='10.0.11.2' )
rightHost3 = self.addHost( 'h7', ip='10.0.12.1' )
rightHost4 = self.addHost( 'h8', ip='10.0.12.2' ) # Add links
self.addLink( leftHost1, leftSwitch )
self.addLink( leftHost2, leftSwitch )
self.addLink( leftHost3, leftSwitch )
self.addLink( leftHost4, leftSwitch )
self.addLink( leftSwitch, middleSwitch )
self.addLink( middleSwitch, rightSwitch )
self.addLink( rightSwitch, rightHost1 )
self.addLink( rightSwitch, rightHost2 )
self.addLink( rightSwitch, rightHost3 )
self.addLink( rightSwitch, rightHost4 ) topos = { 'mytopo': ( lambda: MyTopo() ) }

创建topo之后用dump命令验证,可见它们的ip确实如代码中指定的一样。

mininet@mininet-vm:~/mininet/custom$ sudo mn --custom topo-3sw-8host.py --topo mytopo --controller=remote,ip=192.168.56.1 --mac
added a switch!
added a switch!
added a switch!
*** Creating network
*** Adding controller
*** Adding hosts:
h1 h2 h3 h4 h5 h6 h7 h8
*** Adding switches:
s1 s2 s3
*** Adding links:
(h1, s1) (h2, s1) (h3, s1) (h4, s1) (h5, s3) (h6, s3) (h7, s3) (h8, s3) (s1, s2) (s2, s3)
*** Configuring hosts
h1 h2 h3 h4 h5 h6 h7 h8
*** Starting controller
*** Starting switches
s1 s2 s3
*** Starting CLI:
mininet> dump
<RemoteController c0: 192.168.56.1: pid=>
<OVSSwitch s1: lo:127.0.0.1,s1-eth1:None,s1-eth2:None,s1-eth3:None,s1-eth4:None,s1-eth5:None pid=>
<OVSSwitch s2: lo:127.0.0.1,s2-eth1:None,s2-eth2:None pid=>
<OVSSwitch s3: lo:127.0.0.1,s3-eth1:None,s3-eth2:None,s3-eth3:None,s3-eth4:None,s3-eth5:None pid=>
<Host h1: h1-eth0:10.0.0.1 pid=>
<Host h2: h2-eth0:10.0.0.2 pid=>
<Host h3: h3-eth0:10.0.1.1 pid=>
<Host h4: h4-eth0:10.0.1.2 pid=>
<Host h5: h5-eth0:10.0.11.1 pid=>
<Host h6: h6-eth0:10.0.11.2 pid=>
<Host h7: h7-eth0:10.0.12.1 pid=>
<Host h8: h8-eth0:10.0.12.2 pid=>
mininet>

Mininet 创建topo的时候指定host的ip的更多相关文章

  1. 使用Mininet创建网络拓扑

    使用Mininet创建Topo Python脚本实现创建拓扑 #coding:utf-8 from mininet.net import Mininet from mininet.topo impor ...

  2. PDO创建mysql数据库并指定utf8编码

    <?php //PDO创建mysql数据库并指定utf8编码 header('Content-type:text/html; charset=utf-8'); $servername = &qu ...

  3. expect脚本同步文件 expect脚本指定host和要同步的文件 构建文件分发系统 批量远程执行命令

    自动同步文件 #!/usr/bin/expect set " spawn rsync -av root@.txt /tmp/ expect { "yes/no" { se ...

  4. expect脚本同步文件、expect脚本指定host和要同步的文件、构建文件分发系统、批量远程执行命令

    7月20日任务 20.31 expect脚本同步文件20.32 expect脚本指定host和要同步的文件20.33 构建文件分发系统20.34 批量远程执行命令扩展:shell多线程 http:// ...

  5. Linux centosVMware运行告警系统、分发系统-expect讲解、自动远程登录后,执行命令并退出、expect脚本传递参数、expect脚本同步文件、指定host和要同步的文件、shell项目-分发系统-构建文件分发系统、分发系统-命令批量执行

    一运行告警系统 创建一个任务计划crontab -e 每一分钟都执行一次 调试时把主脚本里边log先注释掉 再次执行 没有发现502文件说明执行成功了,每日有错误,本机IP 负载不高 二.分发系统-e ...

  6. 如何在Mininet中修改host的IP地址

    how to update virtual host's IP in mininet? I got it! do like this: mininet> py h1.setIP('10.0.0. ...

  7. [转]php curl 设置host curl_setopt CURLOPT_HTTPHEADER 指定host

    From : http://digdeeply.org/archives/10132139.html 我们在开发测试时,有时web服务器会绑定一个域名,但是因为dns是无法解析的,我们需要设置host ...

  8. mysql中如何在创建数据库的时候指定数据库的字符集?

    需求描述: 在创建DB的时候指定字符集. 操作过程: 1.使用create database语句创建数据库 mysql> create database if not exists test03 ...

  9. centos shell编程4【分发系统】 服务器标准化 mkpasswd 生成密码的工具 expect讲解 expect传递参数 expect自动同步文件 expect指定host和要同步的文件 expect文件分发系统 expect自动发送密钥脚本 Linux脚本执行方式 第三十八节课

    centos shell编程4[分发系统] 服务器标准化  mkpasswd 生成密码的工具  expect讲解   expect传递参数   expect自动同步文件  expect指定host和要 ...

随机推荐

  1. javascript对象与实例

    var person=new Object(); var person2={}; 一切都是对象 person是Object的实例, 也是对象. 第二个person2也是如此,只不过它是采用字面量的方式 ...

  2. 动态创建MySQL数据库

    import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sq ...

  3. linux下文件的复制、移动与删除

    linux下文件的复制.移动与删除命令为:cp,mv,rm 一.文件复制命令cp     命令格式:cp [-adfilprsu] 源文件(source) 目标文件(destination)      ...

  4. delphi下,不错的多语言翻译组件

    http://yktoo.com/en/software/dklangTraned http://sourceforge.net/projects/dklang/

  5. trade 主要前端组件

    jQuery Custombox http://www.jqueryfuns.com/resource/view/27

  6. WebApp

    目前的手机APP有三类:原生APP,WebAPP,HybridApp:HybridApp结合了前两类APP各自的优点,越来越流行. Hybrid App的兴起是现阶段移动互联网产业的一种偶然.移动互联 ...

  7. 感知器算法PLA

    for batch&supervised binary classfication,g≈f <=> Eout(g)≥0 achieved through Eout(g)≈Ein(g ...

  8. 如果在配置中将“system.serviceModel/serviceHostingEnvironment/multipleSiteBindingsEnabled”设置为 true,则需要终结点指定相对地址。如果在终结点上指定相对侦听 URI,则该地址可以是绝对地址。若要解决此问题,请为终结点“http://localhost/Service1.svc”指定相对 URI。

    问题: 如果在配置中将"system.serviceModel/serviceHostingEnvironment/multipleSiteBindingsEnabled"设置为 ...

  9. MySQL SHOW 语句大全

    常用的mysql show命令如下: 1.show databases;        显示mysql中所有数据库 2.show tables [from databases] ;     显示当前数 ...

  10. iOS JSON解析

    解析json成dic对象 -(void)fetchedData:(NSData*)responseData {//parse out the json dataNSError* error; NSDi ...