test script and diff for measurement changes

parent 1070aaad
......@@ -2,7 +2,7 @@
csv_input=$1
declare -a arr=("s1-eth1" "s1-eth2")
declare -a arr=("s1-eth1" "s1-eth2" "s1-eth3" "s2-eth1" "s2-eth2" "s2-eth3")
start_timestamp=`head -1 $csv_input | cut -d',' -f1`
export start_timestamp
......
#!/bin/bash -x
csv_input=$1
declare -a arr=("s1-eth1" "s1-eth2" "s2-eth1" "s2-eth2")
start_timestamp=`head -1 $csv_input | cut -d',' -f1`
export start_timestamp
for i in "${arr[@]}"
do
echo "$i"
input_filename="$i.data"
output_filename="$i.pdf"
export output_filename
export input_filename
#filed :1 timestamp, 3:bytes_out, 4:bytes_in, 8:total_packets, 9:errors_out, 10:errors_in
grep $i $csv_input | cut -d',' -f1,3,4,9,10 | sort -u -g --output=$input_filename
./gnu_deidtect_bw.scr
rm $input_filename
done
......@@ -12,3 +12,4 @@ result/*
*.csv
input.xml
gr-result/*
mult-result/*
......@@ -73,22 +73,30 @@ def bandwidthTopo(bw, controllerip):
c0 = net.addController('c0', ip=controllerip, port=6633 )
srcLink = custom(TCLink, bw=bw)
src2Link = custom(TCLink, bw=10-bw)
otherLink = custom(TCLink, bw=10)
"Create custom topo."
attacker = net.addHost( 'h1', mac='00:00:00:00:00:21')
brosys = net.addHost( 'h2', mac='00:00:00:00:00:22')
topSwitch = net.addSwitch( 's1' )
h1 = net.addHost( 'h1', mac='00:00:00:00:00:21' )
h2 = net.addHost( 'h2', mac='00:00:00:00:00:22' )
h3 = net.addHost( 'h3', mac='00:00:00:00:00:23' )
h4 = net.addHost( 'h4', mac='00:00:00:00:00:24' )
s1 = net.addSwitch( 's1' )
s2 = net.addSwitch( 's2' )
# Add links
srcLink( attacker, topSwitch )
otherLink( topSwitch, brosys )
srcLink( h1, s1 )
src2Link( s1, h2 )
otherLink( s1, s2 )
otherLink( s2, h3 )
otherLink( s2, h4 )
net.build()
c0.start()
topSwitch.start([c0])
s1.start([c0])
s2.start([c0])
ryu_c = Popen("./ryu_init.sh %s %d 1> ryu.out 2> ryu.out" % (controllerip, 3), shell=True)
ryu_c = Popen("./ryu_init.sh %s %d 1> ryu.out 2> ryu.out" % (controllerip, 2), shell=True)
print "wait 5 sec for controller to connect"
sleep(5)
......@@ -109,7 +117,7 @@ def monitor_devs_ifstat(fname="rate.csv"):
print if_cmd
Popen(if_cmd, shell=True).wait()
def monitor_devs_ng(fname="txrate.csv" , interval_sec=0.01):
def monitor_devs_ng(fname="txrate.csv" , interval_sec=0.1):
"""Uses bwm-ng tool to collect iface tx rate stats. Very reliable."""
cmd = ("sleep 1; bwm-ng -t %s -o csv "
"-u bytes -T rate -C ',' > %s" %
......@@ -138,10 +146,9 @@ def bandwidthTest(bw=5, controllerip="localhost"):
# print "Host : %s\n" % (h.name)
h1 = net.getNodeByName('h1')
print h1.name
h2 = net.getNodeByName('h2')
s1 = net.getNodeByName('s1')
print s1.name
net.pingAll();
......@@ -155,17 +162,14 @@ def bandwidthTest(bw=5, controllerip="localhost"):
#CLI(net)
#start the traffic generation wait for 5 seconds (H1->H3)
tg_cmd = 'mz h1-eth0 -c 0 -t udp sp=49 -A 10.0.0.1 -B 10.0.0.2 -P \"Hello World\" &'
h1_tg_cmd = 'mz h1-eth0 -c 0 -t udp sp=49 -A 10.0.0.1 -B 10.0.0.3 -P \"Hello World\" &'
h2_tg_cmd = 'mz h2-eth0 -c 0 -t udp sp=49 -A 10.0.0.2 -B 10.0.0.4 -P \"Hello World\" &'
print "Traffic generation from H1 started"
h1.cmd(tg_cmd)
h1.cmd(h1_tg_cmd)
h2.cmd(h2_tg_cmd)
sleep_time = 120
i = 10;
while ( i < sleep_time):
print "[%d] Sleeping for %d seconds for rate-limiters to grow" \
%( sleep_time/i, i)
sleep(i)
sleep_time=sleep_time - i;
sleep(sleep_time);
#stop the traffic generation
h1.cmd('killall mz')
......
......@@ -187,7 +187,6 @@ def bandwidthTest(bw=5, controllerip="localhost"):
#start the traffic generation wait for 5 seconds (H1->H3)
tg_cmd = 'mz h1-eth0 -c 0 -t udp sp=49 -A 10.0.0.1 -B 10.0.0.3 -P \"Hello World\" &'
print "Traffic generation from H1 -> H3 started"
#h1.cmd(tg_cmd)
h1.cmd('sudo ethtool -K h1-eth0 tso off')
h1.cmd("ifconfig h1-eth0 mtu 900")
h2.cmd('sudo ethtool -K h2-eth0 tso off')
......@@ -195,6 +194,9 @@ def bandwidthTest(bw=5, controllerip="localhost"):
h3.cmd('sudo ethtool -K h3-eth0 tso off')
h3.cmd("ifconfig h3-eth0 mtu 900")
print "sleep for 5 sec before sending traffic"
sleep(5)
h1.cmd(tg_cmd)
CLI(net)
#stop the traffic generation
......
#!/usr/bin/python
"""
Run deidtect to study the bandwdith sharing behaviour between
service traffic and tap traffic going through a common port.
Praveen Kumar Shanmugam
"""
import sys
sys.path = ['../'] + sys.path
import os
import random
import json
from time import sleep
from optparse import OptionParser
from subprocess import Popen, PIPE
import multiprocessing
from mininet.net import Mininet
from mininet.node import Controller, RemoteController, UserSwitch, CPULimitedHost
from mininet.link import TCLink, Intf
from mininet.cli import CLI
from mininet.log import setLogLevel, info, warn, error, debug
from mininet.util import custom, quietRun, run
import socket
import fcntl
import struct
def get_ip_address(ifname):
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
return socket.inet_ntoa(fcntl.ioctl(
s.fileno(),
0x8915, # SIOCGIFADDR
struct.pack('256s', ifname[:15])
)[20:24])
#Parse command line options and dump results
def parseOptions():
"Parse command line options"
parser = OptionParser()
parser.add_option( '-b', '--bw', dest='bw',
type='int', default=0, help='use bandwidth limiting' )
parser.add_option( '-f', '--if', dest='ifstat',
type='int', default=0, help='use ifstat to monitor' )
parser.add_option( '-c', '--cip', dest='cip',
type='string', default="localhost", help='controller IP' )
( options, args ) = parser.parse_args()
return options, args
opts, args = parseOptions()
def clean():
'''Clean any running instance of mininet and ryu'''
p = Popen("ps aux | grep 'ryu' | awk '{print $2}'",
stdout=PIPE, shell=True)
p.wait()
procs = (p.communicate()[0]).split('\n')
for pid in procs:
try:
pid = int(pid)
Popen('kill %d' % pid, shell=True).wait()
except:
pass
os.system('sudo mn -c')
#Creat a topology with 10 Mbs links except the one with the src host
#connected to the network, configure that with bw
def bandwidthTopo(bw, controllerip):
net = Mininet(controller=RemoteController, switch=UserSwitch)
c0 = net.addController('c0', ip=controllerip, port=6633 )
srcLink = custom(TCLink, bw=bw)
otherLink = custom(TCLink, bw=10)
"Create custom topo."
h1 = net.addHost( 'h1', mac='00:00:00:00:00:21')
h2 = net.addHost( 'h2', mac='00:00:00:00:00:22')
s1 = net.addSwitch( 's1' )
s2 = net.addSwitch( 's2' )
# Add links
srcLink( h1, s1 )
otherLink( s1, s2 )
otherLink( h2, s2 )
#intf = Intf('s3-eth2', node=s1)
net.build()
c0.start()
s1.start([c0])
s2.start([c0])
ryu_c = Popen("./ryu_init.sh %s %d 1> ryu.out 2> ryu.out" % (controllerip, 2), shell=True)
print "wait 5 sec for controller to connect"
sleep(5)
return net, ryu_c
def hostArray( net ):
"Return array[1..N] of net.hosts"
try:
host_array = sorted(net.hosts, key=lambda x: int(x.name))
except:
host_array = sorted(net.hosts, key=lambda x: x.name)
return host_array
def monitor_devs_ifstat(fname="rate.csv"):
if_cmd = 'ifstat -a -t > %s &' % (fname)
print if_cmd
Popen(if_cmd, shell=True).wait()
def monitor_devs_ng(fname="txrate.csv" , interval_sec=0.01):
"""Uses bwm-ng tool to collect iface tx rate stats. Very reliable."""
'''
#ifstat - also gives the same result, :(
cmd = ("ifstat -t -n -b -i s1-eth1,s2-eth2,s3-eth1 > %s" % (fname))
'''
cmd = ("sleep 1; bwm-ng -t %s -o csv "
"-u bytes -T rate -C ',' > %s" %
(interval_sec * 1000, fname))
Popen(cmd, shell=True).wait()
def monitorInterfacesInit(net, outfile):
monitors = []
#monitors.append(multiprocessing.Process(target=monitor_devs_ifstat,
# args=("rate.csv",)))
os.system("rm -f %s" % outfile)
monitors.append(multiprocessing.Process(target=monitor_devs_ng,
args=(outfile, 1,)))
return monitors
def bandwidthTest(bw=5, controllerip="localhost"):
print bw
print controllerip
net, ryu_c = bandwidthTopo(bw,controllerip)
hosts = hostArray(net)
#for h in hosts:
# print "Host : %s\n" % (h.name)
h1 = net.getNodeByName('h1')
print h1.name
h2 = net.getNodeByName('h2')
print h2.name
s1 = net.getNodeByName('s1')
s2 = net.getNodeByName('s2')
s1.cmd("ifconfig s1-eth1 mtu 900")
s2.cmd("ifconfig s2-eth2 mtu 900")
print s1.name
tg_cmd = 'mz h1-eth0 -c 0 -t udp sp=49 -A 10.0.0.1 -B 10.0.0.2 -P \"Hello World\" &'
h1.cmd('sudo ethtool -K h1-eth0 tso off')
h1.cmd("ifconfig h1-eth0 mtu 900")
h2.cmd('sudo ethtool -K h2-eth0 tso off')
h2.cmd("ifconfig h2-eth0 mtu 900")
outfile="txrate%s.csv" % bw
monitors = monitorInterfacesInit(net,outfile);
for m in monitors:
m.start();
#vlan alone
s_h1h2cmd=[]
s_h1h2cmd.append("dpctl unix:/tmp/s1 flow-mod cmd=add,table=0 in_port=1 apply:push_vlan=0x8100,set_field=vlan_vid:100,output=2")
s_h2h1cmd=[]
s_h2h1cmd.append("dpctl unix:/tmp/s2 flow-mod cmd=add,table=0 vlan_vid=100 apply:pop_vlan,output=2")
#metering flow
'''
s_h1h2cmd=[]
s_h1h2cmd.append("dpctl unix:/tmp/s1 meter-mod cmd=add,flags=1,meter=2 drop:rate=10000")
s_h1h2cmd.append("dpctl unix:/tmp/s1 flow-mod cmd=add,table=0 in_port=1 apply:push_vlan=0x8100,set_field=vlan_vid:100,output=2")
#s_h1h2cmd.append("dpctl unix:/tmp/s1 flow-mod cmd=add,table=0 vlan_vid=200 meter:2 apply:pop_vlan,output=1")
s_h1h2cmd.append("dpctl unix:/tmp/s1 flow-mod cmd=add,table=0 vlan_vid=200 apply:pop_vlan,output=1")
s_h2h1cmd=[]
s_h2h1cmd.append("dpctl unix:/tmp/s2 meter-mod cmd=add,flags=1,meter=2 drop:rate=10000")
s_h2h1cmd.append("dpctl unix:/tmp/s2 flow-mod cmd=add,table=0 in_port=2 apply:push_vlan=0x8100,set_field=vlan_vid:200,output=1")
s_h2h1cmd.append("dpctl unix:/tmp/s2 flow-mod cmd=add,table=0 vlan_vid=100 apply:pop_vlan,output=2")
s_h1h2cmd="dpctl unix:/tmp/s1 flow-mod cmd=add,table=0 in_port=1 goto:20; dpctl unix:/tmp/s1 flow-mod cmd=add,table=20 in_port=1 apply:push_vlan=0x8100,set_field=vlan_vid:100,output=2; dpctl unix:/tmp/s1 flow-mod cmd=add,table=0 vlan_vid=200 apply:pop_vlan,output=1"
s_h2h1cmd="dpctl unix:/tmp/s2 flow-mod cmd=add,table=0 in_port=2 goto:20; dpctl unix:/tmp/s2 flow-mod cmd=add,table=20 in_port=2 apply:push_vlan=0x8100,set_field=vlan_vid:200,output=1; dpctl unix:/tmp/s2 flow-mod cmd=add,table=0 vlan_vid=100 apply:pop_vlan,output=2"
'''
sleep(5)
for cmd in s_h1h2cmd:
s1.cmd(cmd)
sleep(1)
for cmd in s_h2h1cmd:
s2.cmd(cmd)
sleep(1)
sleep(5)
if opts.ifstat == 1:
Popen(("ifstat -a -t -i s1-eth1,s2-eth2 &"), shell=True).wait();
print "Traffic generation from H1 -> H2 started"
h1.cmd(tg_cmd)
print "Sleep for 120 second test"
sleep(120)
#CLI(net)
#stop the traffic generation
h1.cmd('killall mz')
if opts.ifstat == 1:
Popen(("killall ifstat"), shell=True).wait();
print "Stopped traffic generation"
#generate the graph
for m in monitors:
m.terminate();
net.stop();
Popen(("killall bwm-ng"), shell=True).wait();
return
def setupGreTunnelPort():
Popen(("./localGreInit.sh"), shell=True).wait();
print "GRE port initialised.."
def drawGraph(directory, infile):
Popen(("mkdir -p mult-result/bw/%s" % directory), shell=True).wait() ;
Popen(("cp -v ../graphScripts/drawMultBwGraph.sh drawBwGraph.sh"),
shell=True).wait();
Popen(("cp -v ../graphScripts/gnu_deidtect_bw.scr gnu_deidtect_bw.scr"),
shell=True).wait();
Popen(("./drawBwGraph.sh %s" % infile), shell=True).wait();
Popen(("mv -v *.pdf mult-result/bw/%s/" % directory), shell=True).wait();
Popen(("rm -v drawBwGraph.sh gnu_deidtect_bw.scr"), shell=True).wait();
print "Graph Generated for BW = %d " % directory
def DEIDtectBWTest(opts):
bw = opts.bw
controllerip=get_ip_address('eth0')
print "Rollback to known state"
clean();
bandwidthTest(bw=bw,controllerip=controllerip)
print "Cleanup the process"
clean();
infile="txrate%s.csv" % bw
drawGraph(bw, infile);
if __name__ == '__main__':
#global opts
DEIDtectBWTest(opts);
......@@ -188,7 +188,7 @@ def bandwidthTest(bw=5, controllerip="localhost"):
#start the traffic generation wait for 5 seconds (H1->H3)
tg_cmd = 'mz h1-eth0 -c 0 -t udp sp=49 -A 10.0.0.1 -B 10.0.0.3 -P \"Hello World\" &'
print "Traffic generation from H1 -> H3 started"
#h1.cmd(tg_cmd)
h1.cmd(tg_cmd)
CLI(net)
......
#!/bin/bash -x
declare -a arr=(5 6 7 8 9 10)
declare -a arr=(1 2 3 4 5 6 7 8 9 10)
for i in "${arr[@]}"
do
echo "Running BW Test with source link setto $i MB"
......
#!/bin/bash -x
declare -a arr=(1 2 3 4 5 6 7 8 9 10)
for i in "${arr[@]}"
do
echo "Running BW Test with source link setto $i MB"
python gr-bw-test.py -b $i -c localhost
done
#!/bin/bash -x
declare -a arr=(1 2 3 4 5 6 7 8 9 10)
for i in "${arr[@]}"
do
echo "Running BW Test with source link setto $i MB"
python multitable-test.py -b $i -c localhost
done
Changes were done to ovs flow rules to moniotor tunnel traffic, this won't be
checked in to the actual file repo
The diff of the corresponding files are in "diff.txt"
diff --git a/Code/OpenStack/deidtect-cloud/cloudOFHelper.py b/Code/OpenStack/deidtect-cloud/cloudOFHelper.py
index d475a1a..a546517 100644
--- a/Code/OpenStack/deidtect-cloud/cloudOFHelper.py
+++ b/Code/OpenStack/deidtect-cloud/cloudOFHelper.py
@@ -93,7 +93,7 @@ def computeOFlowInstall(dic, start_response):
LOG.info("OVSBRIDGE: %s @ %s" ,OVSPORTNAME, OVSPORTNUMBER)
if cmd == "add":
- computetunflow = 'sudo ovs-ofctl add-flow br-tun priority=3,tun_id=%d,actions=mod_vlan_vid:%d,output:%d' \
+ computetunflow = 'sudo ovs-ofctl add-flow br-tun priority=3,tun_id=%d,actions=mod_vlan_vid:%d,output:%d,output:LOCAL' \
% (int(tunid), int(vlanid), COMPUTE_OVS_PATCH_PORT)
LOG.info("%s", computetunflow)
ovscmdlist.append(computetunflow)
@@ -182,7 +182,7 @@ def networkOFlowInstall(dic, start_response):
LOG.info("%s", networkexpatch)
ovscmdlist.append(networkexpatch)
- networkexgre='sudo ovs-ofctl add-flow br-tun priority=3,dl_vlan=%d,actions=strip_vlan,set_tunnel:%d,output:%d' \
+ networkexgre='sudo ovs-ofctl add-flow br-tun priority=3,dl_vlan=%d,actions=strip_vlan,set_tunnel:%d,output:%d,output:LOCAL' \
% (int(vlanid), int(tunid), int(greport))
LOG.info("%s", networkexgre)
diff --git a/Code/OpenStack/deidtect-cloud/wanSDNHelper.py b/Code/OpenStack/deidtect-cloud/wanSDNHelper.py
index 9272984..7692d90 100644
--- a/Code/OpenStack/deidtect-cloud/wanSDNHelper.py
+++ b/Code/OpenStack/deidtect-cloud/wanSDNHelper.py
@@ -71,7 +71,7 @@ def wanActions(dic, start_response):
print cmd,vlanid
if cmd == "add":
- tunflow = 'sudo ovs-ofctl add-flow wan-br priority=3,dl_vlan=%d,actions=output:2' \
+ tunflow = 'sudo ovs-ofctl add-flow wan-br priority=3,dl_vlan=%d,actions=output:2,LOCAL' \
% (int(vlanid))
else:
tunflow = 'sudo ovs-ofctl del-flows wan-br dl_vlan=%d' % (int(vlanid))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment