if ! echo"$DIST" | egrep "Ubuntu|Debian" > /dev/null; then echo"OS must be Ubuntu or Debian" $cd BUILD_DIR return fi if [ "$DIST" = "Ubuntu" ] && ! version_ge $RELEASE 12.04; then echo"Ubuntu version must be >= 12.04" cd$BUILD_DIR return fi if [ "$DIST" = "Debian" ] && ! version_ge $RELEASE 7.0; then echo"Debian version must be >= 7.0" cd$BUILD_DIR return fi
rm -rf $OVS_SRC mkdir -p $OVS_SRC cd$OVS_SRC
if wget $OVS_TARBALL_LOC/openvswitch-$OVS_RELEASE.tar.gz 2> /dev/null; then tar xzf openvswitch-$OVS_RELEASE.tar.gz else echo"Failed to find OVS at $OVS_TARBALL_LOC/openvswitch-$OVS_RELEASE.tar.gz" cd$BUILD_DIR return fi
# Build OVS parallel=`grep processor /proc/cpuinfo | wc -l` cd$BUILD_DIR/openvswitch/openvswitch-$OVS_RELEASE DEB_BUILD_OPTIONS='parallel=$parallel nocheck' fakeroot debian/rules binary cd .. for pkg in common datapath-dkms pki switch; do pkg=openvswitch-${pkg}_$OVS_RELEASE*.deb echo"Installing $pkg" $pkginst$pkg done if$pkginst openvswitch-controller_$OVS_RELEASE*.deb 2>/dev/null; then echo"Ignoring error installing openvswitch-controller" fi
/sbin/modinfo openvswitch sudo ovs-vsctl show # Switch can run on its own, but # Mininet should control the controller # This appears to only be an issue on Ubuntu/Debian if sudo service openvswitch-controller stop 2>/dev/null; then echo"Stopped running controller" fi if [ -e /etc/init.d/openvswitch-controller ]; then sudo update-rc.d openvswitch-controller disable fi }
# Build OVS parallel=`grep processor /proc/cpuinfo | wc -l` cd$BUILD_DIR/openvswitch/openvswitch-$OVS_RELEASE DEB_BUILD_OPTIONS='parallel=$parallel nocheck' fakeroot debian/rules binary cd .. for pkg in common datapath-dkms pki switch; do pkg=openvswitch-${pkg}_$OVS_RELEASE*.deb echo"Installing $pkg" $pkginst$pkg done if$pkginst openvswitch-controller_$OVS_RELEASE*.deb 2>/dev/null; then echo"Ignoring error installing openvswitch-controller" fi
/sbin/modinfo openvswitch sudo ovs-vsctl show # Switch can run on its own, but # Mininet should control the controller # This appears to only be an issue on Ubuntu/Debian if sudo service openvswitch-controller stop 2>/dev/null; then echo"Stopped running controller" fi if [ -e /etc/init.d/openvswitch-controller ]; then sudo update-rc.d openvswitch-controller disable fi }
到最后可能会遇到这样的错误:
解决办法如下:
1 2 3 4 5 6 7 8
root@SDN:/home/low/mininet-wifi/mininet/util# cd ../../openvswitch/ root@SDN:/home/low/mininet-wifi/mininet/util# dpkg -i *.deb ... root@SDN:/home/low/mininet-wifi/mininet/util# service openvswitch-switch start root@SDN:/home/low/mininet-wifi/mininet/util# ovs-vsctl --version ovs-vsctl (Open vSwitch) 2.8.1 DB Schema 7.15.0
此时ovs-vsctl版本已经升级成功!
0x03 拓扑创建
在使用Openflow 1.3 时,需要将OVS交换机切换到用户态并指定协议版本:
1 2
ovs-vsctl set bridge s1 datapath_type=netdev ovs-vsctl set bridge s1 protocols=OpenFlow13
from mininet.net import Mininet from mininet.cli import CLI from mininet.node import RemoteController,Controller from mininet.log import info import sys import os import time
net.start() # time.sleep(2) print("*** set bridge s1 work moudle") os.system("ovs-vsctl set bridge s1 datapath_type=netdev") os.system("ovs-vsctl set bridge s1 protocols=OpenFlow13") CLI(net)