diff --git a/ryu/app/beba/test/InSP__ryu.py b/ryu/app/beba/test/InSP__ryu.py index fc183a611..b2692092c 100644 --- a/ryu/app/beba/test/InSP__ryu.py +++ b/ryu/app/beba/test/InSP__ryu.py @@ -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') @@ -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 @@ -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): diff --git a/ryu/app/beba/test/beba.py b/ryu/app/beba/test/beba.py new file mode 100644 index 000000000..d346fdf06 --- /dev/null +++ b/ryu/app/beba/test/beba.py @@ -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} diff --git a/ryu/app/beba/test/ddos.py b/ryu/app/beba/test/ddos.py index b7c02038c..a9723fc2c 100644 --- a/ryu/app/beba/test/ddos.py +++ b/ryu/app/beba/test/ddos.py @@ -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") @@ -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) diff --git a/ryu/app/beba/test/experimenter_error_msg__ryu.py b/ryu/app/beba/test/experimenter_error_msg__ryu.py index 3145c3c88..d09e8b024 100644 --- a/ryu/app/beba/test/experimenter_error_msg__ryu.py +++ b/ryu/app/beba/test/experimenter_error_msg__ryu.py @@ -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): @@ -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 @@ -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() + diff --git a/ryu/app/beba/test/forwarding_consistency_1_to_many.py b/ryu/app/beba/test/forwarding_consistency_1_to_many.py index dbda688bb..2e881a393 100644 --- a/ryu/app/beba/test/forwarding_consistency_1_to_many.py +++ b/ryu/app/beba/test/forwarding_consistency_1_to_many.py @@ -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") @@ -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) diff --git a/ryu/app/beba/test/maclearning.py b/ryu/app/beba/test/maclearning.py index c92f44a3f..3f69bd1df 100644 --- a/ryu/app/beba/test/maclearning.py +++ b/ryu/app/beba/test/maclearning.py @@ -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") @@ -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) diff --git a/ryu/app/beba/test/portknocking.py b/ryu/app/beba/test/portknocking.py index 822897e9d..105c6422b 100644 --- a/ryu/app/beba/test/portknocking.py +++ b/ryu/app/beba/test/portknocking.py @@ -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") @@ -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) diff --git a/ryu/app/beba/test/run_all.sh b/ryu/app/beba/test/run_all.sh index 547bcd5a6..7fc1312bd 100755 --- a/ryu/app/beba/test/run_all.sh +++ b/ryu/app/beba/test/run_all.sh @@ -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]=$?; @@ -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