diff options
-rw-r--r-- | doc/thesis/chapters/conclusions.tex | 5 | ||||
-rw-r--r-- | doc/thesis/chapters/implementation.tex | 80 | ||||
-rw-r--r-- | flowgraphs/qpsk_sim.grc | 3 | ||||
-rwxr-xr-x | flowgraphs/qpsk_sim.py | 2 | ||||
-rw-r--r-- | src/gr-fadingui/grc/fadingui_ber.block.yml | 7 | ||||
-rw-r--r-- | src/gr-fadingui/python/ber.py | 41 |
6 files changed, 120 insertions, 18 deletions
diff --git a/doc/thesis/chapters/conclusions.tex b/doc/thesis/chapters/conclusions.tex index 15697fd..30af17d 100644 --- a/doc/thesis/chapters/conclusions.tex +++ b/doc/thesis/chapters/conclusions.tex @@ -1,3 +1,8 @@ % vim: set ts=2 sw=2 noet: \chapter{Conclusions} + + +\subsection{Next Steps} + +Create some exacter calculation environment to verifite the simulation in a exacter way.
\ No newline at end of file diff --git a/doc/thesis/chapters/implementation.tex b/doc/thesis/chapters/implementation.tex index c945da9..ae4571f 100644 --- a/doc/thesis/chapters/implementation.tex +++ b/doc/thesis/chapters/implementation.tex @@ -4,6 +4,8 @@ \section{Overview} +First of all the tools which were used in this theses are interdused; software and hardware. Then the sender and receiver chain are explained in detail and how they are implemented. This both chains are the same for the simulation itself and the hardware implementation. Also the channel in details are explained which is inportent for the simulation to illustrate the multipath fading effect. After some measurements are tried, with the help of the bit error rate, to compare it with the simulation. + \section{Software Stack} \subsection{GNU Radio} @@ -240,6 +242,8 @@ def block_phase(self, start, end): Here its possible to add some AWGN noise in the channel line. Different parameters can be changed like the noise voltage, time or the frequency offset. +In this part the fading blocks for the simulation are added. Tow different types are implemented a discrete-time one and a statistical one. First to get a better understanding of the material the discrete-time modeled one and after the more realistic one, based on the Rayleight and Rician distribution. + \skelpar[5]{ Discuss the multitap FIR model we used. How it is possible to set the delay etc. Also mathematics for the interpolation. } @@ -251,28 +255,82 @@ Here its possible to add some AWGN noise in the channel line. Different paramete %For the a first simulation with some fading the 16QAM simulation model has been extended with a FIR-Filter in the Chanel. The results of this simulation are shown in \figref{fig:simul16QAM} and \figref{fig:simul16QAM_1} as the blue Signal. \subsection{Fading with Discrete-time model} -\begin{german} -%TO DO: übersetzen -Für die statische gemäss \ref{sec:discrete-time-model} implementation und veranschaulichen des Fading effekts wurde ein eigener Block kreaiert und in den Channel implementiert. Dieser Block basiert auf einem FIR Filter. Es kann mit direcktem Pfad oder ohne dargestellt werden (Line of Sight). Mit Hilfe dieses Filters wird die Verspätung, anhand Zeitlicher delay, der nebenpfaden dargestellt. Es ist möglich beliebig viele dieser Pfade mit unterschiedlicher stärke zu simulieren, solange das für jeden verspäteten Pfad eine dazugehörige Amplute angegeben wird. Leider werden diese simulationswerte nicht mit der Wircklichkeit übereinstien, da zuviele unkalkulierbaren nebeneffekte auftretten. -Dieser Block wurde zusätzlich mit der methode in \ref{sec:fractional-delay} beschriben implementiert um nichtganzahlige delay Werte zuzulassen, im vergleich zu den sampels zu erlauben, welche in \figref{fig:fractional-delay-sinc-plot} dargestellt sind. Bei dem die sinc-funktion auf kein ganzzahliges sample fählt. Was widerum bedeutet das bei den anderen abgetasteten Werten nicht null ergeben. -\end{german} + +For the statical version according to \ref{sec:discrete-time-model} to implement and illustrat the fading effect, a separate block was created and implemented in the channel. Nearer shown in \ref{lst:fir-block}. This block is based on a FIR filter. It can be displayed with a direct path or without one. With the help of this filter, the delay of the line of side paths are illustrated. In this block it is possible to simulate any number of these paths with different strengths, as long as there is an associated amplitude specified for each delayed path. Unfortunately, these simulation values do not correspond to the realety, because too many incalculable side effects occur, which aren't possiple to ilustrate in this simulation.
+This block was additionally implemented with the method described in \ref{sec:fractional-delay} to allow non-integer delay values compared to the samples shown in \figref{fig:fractional-delay-sinc-plot}. Where the sinc function does not select an integer sample. Which in turn means that the other sampled values do not add up to zero.
Thus, they will be distributed among the other whole numbers. A window function could also be implemented to limit these values. Here none was implemented because the sinc function is restricted. + +\skelpar[5]{ + Discrabe a perfect plot +} + +%\begin{german} +%Für die statische gemäss \ref{sec:discrete-time-model} implementation und veranschaulichen des Fading effekts wurde ein eigener Block kreaiert und in den Channel implementiert \ref{lst:fir-block}. Dieser Block basiert auf einem FIR Filter. Es kann mit direcktem Pfad oder ohne dargestellt werden (Line of Sight). Mit Hilfe dieses Filters wird die Verspätung, anhand Zeitlicher delay, der nebenpfaden dargestellt. Es ist möglich beliebig viele dieser Pfade mit unterschiedlicher stärke zu simulieren, solange das für jeden verspäteten Pfad eine dazugehörige Amplute angegeben wird. Leider werden diese simulationswerte nicht mit der Wircklichkeit übereinstien, da zuviele unkalkulierbaren nebeneffekte auftretten. +%Dieser Block wurde zusätzlich mit der methode in \ref{sec:fractional-delay} beschriben implementiert um nichtganzahlige delay Werte zuzulassen, im vergleich zu den sampels zu erlauben, welche in \figref{fig:fractional-delay-sinc-plot} dargestellt sind. Bei dem die sinc-funktion auf kein ganzzahliges sample fählt. Was widerum bedeutet das bei den anderen abgetasteten Werten nicht null ergeben. +%\end{german} + +\begin{lstlisting}[ + texcl = true, language = python, escapechar = {`}, + float, captionpos = b, label = {lst:fir-block}, + caption = { + Block FIR Filter function referenced in listing \ref{lst:phasecorr-work}. + }, + ] + def work(self, input_items, output_items): + inp = input_items[0] + oup = output_items[0] + # reads the moduled signal + if len(self.amplitudes) != len(self.delays): + raise Exception("Amplitudes and Delay length dont match") + if np.min(self.delays)<0: + raise Exception("Delay can't be negativ") + # Some test that there are as match delays as amplitudes and no negative filter values + max_order = 2 * np.floor(np.max(self.delays)) + 1 + # find the maximal order of the Filter + max_samples = np.arange(0, max_order +1) + max_len = len(max_samples) + sum_x = np.zeros(int(max_len)) + + for (a,d) in zip(self.amplitudes,self.delays): + order = 2 * np.floor(d) + 1 + samples = np.arange(0, order +1) + h = a*(np.sinc(samples-d)) + # impuls respond + h_len = np.concatenate([h, np.zeros(max_len-len(h))]) + sum_x += h_len + # add them al together to have one array with al amplitudes one the position of the delay (in samples) + sum_x[0] = self.los + # if there is no direct line ad the first delayed amplitude to a zero else to a one. + y = np.convolve(inp, sum_x) + y += np.concatenate([self.temp,np.zeros(len(y)-len(self.temp))]) + oup[:] = y[:len(inp)] + self.temp = y[len(inp):] + # The output need to have the same lenght as the input. + return len(oup) + +\end{lstlisting} % Bild einfügen \subsection{Fading with Statistical model} -% TO DO quellen %Compact Rayleigh and Rician fading simulator based on random walk processes
A. Alimohammad S.F. Fard B.F. Cockburn C. Schlegel
26th November 2008 + +% TODO: Quelle https://ch.mathworks.com/help/comm/ug/fading-channels.html?searchHighlight=rician%20fading&s_tid=srchtitle_rician%2520fading_2#a1070327427b1 -\ref{statistical_model} -Whit the help \begin{german} - Um den effect des multipaht fadinngs nicht nur statisch dar zu stellen, wurde ein zweites model kreiert mit hilfe des Frequency Selective Fading Models von Gnu Radio. - Welcher nach dem Algorthmus aud dem paper \cite{Alimohammad2009} - + Um den effect des multipaht fadinngs nicht nur statisch darzu stellen, wurde ein zweites model kreiert mit hilfe des Frequency Selective Fading Models von Gnu Radio, gemäss \ref{statistical_model}. + Welcher nach dem Algorthmus aud dem paper \cite{Alimohammad2009} implementiert wurde. + Um die resultate einigermassse nach vollziehen zu können wurde ein MATLAP model zur veranschaulichung erstelle. + Um ein realistisches beispiel zu haben wurden werte aus dem Skript \cite{Mathis} genomen \end{german} +Some realistic value for this block are: +The first delay when theirs non line of side is zero. The second delayed path depend on the environment of measurement. In an indoor enviroment it is usaely between \(1\cdot10^{-9}\) to \(1\cdot10^{-7}\) and in an outdoor environment between \(1\cdot10^{-7}\) to \(1\cdot10^{-5}\). The rest depends on on the bandwith + +\skelpar[5]{ + Simulation mit Werten aus dem Skript +} \subsection{Measurements} diff --git a/flowgraphs/qpsk_sim.grc b/flowgraphs/qpsk_sim.grc index e5078ea..efd8999 100644 --- a/flowgraphs/qpsk_sim.grc +++ b/flowgraphs/qpsk_sim.grc @@ -471,6 +471,7 @@ blocks: - name: fadingui_ber_0 id: fadingui_ber parameters: + address: udp://localhost:31415 affinity: '' alias: '' comment: '' @@ -480,7 +481,7 @@ blocks: bus_sink: false bus_source: false bus_structure: null - coordinate: [1184, 1300.0] + coordinate: [1184, 1292.0] rotation: 0 state: true - name: fadingui_datasource_0 diff --git a/flowgraphs/qpsk_sim.py b/flowgraphs/qpsk_sim.py index 2d135f0..f2d1a26 100755 --- a/flowgraphs/qpsk_sim.py +++ b/flowgraphs/qpsk_sim.py @@ -52,7 +52,7 @@ class qpsk_sim(gr.top_block): self.fadingui_netsink_1 = fadingui.netsink(address='udp://localhost:31418', dtype="complex", vlen=1) self.fadingui_netsink_0 = fadingui.netsink(address='udp://localhost:31416', dtype="complex", vlen=1) self.fadingui_multipath_fading_0 = fadingui.multipath_fading(amplitudes=[0.12], delays=[1.8], los =True) - self.fadingui_ber_0 = fadingui.ber(vgl=testvec + list(np.zeros(4)), vlen=frame_len) + self.fadingui_ber_0 = fadingui.ber(vgl=testvec + list(np.zeros(4)), vlen=frame_len,address='udp://localhost:31415') self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(sps, 2 * np.pi / 100, rrc_taps, 32, 16, 1.5, 1) self.digital_corr_est_cc_0 = digital.corr_est_cc(access_code_symbols, 1, len(access_code_symbols) // 2, 0.9, digital.THRESHOLD_ABSOLUTE) self.digital_constellation_modulator_0 = digital.generic_mod( diff --git a/src/gr-fadingui/grc/fadingui_ber.block.yml b/src/gr-fadingui/grc/fadingui_ber.block.yml index 3070311..477f9ff 100644 --- a/src/gr-fadingui/grc/fadingui_ber.block.yml +++ b/src/gr-fadingui/grc/fadingui_ber.block.yml @@ -4,7 +4,7 @@ category: '[fadingui]' templates: imports: import fadingui - make: fadingui.ber(vgl=${vgl}, vlen=${vlen}) + make: fadingui.ber(vgl=${vgl}, vlen=${vlen},address=${address}) # Make one 'parameters' list entry for every parameter you want settable from the GUI. # Keys include: @@ -18,6 +18,11 @@ parameters: - id: vlen label: Vec Length dtype: int +- id: address + label: Address + dtype: string + default: "udp://localhost:31415" + # Make one 'inputs' list entry per input and one 'outputs' list entry per output. # Keys include: diff --git a/src/gr-fadingui/python/ber.py b/src/gr-fadingui/python/ber.py index 5b71f35..205dcd4 100644 --- a/src/gr-fadingui/python/ber.py +++ b/src/gr-fadingui/python/ber.py @@ -19,6 +19,8 @@ # Boston, MA 02110-1301, USA. # +import socket +from urllib.parse import urlparse import numpy as np from gnuradio import gr @@ -32,7 +34,7 @@ class ber(gr.sync_block): """ docstring for block ber """ - def __init__(self, vgl, vlen): + def __init__(self, vgl, vlen, address): gr.sync_block.__init__(self, name="ber", in_sig=[np.dtype(str(vlen) + "b")], @@ -40,9 +42,34 @@ class ber(gr.sync_block): self.vgl=vgl self.vlen=vlen + # Create a socket and parse remote machine url + self.socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) + self.url = urlparse(address) + self.srv = (self.url.hostname, self.url.port) + + + def send(self, data): + """ + Send the data to self.srv + + @param data Data as python bytes + @return Number of bytes that were actually sent + """ + assert type(data) == bytes + return self.socket.sendto(data, self.srv) + + def encode(self, data): + """ + Encode the data into a dead simple format + """ + # FIXME: this could be (very) slow, is there a faster way with numpy? + # Maybe numpy.array2string + return bytes(str(data) + "\n", "ascii") + + def work(self, input_items, output_items): - inp = input_items[0] + log.debug(f"Length: {len(inp)}") log.debug(f"Inp_vector:{inp}") @@ -52,7 +79,13 @@ class ber(gr.sync_block): ber = sum(np.unpackbits(v)) trueber = ber - 32 - log.debug(f"BER {trueber if trueber > 0 else 0} in Paket {i}") + if trueber < 0: + trueber = 0 + log.debug(f"BER {trueber} in Paket {i}") + + self.send(self.encode(trueber)) + + return len(inp) - return len(input_items[0]) + #return len(input_items[0]) |