Ejemplo n.º 1
0
def run_experiment():
    network_flow_algorithm = __network_flow_algorithm(network_flow_algorithm = CURRENT_NETWORK_FLOW_ALGORITHM)

    firedex_configuration = FiredexConfiguration(
        network_flows = CURRENT_NETWORK_FLOWS,
        priorities = 0,
        network_flow_algorithm = CURRENT_NETWORK_FLOW_ALGORITHM,
        priority_algorithm = "",
        drop_rate_algorithm = "",
        rho_tolerance = 0
    )

    SUBSCRIBER = "subscriber1"
    HOST = "10.0.0.1"
    subscriptions = []

    for i in range(21):
        random_subscription = __random_subscription(SUBSCRIBER, "topic")
        subscriptions.append(random_subscription)

    network_flows = network_flow_algorithm.apply(
        firedex_configuration = firedex_configuration,
        subscriber = SUBSCRIBER,
        host = HOST,
        subscriber_subscriptions = subscriptions
    )

    mean = numpy.mean( [ subscription.utility_function() for subscription in subscriptions ] )
    variance = numpy.var( [ subscription.utility_function() for subscription in subscriptions ] )

    intra_variance = 0
    for network_flow in network_flows:
        weight = float( network_flow.subscriptions().__len__() ) / float( subscriptions.__len__() )
        current_variance = numpy.var( [ subscription.utility_function() for subscription in network_flow.subscriptions() ] )
        intra_variance += weight * current_variance

    inter_variance = 0
    for network_flow in network_flows:
        weight = float( network_flow.subscriptions().__len__() ) / float( subscriptions.__len__() )
        current_mean = numpy.mean( [ subscription.utility_function() for subscription in network_flow.subscriptions() ] )
        inter_variance += weight * ( (current_mean - mean) ** 2 )

    # print("intra-variance: ", intra_variance)
    # print("inter-variance: ", inter_variance)
    # print( intra_variance + inter_variance, variance )

    INTRA_VARIANCES.append(intra_variance)
    INTER_VARIANCES.append(inter_variance)
    VARIANCES.append(variance)
Ejemplo n.º 2
0
def push_experiment_configuration():
    json_request = request.json

    experiment_configuration = json.loads(json_request)
    network_configuration = experiment_configuration["network_configuration"]
    controller_configuration = experiment_configuration[
        "controller_configuration"]
    firedex_configuration = experiment_configuration["firedex_configuration"]

    bandwidth = network_configuration["bandwidth"]
    delay = network_configuration["delay"]
    error_rate = network_configuration["error_rate"]

    configuration.network_configuration = NetworkConfiguration(
        bandwidth=bandwidth, delay=delay, error_rate=error_rate)

    host = controller_configuration["host"]
    port = controller_configuration["port"]
    switch_identifier = controller_configuration["switch_identifier"]

    configuration.controller_configuration = ControllerConfiguration(
        host=host, port=port, switch_identifier=switch_identifier)

    network_flows = firedex_configuration["network_flows"]
    priorities = firedex_configuration["priorities"]
    network_flow_algorithm = firedex_configuration["network_flow_algorithm"]
    priority_algorithm = firedex_configuration["priority_algorithm"]
    drop_rate_algorithm = firedex_configuration["drop_rate_algorithm"]
    rho_tolerance = firedex_configuration["rho_tolerance"]

    configuration.firedex_configuration = FiredexConfiguration(
        network_flows=network_flows,
        priorities=priorities,
        network_flow_algorithm=__network_flow_algorithm(
            network_flow_algorithm=network_flow_algorithm),
        priority_algorithm=__priority_algorithm(
            priority_algorithm=priority_algorithm),
        drop_rate_algorithm=__drop_rate_algorithm(
            drop_rate_algorithm=drop_rate_algorithm),
        rho_tolerance=rho_tolerance)

    configuration.publishers_configuration = PublishersConfiguration()
    configuration.subscribers_configuration = SubscribersConfiguration()

    return jsonify({"result": "successful"})
Ejemplo n.º 3
0
def run_experiment():
    network_flow_algorithm = __network_flow_algorithm(
        network_flow_algorithm=NETWORK_FLOW_ALGORITHM)
    priority_algorithm = __priority_algorithm(
        priority_algorithm=PRIORITY_ALGORITHM)
    drop_rate_algorithm = __drop_rate_algorithm(
        drop_rate_algorithm=CURRENT_DROP_RATE_ALGORITHM)

    network_configuration = NetworkConfiguration(bandwidth=BANDWIDTH,
                                                 delay=0,
                                                 error_rate=0)

    firedex_configuration = FiredexConfiguration(
        network_flows=NETWORK_FLOWS,
        priorities=PRIORITIES,
        network_flow_algorithm=NETWORK_FLOW_ALGORITHM,
        priority_algorithm=PRIORITY_ALGORITHM,
        drop_rate_algorithm=CURRENT_DROP_RATE_ALGORITHM,
        rho_tolerance=RHO_TOLERANCE)

    TOPIC = []
    for topic_index in range(1, 21 + 1):
        TOPIC.append("topic%d" % topic_index)

    publishers_configuration = PublishersConfiguration()
    for topic in TOPIC:
        publishers_configuration.publication_collection().add_publication(
            publisher="publisher", topic=topic, rate=10, message_size=51)

    subscriptions = []

    for subscriber_index in range(SUBSCRIBERS):
        subscriber = "subscriber%d" % subscriber_index
        host = "10.0.0.%d" % subscriber_index

        for topic_index in range(1, 21 + 1):
            topic = "topic%d" % topic_index
            utility_function = __random_utility_function(0.01, 100)

            publication_collection = publishers_configuration.publication_collection(
            )
            publications_load_by_topic = publication_collection.publications_load_by_topic(
                topic=topic)
            adjusted_utility_function = float(utility_function) / float(
                publications_load_by_topic)

            random_subscription = Subscription(
                subscriber=subscriber,
                topic=topic,
                utility_function=utility_function,
                adjusted_utility_function=adjusted_utility_function)

            subscriptions.append(random_subscription)

    network_flows = []

    for subscriber_index in range(SUBSCRIBERS):
        subscriber = "subscriber%d" % subscriber_index
        host = "10.0.0.%d" % subscriber_index

        subscriber_subscriptions = __subscriber_subscriptions(
            subscriber, subscriptions)

        subscriber_network_flows = network_flow_algorithm.apply(
            firedex_configuration=firedex_configuration,
            subscriber=subscriber,
            host=host,
            subscriber_subscriptions=subscriber_subscriptions)

        network_flows.extend(subscriber_network_flows)

    priority_algorithm.apply(firedex_configuration=firedex_configuration,
                             network_flows=network_flows)

    drop_rate_algorithm.apply(
        network_configuration=network_configuration,
        firedex_configuration=firedex_configuration,
        publishers_configuration=publishers_configuration,
        network_flows=network_flows)

    sum_achieved_utility = 0
    max_achieved_utility = 0
    for network_flow in network_flows:
        sum_achieved_utility += __achieved_utility(network_flow)
        network_flow.set_drop_rate(0)
        max_achieved_utility += __achieved_utility(network_flow)

    ACHIEVED_UTILITIES.append(sum_achieved_utility)
    MAX_ACHIEVED_UTILITIES.append(max_achieved_utility)
Ejemplo n.º 4
0
def run_experiment():
    network_flow_algorithm = __network_flow_algorithm(
        network_flow_algorithm=NETWORK_FLOW_ALGORITHM)
    priority_algorithm = __priority_algorithm(
        priority_algorithm=CURRENT_PRIORITY_ALGORITHM)

    firedex_configuration = FiredexConfiguration(
        network_flows=NETWORK_FLOWS,
        priorities=CURRENT_PRIORITIES,
        network_flow_algorithm=NETWORK_FLOW_ALGORITHM,
        priority_algorithm=CURRENT_PRIORITY_ALGORITHM,
        drop_rate_algorithm="",
        rho_tolerance=0)

    subscriptions = []

    for subscriber_index in range(SUBSCRIBERS):
        subscriber = "subscriber%d" % subscriber_index
        host = "10.0.0.%d" % subscriber_index

        for i in range(21):
            random_subscription = __random_subscription(subscriber, "topic")
            subscriptions.append(random_subscription)

    network_flows = []

    for subscriber_index in range(SUBSCRIBERS):
        subscriber = "subscriber%d" % subscriber_index
        host = "10.0.0.%d" % subscriber_index

        subscriber_subscriptions = __subscriber_subscriptions(
            subscriber, subscriptions)

        subscriber_network_flows = network_flow_algorithm.apply(
            firedex_configuration=firedex_configuration,
            subscriber=subscriber,
            host=host,
            subscriber_subscriptions=subscriber_subscriptions)

        network_flows.extend(subscriber_network_flows)

    priority_algorithm.apply(firedex_configuration=firedex_configuration,
                             network_flows=network_flows)

    mean = numpy.mean(
        [network_flow.utility_function() for network_flow in network_flows])
    variance = numpy.var(
        [network_flow.utility_function() for network_flow in network_flows])

    network_flows_by_priority = __network_flows_by_priority(network_flows)

    intra_variance = 0
    for priority in network_flows_by_priority.keys():
        weight = float(network_flows_by_priority[priority].__len__()) / float(
            network_flows.__len__())
        current_variance = numpy.var([
            network_flow.utility_function()
            for network_flow in network_flows_by_priority[priority]
        ])
        intra_variance += weight * current_variance

    inter_variance = 0
    for priority in network_flows_by_priority.keys():
        weight = float(network_flows_by_priority[priority].__len__()) / float(
            network_flows.__len__())
        current_mean = numpy.mean([
            network_flow.utility_function()
            for network_flow in network_flows_by_priority[priority]
        ])
        inter_variance += weight * ((current_mean - mean)**2)

    # print("intra-variance: ", intra_variance)
    # print("inter-variance: ", inter_variance)
    # print( intra_variance + inter_variance, variance )

    INTRA_VARIANCES.append(intra_variance)
    INTER_VARIANCES.append(inter_variance)
    VARIANCES.append(variance)
Ejemplo n.º 5
0
def firedex_scenario():
    configuration.firedex_configuration = FiredexConfiguration()
    print("Firedex configuration loaded.")