Hi,

I don't this is reasonable way though...
How about filtering by Datapath ID as following?

# The case with s1(dpid=1), s2(dpid=2) and s3(dpid=3)
$ git diff
diff --git a/ryu/app/rest_router.py b/ryu/app/rest_router.py
index 81a3be4..38127ad 100644
--- a/ryu/app/rest_router.py
+++ b/ryu/app/rest_router.py
@@ -218,6 +218,8 @@ class RestRouterAPI(app_manager.RyuApp):
     def __init__(self, *args, **kwargs):
         super(RestRouterAPI, self).__init__(*args, **kwargs)
 
+        self._target_dpids = [1]  # registers target Datapath IDs
+
         # logger configure
         RouterController.set_logger(self.logger)
 
@@ -259,8 +261,13 @@ class RestRouterAPI(app_manager.RyuApp):
                        action='delete_vlan_data',
                        conditions=dict(method=['DELETE']))
 
+    def _check_dpid(self, dpid):
+        return dpid in self._target_dpids
+
     @set_ev_cls(dpset.EventDP, dpset.DPSET_EV_DISPATCHER)
     def datapath_handler(self, ev):
+        if not self._check_dpid(ev.dp.id):
+            return
         if ev.enter:
             RouterController.register_router(ev.dp)
         else:
@@ -268,6 +275,8 @@ class RestRouterAPI(app_manager.RyuApp):
 
     @set_ev_cls(ofp_event.EventOFPPacketIn, MAIN_DISPATCHER)
     def packet_in_handler(self, ev):
+        if not self._check_dpid(ev.msg.datapath.id):
+            return
         RouterController.packet_in_handler(ev.msg)
 
     def _stats_reply_handler(self, ev):
@@ -292,11 +301,15 @@ class RestRouterAPI(app_manager.RyuApp):
     # for OpenFlow version1.0
     @set_ev_cls(ofp_event.EventOFPFlowStatsReply, MAIN_DISPATCHER)
     def stats_reply_handler_v1_0(self, ev):
+        if not self._check_dpid(ev.msg.datapath.id):
+            return
         self._stats_reply_handler(ev)
 
     # for OpenFlow version1.2/1.3
     @set_ev_cls(ofp_event.EventOFPStatsReply, MAIN_DISPATCHER)
     def stats_reply_handler_v1_2(self, ev):
+        if not self._check_dpid(ev.msg.datapath.id):
+            return
         self._stats_reply_handler(ev)
 
     # TODO: Update routing table when port status is changed.
diff --git a/ryu/app/simple_switch_13.py b/ryu/app/simple_switch_13.py
index 3e7c598..97d8bae 100644
--- a/ryu/app/simple_switch_13.py
+++ b/ryu/app/simple_switch_13.py
@@ -30,8 +30,15 @@ class SimpleSwitch13(app_manager.RyuApp):
         super(SimpleSwitch13, self).__init__(*args, **kwargs)
         self.mac_to_port = {}
 
+        self._target_dpids = [2, 3]  # registers target Datapath IDs
+
+    def _check_dpid(self, dpid):
+        return dpid in self._target_dpids
+
     @set_ev_cls(ofp_event.EventOFPSwitchFeatures, CONFIG_DISPATCHER)
     def switch_features_handler(self, ev):
+        if not self._check_dpid(ev.msg.datapath.id):
+            return
         datapath = ev.msg.datapath
         ofproto = datapath.ofproto
         parser = datapath.ofproto_parser
@@ -65,6 +72,8 @@ class SimpleSwitch13(app_manager.RyuApp):
 
     @set_ev_cls(ofp_event.EventOFPPacketIn, MAIN_DISPATCHER)
     def _packet_in_handler(self, ev):
+        if not self._check_dpid(ev.msg.datapath.id):
+            return
         # 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:


Thanks,
Iwase


On 2016年12月05日 21:05, Kanwardeep SINGH BAWEJA wrote:
> Hi
> I am kanwardeep from Bits pilani,India. I am trying to implement topology 
> based hybrid SDN in mininet using ryu framework. But I am stuck at this 
> problem. I would be highly grateful if some one can help me.
> So the topology I want design is here (https://i.stack.imgur.com/b6Ler.png). 
> Now i want to run s1 as a router (using rest_router.py) and s3,s3 as ovs 
> switches (using simple_switch_13.py) but I want to run both the scripts in 
> one controller.
> Can some one suggest how to go about this so that when a packet arrives at s2 
> or s3 the controller sends it to router and when it reaches router the 
> controller see's the destination IP and forwards it accordingly.
> 
> 
> ------------------------------------------------------------------------------
> 
> 
> 
> _______________________________________________
> Ryu-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/ryu-devel
> 

------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today.http://sdm.link/xeonphi
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to