示例,要创建一个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. yum安装报错有冲突file /usr/lib64/php/modules/fileinfo.so conflicts between

    yum安装报错有冲突file /usr/lib64/php/modules/fileinfo.so conflicts between attempted installs of php-pecl-f ...

  2. SASS语法备忘

    sass语法 关于sass 3.3.0更新说明——3.3.0 sublime相关插件为:scss语法高亮,sass语法高亮,编译,保存即编译,格式化 文件后缀名 sass有两种后缀名文件:一种后缀名为 ...

  3. linux gd库不支持jpeg解决办法

    1. 查看gd库是否支持jpeg gd_info(); 2. 如果JPEG Support 不为1则不支持. 3.首先下载 libjpeg http://www.ijg.org/ ,进行安装 安装目录 ...

  4. 学习php中常用语句与函数

    1.while循环多用于不清楚循环次数的情况下,如需要把从数据库中读取出的多条记录(不清楚到底有多少条)并且要根据某个字段的值进行分类,每类值的具体数目,如下图: 其中选项有三种值,对每个值的票数时行 ...

  5. PHP版本中的VC6,VC9,VC11,TS,NTS区别

    以windows为例,看看下载到得php zip的文件名 php-5.4.4-nts-Win32-VC9-x86.zip VC6:legacy Visual Studio 6 compiler,是使用 ...

  6. linux c 打印彩色字符

    #include <stdio.h> #include <string.h> int main(int argc, char **argv) { , j = , str_len ...

  7. ASP.NET对HTML元素进行权限控制(一)

    一个HTML页面有很多的元素比如<DIV>,<P>等.这些元素构成了HTML页面.在Web开发中权限控制是每个系统都要用到了.界面每个元素的权限也是需要控制的.比如一个查询用户 ...

  8. C#——中文转化成拼音

    在KS系统中用到了中文转化成拼音的功能.通过查阅资料为下面是代码. /// <summary> /// MyConvert 的摘要说明 /// </summary> publi ...

  9. epoll分析

      Epoll详解及源码分析 1.什么是epoll epoll是当前在Linux下开发大规模并发网络程序的热门人选,epoll 在Linux2.6内核中正式引入,和select相似,都是I/O多路复用 ...

  10. Error: Cannot find module 'express'

    安装Express命令如下: npm install -g express 安装成功之后会在C:\Users\[YOUR_USER_NAME]\AppData\Roaming\npm\node_mod ...