def check_blackholes(simulation): '''Do any switches: - send packets into a down link? - drop packets that are supposed to go out their in_port? This method double checks whether it's possible for any packets to fall into the blackhole in the first place. Slightly different than check_connectivity. blackholes imply no connectivity, but not vice versa. No connectivity could also be due to: - a loop - PacketIn-based reactive routing ''' # TODO(cs): just realized -- the C-version of Hassell might be configured to # *stop* as soon as it gets to an edge port. At least, this is the # behavior of the find_reachability function in python Hassell. So we'd # have to do an iterative computation: all switches that are one # hop away, then two hops, etc. Otherwise we wouldn't find blackholes in # the middle of the network. # For now, use a python method that explicitly # finds blackholes rather than inferring them from check_reachability # Warning! depends on python Hassell -- may be really slow! NTF = hsa_topo.generate_NTF(simulation.topology.live_switches) TTF = hsa_topo.generate_TTF(simulation.topology.live_links) blackholes = hsa.find_blackholes(NTF, TTF, simulation.topology.access_links) return blackholes
def test_blackhole(self): switch1 = create_switch(1, 2) flow_mod = ofp_flow_mod(xid=124, priority=1, match=ofp_match(in_port=1, nw_src="1.2.3.4"), action=ofp_action_output(port=2)) switch1.table.process_flow_mod(flow_mod) switch2 = create_switch(2, 2) network_links = [Link(switch1, switch1.ports[2], switch2, switch2.ports[2]), Link(switch2, switch2.ports[2], switch1, switch1.ports[2])] NTF = hsa_topo.generate_NTF([switch1, switch2]) TTF = hsa_topo.generate_TTF(network_links) access_links = [MockAccessLink(switch1, switch1.ports[1]), MockAccessLink(switch2, switch2.ports[1])] blackholes = hsa.find_blackholes(NTF, TTF, access_links) self.assertEqual([(100002, [100001, 100002])], blackholes)