Hi Yusuke,
The following is my openflow version:
govind@govind-RYU-virtual-machine:~/ryu$ ovs-vswitchd --version
ovs-vswitchd (Open vSwitch) 2.0.2
Compiled Aug 15 2014 14:31:03
OpenFlow versions 0x1:0x1
when I run the controller script "simple_switch_scott.py" my edited file
(also attached herewith for your reference), I am not able to see the logs
for flow modification in the switch as shown below:
2015-04-13T18:49:00.223Z|00624|rconn|INFO|s1<->tcp:127.0.0.1:6633:
connecting...
2015-04-13T18:49:00.238Z|00625|rconn|INFO|s1<->tcp:127.0.0.1:6633: connected
However, when I run the normal simple_switch.py script, I get a flow mod
message from controller to switch as shown below:
2015-04-13T18:40:45.951Z|00416|rconn|INFO|s1<->tcp:127.0.0.1:6633: connected
2015-04-13T18:41:59.927Z|00417|ofproto|INFO|s1: 2 flow_mods 10 s ago (2
adds)
Please suggest what should be my next step to achieve the desired result.
Regards,
Govind Prasad
On Mon, Apr 13, 2015 at 1:42 AM, Yusuke Iwase <iwase.yusu...@gmail.com>
wrote:
> Hi Govind,
>
> Did you get any error messages from ryu-manager?
> If not, first, please check OpenFlow version of your swtich.
> ("simple_switch.py" is OpenFlow 1.0 App.)
>
> And, by capturing packet with Wireshark, you can get the helpful
> information for debug.
> (e.g. whether Controller sends FlowMod message? Switch sends any Error
> Message?...etc)
>
> Thanks,
> Iwase
>
> On 2015年04月13日 15:02, Govind Prasad wrote:
> > Hi Yusuke,
> >
> > Thanks for the suggestion, I tried the following code in
> "simple_switch.py" however when I send TCP packets from h1 to h2 using
> iperf in mininet, the packets are getting transmitted but the flows are not
> getting written in the switch table:
> >
> > @set_ev_cls(ofp_event.EventOFPPacketIn, MAIN_DISPATCHER)
> > def _packet_in_handler(self, ev):
> > msg = ev.msg
> >
> > pkt = packet.Packet(msg.data)
> > pkt_tcp = pkt.get_protocol(tcp.tcp)
> >
> > if pkt_tcp:
> > mod = datapath.ofproto_parser.OFPFlowMod(
> > datapath=datapath, match=match, cookie=0,
> > command=ofproto.OFPFC_ADD, idle_timeout=100,
> hard_timeout=0,
> > priority=ofproto.OFP_DEFAULT_PRIORITY,
> > flags=ofproto.OFPFF_SEND_FLOW_REM, actions=actions)
> > datapath.send_msg(mod)
> > else:
> > mod = datapath.ofproto_parser.OFPFlowMod(
> > datapath=datapath, match=match, cookie=0,
> > command=ofproto.OFPFC_ADD, idle_timeout=30,
> hard_timeout=0,
> > priority=ofproto.OFP_DEFAULT_PRIORITY,
> > flags=ofproto.OFPFF_SEND_FLOW_REM, actions=actions)
> > datapath.send_msg(mod)
> >
> >
> > can you please advise whether I am doing it right as I am not very good
> in programming and started learning python these days.
> >
> > Appreciate your help!!!
> >
> > Regards,
> > Govind Prasad
> >
> >
> >
> > On Sun, Apr 12, 2015 at 8:30 PM, Yusuke Iwase <iwase.yusu...@gmail.com
> <mailto:iwase.yusu...@gmail.com>> wrote:
> >
> > Hi Govind,
> >
> > > 4. If port numbe is greater than 5000, idle timeout is 100 seconds.
> >
> > You can parse the Packet-In data and get the port number by using
> packet library.
> >
> > e.g.)
> > @set_ev_cls(ofp_event.EventOFPPacketIn, MAIN_DISPATCHER)
> > def _packet_in_handler(self, ev):
> > msg = ev.msg
> >
> > pkt = packet.Packet(msg.data)
> > pkt_tcp = pkt.get_protocol(tcp.tcp)
> >
> > if pkt_tcp:
> > dst_port = pkt_tcp.dst_port
> > print "dst_port = %d" % dst_port
> >
> >
> > For more information of packet library, please refer to the Ryu-Book.
> > (http://osrg.github.io/ryu-book/en/html/packet_lib.html)
> >
> > Thanks,
> > Iwase
> >
> > On 2015年04月13日 08:18, Govind Prasad wrote:
> > > Hi yusuke,
> > >
> > > Thanks fir the info however can you please specify how to
> implement the following scenario:
> > >
> > > 1. Iperf client send the tcp message on port 8000
> > > 2. Iperf server receives the tcp port through ovs
> > > 3. Ryu asks the ovs to write the flow with default values
> > > 4. If port numbe is greater than 5000, idle timeout is 100 seconds.
> > >
> > > This is what I want to implement. Can you please guide.
> > >
> > > Regard,
> > > Govind
> > >
> > > Sent from my iPhone
> > >
> > >> On Apr 10, 2015, at 10:23 AM, Govind Prasad <
> pr.govind1...@gmail.com <mailto:pr.govind1...@gmail.com>> wrote:
> > >>
> > >> Hi Yusuke,
> > >>
> > >> Thanks a lot for the response, I will check and reply with my
> queries today.
> > >>
> > >> Thanks once again!!!
> > >>
> > >> Regards,
> > >> Govind
> > >>
> > >> Sent from my iPhone
> > >>
> > >>> On Apr 10, 2015, at 12:45 AM, Yusuke Iwase <
> iwase.yusu...@gmail.com <mailto:iwase.yusu...@gmail.com>> wrote:
> > >>>
> > >>> Hi Govind,
> > >>>
> > >>> To learn "How to implement Ryu Application", please refer to the
> ryu-book.
> > >>> The first chapter shows implementation of a simple switching hub.
> > >>> (http://osrg.github.io/ryu-book/en/html/switching_hub.html)
> > >>>
> > >>> And, to set the idle timeout, please refer to "OpenFlow protocol
> API reference" on the Ryu-Documentations.
> > >>> If you use OpenFlow 1.3, the following section is helpful for
> you.
> > >>> (
> http://ryu.readthedocs.org/en/latest/ofproto_v1_3_ref.html#modify-state-messages
> )
> > >>>
> > >>> Thanks,
> > >>> Iwase
> > >>>
> > >>>> On 2015年04月08日 23:44, Govind prasad wrote:
> > >>>>
> > >>>> Hi experts,
> > >>>>
> > >>>> I am working on an application which works as follows:
> > >>>>
> > >>>> 1. The switch gets the first TCP packet
> > >>>> 2. It sends the packet to the controller
> > >>>> 3. The controller invokes an application which was looking for
> TCP packets.
> > >>>> 4. The application sets a extended idle timeout (fore ample 1
> hour) and sends the flow back to the controller.
> > >>>> 5. Now the controller sends the flow modification message for
> this flow with the extended idle timeout.
> > >>>>
> > >>>> Can anyone help me in building this application which extends
> the idle timeout. I am very new to sdn and programming so would require
> your esteemed support on this.
> > >>>>
> > >>>> Regards,
> > >>>> Govind
> > >>>> Sent from my iPhone
> > >>>>
> ------------------------------------------------------------------------------
> > >>>> BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT
> > >>>> Develop your own process in accordance with the BPMN 2 standard
> > >>>> Learn Process modeling best practices with Bonita BPM through
> live exercises
> > >>>>
> http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual-
> event?utm_
> > >>>>
> source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF
> > >>>> _______________________________________________
> > >>>> Ryu-devel mailing list
> > >>>> Ryu-devel@lists.sourceforge.net <mailto:
> Ryu-devel@lists.sourceforge.net>
> > >>>> https://lists.sourceforge.net/lists/listinfo/ryu-devel
> > >>>
> > >>>
> ------------------------------------------------------------------------------
> > >>> BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT
> > >>> Develop your own process in accordance with the BPMN 2 standard
> > >>> Learn Process modeling best practices with Bonita BPM through
> live exercises
> > >>> http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual-
> event?utm_
> > >>>
> source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF
> > >>> _______________________________________________
> > >>> Ryu-devel mailing list
> > >>> Ryu-devel@lists.sourceforge.net <mailto:
> Ryu-devel@lists.sourceforge.net>
> > >>> https://lists.sourceforge.net/lists/listinfo/ryu-devel
> > >
> > >
> ------------------------------------------------------------------------------
> > > BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT
> > > Develop your own process in accordance with the BPMN 2 standard
> > > Learn Process modeling best practices with Bonita BPM through live
> exercises
> > > http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual-
> event?utm_
> > >
> source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF
> > > _______________________________________________
> > > Ryu-devel mailing list
> > > Ryu-devel@lists.sourceforge.net <mailto:
> Ryu-devel@lists.sourceforge.net>
> > > https://lists.sourceforge.net/lists/listinfo/ryu-devel
> > >
> >
> >
> >
> >
> >
> ------------------------------------------------------------------------------
> > BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT
> > Develop your own process in accordance with the BPMN 2 standard
> > Learn Process modeling best practices with Bonita BPM through live
> exercises
> > http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual-
> event?utm_
> > source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF
> >
> >
> >
> > _______________________________________________
> > 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.
"""
An OpenFlow 1.0 L2 learning switch implementation.
"""
import logging
import struct
from ryu.base import app_manager
from ryu.controller import mac_to_port
from ryu.controller import ofp_event
from ryu.controller.handler import MAIN_DISPATCHER
from ryu.controller.handler import set_ev_cls
from ryu.ofproto import ofproto_v1_0
from ryu.lib.mac import haddr_to_bin
from ryu.lib.packet import packet
from ryu.lib.packet import ethernet
class SimpleSwitch(app_manager.RyuApp):
OFP_VERSIONS = [ofproto_v1_0.OFP_VERSION]
def __init__(self, *args, **kwargs):
super(SimpleSwitch, self).__init__(*args, **kwargs)
self.mac_to_port = {}
def add_flow(self, datapath, in_port, dst, actions):
ofproto = datapath.ofproto
match = datapath.ofproto_parser.OFPMatch(
in_port=in_port, dl_dst=haddr_to_bin(dst))
@set_ev_cls(ofp_event.EventOFPPacketIn, MAIN_DISPATCHER)
def _packet_in_handler(self, ev):
msg = ev.msg
pkt = packet.Packet(msg.data)
pkt_tcp = pkt.get_protocol(tcp.tcp)
if pkt_tcp:
dst_port = pkt_tcp.dst_port
print "dst_port = %d" % dst_port
if dst_port<5000:
mod = datapath.ofproto_parser.OFPFlowMod(
datapath=datapath, match=match, cookie=0,
command=ofproto.OFPFC_ADD, idle_timeout=100, hard_timeout=0,
priority=ofproto.OFP_DEFAULT_PRIORITY,
flags=ofproto.OFPFF_SEND_FLOW_REM, actions=actions)
datapath.send_msg(mod)
#if in_port>12001:
# mod = datapath.ofproto_parser.OFPFlowMod(
# datapath=datapath, match=match, cookie=0,
# command=ofproto.OFPFC_ADD, idle_timeout=100, hard_timeout=0,
# priority=ofproto.OFP_DEFAULT_PRIORITY,
# flags=ofproto.OFPFF_SEND_FLOW_REM, actions=actions)
# datapath.send_msg(mod)
else:
mod = datapath.ofproto_parser.OFPFlowMod(
datapath=datapath, match=match, cookie=0,
command=ofproto.OFPFC_ADD, idle_timeout=30, hard_timeout=0,
priority=ofproto.OFP_DEFAULT_PRIORITY,
flags=ofproto.OFPFF_SEND_FLOW_REM, actions=actions)
datapath.send_msg(mod)
@set_ev_cls(ofp_event.EventOFPPacketIn, MAIN_DISPATCHER)
def _packet_in_handler(self, ev):
msg = ev.msg
datapath = msg.datapath
ofproto = datapath.ofproto
pkt = packet.Packet(msg.data)
eth = pkt.get_protocol(ethernet.ethernet)
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, msg.in_port)
# learn a mac address to avoid FLOOD next time.
self.mac_to_port[dpid][src] = msg.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 = [datapath.ofproto_parser.OFPActionOutput(out_port)]
# install a flow to avoid packet_in next time
if out_port != ofproto.OFPP_FLOOD:
self.add_flow(datapath, msg.in_port, dst, actions)
data = None
if msg.buffer_id == ofproto.OFP_NO_BUFFER:
data = msg.data
out = datapath.ofproto_parser.OFPPacketOut(
datapath=datapath, buffer_id=msg.buffer_id, in_port=msg.in_port,
actions=actions, data=data)
datapath.send_msg(out)
@set_ev_cls(ofp_event.EventOFPPortStatus, MAIN_DISPATCHER)
def _port_status_handler(self, ev):
msg = ev.msg
reason = msg.reason
port_no = msg.desc.port_no
ofproto = msg.datapath.ofproto
if reason == ofproto.OFPPR_ADD:
self.logger.info("port added %s", port_no)
elif reason == ofproto.OFPPR_DELETE:
self.logger.info("port deleted %s", port_no)
elif reason == ofproto.OFPPR_MODIFY:
self.logger.info("port modified %s", port_no)
else:
self.logger.info("Illeagal port state %s %s", port_no, reason)
------------------------------------------------------------------------------
BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT
Develop your own process in accordance with the BPMN 2 standard
Learn Process modeling best practices with Bonita BPM through live exercises
http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual- event?utm_
source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF
_______________________________________________
Ryu-devel mailing list
Ryu-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ryu-devel