Good morning,
I'm a student in the University of Aveiro, Portugal. I'm doing some simple
experiences using mininet-wifi and ryu. I'm runnig this apps in ryu:
rest_qos.py, rest_conf_switch_rest_13.py and conf_simple_switch13.py. I want to
add queues in ap1 for flows prioritation, i can add queues just fine, but when
i want to add queues with diferent priority it doesn't work. I'm using an
app(app_qos.py),that talks with RYU via REST, for queues configurations and
when i put "priority":"2" in the queue definition, it doesnt do anything
because when i do " sudo ovs-vsctl list Queue" it doesn't appears in the
"other_config" section.
My simple code is in annex, can you help me ? it's really important.
Best Regards,
Marlene Brás
from switch import RyuSwitch
import sys
def app(n):
n_stations=int(n)
switch1 = RyuSwitch()
switch1.DPID=1000000000000001
#Set the OVSDB address
ovsdb_addr= '"tcp:127.0.0.1:6632"'
res=switch1.set_ovsdb_add(ovsdb_addr)
#Verifing the number of SW
DPID_list = switch1.get_all_sw()
switch1.DPID = DPID_list[0]
numb_sw=len(DPID_list) #number of SW
print "Number of Switches:"
print numb_sw
print "\nDPID SW1:"
print switch1.DPID
#Adding the queues for Qos
queue_settings={"port_name":"ap1-eth2",
"type": "linux-htb","max_rate": "20000000",
"queues":[
{"max_rate":"20000000"},
{"min_rate":"7000000","max_rate":"20000000"},
{"min_rate":"3000000","max_rate":"20000000"}
]
}
for w in range(3):
res = switch1.add_queue(queue_settings)
if(w==2):
print "\nQueue added:"
print res
ip_dest="10.0.0.%s"%(n_stations+2)
ip_src_1="10.0.0.%s"%(n_stations-1)
ip_src_2="10.0.0.%s"%(n_stations)
#Adding QoS rules
#Adding rule for sta1 traffic
qos_rule1={ "priority": "1", "match": {"nw_src":ip_src_1,"nw_dst":ip_dest,"nw_proto": "UDP"}, "actions":{"queue":"1"}}
res=switch1.add_rule(qos_rule1)
print "\nRule for %s added:"%ip_src_1
print res
#Adding rule for sta2 traffic
qos_rule2={ "priority": "1", "match": {"nw_src":ip_src_2,"nw_dst":ip_dest,"nw_proto": "UDP"}, "actions":{"queue":"2"}}
res=switch1.add_rule(qos_rule2)
print "\nRule for %s added:"% ip_src_2
print res
if __name__ == '__main__':
app(sys.argv[1])
#!/usr/bin/python
import sys, os, time, math
from mininet.node import Controller, RemoteController, OVSKernelSwitch
from mininet.log import setLogLevel, info
from mininet.net import Mininet
from mn_wifi.node import OVSKernelAP
from mn_wifi.cli import CLI_wifi
from mn_wifi.net import Mininet_wifi
def topology(ns, qos, nexp, BW_1mi,BW_1ma,prio_1,BW_2mi,BW_2ma,prio_2):
nstations=int(ns)
ne=int(nexp)
stations={}
BW1_min=int(BW_1mi)
BW1_max=int(BW_1ma)
BW2_min=int(BW_2mi)
BW2_max=int(BW_2ma)
prio1=int(prio_1)
prio2=int(prio_2)
info("Create a network.")
net = Mininet_wifi(controller=RemoteController)
info("*** Creating nodes\n")
###Adding the Access Point
ap1 = net.addAccessPoint('ap1', ssid="wifi", mode="g", channel="5", protocols='OpenFlow13')
###Adding stations
for x in range(nstations): #from 0 to nstations-1
stations[x]=net.addStation('sta%s' % (x+1) ,mac='00:02:00:00:00:%s' % (x+2), ip='10.0.0.%s/24' % (x+2))
###Adding the host
h1 = net.addHost('h1', mac='00:02:00:00:00:%s' % (nstations+2) , ip='10.0.0.%s/24' % (nstations+2))
###Adding the controller
c0 = net.addController('c0')
info("*** Configuring wifi nodes\n")
net.configureWifiNodes()
for y in range(1,nstations+1):
y=str(y)
s='sta'+y
net.addLink(s,ap1) #medium without noise ??
net.addLink(h1,ap1)
info("*** Starting network\n")
net.build()
c0.start()
ap1.start([c0])
os.system('sudo ovs-vsctl set Bridge ap1 protocols=OpenFlow13')
os.system('sudo ovs-vsctl set-manager ptcp:6632 ')
os.system('sudo ovs-vsctl --all destroy Qos')
os.system('sudo ovs-vsctl --all destroy Queue')
if qos:
print "App Launch"
os.system('sudo python qos_app.py %s'%nstations+' %s'%BW1_min+' %s'%BW1_max+' %s'%prio1+' %s'%BW2_min+' %s'%BW2_max+' %s'%prio2)
#os.system('sudo python qos_app2.py %s'%nstations)
net.pingAll()
time.sleep(1)
'''
print "\nStarting Ping Tests"
for j in range(nstations):
stations[j].cmd('ping -c 5 %s'%h1.IP()+' >> ping_test%s'%j+'.txt') #repeat 5 times for each stations
time.sleep(10)
'''
print "\nStarting Iperf Tests"
#for z in range(5):
print ne
h1.cmd('iperf -s -u >> tryperfserver_udp%s'%ne+'.txt &')
for k in range(nstations):
print stations[k]
stations[k].cmd('iperf -c %s -u -b 20M -t 40 &' % h1.IP())
time.sleep(40)
("\n*** Running CLI\n")
CLI_wifi(net)
info("*** Stopping network\n")
net.stop()
if __name__ == '__main__':
setLogLevel('info')
qos = True if '-q' in sys.argv[2] else False
topology(sys.argv[1],qos,sys.argv[3],sys.argv[4],sys.argv[5],sys.argv[6],sys.argv[7],sys.argv[8],sys.argv[9])
import requests
import json
class RyuSwitch(object):
def __init__(self, DPID=None):
# Set switch DPID
self.DPID = DPID
# Base REST API URI
self.API = "http://localhost:8080"
##ABOUT OVSDB CONFIGURATION
#set ovsdb address
def set_ovsdb_add(self, payload):
rest_uri = self.API + "/v1.0/conf/switches/" + str(self.DPID) + '/ovsdb_addr'
r = requests.put(rest_uri,payload)
if r.status_code == 200:
return r.json()
else:
return False
##ABOUT SWITCH'S CONFIGURATIONS
#get all the switches
def get_all_sw(self):
# GET /v1.0/conf/switches
rest_uri = self.API + "/v1.0/conf/switches"
r = requests.get(rest_uri)
if r.status_code == 200:
return r.json()
else:
return False
# get all the configuration keys of a switch
def get_sw_conf(self):
# GET /v1.0/conf/switches/<dpid>
rest_uri = self.API + "/v1.0/conf/switches/" + str(self.DPID)
req = requests.get(rest_uri)
if req.status_code == 200: #returns HTTP 200 status if successful
return req.json()
else:
return False #If submission fails,returns HTTP 400 status.
#delete all the configuration of a switch
def del_sw_conf(self):
# DELETE /v1.0/conf/switches/<dpid>
rest_uri = self.API + "/v1.0/conf/switches/" + str(self.DPID)
req = requests.delete(rest_uri)
if req.status_code == 200: #returns HTTP 200 status if successful
return req.json()
else:
return False #If submission fails,returns HTTP 400 status.
##ABOUT QUEUE
#crete a queue
def add_queue(self,payload):
# payload= {"port_name":"<name of port>",
# "type": "<linux-htb or linux-other>",
# "max-rate": "<int>",
# "queues":[{"max_rate": "<int>", "min_rate": "<int>"},...]}
# POST /qos/queue/{switch-id}
rest_uri = self.API + "/qos/queue/" + str(self.DPID)
req = requests.post(rest_uri, json.dumps(payload))
if req.status_code == 200: #returns HTTP 200 status if successful
return req.json()
else:
return False #If submission fails,returns HTTP 400 status.
def del_queue(self):
# DELETE /qos/queue/{switch-id}
rest_uri = self.API + "/qos/queue/" + str(self.DPID)
req = requests.delete(rest_uri)
if req.status_code == 200: #returns HTTP 200 status if successful
return req.json()
else:
return False #If submission fails,returns HTTP 400 status.
def add_rule(self,payload):
#payload={"priority": "<value>",
# "match": {"<field1>": "<value1>", "<field2>": "<value2>",...},
# "actions": {"<action1>": "<value1>", "<action2>": "<value2>",...}
# }
#POST /qos/rules/{switch-id}
rest_uri = self.API + "/qos/rules/" + str(self.DPID)
req = requests.post(rest_uri, json.dumps(payload))
if req.status_code == 200: #returns HTTP 200 status if successful
return req.json()
else:
return False #If submission fails,returns HTTP 400 status.
def del_rule(self):
# DELETE /qos/rules/{switch-id}
rest_uri = self.API + "/qos/rules/" + str(self.DPID)
req = requests.delete(rest_uri)
if req.status_code == 200: #returns HTTP 200 status if successful
return req.json()
else:
return False #If submission fails,returns HTTP 400 status.
_______________________________________________
Ryu-devel mailing list
Ryu-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ryu-devel