<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">Hello …<div><br></div><div><table cellspacing="0" cellpadding="0" border="0" style="position: static; z-index: auto;"><tbody><tr><td valign="top"><p dir="ltr">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]<br>Now i want to install flows for them </p></td></tr></tbody></table><div><br></div></div><div>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</div><div><br></div><div><br></div><div><div>def _handle_PacketIn (self, event):</div><div><br></div><div>        def flood(): #floods the packet</div><div>           </div><div>            msg = of.ofp_packet_out() </div><div>            msg.actions.append(of.ofp_action_output(port = of.OFPP_FLOOD))</div><div>            msg.data = packet_in.data </div><div>            msg.in_port = in_port</div><div>            self.connection.send(msg)</div><div><br></div><div>            </div><div>        def drop():# drops the message</div><div>         </div><div>            if packet_in.buffer_id is not None: </div><div><br></div><div>                msg = of.ofp_packet_out()</div><div>                msg.buffer_id = packet_in.buffer_id</div><div>                    </div><div>                msg.in_port = in_port </div><div>                self.connection.send(msg)</div><div><br></div><div><br></div><div>             </div><div>        packet = event.parsed </div><div>        packet_in = event.ofp </div><div>        in_port = event.port</div><div>        #print in_port</div><div>        dpid = event.dpid</div><div>       </div><div>        </div><div>        </div><div>        if packet.type == packet.LLDP_TYPE:</div><div>            self.receive_topology_packet(dpid,in_port,packet)</div><div><br></div><div>            return</div><div>        </div><div>            </div><div>            </div><div>        self.host_table[packet.src] = in_port</div><div>        </div><div><br></div><div>        if <a href="http://packet.dst.is">packet.dst.is</a>_multicast:</div><div>            flood()</div><div>            return</div><div>                   </div><div>        if packet.dst not in self.host_table: # check for unknown destination</div><div>        </div><div>            flood()</div><div>            return</div><div>        </div><div>        else:</div><div>            </div><div>            print "%s" %(packet.src)</div><div>            print "%s" %(packet.dst)</div><div>            p_s = str(packet.src)</div><div>            p_d = str(packet.dst)</div><div>          </div><div>            dpid_src = dpid</div><div>            print "src dpid",dpid_src</div><div>            for s in range(len(switch)):</div><div><br></div><div>                    </div><div>                if p_d[-1:] == str(switch[s]):</div><div>                    dpid_dst = switch[s]</div><div>                    print "dest dpid",dpid_dst</div><div><br></div><div>            best_route = []</div><div>            best_route = spf.shortest_path(dpid_src,dpid_dst)</div><div>            best_route.reverse()</div><div>            print best_route</div><div>        </div><div>            print " known"</div><div>            </div><div><br></div><div>            msg = of.ofp_flow_mod()</div><div><br></div><div>            if not packet.type == packet.VLAN_TYPE:</div><div>                print "attaching a vlan id"</div><div>                msg.actions.append(of.ofp_action_vlan_vid(vlan_vid = dpid_dst))</div><div><br></div><div>            elif dpid_src == dpid_dst:</div><div>                    print "arived at destination striping vtag"</div><div>                    msg.actions.append(of.ofp_action_strip_vlan())                                                                                                                                              </div><div><br></div><div>              </div><div>            if best_route:</div><div>                if not best_route[0] == dpid_dst:</div><div>                    next_hop = best_route[0]</div><div>                </div><div><br></div><div>                    if not dpid_src== dpid_dst:</div><div>                        for p in topo[dpid_src]:</div><div>                            temp = topo[dpid_src][p]</div><div>                            if temp [0]== next_hop:   # in topo[dpid_src][p]:</div><div>                                print"yes"</div><div>                                print"p",p</div><div>                                            #dp,op = topo[dpid][p]</div><div>                                op = p</div><div>                                print "outport",op</div><div>                else:</div><div>                    print"we r at destination"</div><div>                    op = self.host_table[packet.dst]</div><div>                    print "op"</div><div><br></div><div>          </div><div>                print"sending flow"                      </div><div>                msg = of.ofp_flow_mod()  # installing flow</div><div>                msg.match = of.ofp_match.from_packet(packet, in_port)</div><div>                msg.idle_timeout = 10</div><div>                msg.hard_timeout = 30</div><div>                           </div><div>                msg.actions.append(of.ofp_action_output(port = op))</div><div>                msg.data = packet_in</div><div>                    </div><div>                self.connection.send(msg)</div><div>                </div><div>                msg = of.ofp_packet_out() </div><div>                msg.actions.append(of.ofp_action_output(port = op))</div><div>                msg.data = packet_in.data </div><div>                msg.in_port = in_port</div><div>                self.connection.send(msg)</div><div>                print "flow sent"</div></div></body></html>