示例#1
0
 def test_no_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)
     flow_mod = ofp_flow_mod(xid=124,
                             priority=1,
                             match=ofp_match(in_port=2, nw_src="1.2.3.4"),
                             action=ofp_action_output(port=1))
     switch2.table.process_flow_mod(flow_mod)
     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([], blackholes)
示例#2
0
  def python_check_blackholes(simulation, check_liveness_first=True):
    '''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!
    import topology_loader.topology_loader as hsa_topo
    import headerspace.applications as hsa
    if check_liveness_first:
      simulation.controller_manager.check_controller_status()
      if simulation.controller_manager.all_controllers_down():
        return simulation.controller_manager.cids
    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)
    violations = [ str(b) for b in blackholes ]
    violations = list(set(violations))
    return violations
示例#3
0
    def python_check_blackholes(simulation, check_liveness_first=True):
        '''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!
        import topology_loader.topology_loader as hsa_topo
        import headerspace.applications as hsa
        if check_liveness_first:
            simulation.controller_manager.check_controller_status()
            if simulation.controller_manager.all_controllers_down():
                return simulation.controller_manager.cids
        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)
        violations = [str(b) for b in blackholes]
        violations = list(set(violations))
        return violations
示例#4
0
 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])]
   switches = [switch1, switch2]
   NTF = hsa_topo.generate_NTF(switches)
   TTF = hsa_topo.generate_TTF(network_links)
   access_links = [ MockAccessLink(sw, sw.ports[1]) for sw in switches ]
   blackholes = hsa.find_blackholes(NTF, TTF, access_links)
   self.assertEqual([(200002, [100001, 100002])], [ s[1:] for s in blackholes])
示例#5
0
 def test_no_blackhole_without_rules(self):
     """ An ingress switch with no rule should not count as a
 blackhole """
     switch1 = create_switch(1, 2)
     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]),
     ]
     switches = [switch1, switch2]
     NTF = hsa_topo.generate_NTF(switches)
     TTF = hsa_topo.generate_TTF(network_links)
     access_links = [MockAccessLink(sw, sw.ports[1]) for sw in switches]
     blackholes = hsa.find_blackholes(NTF, TTF, access_links)
     self.assertEqual(blackholes, [])
示例#6
0
 def test_no_blackhole_without_rules(self):
     ''' An ingress switch with no rule should not count as a
 blackhole '''
     switch1 = create_switch(1, 2)
     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])
     ]
     switches = [switch1, switch2]
     NTF = hsa_topo.generate_NTF(switches)
     TTF = hsa_topo.generate_TTF(network_links)
     access_links = [MockAccessLink(sw, sw.ports[1]) for sw in switches]
     blackholes = hsa.find_blackholes(NTF, TTF, access_links)
     self.assertEqual(blackholes, [])
示例#7
0
 def test_no_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)
   flow_mod = ofp_flow_mod(xid=124, priority=1, match=ofp_match(in_port=2, nw_src="1.2.3.4"), action=ofp_action_output(port=1))
   switch2.table.process_flow_mod(flow_mod)
   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([], blackholes)
示例#8
0
 def test_blackhole_with_no_action_rules(self):
     """ An ingress switch with an explicit drop rule should count as a
 blackhole """
     switch1 = create_switch(1, 2)
     flow_mod = ofp_flow_mod(
         xid=124, priority=1, match=ofp_match(in_port=switch1.ports[1].port_no, nw_src="1.2.3.4")
     )
     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]),
     ]
     switches = [switch1, switch2]
     NTF = hsa_topo.generate_NTF(switches)
     TTF = hsa_topo.generate_TTF(network_links)
     access_links = [MockAccessLink(sw, sw.ports[1]) for sw in switches]
     blackholes = hsa.find_blackholes(NTF, TTF, access_links)
     self.assertNotEqual(blackholes, [])
示例#9
0
 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])
     ]
     switches = [switch1, switch2]
     NTF = hsa_topo.generate_NTF(switches)
     TTF = hsa_topo.generate_TTF(network_links)
     access_links = [MockAccessLink(sw, sw.ports[1]) for sw in switches]
     blackholes = hsa.find_blackholes(NTF, TTF, access_links)
     self.assertEqual([(200002, [100001, 100002])],
                      [s[1:] for s in blackholes])
示例#10
0
 def test_blackhole_with_no_action_rules(self):
     ''' An ingress switch with an explicit drop rule should count as a
 blackhole '''
     switch1 = create_switch(1, 2)
     flow_mod = ofp_flow_mod(xid=124,
                             priority=1,
                             match=ofp_match(
                                 in_port=switch1.ports[1].port_no,
                                 nw_src="1.2.3.4"))
     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])
     ]
     switches = [switch1, switch2]
     NTF = hsa_topo.generate_NTF(switches)
     TTF = hsa_topo.generate_TTF(network_links)
     access_links = [MockAccessLink(sw, sw.ports[1]) for sw in switches]
     blackholes = hsa.find_blackholes(NTF, TTF, access_links)
     self.assertNotEqual(blackholes, [])