Ejemplo n.º 1
0
    def test_001_t(self):
        n_frames = 20
        timeslots = 9
        subcarriers = 128
        active_subcarriers = 110
        cp_len = subcarriers // 2
        smap = get_subcarrier_map(subcarriers, active_subcarriers)
        seed = 4711
        ftype = 'rrc'
        falpha = .5

        preamble, x_preamble = mapped_preamble(seed, ftype, falpha,
                                               active_subcarriers, subcarriers,
                                               smap, 2, cp_len, cp_len // 2)
        frame_len = len(preamble) + timeslots * subcarriers + cp_len
        frame_gap = np.zeros(frame_len, dtype=np.complex)
        data = frame_gap
        ref = np.array([], dtype=np.complex)
        for i in range(n_frames):
            d_block = modulate_mapped_gfdm_block(
                get_random_qpsk(timeslots * active_subcarriers), timeslots,
                subcarriers, active_subcarriers, 2, falpha)
            frame = pinch_cp_add_block(d_block, timeslots, subcarriers, cp_len,
                                       cp_len // 2)
            frame = np.concatenate((preamble, frame))
            ref = np.concatenate((ref, frame))
            data = np.concatenate((data, frame, frame_gap))

        # print np.sum(np.abs(x_preamble) ** 2)
        # import matplotlib.pyplot as plt
        # plt.plot(data.real)
        # plt.plot(data.imag)
        # plt.show()
        backoff = 80

        src = blocks.vector_source_c(data)
        e_detector = gfdm.frame_energy_detector_cc(10., 32, frame_len, backoff,
                                                   'energy')
        detector = gfdm.simple_preamble_sync_cc(frame_len, subcarriers, cp_len,
                                                x_preamble, 'energy', 'frame')
        snk = blocks.vector_sink_c()

        self.tb.connect(src, e_detector, detector, snk)
        self.tb.run()
        # check data
        res = np.array(snk.data())
        tags = snk.tags()
        for t in tags:
            print 'srcid {}, key {}, offset {}, value {}'.format(
                t.srcid, t.key, t.offset, t.value)

        self.assertComplexTuplesAlmostEqual(res, ref[0:len(res)], 5)
Ejemplo n.º 2
0
    def test_001_t(self):
        n_frames = 20
        timeslots = 9
        subcarriers = 128
        active_subcarriers = 110
        cp_len = subcarriers // 2
        smap = get_subcarrier_map(subcarriers, active_subcarriers)
        seed = 4711
        ftype = 'rrc'
        falpha = .5
        tag_key = 'frame_start'

        preamble, x_preamble = mapped_preamble(seed, ftype, falpha,
                                               active_subcarriers, subcarriers,
                                               smap, 2, cp_len, cp_len // 2)
        block_len = timeslots * subcarriers
        offset = len(preamble) + cp_len
        frame_len = len(preamble) + timeslots * subcarriers + cp_len

        data = np.array([], dtype=np.complex)
        ref = np.array([], dtype=np.complex)
        tags = []
        print 'frame_len: ', frame_len
        for i in range(n_frames):
            d_block = modulate_mapped_gfdm_block(
                get_random_qpsk(timeslots * active_subcarriers), timeslots,
                subcarriers, active_subcarriers, 2, falpha)
            frame = pinch_cp_add_block(d_block, timeslots, subcarriers, cp_len,
                                       cp_len // 2)
            frame = np.concatenate((preamble, frame))
            r = frame[offset:offset + block_len]
            ref = np.concatenate((ref, r))
            tag = gr.tag_t()
            tag.key = pmt.string_to_symbol(tag_key)
            tag.offset = len(data)
            tag.srcid = pmt.string_to_symbol('qa')
            tag.value = pmt.from_long(block_len)
            tags.append(tag)
            data = np.concatenate((data, frame))

        src = blocks.vector_source_c(data, False, 1, tags)
        cp_rm = gfdm.remove_prefix_cc(frame_len, block_len, offset, tag_key)
        snk = blocks.vector_sink_c()
        self.tb.connect(src, cp_rm, snk)
        self.tb.run()

        # # check data
        res = np.array(snk.data())
        tags = snk.tags()
        self.assertTrue(len(tags) == 0)  # propagation policy is TPP_DONT
        self.assertComplexTuplesAlmostEqual(res, ref, 5)
Ejemplo n.º 3
0
    def test_001_t(self):
        n_frames = 20
        timeslots = 9
        subcarriers = 128
        active_subcarriers = 110
        cp_len = subcarriers // 2
        smap = get_subcarrier_map(subcarriers, active_subcarriers)
        seed = 4711
        ftype = 'rrc'
        falpha = .5
        tag_key = 'frame_start'

        preamble, x_preamble = mapped_preamble(seed, ftype, falpha, active_subcarriers, subcarriers, smap, 2, cp_len, cp_len // 2)
        block_len = timeslots * subcarriers
        offset = len(preamble) + cp_len
        frame_len = len(preamble) + timeslots * subcarriers + cp_len

        data = np.array([], dtype=np.complex)
        ref = np.array([], dtype=np.complex)
        tags = []
        print 'frame_len: ', frame_len
        for i in range(n_frames):
            d_block = modulate_mapped_gfdm_block(get_random_qpsk(timeslots * active_subcarriers), timeslots, subcarriers, active_subcarriers, 2, falpha)
            frame = pinch_cp_add_block(d_block, timeslots, subcarriers, cp_len, cp_len // 2)
            frame = np.concatenate((preamble, frame))
            r = frame[offset:offset + block_len]
            ref = np.concatenate((ref, r))
            tag = gr.tag_t()
            tag.key = pmt.string_to_symbol(tag_key)
            tag.offset = len(data)
            tag.srcid = pmt.string_to_symbol('qa')
            tag.value = pmt.from_long(block_len)
            tags.append(tag)
            data = np.concatenate((data, frame))

        src = blocks.vector_source_c(data, False, 1, tags)
        cp_rm = gfdm.remove_prefix_cc(frame_len, block_len, offset, tag_key)
        snk = blocks.vector_sink_c()
        self.tb.connect(src, cp_rm, snk)
        self.tb.run()

        # # check data
        res = np.array(snk.data())
        tags = snk.tags()
        self.assertTrue(len(tags) == 0)  # propagation policy is TPP_DONT
        self.assertComplexTuplesAlmostEqual(res, ref, 5)
Ejemplo n.º 4
0
    def test_001_t(self):
        n_frames = 20
        timeslots = 9
        subcarriers = 128
        active_subcarriers = 110
        cp_len = subcarriers // 2
        smap = get_subcarrier_map(subcarriers, active_subcarriers)
        seed = 4711
        ftype = 'rrc'
        falpha = .5

        preamble, x_preamble = mapped_preamble(seed, ftype, falpha, active_subcarriers, subcarriers, smap, 2, cp_len, cp_len // 2)
        frame_len = len(preamble) + timeslots * subcarriers + cp_len
        frame_gap = np.zeros(frame_len, dtype=np.complex)
        data = frame_gap
        ref = np.array([], dtype=np.complex)
        for i in range(n_frames):
            d_block = modulate_mapped_gfdm_block(get_random_qpsk(timeslots * active_subcarriers), timeslots, subcarriers, active_subcarriers, 2, falpha)
            frame = pinch_cp_add_block(d_block, timeslots, subcarriers, cp_len, cp_len // 2)
            frame = np.concatenate((preamble, frame))
            ref = np.concatenate((ref, frame))
            data = np.concatenate((data, frame, frame_gap))

        # print np.sum(np.abs(x_preamble) ** 2)
        # import matplotlib.pyplot as plt
        # plt.plot(data.real)
        # plt.plot(data.imag)
        # plt.show()
        backoff = 80

        src = blocks.vector_source_c(data)
        e_detector = gfdm.frame_energy_detector_cc(10., 32, frame_len, backoff, 'energy')
        detector = gfdm.simple_preamble_sync_cc(frame_len, subcarriers, cp_len, x_preamble, 'energy', 'frame')
        snk = blocks.vector_sink_c()

        self.tb.connect(src, e_detector, detector, snk)
        self.tb.run()
        # check data
        res = np.array(snk.data())
        tags = snk.tags()
        for t in tags:
            print 'srcid {}, key {}, offset {}, value {}'.format(t.srcid, t.key, t.offset, t.value)

        self.assertComplexTuplesAlmostEqual(res, ref[0:len(res)], 5)