add LOG to modules, whitelist only TCP rather than all, use iperf for sending...

add LOG to modules, whitelist only TCP rather than all, use iperf for sending tcp traffic instead of mz
parent 0bd96926
......@@ -88,7 +88,7 @@ def bandwidthTopo(bw, controllerip):
# Add links
srcLink( attacker, topSwitch )
srcLink( topSwitch, brosys )
otherLink( topSwitch, brosys )
otherLink( topSwitch, bottomSwitch)
otherLink( bottomSwitch, brosys2 )
otherLink( bottomSwitch, lvl2Switch )
......@@ -181,11 +181,14 @@ def bandwidthTest(bw=5, controllerip="localhost"):
#start the traffic generation wait for 5 seconds (H1->H3)
h1_tg_cmd = 'mz h1-eth0 -c 0 -t udp sp=49 -A 10.0.0.1 -B 10.0.0.3 -P \"H1 Hello World\" &'
h2_tg_cmd = 'mz h2-eth0 -c 0 -t tcp dp=80 -A 10.0.0.2 -B 10.0.0.3 -P \"H2 Hello World\" &'
#h2_tg_cmd = 'mz h2-eth0 -c 0 -t tcp dp=80 -A 10.0.0.2 -B 10.0.0.3 -P \"H2 Hello World\" &'
h2_tg_cmd = 'iperf -c 10.0.0.3 -t 120 &'
h3_tg_cmd = 'iperf -s &'
print "Traffic generation from H1 started"
h1.cmd(h1_tg_cmd)
if opts.mode != "all":
h3.cmd(h3_tg_cmd);
h2.cmd(h2_tg_cmd);
sleep_time = 20
......@@ -215,7 +218,7 @@ def bandwidthTest(bw=5, controllerip="localhost"):
print s1.cmd('dpctl unix:/tmp/s2 meter-config')
if sleep_time == 50:
print "Stop TCP traffic alone @50s"
h2.cmd("killall mz")
#h2.cmd("killall mz")
h1.cmd(h1_tg_cmd)
#print s1.cmd('dpctl unix:/tmp/s1 stats-meter')
print "[%d] Sleeping for %d seconds for rate-limiters to grow" \
......@@ -228,8 +231,8 @@ def bandwidthTest(bw=5, controllerip="localhost"):
#stop the traffic generation
h1.cmd('killall mz')
if opts.mode != "all":
h2.cmd('killall mz')
#if opts.mode != "all":
#h2.cmd('killall mz')
print "Stopped traffic generation"
#generate the graph
......
#!/bin/sh -x
if [ $# -eq 1 ]
then
HOST="$1";
else
HOST="localhost"
fi
CMD="add"
TAPID=3
curl -d "{\
'dpid':'0000000000000002',\
'output':2,\
'vlan_id':100,\
'tapID': $TAPID \
}" http://$HOST:8080/policy/tap/e2etunnel/{$CMD}
......@@ -35,7 +35,7 @@ from ryu.lib import objectTapDB as oDB
from ryu.lib import meterDB
LOG = logging.getLogger('ryu.app.cnac_rest')
LOG.setLevel(logging.DEBUG)
LOG.setLevel(logging.INFO)
CMD_PATTERN = r'[a-f]|all'
global tapDb
tapDb = {}
......
......@@ -34,6 +34,10 @@ from ryu.lib import ofctl_v1_3
from ryu.topology.switches import get_switch, get_link
import networkx as nx
import matplotlib.pyplot as plt
import logging
LOG = logging.getLogger('ryu.app.rest_net_topology')
LOG.setLevel(logging.INFO)
# REST API for switch configuration
#
......@@ -97,8 +101,8 @@ class TopoNetController(ControllerBase):
# corresponding tap id.
# install drop rules only in IDS table(20)
def whitelistEntry(self, req, **kwargs):
print "whitelist traffic"
print "using dp id instead of tap id for now :("
LOG.info("whitelist traffic")
LOG.info("using dp id instead of tap id for now :(")
try:
post_values = eval(req.body)
......@@ -122,7 +126,7 @@ class TopoNetController(ControllerBase):
ipv4_src = post_values.get('ipv4_src',0)
ipv4_dst = post_values.get('ipv4_dst',0)
print "ip-src[%s] ip-dst[%s]" % (ipv4_src, ipv4_dst)
LOG.info("ip-src[%s] ip-dst[%s]",ipv4_src, ipv4_dst)
if ipv4_src is 0:
print "invalid ipv4_src"
......@@ -135,10 +139,10 @@ class TopoNetController(ControllerBase):
flow_timeout = 60
ids_table = 20
#Drop UDP packets
ip_proto = inet.IPPROTO_UDP
match = ofp.OFPMatch(eth_type=eth_type, ip_proto=ip_proto, ipv4_src=ipv4_src, ipv4_dst=ipv4_dst)
#ip_proto = inet.IPPROTO_UDP
#match = ofp.OFPMatch(eth_type=eth_type, ip_proto=ip_proto, ipv4_src=ipv4_src, ipv4_dst=ipv4_dst)
#set hardtime out to be 10s for now :)
mod_flow(dp, table_id=ids_table, command=of.OFPFC_ADD, priority=priority_to_set, hard_timeout=flow_timeout, match=match)
#mod_flow(dp, table_id=ids_table, command=of.OFPFC_ADD, priority=priority_to_set, hard_timeout=flow_timeout, match=match)
#Drop TCP packets
ip_proto = inet.IPPROTO_TCP
......
......@@ -110,7 +110,7 @@ def bandwidthTopo(bw, controllerip):
bottomSwitch.start([c0])
lvl2Switch.start([c0])
ryu_c = Popen("./ryu_init.sh %s %d 1> ryu.out 2> /tmp/ryu.out" % (controllerip, 3), shell=True)
ryu_c = Popen("./ryu_init.sh %s %d 1> ryu.out 2> ryu.out" % (controllerip, 3), shell=True)
print "wait 5 sec for controller to connect"
sleep(5)
......@@ -186,19 +186,28 @@ def bandwidthTest(bw=5, controllerip="localhost"):
#start the traffic generation wait for 5 seconds (H1->H3)
server_start = 'vsftpd &'
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\" &'
#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=51 -A 10.0.0.2 -B 10.0.0.3 -P \"Hello World\" &'
print "Traffic generation from H1,H2 -> H3 started"
h1.cmd(h1_tg_cmd)
h2.cmd(h2_tg_cmd)
print "iperf server @H3"
h3.cmd("iperf -s &")
print "sFTP server started @ H3"
h3.cmd(server_start)
h1_tg_cmd='iperf -c 10.0.0.3 -t 200 &'
print "Traffic generation from H1,H2 -> H3 started"
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")
h3.cmd('sudo ethtool -K h3-eth0 tso off')
h3.cmd("ifconfig h3-eth0 mtu 900")
print h1_tg_cmd
print h2_tg_cmd
sleep(5)
print "wait for configs to take effect 5s delay"
hrstr = h1.cmd(h1_tg_cmd)
print hrstr
hrstr = h2.cmd(h2_tg_cmd)
print hrstr
#CLI(net)
......@@ -206,7 +215,7 @@ def bandwidthTest(bw=5, controllerip="localhost"):
print "Sleeping for %d seconds before TAP is applied" % sleep_time
sleep(sleep_time)
p = Popen(("./bwTestTapFlow.sh %s" % controllerip), shell=True, stdout=PIPE, stderr=PIPE)
p = Popen(("./bwTestWhiteListTapFlow.sh %s" % controllerip), shell=True, stdout=PIPE, stderr=PIPE)
out, err = p.communicate()
print out
print err
......@@ -218,9 +227,10 @@ def bandwidthTest(bw=5, controllerip="localhost"):
print "Stop H2 -> H3 traffic"
h2.cmd('killall mz')
print "FTP start.."
h1.cmd("../scripts/testFTP.sh")
ftpstr = h1.cmd("../scripts/testFTP.sh")
print ftpstr
print "FTP complete.."
h1.cmd(h1_tg_cmd)
#h1.cmd(h1_tg_cmd)
sleep_time = 150
print "Sleep for %d seconds to show the effect of whitelist of H1->H3 [IP]" \
......@@ -228,7 +238,7 @@ def bandwidthTest(bw=5, controllerip="localhost"):
sleep(sleep_time)
#stop the traffic generation
h1.cmd('killall mz')
#h1.cmd('killall mz')
h3.cmd('killall vsftpd')
print "Stopped traffic generation"
print "Stopped sFTP server"
......@@ -237,6 +247,8 @@ def bandwidthTest(bw=5, controllerip="localhost"):
for m in monitors:
m.terminate();
Popen("killall bwm-ng", shell=True).wait();
net.stop();
return
......
Have the IDS configured to already with switch DPID of s2 and run the below
command for generating the graph:
[Code/ryu dir]sudo python whitelist-test.py -b 2
This source diff could not be displayed because it is too large. You can view the blob instead.
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