def cloudlab_config(cca,
                    end_time,
                    queue_size=1024,
                    btlbw=10,
                    rtt=40,
                    kind='iperf'):
    config = {}
    config['server'] = dict(HOST_SERVER._asdict())
    config['client'] = dict(HOST_CLIENT._asdict())
    config['experiments'] = {}

    num_flows = [1]
    # cca alone experiments
    for num_cca_flows in num_flows:
        experiment_name = '{}{}-{}bw-{}rtt-{}q'.format(cca, num_cca_flows,
                                                       btlbw, rtt, queue_size)
        experiment = {'btlbw': btlbw, 'queue_size': queue_size}
        experiment['flows'] = [{
            'ccalg': cca,
            'start_time': 0,
            'end_time': end_time,
            'rtt': rtt,
            'kind': kind
        } for _ in range(num_cca_flows)]
        config['experiments'][experiment_name] = experiment
    return config
def cubic_bbr_bdp_config(server, client, end_time):
    config = {}
    config['server'] = HOST_SERVER._as_dict()
    config['client'] = client
    config['experiments'] = {}

    #experiment_params = [{'btlbw':400, 'rtt':30, 'bdp':1024},
    #                     {'btlbw':10, 'rtt':3, 'bdp':4}]

    experiment_params = [{
        'btlbw': 100,
        'rtt': 1,
        'bdp': 8
    }, {
        'btlbw': 15,
        'rtt': 100,
        'bdp': 128
    }, {
        'btlbw': 120,
        'rtt': 100,
        'bdp': 1024
    }]
    #{'btlbw':400, 'rtt':30, 'bdp':1024},
    #{'btlbw':10, 'rtt':3, 'bdp':4}]

    for params in experiment_params:
        btlbw = params['btlbw']
        rtt = params['rtt']
        bdp = params['bdp']
        queue_sizes_as_bdp = [0.25, 0.5, 1.0, 4.0, 16.0]
        queue_sizes = list(map(lambda x: x * bdp, queue_sizes_as_bdp))

        for size in queue_sizes:
            if size >= 4:
                experiment_name = 'cubic-bbr-{}bw-{}rtt-{}q'.format(
                    btlbw, rtt, int(size))
                experiment = {'btlbw': btlbw, 'queue_size': int(size)}
                cubic_flows = [{
                    'ccalg': 'cubic',
                    'start_time': 0,
                    'end_time': end_time,
                    'rtt': rtt
                }]
                bbr_flows = [{
                    'ccalg': 'bbr',
                    'start_time': 0,
                    'end_time': end_time,
                    'rtt': rtt
                }]
                experiment['flows'] = cubic_flows + bbr_flows
                config['experiments'][experiment_name] = experiment
    return config
def ccalg_predict_config(btlbw,
                         rtts,
                         end_time,
                         queue_sizes,
                         exp_name_suffix=None,
                         ccalgs=None,
                         loss=None):
    config = {}
    config['server'] = HOST_SERVER._asdict()
    config['client'] = HOST_CLIENT._asdict()
    config['experiments'] = {}

    if ccalgs is None:
        ccalgs = ['bbr', 'cubic', 'reno']
    if loss is None:
        loss = [None]
    for rtt in rtts:
        for queue_size in queue_sizes:
            for ccalg in ccalgs:
                for loss_rate in loss:
                    if exp_name_suffix is None:
                        experiment_name = '{}-{}bw-{}rtt-{}q'.format(
                            ccalg, btlbw, rtt, int(queue_size))
                    else:
                        experiment_name = '{}-{}bw-{}rtt-{}q-{}'.format(
                            ccalg, btlbw, rtt, int(queue_size),
                            exp_name_suffix)

                    if loss_rate is not None:
                        experiment_name = '{}-{}bw-{}rtt-{}q-{}loss-{}'.format(
                            ccalg, btlbw, rtt, int(queue_size),
                            float(loss_rate), exp_name_suffix)
                        experiment = {
                            'btlbw': btlbw,
                            'queue_size': int(queue_size),
                            'loss_rate': float(loss_rate)
                        }
                    else:
                        experiment = {
                            'btlbw': btlbw,
                            'queue_size': int(queue_size)
                        }
                    flows = [{
                        'ccalg': ccalg,
                        'start_time': 0,
                        'end_time': end_time,
                        'rtt': int(rtt)
                    }]
                    experiment['flows'] = flows
                    config['experiments'][experiment_name] = experiment
    return config