Exemple #1
0
    def test_001_t(self):
        num_frames = 5
        total_subcarriers = 8
        used_subcarriers = 4
        channel_map = ft.get_channel_map(used_subcarriers, total_subcarriers)
        payload_symbols = 8
        overlap = 4
        num_preamble_symbols = 4

        payload = ft.get_payload(payload_symbols, used_subcarriers)
        frame = ft.get_frame(payload, total_subcarriers, channel_map, payload_symbols, overlap)
        frame = np.tile(frame, num_frames).flatten()
        payload = np.tile(payload, num_frames).flatten()

        # set up fg
        src = blocks.vector_source_c(frame, repeat=False, vlen=total_subcarriers)
        deframer = fbmc.deframer_vcb(used_subcarriers, total_subcarriers, num_preamble_symbols, payload_symbols, overlap, channel_map)
        snk = blocks.vector_sink_b(1)
        self.tb.connect(src, deframer, snk)
        self.tb.run()

        # check data
        res = np.array(snk.data())
        print res
        print payload

        self.assertTupleEqual(tuple(payload), tuple(res))
Exemple #2
0
    def test_001_frames(self):
        num_frames = 501
        total_subcarriers = 8
        used_subcarriers = 4
        channel_map = ft.get_channel_map(used_subcarriers, total_subcarriers)
        payload_symbols = 8
        overlap = 4

        preamble = ft.get_preamble(total_subcarriers)
        num_preamble_symbols = len(preamble) // total_subcarriers
        payload = ft.get_payload(payload_symbols, used_subcarriers)
        payload = np.tile(payload, num_frames).flatten()

        src = blocks.vector_source_b(payload, repeat=False)
        framer = fbmc.frame_generator_bvc(used_subcarriers, total_subcarriers,
                                          payload_symbols, overlap,
                                          channel_map, preamble)
        deframer = fbmc.deframer_vcb(used_subcarriers, total_subcarriers,
                                     num_preamble_symbols, payload_symbols,
                                     overlap, channel_map)
        snk = blocks.vector_sink_b(1)
        self.tb.connect(src, framer, deframer, snk)
        self.tb.run()

        res = np.array(snk.data())
        print res
        print payload

        self.assertTupleEqual(tuple(payload), tuple(res))
Exemple #3
0
    def test_001_frames(self):
        num_frames = 501
        total_subcarriers = 8
        used_subcarriers = 4
        channel_map = ft.get_channel_map(used_subcarriers, total_subcarriers)
        payload_symbols = 8
        overlap = 4

        preamble = ft.get_preamble(total_subcarriers)
        num_preamble_symbols = len(preamble) // total_subcarriers
        payload = ft.get_payload(payload_symbols, used_subcarriers)
        payload = np.tile(payload, num_frames).flatten()

        src = blocks.vector_source_b(payload, repeat=False)
        framer = fbmc.frame_generator_bvc(used_subcarriers, total_subcarriers, payload_symbols, overlap, channel_map, preamble)
        deframer = fbmc.deframer_vcb(used_subcarriers, total_subcarriers, num_preamble_symbols, payload_symbols, overlap, channel_map)
        snk = blocks.vector_sink_b(1)
        self.tb.connect(src, framer, deframer, snk)
        self.tb.run()

        res = np.array(snk.data())
        print res
        print payload

        self.assertTupleEqual(tuple(payload), tuple(res))
    def test_001_t(self):
        num_frames = 10
        total_subcarriers = 8
        used_subcarriers = 4
        channel_map = ft.get_channel_map(used_subcarriers, total_subcarriers)
        payload_symbols = 8
        overlap = 4

        preamble = ft.get_preamble(total_subcarriers)

        payload = ft.get_payload(payload_symbols, used_subcarriers)
        frame = ft.get_frame(payload, total_subcarriers, channel_map, payload_symbols, overlap)

        frame = np.tile(frame, num_frames).flatten()
        payload = np.tile(payload, num_frames).flatten()

        # create and connect blocks
        src = blocks.vector_source_b(payload, repeat=False)
        framer = fbmc.frame_generator_bvc(used_subcarriers, total_subcarriers, payload_symbols, overlap, channel_map, preamble)
        snk = blocks.vector_sink_c(total_subcarriers)
        self.tb.connect(src, framer, snk)

        print "framer.channel_map() = ", framer.channel_map()
        # run fg
        self.tb.run()
        # check data

        res = np.array(snk.data())
        # print np.reshape(res.astype(float), (-1, total_subcarriers)).T
        print "len(frame) =", len(frame)
        print "len(res)   =", len(res)

        self.assertComplexTuplesAlmostEqual(frame, res[0:len(frame)])
Exemple #5
0
    def test_001_t(self):
        num_frames = 5
        total_subcarriers = 8
        used_subcarriers = 4
        channel_map = ft.get_channel_map(used_subcarriers, total_subcarriers)
        payload_symbols = 8
        overlap = 4
        num_preamble_symbols = 4

        payload = ft.get_payload(payload_symbols, used_subcarriers)
        frame = ft.get_frame(payload, total_subcarriers, channel_map,
                             payload_symbols, overlap)
        frame = np.tile(frame, num_frames).flatten()
        payload = np.tile(payload, num_frames).flatten()

        # set up fg
        src = blocks.vector_source_c(frame,
                                     repeat=False,
                                     vlen=total_subcarriers)
        deframer = fbmc.deframer_vcb(used_subcarriers, total_subcarriers,
                                     num_preamble_symbols, payload_symbols,
                                     overlap, channel_map)
        snk = blocks.vector_sink_b(1)
        self.tb.connect(src, deframer, snk)
        self.tb.run()

        # check data
        res = np.array(snk.data())
        print res
        print payload

        self.assertTupleEqual(tuple(payload), tuple(res))
Exemple #6
0
    def test_003_small_frame_mod(self):
        num_frames = 300
        total_subcarriers = 8
        used_subcarriers = 4
        channel_map = np.array(
            (0, 0, 1, 1, 1, 1, 0,
             0))  #ft.get_channel_map(used_subcarriers, total_subcarriers)
        payload_symbols = 8
        overlap = 4
        taps = ft.generate_phydyas_filter(total_subcarriers, overlap)

        preamble = ft.get_preamble(total_subcarriers)
        num_preamble_symbols = len(preamble) // total_subcarriers
        payload = ft.get_payload(payload_symbols, used_subcarriers)
        payload = np.tile(payload, num_frames).flatten()

        src = blocks.vector_source_b(payload, repeat=False)
        framer = fbmc.frame_generator_bvc(used_subcarriers, total_subcarriers,
                                          payload_symbols, overlap,
                                          channel_map, preamble)
        snk_frame = blocks.vector_sink_c(total_subcarriers)  # a debug output

        mod = fbmc.tx_sdft_vcc(taps, total_subcarriers)
        demod = fbmc.rx_sdft_cvc(taps, total_subcarriers)
        skipper = blocks.skiphead(8 * total_subcarriers, 4)

        snk_rx = blocks.vector_sink_c(total_subcarriers)
        deframer = fbmc.deframer_vcb(used_subcarriers, total_subcarriers,
                                     num_preamble_symbols, payload_symbols,
                                     overlap, channel_map)
        snk = blocks.vector_sink_b(1)
        self.tb.connect(src, framer, mod, demod, skipper, deframer, snk)
        self.tb.connect(framer, snk_frame)
        self.tb.connect(skipper, snk_rx)
        self.tb.run()

        res = np.array(snk.data())
        print "len(res) = ", len(res), ", len(payload) = ", len(payload)
        print "ref: ", payload
        print "res: ", res

        moddata = np.array(snk_frame.data())
        print "len(moddata) = ", len(moddata)
        rxdata = np.array(snk_rx.data())
        print "len(rxdata) = ", len(
            rxdata), " diff: ", len(moddata) - len(rxdata)

        # plt.plot(rxdata.real * 0.03)
        # for i in range(len(moddata)):
        #     if (i + 1) % total_subcarriers == 0:
        #         plt.axvline(i)
        # plt.plot(moddata.real)
        # plt.grid()
        # plt.show()

        print "len(payload) = ", len(payload)
        print "len(result ) = ", len(res)

        self.assertTupleEqual(tuple(payload[:len(res)]), tuple(res))
Exemple #7
0
    def test_004_config_frame_mod(self):
        num_frames = 10
        cfg = fbmc.fbmc_config(num_used_subcarriers=20, num_payload_sym=16, num_overlap_sym=4, modulation="QPSK",
                                    preamble="IAM", samp_rate=250000)
        total_subcarriers = cfg.num_total_subcarriers()  # 8
        used_subcarriers = cfg.num_used_subcarriers()  # 4
        channel_map = cfg.channel_map()  # ft.get_channel_map(used_subcarriers, total_subcarriers)
        payload_symbols = cfg.num_payload_sym()  # 8
        overlap = cfg.num_overlap_sym()  # 4
        taps = cfg.phydyas_impulse_taps(cfg.num_total_subcarriers(), cfg.num_overlap_sym())  # ft.generate_phydyas_filter(total_subcarriers, overlap)

        preamble = ft.get_preamble(total_subcarriers)
        num_preamble_symbols = len(preamble) // total_subcarriers
        payload = ft.get_payload(payload_symbols, used_subcarriers)
        payload = np.tile(payload, num_frames).flatten()

        src = blocks.vector_source_b(payload, repeat=False)
        framer = fbmc.frame_generator_bvc(used_subcarriers, total_subcarriers, payload_symbols, overlap, channel_map, preamble)
        snk_frame = blocks.vector_sink_c(total_subcarriers)  # a debug output

        mod = fbmc.tx_sdft_vcc(taps, total_subcarriers)
        demod = fbmc.rx_sdft_cvc(taps, total_subcarriers)
        skipper = blocks.skiphead(8 * total_subcarriers, 4)

        snk_rx = blocks.vector_sink_c(total_subcarriers)
        deframer = fbmc.deframer_vcb(used_subcarriers, total_subcarriers, num_preamble_symbols, payload_symbols, overlap, channel_map)
        snk = blocks.vector_sink_b(1)
        self.tb.connect(src, framer, mod, demod, skipper, deframer, snk)
        self.tb.connect(framer, snk_frame)
        self.tb.connect(skipper, snk_rx)
        self.tb.run()

        res = np.array(snk.data())
        print res
        print payload

        moddata = np.array(snk_frame.data())
        print "len(moddata) = ", len(moddata)
        rxdata = np.array(snk_rx.data())
        print "len(rxdata) = ", len(rxdata)

        # plt.plot(rxdata.real * 0.03)
        # for i in range(len(moddata)):
        #     if (i + 1) % total_subcarriers == 0:
        #         plt.axvline(i)
        # plt.plot(moddata.real)
        # plt.grid()
        # plt.show()

        print "len(payload) = ", len(payload)
        print "len(result)  = ", len(res)

        self.assertTupleEqual(tuple(payload[:len(res)]), tuple(res))
Exemple #8
0
    def test_003_small_frame_mod(self):
        num_frames = 300
        total_subcarriers = 8
        used_subcarriers = 4
        channel_map = np.array((0, 0, 1, 1, 1, 1, 0, 0)) #ft.get_channel_map(used_subcarriers, total_subcarriers)
        payload_symbols = 8
        overlap = 4
        taps = ft.generate_phydyas_filter(total_subcarriers, overlap)

        preamble = ft.get_preamble(total_subcarriers)
        num_preamble_symbols = len(preamble) // total_subcarriers
        payload = ft.get_payload(payload_symbols, used_subcarriers)
        payload = np.tile(payload, num_frames).flatten()


        src = blocks.vector_source_b(payload, repeat=False)
        framer = fbmc.frame_generator_bvc(used_subcarriers, total_subcarriers, payload_symbols, overlap, channel_map, preamble)
        snk_frame = blocks.vector_sink_c(total_subcarriers)  # a debug output

        mod = fbmc.tx_sdft_vcc(taps, total_subcarriers)
        demod = fbmc.rx_sdft_cvc(taps, total_subcarriers)
        skipper = blocks.skiphead(8 * total_subcarriers, 4)

        snk_rx = blocks.vector_sink_c(total_subcarriers)
        deframer = fbmc.deframer_vcb(used_subcarriers, total_subcarriers, num_preamble_symbols, payload_symbols, overlap, channel_map)
        snk = blocks.vector_sink_b(1)
        self.tb.connect(src, framer, mod, demod, skipper, deframer, snk)
        self.tb.connect(framer, snk_frame)
        self.tb.connect(skipper, snk_rx)
        self.tb.run()

        res = np.array(snk.data())
        print "len(res) = ", len(res), ", len(payload) = ", len(payload)
        print "ref: ", payload
        print "res: ", res

        moddata = np.array(snk_frame.data())
        print "len(moddata) = ", len(moddata)
        rxdata = np.array(snk_rx.data())
        print "len(rxdata) = ", len(rxdata), " diff: ", len(moddata) - len(rxdata)

        # plt.plot(rxdata.real * 0.03)
        # for i in range(len(moddata)):
        #     if (i + 1) % total_subcarriers == 0:
        #         plt.axvline(i)
        # plt.plot(moddata.real)
        # plt.grid()
        # plt.show()

        print "len(payload) = ", len(payload)
        print "len(result ) = ", len(res)

        self.assertTupleEqual(tuple(payload[:len(res)]), tuple(res))
Exemple #9
0
    def test_001_t(self):
        num_frames = 10
        total_subcarriers = 8
        used_subcarriers = 4
        channel_map = ft.get_channel_map(used_subcarriers, total_subcarriers)
        payload_symbols = 8
        overlap = 4

        preamble = ft.get_preamble(total_subcarriers)

        payload = ft.get_payload(payload_symbols, used_subcarriers)
        frame = ft.get_frame(payload, total_subcarriers, channel_map,
                             payload_symbols, overlap)

        frame = np.tile(frame, num_frames).flatten()
        payload = np.tile(payload, num_frames).flatten()

        # create and connect blocks
        src = blocks.vector_source_b(payload, repeat=False)
        framer = fbmc.frame_generator_bvc(used_subcarriers, total_subcarriers,
                                          payload_symbols, overlap,
                                          channel_map, preamble)
        snk = blocks.vector_sink_c(total_subcarriers)
        self.tb.connect(src, framer, snk)

        print "framer.channel_map() = ", framer.channel_map()
        # run fg
        self.tb.run()
        # check data

        res = np.array(snk.data())
        # print np.reshape(res.astype(float), (-1, total_subcarriers)).T
        print "len(frame) =", len(frame)
        print "len(res)   =", len(res)

        self.assertComplexTuplesAlmostEqual(frame, res[0:len(frame)])
Exemple #10
0
    def test_004_config_frame_mod(self):
        num_frames = 10
        cfg = fbmc.fbmc_config(num_used_subcarriers=20,
                               num_payload_sym=16,
                               num_overlap_sym=4,
                               modulation="QPSK",
                               preamble="IAM",
                               samp_rate=250000)
        total_subcarriers = cfg.num_total_subcarriers()  # 8
        used_subcarriers = cfg.num_used_subcarriers()  # 4
        channel_map = cfg.channel_map(
        )  # ft.get_channel_map(used_subcarriers, total_subcarriers)
        payload_symbols = cfg.num_payload_sym()  # 8
        overlap = cfg.num_overlap_sym()  # 4
        taps = cfg.phydyas_impulse_taps(
            cfg.num_total_subcarriers(), cfg.num_overlap_sym(
            ))  # ft.generate_phydyas_filter(total_subcarriers, overlap)

        preamble = ft.get_preamble(total_subcarriers)
        num_preamble_symbols = len(preamble) // total_subcarriers
        payload = ft.get_payload(payload_symbols, used_subcarriers)
        payload = np.tile(payload, num_frames).flatten()

        src = blocks.vector_source_b(payload, repeat=False)
        framer = fbmc.frame_generator_bvc(used_subcarriers, total_subcarriers,
                                          payload_symbols, overlap,
                                          channel_map, preamble)
        snk_frame = blocks.vector_sink_c(total_subcarriers)  # a debug output

        mod = fbmc.tx_sdft_vcc(taps, total_subcarriers)
        demod = fbmc.rx_sdft_cvc(taps, total_subcarriers)
        skipper = blocks.skiphead(8 * total_subcarriers, 4)

        snk_rx = blocks.vector_sink_c(total_subcarriers)
        deframer = fbmc.deframer_vcb(used_subcarriers, total_subcarriers,
                                     num_preamble_symbols, payload_symbols,
                                     overlap, channel_map)
        snk = blocks.vector_sink_b(1)
        self.tb.connect(src, framer, mod, demod, skipper, deframer, snk)
        self.tb.connect(framer, snk_frame)
        self.tb.connect(skipper, snk_rx)
        self.tb.run()

        res = np.array(snk.data())
        print res
        print payload

        moddata = np.array(snk_frame.data())
        print "len(moddata) = ", len(moddata)
        rxdata = np.array(snk_rx.data())
        print "len(rxdata) = ", len(rxdata)

        # plt.plot(rxdata.real * 0.03)
        # for i in range(len(moddata)):
        #     if (i + 1) % total_subcarriers == 0:
        #         plt.axvline(i)
        # plt.plot(moddata.real)
        # plt.grid()
        # plt.show()

        print "len(payload) = ", len(payload)
        print "len(result)  = ", len(res)

        self.assertTupleEqual(tuple(payload[:len(res)]), tuple(res))