def _handle_ConnectionUp(self, event): sw = self.switches.get(event.dpid) sw_str = dpidToStr(event.dpid) log.info("Saw switch com up: %s", sw_str) name_str = self.t.id_gen(dpid=event.dpid).name_str() if name_str not in self.t.switches(): log.warn("Ignoring unknown switch %s" % sw_str) return if sw is None: log.info("Added fresh switch %s" % sw_str) sw = Switch() self.switches[event.dpid] = sw sw.connect(event.connection) else: log.info("Odd - already saw switch %s come up" % sw_str) sw.connect(event.connection) sw.connection.send(of.ofp_set_config(miss_send_len=MISS_SEND_LEN)) if len(self.switches) == len(self.t.switches()): log.info("Woo! All switches up") self.all_switches_up = True self._save_paths() # log.info("self.routeTable : %s" % self.routeTable) start = time() self._install_paths() log.info("use %s seconds to install paths" % (time() - start)) # the pre_install_paths should have been installed log.info("Woo! All paths ok")
def _handle_ConnectionUp (self, event): sw = self.switches.get(event.dpid) sw_str = dpidToStr(event.dpid) log.info("Saw switch com up: %s", sw_str) name_str = self.t.id_gen(dpid = event.dpid).name_str() if name_str not in self.t.switches(): log.warn("Ignoring unknown switch %s" % sw_str) return if sw is None: log.info("Added fresh switch %s" % sw_str) sw = Switch() self.switches[event.dpid] = sw sw.connect(event.connection) else: log.info("Odd - already saw switch %s come up" % sw_str) sw.connect(event.connection) sw.connection.send(of.ofp_set_config(miss_send_len = MISS_SEND_LEN)) if len(self.switches) == len(self.t.switches()): log.info("Woo! All switches up") self.all_switches_up = True self._save_paths() # log.info("self.routeTable : %s" % self.routeTable) self._install_paths() log.info("Woo! All paths ok")
def _handle_ConnectionUp(self, event): """ Is called whenever a switch in the Mininet topoplogy comes up, and registers it in the controller. """ log.info('Connection up') log.info(event.connection.features) log.info(event.ofp) switch_dpid = event.dpid switch = self.switches.get(event.dpid) # The name of the switch as known by the topology object. switch_name_str = dpid_to_str(switch_dpid) # Controller ignores switch if this is not a switch we recognize. if switch_name_str not in self.topology.switches(): log.warn("Ignoring unknown switch %s" % switch_name_str) return # We expect the switch to be None, so we create it. if switch is None: log.info("Added fresh switch %s" % switch_name_str) switch = Switch(log) self.switches[event.dpid] = switch switch.connect( event.connection) # Connect the switch to this event. # Give the Routing class the new switch object for registration. self.routing.register_switch(switch) else: log.warn("Odd - already saw switch %s come up" % switch_name_str) if len(self.switches) == len(self.topology.switches()): log.info(" Woo! All switches up") # Not sure if this is necessary: Clear all flow table entries for this switch # But does not affect ping all success. clear = of.ofp_flow_mod(command=of.OFPFC_DELETE) event.connection.send(clear) event.connection.send(of.ofp_barrier_request())
def _handle_ConnectionUp (self, event): sw = self.switches.get(event.dpid) sw_str = dpidToStr(event.dpid) log.info("Saw switch com up: %s", sw_str) name_str = self.t.id_gen(dpid = event.dpid).name_str() if name_str not in self.t.switches(): log.warn("Ignoring unknown switch %s" % sw_str) return if sw is None: log.info("Added fresh switch %s" % sw_str) sw = Switch() self.switches[event.dpid] = sw sw.connect(event.connection) else: log.info("Odd - already saw switch %s come up" % sw_str) sw.connect(event.connection) sw.connection.send(of.ofp_set_config(miss_send_len = MISS_SEND_LEN)) if len(self.switches) == len(self.t.switches()): log.info("Woo! All switches up") self.all_switches_up = True self._save_paths() # log.info("self.routeTable : %s" % self.routeTable) # self._install_paths() log.info("Woo! All paths ok") # suppose here we have a traffic matrix # find the routing policies for this traffic matrix #for i in range(10): # num_matrix = i # self.test(num_matrix) self.input_traffic()
def _handle_ConnectionUp(self, event): sw = self.switches.get(event.dpid) sw_str = dpidToStr(event.dpid) log.info("Saw switch com up: %s", sw_str) name_str = self.t.id_gen(dpid=event.dpid).name_str() if name_str not in self.t.switches(): log.warn("Ignoring unknown switch %s" % sw_str) return if sw is None: log.info("Added fresh switch %s" % sw_str) sw = Switch() self.switches[event.dpid] = sw sw.connect(event.connection) else: log.info("Odd - already saw switch %s come up" % sw_str) sw.connect(event.connection) sw.connection.send(of.ofp_set_config(miss_send_len=MISS_SEND_LEN)) if len(self.switches) == len(self.t.switches()): log.info("Woo! All switches up") self.all_switches_up = True self._save_paths() # log.info("self.routeTable : %s" % self.routeTable) # self._install_paths() log.info("Woo! All paths ok") # suppose here we have a traffic matrix # find the routing policies for this traffic matrix #for i in range(10): # num_matrix = i # self.test(num_matrix) self.input_traffic()