When the controller and the switches perform handshake, i.e. config-dispatch event you can store the datapath object of switches  in a dictionary then use these object to initiate a packet out
 
Something like this: https://github.com/osrg/ryu/blob/master/ryu/app/simple_monitor_13.py

If you search on the net you will be able to find some better examples.

Regards,
M. Reza

From: mirakyanmar...@gmail.com
Sent: July 27, 2019 9:46 AM
To: ryu-devel@lists.sourceforge.net
Subject: [Ryu-devel] Initiate event from within a ryu app

Dear Ryu developers,

I'm trying to initiate the sending of a packet from within a Ryu app but not sure how to do it right. The main problem is that I'm not sure how to create a new Datapath/OFPPacketIn event object so that I can send an event. Right now I have the following code snippet:

from ryu.baseimport app_manager
from ryu.controllerimport ofp_event
from ryu.lib.packetimport ethernet, ipv4, icmp
from ryu.ofprotoimport ofproto_v1_3


class RyuEventSender(app_manager.RyuApp):
OFP_VERSIONS = [ofproto_v1_3.OFP_VERSION]

def send_packet(self):
        pkt = ethernet.ethernet(dst='5e:cc:cc:b1:49:4b') / \
ipv4.ipv4(src='192.168.70.2',
dst='192.168.70.3',
proto=1) / \
              icmp.icmp()
        pkt.serialize()

ev = ... # Create an ofp_event.EventOFPPacketIn event
self.send_event_to_observers(ev)
print('[SENDER]:', ev.msg)

def start(self):
super().start()
self.send_packet()
Can you point me to how to create a Datapath object or a valid OFPPacketIn event or any other way of sending a packet from within Ryu?

Thanks in advance.
Best,
Martin

_______________________________________________
Ryu-devel mailing list
Ryu-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to