@EggGump
2019-01-17T13:49:56.000000Z
字数 3081
阅读 667
sdn
ubuntu-18.04.1-desktop-amd64
vmware14
主要注意安装好ubuntu后要更换源,更换源会付带
ali的源
deb http://mirrors.aliyun.com/ubuntu/ trusty main multiverse restricted universe
deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main multiverse restricted universe
deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main multiverse restricted universe
deb http://mirrors.aliyun.com/ubuntu/ trusty-security main multiverse restricted universe
deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main multiverse restricted universe
deb-src http://mirrors.aliyun.com/ubuntu/ trusty main multiverse restricted universe
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main multiverse restricted universe
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main multiverse restricted universe
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main multiverse restricted universe
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main multiverse restricted universe
源的位置:/etc/apt/sources.listsudo
sudo apt-get update
sudo apt-get -f install
sudo apt-get upgrade
,我使用的是aliyun的源
sudo mn
参考博客:https://github.com/mininet/mininet/wiki/Installing-new-version-of-Open-vSwitch
ovs-vsctl show #查看ovs版本,为2.0.1之类的就需要升级
sudo -s #先给自已一个root权限ma
mkdir ovs
cd ovs
wget http://openvswitch.org/releases/openvswitch-2.6.1.tar.gz
tar -xzf openvswitch-2.6.1.tar.gz # 解压并进入目录
cd openvswitch-2.6.1.tar.gz
dpkg-checkbuilddeps #检查依赖
sudo apt-get install (检查出来的依赖)
sudo apt install dpkg-dev fakeroot build-essential openssl debhelper autoconf automake libssl-dev python-all python-twisted-conch clang pkg-config gcc m4 libtool sparse#书上的依赖
uname -r #检查linux内核版本 4.2.0-27-generic
./configure --prefix=/usr --with-linux=/lib/modules/`uname -r`/build #编译
make #注意以下需要root权限
make install
make modules_install
rmmod openvswitch
depmod -a
/sbin/modprob openvswitch
git clone git://github.com/mininet/mininet
cd mininet
git tag #可查看所有的版本
git checkout -b 版本
sudo util/install.sh -a #安装
书上的更新方法(未尝试):
cd mininet
git fetch
git checkout master
git pull
sudo make install 或 sudo make develop
查看所有结点相关信息
dump
只查看所有的结点
nodes
查看网络的连接
net
ping的使用
h1 ping -c 4 h2
xterm和gterm为一个节点开启一个终端
xterm h1
gterm h1 h2 #这是启动两个节点的终端
link命令
link s1 h1 down #关掉s1与h1的连接
link s1 h1 up #打开s1与h1的连接
ipref测速
iperf #测tcp
iperfudp #测udp
dpctl 数据通路和检测工具
dpctl show #查看switch的基本信息
执行外部指令 py 和 sh
py locals()
py h1.IP()
sh ls
help命令
帮助我们列举出所支持的命令,另外,使用tab也可以进行自动补全。
from mininet.topo import Topo
class homeworkTopo(Topo):
def __init__(self):
Topo.__init__(self)
# c = self.addController('c')
s1 = self.addSwitch('s1')
s2 = self.addSwitch('s2')
s3 = self.addSwitch('s3')
s4 = self.addSwitch('s4')
s5 = self.addSwitch('s5')
h1 = self.addHost('h1')
h2 = self.addHost('h2')
h3 = self.addHost('h3')
h4 = self.addHost('h4')
# self.addLink(s1,c)
self.addLink(s1,s2)
self.addLink(s2,s3)
self.addLink(s2,s4)
self.addLink(s2,s5)
self.addLink(s3,h1)
self.addLink(h2,s4)
self.addLink(h3,s5)
self.addLink(h4,s5)
topos = {'homeworkTopo':(lambda:homeworkTopo())}
sudo mn --custom=homeworktopo.py --topo homeworkTopo
启动后可以通过 net,dump,nodes查看脚本