[pox-dev] Installing SPF in Switches

Murphy McCauley murphy.mccauley at gmail.com
Mon Nov 11 22:23:20 PST 2013


On Nov 11, 2013, at 10:04 PM, Muhammad Furqan Gagan <furqan.gagan at gmail.com> wrote:

> Yeah I check them ..
> 
> they are using core discovery module to learn the topology..
> 
> And I am learning the topolopgy in a table via sending and receiving lldp packets..  a switch send to its every port after connecting

That's pretty much what the discovery component does.

But my point was that they both compute and install shortest paths; you should be able to do it more or less the same way.

Some specific comments inline.

> On Nov 11, 2013, at 10:54 PM, Murphy McCauley <murphy.mccauley at gmail.com> wrote:
> 
>> Have you taken a look at the l2_multi and topo_proactive components?  Both of them compute and install shortest paths.
>> 
>> -- Murphy
>> 
>> On Nov 11, 2013, at 9:48 PM, Muhammad Furqan Gagan <furqan.gagan at gmail.com> wrote:
>> 
>>> Hello …
>>> 
>>> I am working on a controller which calculate shrtest path from a function i have made and returns an array of switches in between source and destination switches... When a packet is received i calculate their source and dpids and calculate their shotest path. for example: for switch 1 and switch 7 there is a shortest path [2,3,4,7]
>>> Now i want to install flows for them 
>>> 
>>> 
>>> Currently I am doing this… It is sending the packet and installing flows but I cant ping … I am new to POX so if you can explain it in bit easier way !! Thanks
>>> 
>>> 
>>> def _handle_PacketIn (self, event):
>>> 
>>>         def flood(): #floods the packet
>>>            
>>>             msg = of.ofp_packet_out() 
>>>             msg.actions.append(of.ofp_action_output(port = of.OFPP_FLOOD))
>>>             msg.data = packet_in.data 
>>>             msg.in_port = in_port
>>>             self.connection.send(msg)
>>> 
>>>             
>>>         def drop():# drops the message
>>>          
>>>             if packet_in.buffer_id is not None: 
>>> 
>>>                 msg = of.ofp_packet_out()
>>>                 msg.buffer_id = packet_in.buffer_id
>>>                     
>>>                 msg.in_port = in_port 
>>>                 self.connection.send(msg)
>>> 
>>> 
>>>              
>>>         packet = event.parsed 
>>>         packet_in = event.ofp 
>>>         in_port = event.port
>>>         #print in_port
>>>         dpid = event.dpid
>>>        
>>>         
>>>         
>>>         if packet.type == packet.LLDP_TYPE:
>>>             self.receive_topology_packet(dpid,in_port,packet)
>>> 
>>>             return
>>>         
>>>             
>>>             
>>>         self.host_table[packet.src] = in_port
>>>         
>>> 
>>>         if packet.dst.is_multicast:
>>>             flood()
>>>             return
>>>                    
>>>         if packet.dst not in self.host_table: # check for unknown destination
>>>         
>>>             flood()
>>>             return
>>>         
>>>         else:
>>>             
>>>             print "%s" %(packet.src)
>>>             print "%s" %(packet.dst)
>>>             p_s = str(packet.src)
>>>             p_d = str(packet.dst)
>>>           
>>>             dpid_src = dpid
>>>             print "src dpid",dpid_src
>>>             for s in range(len(switch)):
>>> 
>>>                     
>>>                 if p_d[-1:] == str(switch[s]):
>>>                     dpid_dst = switch[s]
>>>                     print "dest dpid",dpid_dst
>>> 
>>>             best_route = []
>>>             best_route = spf.shortest_path(dpid_src,dpid_dst)
>>>             best_route.reverse()

The reverse here looks strange to me.  Does the path not come back with best_route[0] being the src and best_route[-1] being the dst?

>>>             print best_route
>>>         
>>>             print " known"
>>>             
>>> 
>>>             msg = of.ofp_flow_mod()

I don't think this flow_mod is ever being sent.  You set it up, but then overwrite it before sending.

>>> 
>>>             if not packet.type == packet.VLAN_TYPE:
>>>                 print "attaching a vlan id"
>>>                 msg.actions.append(of.ofp_action_vlan_vid(vlan_vid = dpid_dst))
>>> 
>>>             elif dpid_src == dpid_dst:
>>>                     print "arived at destination striping vtag"
>>>                     msg.actions.append(of.ofp_action_strip_vlan())                                                                                                                                              
>>> 
>>>               
>>>             if best_route:
>>>                 if not best_route[0] == dpid_dst:
>>>                     next_hop = best_route[0]
>>>                 
>>> 
>>>                     if not dpid_src== dpid_dst:
>>>                         for p in topo[dpid_src]:
>>>                             temp = topo[dpid_src][p]
>>>                             if temp [0]== next_hop:   # in topo[dpid_src][p]:
>>>                                 print"yes"
>>>                                 print"p",p
>>>                                             #dp,op = topo[dpid][p]
>>>                                 op = p
>>>                                 print "outport",op
>>>                 else:
>>>                     print"we r at destination"
>>>                     op = self.host_table[packet.dst]
>>>                     print "op"
>>> 
>>>           
>>>                 print"sending flow"                      
>>>                 msg = of.ofp_flow_mod()  # installing flow
>>>                 msg.match = of.ofp_match.from_packet(packet, in_port)
>>>                 msg.idle_timeout = 10
>>>                 msg.hard_timeout = 30
>>>                            
>>>                 msg.actions.append(of.ofp_action_output(port = op))
>>>                 msg.data = packet_in
>>>                     
>>>                 self.connection.send(msg)
>>>                 
>>>                 msg = of.ofp_packet_out() 
>>>                 msg.actions.append(of.ofp_action_output(port = op))
>>>                 msg.data = packet_in.data 
>>>                 msg.in_port = in_port
>>>                 self.connection.send(msg)
>>>                 print "flow sent"

You're sending two flow_mods here, but it looks to me like they probably overlap 100% of the time and the second one may never actually be hit.  Also, you probably mean msg.match.in_port.

-- Murphy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.noxrepo.org/pipermail/pox-dev-noxrepo.org/attachments/20131111/b7f5af0e/attachment-0002.htm>


More information about the pox-dev mailing list