def test_exp():
    mm = MeasMatrix() 
    mm.add('192.168.0.1', r'192.168.0.2')
    mm.add('192.168.0.2', r'NONE')

    setup_measurement(mm, '')
    
    start_qos_measurement(mm)

    time.sleep(30)
    stop_qos_measurement(mm)
    def single(use):
        host_out_dir = makeout('~/data/hidden/{}'.format(use))

        if use == 'react':
            run_react(host_out_dir, use)
        else:
            stop_react()
            stop_react2()

        udp_cm = ConnMatrix()
        cm.add('192.168.0.1', r'192.168.0.2')
        cm.add('192.168.0.2', r'NONE')
        cm.add('192.168.0.3', r'192.168.0.2')

        rtp_cm = ConnMatrix()
        cm.add('192.168.0.1', r'192.168.0.2')
        cm.add('192.168.0.2', r'NONE')

        mm = MeasMatrix()
        mm.add('192.168.0.1', r'192.168.0.2')
        mm.add('192.168.0.2', r'NONE')

        setup_measurement(mm, host_out_dir)

        print('Starting iperf servers')
        iperf_start_servers()
        print('Starting opus receivers')
        opus_start_receivers_new(host_out_dir, rtp_cm)
        print('Waiting for servers to start up')
        time.sleep(10)

        print('Starting iperf streams')
        iperf_start_clients(host_out_dir, udp_cm, tcp=False)
        print('Waiting for iperf streams to start')
        time.sleep(5)
        print('Starting opus streamers')
        opus_start_streamers_new(host_out_dir, rtp_cm)

        print('Giving stream a while to start')
        time.sleep(10)

        print('Starting Qosium')
        start_qos_measurement(mm)

        print('Waiting -- Running experiment')
        time.sleep(120)

        stop_qos_measurement(mm)
def get_MM():
    mm = MeasMatrix()
    mm.add('192.168.0.1', r'192.168.0.2')
    mm.add('192.168.0.2', r'NONE')
    return mm
    def multi(use, stream):
        host_out_dir = multi_makeout(use, stream) 
        print('OUT DIR: {}'.format(host_out_dir)) 
        if use == 'new':
            status = json.loads(fab.run(
                    '{}/reservation/reserver.py get_status {}'.format(
                    project_path, get_my_ip())))
            capacity = float(status['capacity'])/100.0
            allocation = float(status['allocation'])/100.0
            # if get_my_ip() == '192.168.0.1':
            #     allocation = 5.0/100.0
            # elif get_my_ip() == '192.168.0.2':
            #     allocation = 35.0/100.0
            # elif get_my_ip() == '192.168.0.3':
            #     allocation = 35.0/100.0
            # else:
            #     allocation = 5.0/100.0

            run_react(host_out_dir, use, capacity=capacity, prealloc=allocation)
        else:
            stop_react()
            stop_react2()

        cm = ConnMatrix()
        cm.add('192.168.0.1', last)
        cm.add(last, r'NONE')

        # congestion_cm = ConnMatrix()
        # congestion_cm.add('192.168.0.1', last)
        # congestion_cm.add(last, r'NONE')

        mm = MeasMatrix()
        mm.add('192.168.0.1', last)
        mm.add(last, r'NONE')

        setup_measurement(mm, host_out_dir)


        if stream == 'opus':
            print('Starting iperf servers')
            iperf_start_servers()
            print('Starting opus receivers')
            opus_start_receivers_new(host_out_dir, cm)
            print('Waiting for receivers to start up')
            time.sleep(10)

            # Below is the congestion streams, commented out to see RTP performance
            # print('Starting iperf streams')
            # iperf_start_clients(host_out_dir, congestion_cm, tcp=False)
            # print('Waiting for iperf streams to start')
            # time.sleep(5)
            print('Starting opus streamers')
            opus_start_streamers_new(host_out_dir, cm)

        elif stream == 'iperf':
            print('Starting iperf servers')
            iperf_start_servers()
            print('Waiting for server startup')
            time.sleep(10)

            print('Starting iperf clients -- 1G')
            iperf_start_clients(host_out_dir, cm, tcp=False)
        elif stream == 'iperf_low':
            print('Starting iperf servers')
            iperf_start_servers()
            print('Waiting for server startup')
            time.sleep(10)

            print('Starting iperf clients -- 1M')
            iperf_start_clients(host_out_dir, cm, tcp=False, rate='1M')

        print('Giving streams a while to start')
        time.sleep(10)

        print('Starting Qosium')
        start_qos_measurement(mm)

        print('Waiting -- running experiment')
        time.sleep(120)

        stop_qos_measurement(mm)