Esempio n. 1
0
    def setUp(self):
        self.payload = b'0123456789012345678901234567890123456789'
        self.packet_bytes = b'\xaa\xaa\xff\xff\xff\xff\xff\xaa\xaa\xaa\xaa' + \
            b'\xaa_=0123456789012345678901234567890123456789\x11'
        self.packet = dect.Full(self.payload)

        self.mutable_bytes = bytearray(self.packet_bytes)
        self.mutated_bytes = copy.copy(self.mutable_bytes)
        self.mutated_bytes[-1] = 0
        self.mutated_bytes[7] = 0
        self.mutated_packet = dect.Full.from_bytes(self.mutated_bytes)
Esempio n. 2
0
def run_sim() -> bool:
    # Create random dect packet
    payload = os.urandom(40)
    data = dect.Full(payload).to_bytes()

    # Run through simulation chain
    symbols = enc.encode_msb(data)
    moded = mod.modulate(symbols)
    recv, h = chnl.run(moded)
    combined, _ = diversity_technique.selection_from_power(recv)

    symbols_hat = mod.demodulate(combined)
    data_hat = enc.decode_msb(symbols_hat)

    chnl.frame_sent()

    # Check it
    return dect.Full.from_bytes(data_hat).a_field_crc_error_detected()
Esempio n. 3
0
# Copyright 2021 Christian Schneider Pedersen <*****@*****.**>, Helene Bach Vistisen, Julian Teule, Mikkel Filt Bengtson, Victor Büttner <*****@*****.**>
#
# SPDX-License-Identifier: Beerware OR MIT
import ad_path
from antenna_diversity.channel import channel_models
from antenna_diversity.diversity_technique import mrc
from antenna_diversity.encoding import SymbolEncoder
from antenna_diversity import modulation
import numpy as np
from antenna_diversity.protocols import dect

ad_path.nop()

# Create DECT packet
payload = b'0123456789012345678901234567890123456789'
dect_packet = dect.Full(payload)

# Modulate DECT packet
my_pam = modulation.PSK(2)
my_symbols = SymbolEncoder(2).encode_msb(dect_packet.to_bytes())
modulated_symbols = my_pam.modulate(my_symbols)
N = 2

# Creating the channel with N antennas and 10 snr
chnl = channel_models.RayleighAWGNChannel(N, 10)
r, h = chnl.run(modulated_symbols)
print(r)
print(h)

# Using the diversity scheme and demodulate the signal
recv = mrc(r, h)
Esempio n. 4
0
 def test_check_payload_len(self):
     with self.assertRaisesRegex(Exception, "payload is not 40 long"):
         dect.Full(b'hej')