Ejemplo n.º 1
0
    def test_nary_intersection(self):
        field1 = nc.Header({'srcmac': 1})
        field2 = nc.Header({'dstmac': 2})
        field3 = nc.Header({'ethtype': 3})

        inter = nc.nary_intersection([field1, field2, field3])
        self.assertTrue(inter.match(
            nc.Packet({'srcmac':1, 'dstmac':2, 'ethtype':3}), (1,1)))
        self.assertFalse(inter.match(
            nc.Packet({'srcmac':-1, 'dstmac':2, 'ethtype':3}), (1,1)))
        self.assertFalse(inter.match(
            nc.Packet({'srcmac':1, 'dstmac':-2, 'ethtype':3}), (1,1)))
        self.assertFalse(inter.match(
            nc.Packet({'srcmac':2, 'dstmac':2, 'ethtype':-3}), (1,1)))
Ejemplo n.º 2
0
def get_slices():
    p_topo = nxtopo.NXTopo()
    p_topo.add_switch(1)
    p_topo.add_switch(2)
    p_topo.add_switch(3)
    p_topo.add_switch(4)
    p_topo.add_switch(5)
    p_topo.add_host(7)
    p_topo.add_host(8)
    p_topo.add_host(9)
    p_topo.add_link(1, 3)
    p_topo.add_link(1, 4)
    p_topo.add_link(1, 5)
    p_topo.add_link(2, 3)
    p_topo.add_link(2, 4)
    p_topo.add_link(2, 5)
    p_topo.add_link(3, 7)
    p_topo.add_link(4, 8)
    p_topo.add_link(5, 9)
    p_topo.finalize()

    slic_list = [# All traffic to one port
                 getSlice(13, 11, 14, 17, 18, -10,
                    nc.Header({'dstport': 25565}), p_topo),
                 # All IPv6 traffic
                 getSlice(23, 21, 25, 27, 29, -20,
                    nc.Header({'ethtype': 0x86DD}), p_topo),
                 # IPv4 web traffic, tightly specified
                 getSlice(34, 32, 35, 38, 39, -30,
                          # IPv4
                          nc.nary_intersection([nc.Header({'ethtype': 0x0800}),
                                               # TCP
                                               nc.Header({'protocol': 0x06}),
                                               # Port 80
                                               nc.Header({'dstport': 80})]),
                          p_topo)]

    return (p_topo, slic_list)