Hi, Mehran
Sorry for delaying.
As I said, NXTSetControllerId does set "controller_id", not send Packet-In.
To send Packet-In to the specific controller, you should also use
NXActionController.
Did you check my code (simple_switch_13_nx.py) which I've sent to you?
Please refer to this code to implement your apps, I think this contains
enough for you.
Thanks,
Fujimoto
On 2017年07月14日 17:41, mehran shetabi wrote:
hi, Fujimoto
for initializing controllers, i want to populate mac-to-port tables of
all of controllers by sending packet-in with OFPR_NO_MATCH reason to them.
as before, i want to use this code for installing table-miss flow entry:
# install table-miss flow entry
match = parser.OFPMatch()
actions = [parser.OFPActionOutput(ofproto.OFPP_CONTROLLER,
ofproto.OFPCML_NO_BUFFER)]
and then, with Nicira extension action set controller_id for them:
# configuring controller_id of this controller
req = ofproto_v1_0_parser.NXTSetControllerId(datapath,
controller_id=2)
datapath.send_msg(req)
but, when i do this, there is no packet-in to my controller.
why?
can i have OpenFlow action and Nicira Extension action together in my
ryu code?
thank you,
Mehran shetabi
------------------------------------------------------------------------
*From:* Fujimoto Satoshi <satoshi.fujimo...@gmail.com>
*Sent:* Friday, July 14, 2017 5:11 AM
*To:* mehran shetabi; ryu-devel@lists.sourceforge.net
*Subject:* Re: [Ryu-devel] how can i distinguish controllers for
packet in to them?
Hi, Mehran
how can i install table-miss flow entry
with "NXActionController" that consists controller_id of all of
my controller and OFPR_NO_MATCH reason?
You can specify "OFPR_NO_MATCH" to "reason" field in "NXActionController":
parser.NXActionController(max_len=0, controller_id=2,
reason=ofproto.OFPR_NO_MATCH)
However, what is "consists controller_id of all of my controller" ?
I thought you want to send packet-in to the "specific" controller,
so I think there is no need to specify two or more controllers in
"NXActionController".
Anyway, I think it's up to you how to implement your application.
Thanks,
Fujimoto
On 2017年07月14日 08:24, mehran shetabi wrote:
hi, Fujimoto
it is working.
but now my problem is, how can i install table-miss flow entry
with "NXActionController" that consists controller_id of all of
my controller and OFPR_NO_MATCH reason?
i want to populate mac-to-port
table of all of my controller with running pingall
command and then send packet-in to specific controller.
how can i do this?
thank you,
Mehran shetabi
------------------------------------------------------------------------
*From:* Fujimoto Satoshi <satoshi.fujimo...@gmail.com>
*Sent:* Thursday, July 13, 2017 5:40 AM
*To:* mehran shetabi; ryu-devel@lists.sourceforge.net
*Subject:* Re: [Ryu-devel] how can i distinguish controllers for
packet in to them?
Hi, Mehran
is there any conflict between OpenFlow 1.0 and OpenFlow 1.3?
Sorry, I didn't make it clear enough.
"NXTSetControllerId" is not a OpenFlow action, is a Nicira Extension
action.
But in Ryu, this action is provided for only OpenFlow 1.0.
In this solution, we "hack" to use this action in OpenFlow 1.3.
I think there should be no conflict.
And in your code, you should use "NXActionController" to send
Packet-In to the specific controller,
instead of "OFPActionOutput", it cannot do such a thing.
For "NXActionController", you have to specify the "controller_id"
which you specified in "NXTSetControllerId".
I attached a code to this mail, it should be work well.
Please try it.
Thanks,
Fujimoto
On 2017年07月13日 05:50, mehran shetabi wrote:
hi, Fujimoto
is there any conflict between OpenFlow 1.0 and OpenFlow 1.3?
you know, as you said, i use the code in my controller:
from ryu.ofproto import ofproto_v1_0_parser
class SimpleSwitch13(app_manager.RyuApp):
OFP_VERSIONS = [ofproto_v1_3.OFP_VERSION]
def __init__(self, *args, **kwargs):
super(SimpleSwitch13, self).__init__(*args, **kwargs)
self.mac_to_port = {}
@set_ev_cls(ofp_event.EventOFPSwitchFeatures, CONFIG_DISPATCHER)
def switch_features_handler(self, ev):
datapath = ev.msg.datapath
ofproto = datapath.ofproto
parser = datapath.ofproto_parser
dpid = datapath.id
# configuring controller_id of this controller
req = ofproto_v1_0_parser.NXTSetControllerId(datapath,
controller_id=2)
datapath.send_msg(req)
# install table-miss flow entry
match = parser.OFPMatch()
actions = [parser.OFPActionOutput(ofproto.OFPP_CONTROLLER,
ofproto.OFPCML_NO_BUFFER)]
idle_timeout=0
self.add_flow(datapath, 0, match, actions, idle_timeout, dpid)
but after adding the code that you mentioned, my controller didn't
work properly (e.g. pingall command don't work).
how can i fix it?
thank you,
Mehran shetabi
------------------------------------------------------------------------
*From:* Fujimoto Satoshi <satoshi.fujimo...@gmail.com>
*Sent:* Wednesday, July 12, 2017 5:43 AM
*To:* mehran shetabi; ryu-devel@lists.sourceforge.net
*Subject:* Re: [Ryu-devel] how can i distinguish controllers for
packet in to them?
Hi, Mehran
Sorry, I've overlooked about the following action, it may be able to
solve your problem:
http://ryu.readthedocs.io/en/latest/nicira_ext_ref.html#ryu.ofproto.ofproto_v1_3_parser.NXActionController
This action belongs to 'Nicira extensions', not OpenFlow,
but with this, switches can send Packet-In to the specific controller.
To specify the controller, the "controller_id" should be configured.
Ryu can configure it by "NXTSetControllerId", but this can be used
in only OpenFlow 1.0.
Then, it is not a beautiful method, how about the following?
(customizing ryu/app/simple_switch_13.py)
@set_ev_cls(ofp_event.EventOFPSwitchFeatures, CONFIG_DISPATCHER)
def switch_features_handler(self, ev):
datapath = ev.msg.datapath
ofproto = datapath.ofproto
parser = datapath.ofproto_parser
# configuring controller_id of this controller
req = ofproto_v1_0_parser.NXTSetControllerId(datapath,
controller_id=5)
datapath.send_msg(req)
# add an action to send Packet-In to this controller
match = parser.OFPMatch()
actions = [
parser.NXActionController(0, 5, ofproto.OFPR_ACTION)]
self.add_flow(datapath, 0, match, actions)
This can be good for you?
Thanks,
Fujimoto
On 2017年07月11日 14:20, mehran shetabi wrote:
hi, Fujimoto
with setting roles and Async solution, if there are more than two
controllers, how can i distinguish between them?
my problem is, how can i sent packet-in to the exact controller?
thank you,
Mehran shetabi
------------------------------------------------------------------------
*From:* Fujimoto Satoshi <satoshi.fujimo...@gmail.com>
*Sent:* Tuesday, July 11, 2017 4:45 AM
*To:* mehran shetabi; ryu-devel@lists.sourceforge.net
*Subject:* Re: [Ryu-devel] how can i distinguish controllers for
packet in to them?
Hi, Mehran
how can i use OpenFlow channel in Mininet?
Sorry, OpenFlow channel is a connection which is used for OpenFlow
protocol and you already have.
What I meant was that you should have another connection between
controllers and the switch other than OpenFlow channel,
to exchange "raw" packets, not OpenFlow packets.
in the second solution, how can i retrieve Packet-in header?
As I said, in the second solution, the packets will be sent without
Packet-in header.
So, in this solution, there is no way to retrieve Packet-in header.
If you want to get Packet-in header, I think this solution is not
suitable,
then you should apply the first solution (setting roles and Async).
Do you need to get Packet-in header?
If not, I try implementing and tell you how to implement the second
solution.
Thanks,
Fujimoto
On 2017年07月11日 06:04, mehran shetabi wrote:
hi, Fujimoto
in the second solution, how can i retrieve Packet-in header?
is there any solution for it?
thank you,
Mehran shetabi
------------------------------------------------------------------------
*From:* Fujimoto Satoshi <satoshi.fujimo...@gmail.com>
*Sent:* Monday, July 10, 2017 5:35 AM
*To:* mehran shetabi; ryu-devel@lists.sourceforge.net;
satoshi.fujimo...@gmail.com
*Subject:* Re: [Ryu-devel] how can i distinguish controllers for
packet in to them?
Hi, Mehran
Unfortunately, you cannot use the port number which is connected
to the controller in OFPActionOutput().
However, if you can set roles(Master/Slave) to the controllers,
you can use OFPSetAsync to control whether the switch sends
Packet-In to Master or Slave controller:
http://ryu.readthedocs.io/en/latest/ofproto_v1_3_ref.html#ryu.ofproto.ofproto_v1_3_parser.OFPSetAsync
Or, this is not a beautiful method, you can connect controllers
and the switch by another connection, like:
c1 ──of───sw ──of───c2
│ ││ │
└──────┘└──────┘("of" means an OpenFlow channel)
Then, you can specify the port number which is connected to the
controller.
But the controller should receive packets in your application,
and the packets are "raw" packets, so the informations in the
Packet-in header will be lost.
Thanks,
Fujimoto
On 2017年07月10日 07:52, mehran shetabi wrote:
Hi,
In Mininet, I created a topology with one switch, two host, and
two inband RYU controller.
In OFPActionOutput() function, instead of using
ofproto.OFPP_CONTROLLER for output port may I use port number
(e.g. 3) that connected to the controller?
If the answer is no, is there any way to distinguish controllers
for packet in to them?
Thank you,
Mehran shetabi
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org!http://sdm.link/slashdot
_______________________________________________
Ryu-devel mailing list
Ryu-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ryu-devel
# Copyright (C) 2011 Nippon Telegraph and Telephone Corporation.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from ryu.base import app_manager
from ryu.controller import ofp_event
from ryu.controller.handler import CONFIG_DISPATCHER, MAIN_DISPATCHER
from ryu.controller.handler import set_ev_cls
from ryu.ofproto import ofproto_v1_3, ofproto_v1_0_parser
from ryu.lib.packet import packet
from ryu.lib.packet import ethernet
from ryu.lib.packet import ether_types
class SimpleSwitch13(app_manager.RyuApp):
OFP_VERSIONS = [ofproto_v1_3.OFP_VERSION]
def __init__(self, *args, **kwargs):
super(SimpleSwitch13, self).__init__(*args, **kwargs)
self.mac_to_port = {}
@set_ev_cls(ofp_event.EventOFPSwitchFeatures, CONFIG_DISPATCHER)
def switch_features_handler(self, ev):
datapath = ev.msg.datapath
ofproto = datapath.ofproto
parser = datapath.ofproto_parser
# configuring controller_id of this controller
req = ofproto_v1_0_parser.NXTSetControllerId(
datapath, controller_id=2)
datapath.send_msg(req)
# install table-miss flow entry
match = parser.OFPMatch()
actions = [parser.NXActionController(
max_len=0, controller_id=2, reason=ofproto.OFPR_NO_MATCH)]
idle_timeout=0
self.add_flow(datapath, 0, match, actions, idle_timeout)
def add_flow(self, datapath, priority, match, actions, buffer_id=None):
ofproto = datapath.ofproto
parser = datapath.ofproto_parser
inst = [parser.OFPInstructionActions(ofproto.OFPIT_APPLY_ACTIONS,
actions)]
if buffer_id:
mod = parser.OFPFlowMod(datapath=datapath, buffer_id=buffer_id,
priority=priority, match=match,
instructions=inst)
else:
mod = parser.OFPFlowMod(datapath=datapath, priority=priority,
match=match, instructions=inst)
datapath.send_msg(mod)
@set_ev_cls(ofp_event.EventOFPPacketIn, MAIN_DISPATCHER)
def _packet_in_handler(self, ev):
# If you hit this you might want to increase
# the "miss_send_length" of your switch
if ev.msg.msg_len < ev.msg.total_len:
self.logger.debug("packet truncated: only %s of %s bytes",
ev.msg.msg_len, ev.msg.total_len)
msg = ev.msg
datapath = msg.datapath
ofproto = datapath.ofproto
parser = datapath.ofproto_parser
in_port = msg.match['in_port']
pkt = packet.Packet(msg.data)
eth = pkt.get_protocols(ethernet.ethernet)[0]
if eth.ethertype == ether_types.ETH_TYPE_LLDP:
# ignore lldp packet
return
dst = eth.dst
src = eth.src
dpid = datapath.id
self.mac_to_port.setdefault(dpid, {})
self.logger.info("packet in %s %s %s %s", dpid, src, dst, in_port)
# learn a mac address to avoid FLOOD next time.
self.mac_to_port[dpid][src] = in_port
if dst in self.mac_to_port[dpid]:
out_port = self.mac_to_port[dpid][dst]
else:
out_port = ofproto.OFPP_FLOOD
actions = [parser.OFPActionOutput(out_port)]
# install a flow to avoid packet_in next time
if out_port != ofproto.OFPP_FLOOD:
match = parser.OFPMatch(in_port=in_port, eth_dst=dst)
# verify if we have a valid buffer_id, if yes avoid to send both
# flow_mod & packet_out
if msg.buffer_id != ofproto.OFP_NO_BUFFER:
self.add_flow(datapath, 1, match, actions, msg.buffer_id)
return
else:
self.add_flow(datapath, 1, match, actions)
data = None
if msg.buffer_id == ofproto.OFP_NO_BUFFER:
data = msg.data
out = parser.OFPPacketOut(datapath=datapath, buffer_id=msg.buffer_id,
in_port=in_port, actions=actions, data=data)
datapath.send_msg(out)
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Ryu-devel mailing list
Ryu-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ryu-devel