Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests now use Mininet's BEBA node with max verbosity #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions ryu/app/beba/test/InSP__ryu.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from ryu.lib.packet import packet
from ryu.lib.packet import ethernet
from ryu.lib.packet import ether_types
from beba import BebaSwitchDbg,BebaHost

LOG = logging.getLogger('app.beba.pkttmp')

Expand All @@ -28,7 +29,7 @@ def __init__(self, *args, **kwargs):
# Kill Mininet
os.system("sudo mn -c 2> /dev/null")
print 'Starting Mininet'
self.net = Mininet(topo=SingleSwitchTopo(2),switch=UserSwitch,controller=RemoteController,cleanup=True,autoSetMacs=True,listenPort=6634,autoStaticArp=False)
self.net = Mininet(topo=SingleSwitchTopo(2),switch=BebaSwitchDbg,host=BebaHost,controller=RemoteController,cleanup=True,autoSetMacs=True,listenPort=6634,autoStaticArp=False)
self.net.start()
self.test_id = 0

Expand Down Expand Up @@ -154,7 +155,7 @@ def _monitor1(self,datapath):
def restart_mininet(self):
print 'Restarting Mininet\n'
os.system("sudo mn -c 2> /dev/null")
self.net = Mininet(topo=SingleSwitchTopo(2),switch=UserSwitch,controller=RemoteController,cleanup=True,autoSetMacs=True,listenPort=6634,autoStaticArp=False)
self.net = Mininet(topo=SingleSwitchTopo(2),switch=BebaSwitchDbg,host=BebaHost,controller=RemoteController,cleanup=True,autoSetMacs=True,listenPort=6634,autoStaticArp=False)
self.net.start()

def stop_test_and_gracefully_exit(self):
Expand Down
66 changes: 66 additions & 0 deletions ryu/app/beba/test/beba.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
"""
Custom BEBA node and host

This script enables/disables switch max verbosity and debugging with Valgrind via Mininet CLI parameters.
(NB Mininet's verbosity is not affected and can be configured via --verbosity/-v parameter)

The following command starts Mininet with minimum verbosity level (it's equivalent to --switch user)
sudo mn --topo single,4 --controller remote --mac --arp --custom beba.py --switch beba

The following command starts Mininet with Valgrind and maximum verbosity level
sudo mn --topo single,4 --controller remote --mac --arp --custom beba.py --switch beba_dbg

By adding the '--host=beba' option, it is possible to disable the Checksum Offloading for all the hosts
to solve some issues in ofsoftswitch13 checksum correctness.
"""

from mininet.node import UserSwitch, Host

class BebaHost(Host):
def config(self, **params):
r = super(Host, self).config(**params)

self.defaultIntf().rename("eth0")

for off in ["rx", "tx", "sg"]:
cmd = "/sbin/ethtool --offload eth0 %s off" % off
self.cmd(cmd)

# disable IPv6
self.cmd("sysctl -w net.ipv6.conf.all.disable_ipv6=1")
self.cmd("sysctl -w net.ipv6.conf.default.disable_ipv6=1")
self.cmd("sysctl -w net.ipv6.conf.lo.disable_ipv6=1")

return r

class BebaSwitchDbg( UserSwitch ):
def start( self, controllers ):
"""Start OpenFlow reference user datapath.
Log to /tmp/sN-{ofd,ofp}.log.
controllers: list of controller objects"""
# Add controllers
clist = ','.join( [ 'tcp:%s:%d' % ( c.IP(), c.port )
for c in controllers ] )
ofdlog = '/tmp/' + self.name + '-ofd.log'
ofplog = '/tmp/' + self.name + '-ofp.log'
intfs = [ str( i ) for i in self.intfList() if not i.IP() ]

print '[\x1b[31mVALGRIND\x1b[0m]'
self.cmd( 'valgrind --leak-check=full --show-leak-kinds=all --trace-children=yes --track-origins=yes ofdatapath -v -i ' + ','.join( intfs ) +
' punix:/tmp/' + self.name + ' -d %s ' % self.dpid +
self.dpopts +
' 1> ' + ofdlog + ' 2> ' + ofdlog + ' &' )
self.cmd( 'ofprotocol unix:/tmp/' + self.name +
' ' + clist +
' --fail=closed ' + self.opts +
' 1> ' + ofplog + ' 2>' + ofplog + ' &' )
if "no-slicing" not in self.dpopts:
# Only TCReapply if slicing is enable
sleep(1) # Allow ofdatapath to start before re-arranging qdisc's
for intf in self.intfList():
if not intf.IP():
self.TCReapply( intf )

switches = {'beba':UserSwitch , 'beba_dbg':BebaSwitchDbg}

hosts = {'beba':BebaHost}
3 changes: 2 additions & 1 deletion ryu/app/beba/test/ddos.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from mininet.topo import SingleSwitchTopo
from mininet.node import UserSwitch,RemoteController
from mininet.term import makeTerm
from beba import BebaSwitchDbg,BebaHost

if os.geteuid() != 0:
exit("You need to have root privileges to run this script")
Expand Down Expand Up @@ -34,7 +35,7 @@ def wait_for_connection_expiration(max_time=5):
os.system('ryu-manager ../ddos/ddos.py 2> /dev/null &')

print 'Starting Mininet'
net = Mininet(topo=SingleSwitchTopo(2),switch=UserSwitch,controller=RemoteController,cleanup=True,autoSetMacs=True,listenPort=6634,autoStaticArp=True)
net = Mininet(topo=SingleSwitchTopo(2),switch=BebaSwitchDbg,host=BebaHost,controller=RemoteController,cleanup=True,autoSetMacs=True,listenPort=6634,autoStaticArp=True)
net.start()

time.sleep(3)
Expand Down
6 changes: 4 additions & 2 deletions ryu/app/beba/test/experimenter_error_msg__ryu.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import os,subprocess,time,sys
from ryu.ofproto.ofproto_common import BEBA_EXPERIMENTER_ID
import struct
from beba import BebaSwitchDbg,BebaHost

class BebaErrorExperimenterMsg(app_manager.RyuApp):

Expand All @@ -40,7 +41,7 @@ def __init__(self, *args, **kwargs):
# Kill Mininet
os.system("sudo mn -c 2> /dev/null")
print 'Starting Mininet'
self.net = Mininet(topo=SingleSwitchTopo(7),switch=UserSwitch,controller=RemoteController,cleanup=True,autoSetMacs=True,listenPort=6634,autoStaticArp=True)
self.net = Mininet(topo=SingleSwitchTopo(7),switch=BebaSwitchDbg,host=BebaHost,controller=RemoteController,cleanup=True,autoSetMacs=True,listenPort=6634,autoStaticArp=True)
self.net.start()
self.last_error_queue = []
self.test_id = 0
Expand Down Expand Up @@ -818,5 +819,6 @@ def stop_test_and_gracefully_exit(self):
def restart_mininet(self):
print 'Restarting Mininet\n'
os.system("sudo mn -c 2> /dev/null")
self.net = Mininet(topo=SingleSwitchTopo(7),switch=UserSwitch,controller=RemoteController,cleanup=True,autoSetMacs=True,listenPort=6634,autoStaticArp=True)
self.net = Mininet(topo=SingleSwitchTopo(7),switch=BebaSwitchDbg,host=BebaHost,controller=RemoteController,cleanup=True,autoSetMacs=True,listenPort=6634,autoStaticArp=True)
self.net.start()

3 changes: 2 additions & 1 deletion ryu/app/beba/test/forwarding_consistency_1_to_many.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from mininet.topo import SingleSwitchTopo
from mininet.node import UserSwitch,RemoteController
from mininet.term import makeTerm
from beba import BebaSwitchDbg,BebaHost

if os.geteuid() != 0:
exit("You need to have root privileges to run this script")
Expand All @@ -18,7 +19,7 @@
os.system('ryu-manager ../forwarding_consistency_1_to_many.py 2> /dev/null &')

print 'Starting Mininet'
net = Mininet(topo=SingleSwitchTopo(4),switch=UserSwitch,controller=RemoteController,cleanup=True,autoSetMacs=True,listenPort=6634)
net = Mininet(topo=SingleSwitchTopo(4),switch=BebaSwitchDbg,host=BebaHost,controller=RemoteController,cleanup=True,autoSetMacs=True,listenPort=6634)
net.start()

time.sleep(5)
Expand Down
3 changes: 2 additions & 1 deletion ryu/app/beba/test/maclearning.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from mininet.topo import SingleSwitchTopo
from mininet.node import UserSwitch,RemoteController
from mininet.term import makeTerm
from beba import BebaSwitchDbg,BebaHost

if os.geteuid() != 0:
exit("You need to have root privileges to run this script")
Expand All @@ -17,7 +18,7 @@
os.system('ryu-manager ../maclearning.py 2> /dev/null &')

print 'Starting Mininet'
net = Mininet(topo=SingleSwitchTopo(4),switch=UserSwitch,controller=RemoteController,cleanup=True,autoSetMacs=True,listenPort=6634,autoStaticArp=True)
net = Mininet(topo=SingleSwitchTopo(4),switch=BebaSwitchDbg,host=BebaHost,controller=RemoteController,cleanup=True,autoSetMacs=True,listenPort=6634,autoStaticArp=True)
net.start()

time.sleep(6)
Expand Down
3 changes: 2 additions & 1 deletion ryu/app/beba/test/portknocking.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from mininet.topo import SingleSwitchTopo
from mininet.node import UserSwitch,RemoteController
from mininet.term import makeTerm
from beba import BebaSwitchDbg,BebaHost

if os.geteuid() != 0:
exit("You need to have root privileges to run this script")
Expand All @@ -17,7 +18,7 @@
os.system('ryu-manager ../portknock.py 2> /dev/null &')

print 'Starting Mininet'
net = Mininet(topo=SingleSwitchTopo(2),switch=UserSwitch,controller=RemoteController,cleanup=True,autoSetMacs=True,listenPort=6634)
net = Mininet(topo=SingleSwitchTopo(2),switch=BebaSwitchDbg,host=BebaHost,controller=RemoteController,cleanup=True,autoSetMacs=True,listenPort=6634)
net.start()

time.sleep(5)
Expand Down
8 changes: 8 additions & 0 deletions ryu/app/beba/test/run_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ do
then
continue
fi
if [ "$f" == "beba.py" ]
then
continue
fi
echo -e "\n\x1b[33m[Testing $f]\x1b[0m";
sudo python $f;
ret_values[$f]=$?;
Expand All @@ -26,6 +30,10 @@ do
then
continue
fi
if [ "$f" == "beba.py" ]
then
continue
fi
if [[ ${ret_values[$f]} -eq 1 ]]; then
echo -e "$f: \x1b[31mFAILED\x1b[0m";
else
Expand Down