Example #1
0
def requests_from_json(json_data, equipment):
    requests_list = []

    for req in json_data['path-request']:
        #print(f'{req}')
        params = {}
        params['request_id'] = req['request-id']
        params['source'] = req['src-tp-id']
        params['destination'] = req['dst-tp-id']
        params['trx_type'] = req['path-constraints']['te-bandwidth'][
            'trx_type']
        params['trx_mode'] = req['path-constraints']['te-bandwidth'][
            'trx_mode']
        params['format'] = params['trx_mode']
        nd_list = req['optimizations']['explicit-route-include-objects']
        params['nodes_list'] = [
            n['unnumbered-hop']['node-id'] for n in nd_list
        ]
        params['loose_list'] = [
            n['unnumbered-hop']['hop-type'] for n in nd_list
        ]
        params['spacing'] = req['path-constraints']['te-bandwidth']['spacing']

        trx_params = trx_mode_params(equipment, params['trx_type'],
                                     params['trx_mode'], True)
        params.update(trx_params)
        params['power'] = req['path-constraints']['te-bandwidth'][
            'output-power']
        params['nb_channel'] = req['path-constraints']['te-bandwidth'][
            'max-nb-of-channel']

        requests_list.append(Path_request(**params))

    return requests_list
def requests_from_json(json_data, equipment):
    requests_list = []

    for req in json_data['path-request']:
        # init all params from request
        params = {}
        params['request_id'] = req['request-id']
        params['source'] = req['src-tp-id']
        params['destination'] = req['dst-tp-id']
        params['trx_type'] = req['path-constraints']['te-bandwidth'][
            'trx_type']
        params['trx_mode'] = req['path-constraints']['te-bandwidth'][
            'trx_mode']
        params['format'] = params['trx_mode']
        nd_list = req['optimizations']['explicit-route-include-objects']
        params['nodes_list'] = [
            n['unnumbered-hop']['node-id'] for n in nd_list
        ]
        params['loose_list'] = [
            n['unnumbered-hop']['hop-type'] for n in nd_list
        ]
        params['spacing'] = req['path-constraints']['te-bandwidth']['spacing']

        # recover trx physical param (baudrate, ...) from type and mode
        # in trx_mode_params optical power is read from equipment['SI']['default'] and
        # nb_channel is computed based on min max frequency and spacing
        trx_params = trx_mode_params(equipment, params['trx_type'],
                                     params['trx_mode'], True)
        params.update(trx_params)
        # print(trx_params['min_spacing'])
        # optical power might be set differently in the request. if it is indicated then the
        # params['power'] is updated
        if req['path-constraints']['te-bandwidth']['output-power']:
            params['power'] = req['path-constraints']['te-bandwidth'][
                'output-power']

        # same process for nb-channel
        f_min = params['f_min']
        f_max_from_si = params['f_max']
        if req['path-constraints']['te-bandwidth'][
                'max-nb-of-channel'] is not None:
            nch = req['path-constraints']['te-bandwidth']['max-nb-of-channel']
            params['nb_channel'] = nch
            spacing = params['spacing']
            params['f_max'] = f_min + nch * spacing
        else:
            params['nb_channel'] = automatic_nch(f_min, f_max_from_si,
                                                 params['spacing'])

        consistency_check(params, f_max_from_si)

        try:
            params['path_bandwidth'] = req['path-constraints']['te-bandwidth'][
                'path_bandwidth']
        except KeyError:
            pass
        requests_list.append(Path_request(**params))
    return requests_list
Example #3
0
    params = {}
    params['request_id'] = 0
    params['trx_type'] = ''
    params['trx_mode'] = ''
    params['source'] = source.uid
    params['destination'] = destination.uid
    params['nodes_list'] = [destination.uid]
    params['loose_list'] = ['strict']
    params['format'] = ''
    params['path_bandwidth'] = 0
    trx_params = trx_mode_params(equipment)
    if args.power:
        trx_params['power'] = db2lin(float(args.power))*1e-3
    params.update(trx_params)
    req = Path_request(**params)
    path, infos = main(network, equipment, source, destination, sim_params, req)
    save_network(args.filename, network)

    if args.show_channels:
        print('\nThe total SNR per channel at the end of the line is:')
        print('{:>5}{:>26}{:>26}{:>28}{:>28}{:>28}' \
            .format('Ch. #', 'Channel frequency (THz)', 'Channel power (dBm)', 'OSNR ASE (signal bw, dB)', 'SNR NLI (signal bw, dB)', 'SNR total (signal bw, dB)'))
        for final_carrier, ch_osnr, ch_snr_nl, ch_snr in zip(infos[path[-1]][1].carriers, path[-1].osnr_ase, path[-1].osnr_nli, path[-1].snr):
            ch_freq = final_carrier.frequency * 1e-12
            ch_power = lin2db(final_carrier.power.signal*1e3)
            print('{:5}{:26.2f}{:26.2f}{:28.2f}{:28.2f}{:28.2f}' \
                .format(final_carrier.channel_number, round(ch_freq, 2), round(ch_power, 2), round(ch_osnr, 2), round(ch_snr_nl, 2), round(ch_snr, 2)))

    if not args.source:
        print(f'\n(No source node specified: picked {source.uid})')