Exemplo n.º 1
0
    def traffic_per_group_per_tenant_for_unicast(self):
        _traffic_per_group_per_tenant_for_unicast = []

        for t in bar_range(
                self.num_tenants,
                desc='data:traffic_per_group_per_tenant_for_unicast:'):
            tenant_maps = self.tenants_maps[t]
            group_count = tenant_maps['group_count']
            groups_map = tenant_maps['groups_map']

            for g in range(group_count):
                group_map = groups_map[g]
                leafs_map = group_map['leafs_map']
                # pods_map = group_map['pods_map']
                leafs_traffic = 0

                for l in leafs_map:
                    leaf_map = leafs_map[l]
                    leafs_traffic += popcount(leaf_map['bitmap'])

                _traffic_per_group_per_tenant_for_unicast += [
                    6 * leafs_traffic
                ]

        _traffic_per_group_per_tenant_for_unicast = \
            pd.Series(_traffic_per_group_per_tenant_for_unicast)

        return _traffic_per_group_per_tenant_for_unicast
Exemplo n.º 2
0
    def traffic_per_group_per_tenant_for_overlay(self):
        traffic_per_group_per_tenant_for_overlay = []

        for t in bar_range(
                self.num_tenants,
                desc='data:traffic_per_group_per_tenant_for_overlay:'):
            tenant_maps = self.tenants_maps[t]
            group_count = tenant_maps['group_count']
            groups_map = tenant_maps['groups_map']

            for g in range(group_count):
                group_map = groups_map[g]
                leafs_map = group_map['leafs_map']
                # pods_map = group_map['pods_map']
                leafs_traffic = 0

                for l in leafs_map:
                    leaf_map = leafs_map[l]
                    leaf_host_count = popcount(leaf_map['bitmap'])
                    leafs_traffic += 2 * (leaf_host_count - 1)

                traffic_per_group_per_tenant_for_overlay += [
                    (6 * len(leafs_map)) + leafs_traffic
                ]

        traffic_per_group_per_tenant_for_overlay = \
            pd.Series(traffic_per_group_per_tenant_for_overlay)

        return traffic_per_group_per_tenant_for_overlay
Exemplo n.º 3
0
    def traffic_per_group_per_tenant_for_baseerat(self):
        _traffic_per_group_per_tenant_for_baseerat = []

        for t in bar_range(
                self.num_tenants,
                desc='data:traffic_per_group_per_tenant_for_baseerat:'):
            tenant_maps = self.tenants_maps[t]
            group_count = tenant_maps['group_count']
            groups_map = tenant_maps['groups_map']

            for g in range(group_count):
                group_map = groups_map[g]
                leafs_map = group_map['leafs_map']
                pods_map = group_map['pods_map']
                leafs_traffic = 0
                redundant_leafs = 0
                redundant_leafs_traffic = 0

                for p in pods_map:
                    pod_map = pods_map[p]
                    if '~bitmap' in pod_map:
                        redundant_leafs += popcount(pod_map['~bitmap'])

                if 'leafs_default_bitmap' in group_map:
                    redundant_leafs_traffic = redundant_leafs * popcount(
                        group_map['leafs_default_bitmap'])

                for l in leafs_map:
                    leaf_map = leafs_map[l]
                    leafs_traffic += popcount(leaf_map['bitmap'])
                    if '~bitmap' in leaf_map:
                        leafs_traffic += popcount(leaf_map['~bitmap'])

                _traffic_per_group_per_tenant_for_baseerat += [
                    3 + len(pods_map) + len(leafs_map) + leafs_traffic +
                    redundant_leafs + redundant_leafs_traffic
                ]

        _traffic_per_group_per_tenant_for_baseerat = \
            pd.Series(_traffic_per_group_per_tenant_for_baseerat)

        return _traffic_per_group_per_tenant_for_baseerat
Exemplo n.º 4
0
def min_k_union(nodes_map, nodes, k):
    min_k_bitmap = 0
    min_k_nodes = []
    for _ in range(k):
        node = min(
            nodes,
            key=lambda l: popcount(nodes_map[l]['bitmap'] | min_k_bitmap))
        nodes.remove(node)
        min_k_bitmap |= nodes_map[node]['bitmap']
        min_k_nodes += [node]
    return min_k_bitmap, min_k_nodes
Exemplo n.º 5
0
def set_cover(bitmap, submaps):
    if reduce(lambda x, y: x | y, submaps) != bitmap:
        return None
    set_cover_bitmap = 0
    set_cover_submaps = []
    while set_cover_bitmap != bitmap:
        submap = max(submaps, key=lambda s: popcount(s & (~set_cover_bitmap)))
        submaps.remove(submap)
        set_cover_bitmap |= submap
        set_cover_submaps += [submap]
    return set_cover_submaps
Exemplo n.º 6
0
    def traffic_overhead_per_group_per_tenant(self, node_type):
        _traffic_overhead_per_group_per_tenant = []

        for t in bar_range(self.num_tenants,
                           desc='data:traffic_overhead_per_group_per_tenant:'):
            tenant_maps = self.tenants_maps[t]
            group_count = tenant_maps['group_count']
            groups_map = tenant_maps['groups_map']

            for g in range(group_count):
                group_map = groups_map[g]
                nodes_map = group_map[
                    'leafs_map'] if node_type == 'leafs' else group_map[
                        'pods_map']
                _actual_traffic = 0
                _redundant_traffic = 0

                for n in nodes_map:
                    node_map = nodes_map[n]
                    _actual_traffic += popcount(node_map['bitmap'])

                    if '~bitmap' in node_map:
                        _redundant_traffic += popcount(node_map['~bitmap'])

                _traffic_overhead_per_group_per_tenant += [
                    _redundant_traffic / _actual_traffic
                ]

        _traffic_overhead_per_group_per_tenant = pd.Series(
            _traffic_overhead_per_group_per_tenant)

        if self.log_dir is not None:
            _traffic_overhead_per_group_per_tenant.to_csv(
                self.log_dir +
                "/traffic_overhead_per_group_per_tenant_for_%s.csv" %
                node_type,
                index=False)

        return _traffic_overhead_per_group_per_tenant
Exemplo n.º 7
0
    def traffic_per_group_per_tenant_for_overlay_corrected(self):
        traffic_per_group_per_tenant_for_overlay_corrected = []

        for t in bar_range(
                self.num_tenants,
                desc='data:traffic_per_group_per_tenant_for_overlay_corrected:'
        ):
            tenant_maps = self.tenants_maps[t]
            group_count = tenant_maps['group_count']
            groups_map = tenant_maps['groups_map']

            for g in range(group_count):
                group_map = groups_map[g]
                leafs_map = group_map['leafs_map']
                pods_map = group_map['pods_map']
                pods_traffic = 0
                leafs_traffic = 0

                for p in pods_map:
                    pod_map = pods_map[p]
                    pod_leaf_count = popcount(pod_map['bitmap'])
                    pods_traffic += 4 * (pod_leaf_count - 1)

                for l in leafs_map:
                    leaf_map = leafs_map[l]
                    leaf_host_count = popcount(leaf_map['bitmap'])
                    leafs_traffic += 2 * (leaf_host_count - 1)

                traffic_per_group_per_tenant_for_overlay_corrected += [
                    (6 * len(pods_map)) + pods_traffic + leafs_traffic
                ]

        traffic_per_group_per_tenant_for_overlay_corrected = \
            pd.Series(traffic_per_group_per_tenant_for_overlay_corrected)

        return traffic_per_group_per_tenant_for_overlay_corrected
def run(nodes_map, max_bitmaps, max_nodes_per_bitmap, redundancy_per_bitmap, rules_count_map, max_rules,
        probability=1.0 * 2 / 3, num_ports_per_node=48, node_id_width=4):
    if len(nodes_map) <= max_bitmaps:
        header_size = (len(nodes_map) * (num_ports_per_node + node_id_width + 2))
        return header_size, 0

    unassigned_nodes = [n for n in nodes_map]
    num_unassigned_bitmaps = max_bitmaps

    header_size = 0

    # Assign nodes to bitmaps
    for i in range(max_bitmaps):
        num_nodes_per_bitmap = int(ceil(1.0 * len(unassigned_nodes) / num_unassigned_bitmaps))
        for k in range(min(max_nodes_per_bitmap, num_nodes_per_bitmap), 0, -1):
            min_k_bitmap, min_k_nodes = min_k_union(nodes_map, unassigned_nodes, k, probability)
            redundancy = sum([popcount(min_k_bitmap ^ nodes_map[l]['bitmap']) for l in min_k_nodes])
            if redundancy <= redundancy_per_bitmap:
                for n in min_k_nodes:
                    node = nodes_map[n]
                    node['has_bitmap'] = i
                    node['~bitmap'] = min_k_bitmap ^ node['bitmap']
                header_size += (num_ports_per_node + 1) + (k * (node_id_width + 1))
                break
            else:
                unassigned_nodes += min_k_nodes
        num_unassigned_bitmaps -= 1

    # Add a rule or assign nodes to default bitmap
    default_bitmap = 0
    for n in unassigned_nodes:
        node = nodes_map[n]
        if rules_count_map[n] < max_rules:  # Add a rule in node
            node['has_rule'] = True
            rules_count_map[n] += 1
        else:  # Assign leaf to node bitmap
            default_bitmap |= node['bitmap']

    # Calculate redundancy for nodes assigned to default bitmap
    for n in unassigned_nodes:
        node = nodes_map[n]
        if 'has_rule' not in node:
            node['~bitmap'] = default_bitmap ^ node['bitmap']

    if default_bitmap != 0:
        header_size += num_ports_per_node

    return header_size, default_bitmap
Exemplo n.º 9
0
def run(nodes_map, max_bitmaps, max_nodes_per_bitmap, redundancy_per_bitmap,
        rules_count_map, max_rules):
    if len(nodes_map) <= max_bitmaps:
        return

    unassigned_nodes = [n for n in nodes_map]
    num_unassigned_bitmaps = max_bitmaps

    # Assign nodes to bitmaps
    for i in range(max_bitmaps):
        num_nodes_per_bitmap = int(
            ceil(1.0 * len(unassigned_nodes) / num_unassigned_bitmaps))
        for k in range(min(max_nodes_per_bitmap, num_nodes_per_bitmap), 0, -1):
            min_k_bitmap, min_k_nodes = min_k_union(nodes_map,
                                                    unassigned_nodes, k)
            redundancy = sum([
                popcount(min_k_bitmap ^ nodes_map[l]['bitmap'])
                for l in min_k_nodes
            ])
            if redundancy <= redundancy_per_bitmap:
                for n in min_k_nodes:
                    node = nodes_map[n]
                    node['has_bitmap'] = i
                    node['~bitmap'] = min_k_bitmap ^ node['bitmap']
                break
            else:
                unassigned_nodes += min_k_nodes
        num_unassigned_bitmaps -= 1

    # Add a rule or assign nodes to default bitmap
    default_bitmap = 0
    for n in unassigned_nodes:
        node = nodes_map[n]
        if rules_count_map[n] < max_rules:  # Add a rule in node
            node['has_rule'] = True
            rules_count_map[n] += 1
        else:  # Assign node to default bitmap
            default_bitmap |= node['bitmap']

    # Calculate redundancy for leafs assigned to default bitmap
    for n in unassigned_nodes:
        node = nodes_map[n]
        if 'has_rule' not in node:
            node['~bitmap'] = default_bitmap ^ node['bitmap']

    return default_bitmap
Exemplo n.º 10
0
    def traffic_per_group_per_tenant_for_overlay_corrected_params(self):
        traffic_per_group_per_tenant_for_overlay_pods = []
        traffic_per_group_per_tenant_for_overlay_leafs = []
        traffic_per_group_per_tenant_for_overlay_pods_traffic = []

        for t in bar_range(
                self.num_tenants,
                desc=
                'data:traffic_per_group_per_tenant_for_overlay_corrected_params:'
        ):
            tenant_maps = self.tenants_maps[t]
            group_count = tenant_maps['group_count']
            groups_map = tenant_maps['groups_map']

            for g in range(group_count):
                group_map = groups_map[g]
                leafs_map = group_map['leafs_map']
                pods_map = group_map['pods_map']
                pods_traffic = 0

                for p in pods_map:
                    pod_map = pods_map[p]
                    pod_leaf_count = popcount(pod_map['bitmap'])
                    pods_traffic += 4 * (pod_leaf_count - 1)

                traffic_per_group_per_tenant_for_overlay_pods += [
                    len(pods_map)
                ]
                traffic_per_group_per_tenant_for_overlay_leafs += [
                    len(leafs_map)
                ]
                traffic_per_group_per_tenant_for_overlay_pods_traffic += [
                    pods_traffic
                ]

        traffic_per_group_per_tenant_for_overlay_pods = \
            pd.Series(traffic_per_group_per_tenant_for_overlay_pods)
        traffic_per_group_per_tenant_for_overlay_leafs = \
            pd.Series(traffic_per_group_per_tenant_for_overlay_leafs)
        traffic_per_group_per_tenant_for_overlay_pods_traffic = \
            pd.Series(traffic_per_group_per_tenant_for_overlay_pods_traffic)

        return traffic_per_group_per_tenant_for_overlay_pods, \
               traffic_per_group_per_tenant_for_overlay_leafs, \
               traffic_per_group_per_tenant_for_overlay_pods_traffic
Exemplo n.º 11
0
def min_k_union_random(nodes_map, nodes, k, probability):
    min_k_bitmap = 0
    min_k_nodes = []
    for _ in range(k):
        temp_nodes = nodes[:]
        while True:
            if temp_nodes:
                node = min(temp_nodes,
                           key=lambda l: popcount(nodes_map[l]['bitmap'] |
                                                  min_k_bitmap))
                if random.random() < probability:
                    break
                temp_nodes.remove(node)
            else:
                break
        nodes.remove(node)
        min_k_bitmap |= nodes_map[node]['bitmap']
        min_k_nodes += [node]
    return min_k_bitmap, min_k_nodes
Exemplo n.º 12
0
def set_cover_random(bitmap, submaps, probability):
    if reduce(lambda x, y: x | y, submaps) != bitmap:
        return None
    set_cover_bitmap = 0
    set_cover_submaps = []
    while set_cover_bitmap != bitmap:
        temp_submaps = submaps[:]
        while True:
            if temp_submaps:
                submap = max(temp_submaps,
                             key=lambda s: popcount(s & (~set_cover_bitmap)))
                if random.random() < probability:
                    break
                temp_submaps.remove(submap)
            else:
                break
        submaps.remove(submap)
        set_cover_bitmap |= submap
        set_cover_submaps += [submap]
    return set_cover_submaps
Exemplo n.º 13
0
    def traffic_per_group_per_tenant_for_baseerat_bytes(self):
        _traffic_per_group_per_tenant_for_baseerat_bytes = []

        for t in bar_range(
                self.num_tenants,
                desc='data:traffic_per_group_per_tenant_for_baseerat_bytes:'):
            tenant_maps = self.tenants_maps[t]
            group_count = tenant_maps['group_count']
            groups_map = tenant_maps['groups_map']

            for g in range(group_count):
                group_map = groups_map[g]
                leafs_map = group_map['leafs_map']
                pods_map = group_map['pods_map']
                leafs_traffic = 0
                redundant_leafs = 0
                redundant_leafs_traffic = 0

                for p in pods_map:
                    pod_map = pods_map[p]
                    if '~bitmap' in pod_map:
                        redundant_leafs += popcount(pod_map['~bitmap'])

                if 'leafs_default_bitmap' in group_map:
                    redundant_leafs_traffic = redundant_leafs * popcount(
                        group_map['leafs_default_bitmap'])

                for l in leafs_map:
                    leaf_map = leafs_map[l]
                    leafs_traffic += popcount(leaf_map['bitmap'])
                    if '~bitmap' in leaf_map:
                        leafs_traffic += popcount(leaf_map['~bitmap'])

                upstream_leaf_bits = self.num_hosts_per_leaf + self.num_spines_per_pod
                upstream_spine_bits = self.num_leafs_per_pod + self.num_cores
                core_bits = self.num_pods
                downstream_spine_bits = group_map['pods_header_size']
                downstream_leaf_bits = group_map['leafs_header_size']

                header_size_bits = (upstream_leaf_bits + upstream_spine_bits +
                                    core_bits + downstream_spine_bits +
                                    downstream_leaf_bits)

                host_to_leaf_edge_bits = header_size_bits
                leaf_to_spine_edge_bits = host_to_leaf_edge_bits - upstream_leaf_bits
                spine_to_core_edge_bits = leaf_to_spine_edge_bits - upstream_spine_bits
                core_to_spine_edge_bits = spine_to_core_edge_bits - core_bits
                spine_to_leaf_edge_bits = core_to_spine_edge_bits - downstream_spine_bits

                _traffic_per_group_per_tenant_for_baseerat_bytes += \
                    [(host_to_leaf_edge_bits +
                      leaf_to_spine_edge_bits +
                      spine_to_core_edge_bits +
                      (len(pods_map) * core_to_spine_edge_bits) +
                      (len(leafs_map) * spine_to_leaf_edge_bits) +
                      (redundant_leafs * spine_to_leaf_edge_bits)) / 8]

        _traffic_per_group_per_tenant_for_baseerat_bytes = \
            pd.Series(_traffic_per_group_per_tenant_for_baseerat_bytes)

        if self.log_dir is not None:
            _traffic_per_group_per_tenant_for_baseerat_bytes.to_csv(
                self.log_dir +
                "/traffic_per_group_per_tenant_for_baseerat_bytes.csv",
                index=False)

        return _traffic_per_group_per_tenant_for_baseerat_bytes