Mininet
在Coursera SDN开放课程中,编程作业要用Mininet来完成。这里对Mininet做一个简单的介绍。
什么是Mininet
Mininet是由一些虚拟的终端节点(end-hosts)、交换机、路由器连接而成的一个网络仿真器,它采用轻量级的虚拟化技术使得系统可以和真实网络相媲美。
Mininet可以很方便地创建一个支持SDN的网络:host就像真实的电脑一样工作,可以使用ssh登录,启动应用程序,程序可以向以太网端口发送数据包,数据包会被交换机、路由器接收并处理。有了这个网络,就可以灵活地为网络添加新的功能并进行相关测试,然后轻松部署到真实的硬件环境中。
Mininet的特性
可以简单、迅速地创建一个支持用户自定义的网络拓扑,缩短开发测试周期
可以运行真实的程序,在Linux上运行的程序基本上可以都可以在Mininet上运行,如Wireshark
Mininet支持Openflow,在Mininet上运行的代码可以轻松移植到支持OpenFlow的硬件设备上
Mininet可以在自己的电脑,或服务器,或虚拟机,或者云(例如Amazon EC2)上运行
Mininet提供python API,简单易用
Mininet是开源项目,源代码在这里:https://github.com/mininet
……
Mininet安装
使用VirtualBox安装Mininet虚拟机:http://mininet.org/download/
使用Mininet创建一个网络
以Coursera SDN Week3 programming assignment为例,创建一个及其简单的数据中心网络。
Data center networks typically have a tree-like topology. End-hosts connect to top-of-rack switches, which form the leaves (edges) of the tree; one or more core switches form the root; and one or more layers of aggregation switches form the middle of the tree. In a basic tree topology, each switch (except the core switch) has a single parent switch. Additional switches and links may be added to construct more complex tree topologies (e.g., fat tree) in an effort to improve fault tolerance or increase inter-rack bandwidth.
In this assignment, your task is to create a simple tree topology. You will assume each level i.e., core, aggregation, edge and host to be composed of a single layer of switches/hosts with a configurable fanout value (k) looks like:

代码:

# CustomTopo.py
'''
Coursera:
- Software Defined Networking (SDN) course
-- Module 3 Programming Assignment Professor: Nick Feamster
Teaching Assistant: Muhammad Shahbaz
''' from mininet.topo import Topo
from mininet.net import Mininet
from mininet.node import CPULimitedHost
from mininet.link import TCLink
from mininet.util import irange,dumpNodeConnections
from mininet.log import setLogLevel class CustomTopo(Topo):
"Simple Data Center Topology" "linkopts - (1:c1, 2:aggregation, 3: edge) parameters"
"fanout - number of child switch per parent switch"
def __init__(self, linkopts1, linkopts2, linkopts3, fanout=2, **opts):
# Initialize topology and default options
Topo.__init__(self, **opts) # Add your logic here ...
self.fanout = fanout
core = self.addSwitch('c1')
for i in irange(1, fanout):
aggregation = self.addSwitch('a%s' %i)
self.addLink(core, aggregation, **linkopts1)
for j in irange(1, fanout):
edge = self.addSwitch('e%s' %(fanout*(i-1)+j))
self.addLink(aggregation, edge, **linkopts2)
for k in irange(1, fanout):
host = self.addHost('h%s' %((fanout*(fanout*(i-1)+j-1))+k))
self.addLink(edge, host, **linkopts3) topos = { 'custom': ( lambda: CustomTopo() ) } def simpleTest():
"Create and test a simple network"
linkopts1 = dict(bw=10, delay='3ms', use_htb=True)
linkopts2 = dict(bw=8, delay='4ms', loss=1, max_queue_size=900, )
linkopts3 = dict(bw=6, delay='5ms', loss=1, max_queue_size=800)
topo = CustomTopo(linkopts1, linkopts2, linkopts3, fanout=2)
net = Mininet(topo, host=CPULimitedHost, link=TCLink)
net.start()
print "Dumping host connections"
dumpNodeConnections(net.hosts)
print "Testing network connectivity"
net.pingAll()
net.stop() if __name__ == '__main__':
# Tell mininet to print useful information
setLogLevel('info')
simpleTest()

在mininet虚拟机上执行下面操作即可创建自定义的网络拓扑。函数simpleTest()创建网络并进行了简单的ping测试,从屏幕输出可以看到创建的过程。
mininet@mininet-vm:~/mininet$ sudo python CustomTopo.py
更多资料
1. Mininet: http://mininet.org/
2. Mininet wiki: https://github.com/mininet/mininet/wiki
Mininet的更多相关文章
- mininet中iperf sever自动退出
使用iperf 在mininet进行吞吐量测试是常用的方法,之前结束iperf server的方法是运行os.system('pkill iperf')命令. 但是这种方式iperf server有可 ...
- mininet和ryu控制器的连接
1.执行ryu应用程式:ryu-manager --verbose ryu.app.simple_switch_13 2.启动mininet,配置如下:创建3个host,1个交换器(open vSwi ...
- Ubuntu下搭建Mininet环境
Mininet环境搭建分为两个步骤,如下: 1.从GITHUB上获取mininet源码到本地的opt目录下 打开Linux终端,切换目录到根目录 cd / 切换到Linux的opt目录下 cd opt ...
- Mininet在创建拓扑的过程中为什么不打印信息了——了解Mininet的log系统
前言 写这篇博客是为了给我的愚蠢和浪费的6个小时买单! 过程原因分析 我用Mininet创建过不少拓扑了,这次创建的拓扑非常简单,如下图,创建拓扑的代码见github.在以前的拓扑创建过程中,我都是用 ...
- Mininet的内部实现原理简介
原文发表在我的博客主页,转载请注明出处. 前言 之前模拟仿真网络一直用的是Mininet,包括写了一些关于Mininet安装,和真实网络相连接,Mininet简历拓扑的博客,但是大多数都是局限于具体步 ...
- Mininet实验 源码安装Mininet
参考:MiniNet实验1 安装命令: sudo apt-get update sudo apt-get upgrade sudo apt-get install git(安装过git就可以忽略此步) ...
- [SDN] mininet walkthrough
本次学习使用的是mininet的VM-image,所以安装过程就先忽略掉了,主要学习使用方法. 同时完成了在虚拟机上配置minient和Wireshark, 可以直接在虚拟机上操作. 1. Every ...
- mininet之miniedit可视化操作
Mininet 2.2.0之后的版本内置了一个mininet可视化工具miniedit,使用Mininet可视化界面方便了用户自定义拓扑创建,为不熟悉python脚本的使用者创造了更简单的环境,界面直 ...
- Mininet的安装与卸载
1.Mininet的卸载比较简单,只需要执行以下命令: sudo rm -rf /usr/local/bin/mn /usr/local/bin/mnexec /usr/local/lib/pytho ...
- 将Mininet与真实网络相连接
原文发表在我的博客主页,转载请注明出处 前言 Mininet是SDN网络仿真的一大利器,在小规模网络模拟使用上独领风骚,其开源性允许使用者按照自己的需求修改源码,得到想要的数据,其提供了多个函数用来满 ...
随机推荐
- SpringBoot入门篇--热部署
在项目的开发过程中我们难免会涉及到对代码的修改,有bug我们也需要对代码进行修改,这时候我们就需要重启服务器.但是,我们知道的是这个过程是相当的痛苦的,重启服务器涉及到了所有资源的重新加载,过程那是相 ...
- 经典算法 Morris遍历
内容: 1.什么是morris遍历 2.morris遍历规则与过程 3.先序及中序 4.后序 5.morris遍历时间复杂度分析 1.什么是morris遍历 关于二叉树先序.中序.后序遍历的递归和非递 ...
- openStack虚拟机error 错误状态基于差异镜像+基镜像做恢复
- RedHat7.0更新yum源
https://blog.csdn.net/hongbin_xu/article/details/79316614
- springboot1.X 到2.X 的改变
参考:https://blog.csdn.net/tzs_1041218129/article/details/79514845
- angular controller 之间的通信方式
AngularJS中的controller是个函数,用来向视图的作用域($scope)添加额外的功能,我们用它来给作用域对象设置初始状态,并添加自定义行为. 当我们在创建新的控制器时,angularJ ...
- jsp 调用其他jsp页面 跳转
response.sendRedirect("test2.jsp"); window.location.reload("test2.jsp"); locatio ...
- VB6 内存释放
VB在内存释放方面是这样的, 首先和其他任何语言一样,如果是在stack分配的空间的话,操作系统自动进行管理 比如下面的语句 dim a as string '当a 超出它的作用范围以后,就会被释放掉 ...
- 突破MSDE 的2GB数据限制
Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer\MSSQLServer\ ...
- H5-BLOB
BLOB 对象为h5的产物.普遍用于传输或者存储数据. <a 标签的新属性 download 表明 此a标签点击后,不是href跳转而是要下载.download的内容表示下载文件名.但是目前部分 ...