[Ryu-devel] [PATCH v3] ofp_event: Timestamp when OpenFlow event was generated

2017-08-01 Thread IWASE Yusuke
This patch introduces "timestamp" attribute for OpenFlow event classes
which shows when that event was generated by Datapath instance and nearly
equivalent to when Ryu finished receiving the message contained in that
event instance.

Suggested-by: Matthew Hayes 
Signed-off-by: IWASE Yusuke 
---
 ryu/controller/ofp_event.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/ryu/controller/ofp_event.py b/ryu/controller/ofp_event.py
index 6b1c8b3..6eb8e5f 100644
--- a/ryu/controller/ofp_event.py
+++ b/ryu/controller/ofp_event.py
@@ -19,10 +19,10 @@ OpenFlow event definitions.
 """
 
 import inspect
+import time
 
 from ryu.controller import handler
 from ryu import ofproto
-from ryu import utils
 from . import event
 
 
@@ -41,12 +41,14 @@ class EventOFPMsgBase(event.EventBase):
 msg.datapath A ryu.controller.controller.Datapath instance
  which describes an OpenFlow switch from which we received
  this OpenFlow message.
+timestampTimestamp when Datapath instance generated this event.
  ==
 
 The msg object has some more additional members whose values are extracted
 from the original OpenFlow message.
 """
 def __init__(self, msg):
+self.timestamp = time.time()
 super(EventOFPMsgBase, self).__init__()
 self.msg = msg
 
-- 
2.7.4


--
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


Re: [Ryu-devel] [PATCH] packet/icmpv6: Fix parsing undefined nd_option fails

2017-08-01 Thread Shivaram Mysore
Thank you Fujimoto-san 

/Shivaram
::Sent from my mobile device::

> On Aug 1, 2017, at 9:39 PM, Fujimoto Satoshi  
> wrote:
> 
> Hi, Shivaram
> 
> Oops, I overlooked about it.
> 
> It is needed for not only avoiding infinite loop, but also complying RFC.
> For the 'length' field in options, RFC4861 says that:
> 
> The value 0 is invalid.  Nodes MUST
> silently discard an ND packet that contains an
> option with length zero.
> 
> So we should raise an exception when receiving such invalid packets.
> I will make a patch.
> 
> Thanks,
> Fujimoto
> 
>> On 2017年08月02日 12:13, Shivaram Mysore wrote:
>> Hello,
>> 
>> The patch from Bill was suggesting something like this:
>> 
>>  if cls_ is not None:
>>  option = cls_.parser(buf, offset)
>>  else:
>> -option = buf[offset:offset + (length * 8 - 2)]
>> +assert length > 0   # avoid infinite loop when length=0
>> +option = buf[offset:offset + (length * 8)]
>>  options.append(option)
>>  offset += len(option)
>>  msg = cls(ch_l, res >> 6, rou_l, rea_t, ret_t, options)
>> 
>> 
>> Would it be good to check for length too?
>> 
>> Thanks
>> 
>> /Shivaram
>> 
>>> On Tue, Aug 1, 2017 at 7:18 PM, Satoshi Fujimoto 
>>>  wrote:
>>> The length of nd_option is units of 8 octets.
>>> Currently, for nd_options which is undefined in the ICMPv6 packet library,
>>> the parser assumes that the length is [8 * length - 2].
>>> It causes fails while parsing these options.
>>> 
>>> This patch fixes it to parse such options correctly.
>>> 
>>> Signed-off-by: Satoshi Fujimoto 
>>> ---
>>>  ryu/lib/packet/icmpv6.py | 2 +-
>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>> 
>>> diff --git a/ryu/lib/packet/icmpv6.py b/ryu/lib/packet/icmpv6.py
>>> index 1e5eaea..7608169 100644
>>> --- a/ryu/lib/packet/icmpv6.py
>>> +++ b/ryu/lib/packet/icmpv6.py
>>> @@ -363,7 +363,7 @@ class nd_router_advert(stringify.StringifyMixin):
>>>  if cls_ is not None:
>>>  option = cls_.parser(buf, offset)
>>>  else:
>>> -option = buf[offset:offset + (length * 8 - 2)]
>>> +option = buf[offset:offset + (length * 8)]
>>>  options.append(option)
>>>  offset += len(option)
>>>  msg = cls(ch_l, res >> 6, rou_l, rea_t, ret_t, options)
>>> --
>>> 2.7.4
>>> 
>>> 
>>> --
>>> 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
>> 
> 
--
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


Re: [Ryu-devel] [PATCH] packet/icmpv6: Fix parsing undefined nd_option fails

2017-08-01 Thread Fujimoto Satoshi

Hi, Shivaram

Oops, I overlooked about it.

It is needed for not only avoiding infinite loop, but also complying RFC.
For the 'length' field in options, RFC4861 says that:

The value 0 is invalid.  Nodes MUST
silently discard an ND packet that contains an
option with length zero.

So we should raise an exception when receiving such invalid packets.
I will make a patch.

Thanks,
Fujimoto

On 2017年08月02日 12:13, Shivaram Mysore wrote:

Hello,

The patch from Bill was suggesting something like this:

   if cls_ is not None:
 option = cls_.parser(buf, offset)
 else:
-option = buf[offset:offset + (length * 8 - 2)]
+assert length > 0   # avoid infinite loop when length=0
+option = buf[offset:offset + (length * 8)]
 options.append(option)
 offset += len(option)
 msg = cls(ch_l, res >> 6, rou_l, rea_t, ret_t, options)


Would it be good to check for length too?

Thanks

/Shivaram

On Tue, Aug 1, 2017 at 7:18 PM, Satoshi Fujimoto 
> wrote:


The length of nd_option is units of 8 octets.
Currently, for nd_options which is undefined in the ICMPv6 packet
library,
the parser assumes that the length is [8 * length - 2].
It causes fails while parsing these options.

This patch fixes it to parse such options correctly.

Signed-off-by: Satoshi Fujimoto >
---
 ryu/lib/packet/icmpv6.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ryu/lib/packet/icmpv6.py b/ryu/lib/packet/icmpv6.py
index 1e5eaea..7608169 100644
--- a/ryu/lib/packet/icmpv6.py
+++ b/ryu/lib/packet/icmpv6.py
@@ -363,7 +363,7 @@ class nd_router_advert(stringify.StringifyMixin):
 if cls_ is not None:
 option = cls_.parser(buf, offset)
 else:
-option = buf[offset:offset + (length * 8 - 2)]
+option = buf[offset:offset + (length * 8)]
 options.append(option)
 offset += len(option)
 msg = cls(ch_l, res >> 6, rou_l, rea_t, ret_t, options)
--
2.7.4



--
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





--
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


Re: [Ryu-devel] [PATCH v2] manager: Option to enable timestamp

2017-08-01 Thread Iwase Yusuke

Hi Fujita-San,


On 2017年08月02日 10:30, FUJITA Tomonori wrote:

On Tue, 25 Jul 2017 13:23:10 +0900
IWASE Yusuke  wrote:


This patch introduces a new option "--with-timestamp" which enable to
get timestamp when Ryu received the OpenFlow message.

Suggested-by: Matthew Hayes 
Signed-off-by: IWASE Yusuke 
---
  ryu/cmd/manager.py  |  6 ++
  ryu/controller/ofp_event.py | 42 --
  2 files changed, 34 insertions(+), 14 deletions(-)


This needs to be an optional feature?

An event with timestamp sounds pretty reasonable.


Thank you for reviewing.

If we don't need the CLI option, this patch can be more simple!
I will update my patch.

Regards,
Iwase

--
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


Re: [Ryu-devel] [PATCH] packet/icmpv6: Fix parsing undefined nd_option fails

2017-08-01 Thread Shivaram Mysore
Hello,

The patch from Bill was suggesting something like this:

 if cls_ is not None:
 option = cls_.parser(buf, offset)
 else:
-option = buf[offset:offset + (length * 8 - 2)]
+assert length > 0   # avoid infinite loop when length=0
+option = buf[offset:offset + (length * 8)]
 options.append(option)
 offset += len(option)
 msg = cls(ch_l, res >> 6, rou_l, rea_t, ret_t, options)


Would it be good to check for length too?

Thanks

/Shivaram

On Tue, Aug 1, 2017 at 7:18 PM, Satoshi Fujimoto <
satoshi.fujimo...@gmail.com> wrote:

> The length of nd_option is units of 8 octets.
> Currently, for nd_options which is undefined in the ICMPv6 packet library,
> the parser assumes that the length is [8 * length - 2].
> It causes fails while parsing these options.
>
> This patch fixes it to parse such options correctly.
>
> Signed-off-by: Satoshi Fujimoto 
> ---
>  ryu/lib/packet/icmpv6.py | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/ryu/lib/packet/icmpv6.py b/ryu/lib/packet/icmpv6.py
> index 1e5eaea..7608169 100644
> --- a/ryu/lib/packet/icmpv6.py
> +++ b/ryu/lib/packet/icmpv6.py
> @@ -363,7 +363,7 @@ class nd_router_advert(stringify.StringifyMixin):
>  if cls_ is not None:
>  option = cls_.parser(buf, offset)
>  else:
> -option = buf[offset:offset + (length * 8 - 2)]
> +option = buf[offset:offset + (length * 8)]
>  options.append(option)
>  offset += len(option)
>  msg = cls(ch_l, res >> 6, rou_l, rea_t, ret_t, options)
> --
> 2.7.4
>
>
> 
> --
> 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
>
--
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


[Ryu-devel] [PATCH] packet/icmpv6: Fix parsing undefined nd_option fails

2017-08-01 Thread Satoshi Fujimoto
The length of nd_option is units of 8 octets.
Currently, for nd_options which is undefined in the ICMPv6 packet library,
the parser assumes that the length is [8 * length - 2].
It causes fails while parsing these options.

This patch fixes it to parse such options correctly.

Signed-off-by: Satoshi Fujimoto 
---
 ryu/lib/packet/icmpv6.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ryu/lib/packet/icmpv6.py b/ryu/lib/packet/icmpv6.py
index 1e5eaea..7608169 100644
--- a/ryu/lib/packet/icmpv6.py
+++ b/ryu/lib/packet/icmpv6.py
@@ -363,7 +363,7 @@ class nd_router_advert(stringify.StringifyMixin):
 if cls_ is not None:
 option = cls_.parser(buf, offset)
 else:
-option = buf[offset:offset + (length * 8 - 2)]
+option = buf[offset:offset + (length * 8)]
 options.append(option)
 offset += len(option)
 msg = cls(ch_l, res >> 6, rou_l, rea_t, ret_t, options)
-- 
2.7.4


--
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


[Ryu-devel] 4.16 released

2017-08-01 Thread FUJITA Tomonori
Hi,
  
Here's a new release.
=
FUJITA Tomonori (1):
  Ryu 4.16

IWAMOTO Toshihiro (1):
  ofproto: Avoid emitting illegal instruction sets

IWASE Yusuke (5):
  bgp_sample_conf: absolute_import to suppress warnings
  ofproto: Handle OFPErrorExperimenterMsg
  unit/ofproto: Adopt to rename of OFPErrorExperimenterMsg
  doc: Deprecated option html_use_smartypants
  doc: Fix unexpected indent in ryu/lib/packet/bgp.py

Satoshi Fujimoto (1):
  service/ovsdb: get socket from RemoteOvsdb

Travis Gockel (1):
  doc: Minor grammar changes in ryu_app_api

--
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


Re: [Ryu-devel] [PATCH v2] manager: Option to enable timestamp

2017-08-01 Thread FUJITA Tomonori
On Tue, 25 Jul 2017 13:23:10 +0900
IWASE Yusuke  wrote:

> This patch introduces a new option "--with-timestamp" which enable to
> get timestamp when Ryu received the OpenFlow message.
> 
> Suggested-by: Matthew Hayes 
> Signed-off-by: IWASE Yusuke 
> ---
>  ryu/cmd/manager.py  |  6 ++
>  ryu/controller/ofp_event.py | 42 --
>  2 files changed, 34 insertions(+), 14 deletions(-)

This needs to be an optional feature?

An event with timestamp sounds pretty reasonable.

--
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


Re: [Ryu-devel] Bug in ryu/lib/icmpv6.py

2017-08-01 Thread Fujimoto Satoshi

Hi, Shivaram

Bill (CCed) isolated the problem to be inryu/lib/packet/icmpv6.py and 
provided a possible fix which works - 
https://list.waikato.ac.nz/pipermail/faucet-dev/2017-August/000223.html


It looks good!
I will make a patch for this.

There will be a time lag before the patch is merged to master.
Until then, please patch Ryu manually and use it.

Thanks,
Fujimoto

On 2017年08月02日 06:10, Shivaram Mysore wrote:

Hello,

In trying to resolve a SSL connectivity issue per 
https://list.waikato.ac.nz/pipermail/faucet-dev/2017-August/000200.html 
we found a bug in Ryu packet parser code - please see the entire thread


Bill (CCed) isolated the problem to be inryu/lib/packet/icmpv6.py and 
provided a possible fix which works - 
https://list.waikato.ac.nz/pipermail/faucet-dev/2017-August/000223.html


I see that icmpv6.py was updated more than 2 years ago and it has 
shown up now.  Can you please take a look at this and fix?  Ryu does 
not work for me without this fix.


Thanks & Regards

/Shivaram



--
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


--
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


Re: [Ryu-devel] Fields 'OUTPUT' and 'in_port' REST Ryu

2017-08-01 Thread Fujimoto Satoshi

Hi, Nicholas

What you want to know is the meanings of these field in 'Add a flow 
entry' API, right?

http://ryu.readthedocs.io/en/latest/app/ofctl_rest.html#add-a-flow-entry

'in_port' is used in 'match' field. It specifies an incoming port.
If 'in_port' is specified to 2, the flow matches the packet which comes 
from port 2.


And 'OUTPUT' action is simply to send a packet from specific port.
If 'OUTPUT: 2' is specified in 'action' field, the matched packet will 
be sent from port 2.


These are defined in 'A.2.3.7 Flow Match Fields' and 'A.2.5 Action 
Structures' in OpenFlow Spec:

https://www.opennetworking.org/images/stories/downloads/sdn-resources/onf-specifications/openflow/openflow-spec-v1.3.1.pdf


Sorry, I could not make clear what "host destination" and "host sender" 
are referring to.

Did you see these word in Ryu documentation or any other document?


Thanks,
Fujimoto

On 2017年08月01日 18:01, Nicholas Brasini wrote:


Hi guys! I don't understand what means the field 'actions: OUTPUT' and 
'in_port' in REST Ryu. I would like to know what is the host 
destination and the host sender. Thank a lot!



Nicholas



--
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


--
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


[Ryu-devel] Bug in ryu/lib/icmpv6.py

2017-08-01 Thread Shivaram Mysore
Hello,

In trying to resolve a SSL connectivity issue per
https://list.waikato.ac.nz/pipermail/faucet-dev/2017-August/000200.html we
found a bug in Ryu packet parser code - please see the entire thread

Bill (CCed) isolated the problem to be in ryu/lib/packet/icmpv6.py and
provided a possible fix which works -
https://list.waikato.ac.nz/pipermail/faucet-dev/2017-August/000223.html

I see that icmpv6.py was updated more than 2 years ago and it has shown up
now.  Can you please take a look at this and fix?  Ryu does not work for me
without this fix.

Thanks & Regards

/Shivaram
--
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


[Ryu-devel] Fields 'OUTPUT' and 'in_port' REST Ryu

2017-08-01 Thread Nicholas Brasini
Hi guys! I don't understand what means the field 'actions: OUTPUT' and 
'in_port' in REST Ryu. I would like to know what is the host destination and 
the host sender. Thank a lot!


Nicholas
--
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


Re: [Ryu-devel] Modify simple switch app to show flow stats - IP TCP/UDP Protocols

2017-08-01 Thread Boyan Mladenov
Thank you very much.

On Mon, Jul 31, 2017 at 2:12 AM, Fujimoto Satoshi <
satoshi.fujimo...@gmail.com> wrote:

> Hi, Boyan
>
> get_protocol() returns None if the argument doesn't match to the packet.
> So, I guess Ryu might catch a packet other than TCP or UDP, such as SCTP.
>
> If you doesn't need to make a flow for other than TCP or UDP, the code
> should be like this:
>
> if pkt.get_protocol(tcp.tcp):
> l4 = pkt.get_protocol(tcp.tcp)
> else if pkt.get_protocol(udp.udp):
> l4 = pkt.get_protocol(udp.udp)
> else:
> # ignore packets other than TCP or UDP
> return
>
> Thanks,
> Fujimoto
>
> On 2017年07月28日 17:39, Boyan Mladenov wrote:
>
> Hi, Fujimoto Satoshi
>
> Thank you very much for the attachment, it is really helpful.
>
> When i run the application i get the following error and i just can't
> understand why, because everything seems right.
> Any suggestions?
>
>   File 
> "/home/boyan/.local/lib/python2.7/site-packages/ryu/base/app_manager.py",
> line 290, in _event_loop
> handler(ev)
>   File "/home/boyan/ryu/ryu/app/test99.py", line 93, in _packet_in_handler
> src_port = l4.src_port
> AttributeError: 'NoneType' object has no attribute 'src_port'
>
> The code is:
>
>  if pkt.get_protocol(ipv4.ipv4):
> ip = pkt.get_protocol(ipv4.ipv4)
> src_addr = ip.src
> dst_addr = ip.dst
>
> if pkt.get_protocol(tcp.tcp):
> l4 = pkt.get_protocol(tcp.tcp)
> else:
> l4 = pkt.get_protocol(udp.udp)
> src_port = l4.src_port
> dst_port = l4.dst_port
>
> out_port = self.mac_to_port[dpid][eth.dst]
>
> actions = [parser.OFPActionOutput(out_port)]
>
> Thanks
>
> On Thu, Jul 27, 2017 at 4:59 AM, Fujimoto Satoshi <
> satoshi.fujimo...@gmail.com> wrote:
>
>> Hi, Boyan
>> Sorry for delaying.
>>
>> You can use get_protocol() to extract informations from packet.
>> For example, get_protocol(tcp.tcp) will get a TCP instance if the packet
>> is a TCP protocol packet.
>> And the TCP instance has sport/dport fields, so you can get informations
>> to build your flows:
>> http://ryu.readthedocs.io/en/latest/library_packet_ref/packe
>> t_tcp.html
>>
>> I tried to modify simple_switch_13.py to build flows for each IP src/dst
>> TCP/UDP sport/dport and attach it to this mail.
>> I wish it will help your understanding.
>>
>> Thanks,
>> Fujimoto
>>
>>
>> On 2017年07月25日 09:41, Boyan Mladenov wrote:
>>
>> Dear, all
>>
>> I am trying to modify the simple_switch_13.py so that i can extract and
>> save flow statistics about the IP src/dst TCP/UDP sport/dport. I got
>> familiar with the simple switch and the traffic monitor from where i get
>> the function for continuously showing and the data. Also the functions
>> about flow stats request and reply.
>>
>> I am having problems creating the match fields in order to modify the
>> flow table to show ip_src, ip_dst, tcp_sport, tcp_dport, protocols.
>> I have to create each single line (flow) in the table, In simple switch
>> the match is the ingress port, but in my case i have to modify it in order
>> to display the IPs IPd TCPs UDPs TCPd UDPd.
>> Probably the steps to follow are to extract the info from the packet in,
>> building a table like mac_to_port in order to get the instructions out to
>> specific port build the flow mod, putting together the match and the action
>> and send it to the switch - to fill the table.
>> I have read the ryubook and ryureadthedocs - saw the functions under
>> messages and structures, and other but still çan't figure out where to to
>> write the new functions, and what to leave from the simple switch.
>>
>> I will greatly appreciate if someone is willing to help me. it will be
>> really nice to see an example of match field of IPs/d build into the
>> simplle switch.
>>  Thank you in advance .
>>
>> from operator import attrgetter
>> from ryu.base import app_manager
>> from ryu.controller import ofp_event
>> from ryu.controller.handler import CONFIG_DISPATCHER, MAIN_DISPATCHER,
>> DEAD_DISPATCHER
>> from ryu.controller.handler import set_ev_cls
>> from ryu.ofproto import ofproto_v1_3
>> from ryu.lib.packet import packet
>> from ryu.lib.packet import ipv4
>> from ryu.lib.packet import tcp
>> from ryu.lib.packet import ethernet
>> from ryu.lib.packet import ether_types
>> from ryu.lib import hub
>>
>>
>> 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 = {}
>> self.datapaths = {}
>> self.monitor_thread = hub.spawn(self._monitor)
>>
>> @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
>>