# Some bandwidth calculations

source: Hongler's class

The goal of this chapter is to find out how much packets we can push around, to try and estimate how much ranging sequences we can do per second.

The biggest issue when doing communication is that the radio communication system we use is half duplex: as every node wants to transmit or receive on the same medium (same frequency), two nodes cannot communicate at the same time in any direction. This also means that collisions can occur and will invalidate any communications happening at the same time. Therefore, we need to evaluate the likelihood of such interferences.

We start by assuming that the probability of a packet transmission by a node in an interval $t$ is given by a memoryless law:

\begin{equation}
f(t) = \lambda e^{-\lambda t}
\end{equation}

We note $\lambda$ the average time between two ranging measurements and $\mu$ the average time it takes for a full measurement sequence to complete.

One good approximation can be given by the M/M/1 queuing theory framework. Of course this is a bit simplistic, as the shared medium cannot hold ininitely many customers. We first start by computing the load factor $\rho = \frac{\lambda}{\mu}$.

From M/M/1, we know that $p_n = (1 - \rho) \rho^n$ is the probability of having $n$ ranging transactions at the same time. We are interested in the probability of having $n > 1$, as this creates a collision.

\begin{eqnarray}
p(n>1) &=& 1 - p_0 - p_1 \\
       &=& 1 - (1 - \rho) (1 + \rho)
\end{eqnarray}

The rate of successful measurements ($\lambda'$) is given by the rate of measurement attemps multiplied by the success rate:

\begin{equation}
\lambda' = \lambda \cdot (1 - p(n>1))
\end{equation}


```python
import sympy as sp
import numpy as np
import matplotlib.pyplot as plt
sp.init_printing()
%matplotlib inline
```


```python
initiate_rate, completion_rate = sp.symbols('lambda mu')
rho = initiate_rate / completion_rate
```


```python
p_collision = 1 - (1 - rho) - (1 - rho) * rho
real_rate = (1 - p_collision) * initiate_rate
optimal_rate = sp.solve(sp.diff(real_rate, initiate_rate), initiate_rate)
optimal_rate
```


```python
real_rate_num = sp.lambdify([initiate_rate, completion_rate], real_rate)
durations = [5e-3, 10e-3, 30e-3]
legends = ['{} ms'.format(int(i * 1000)) for i in durations]
for measurement_sequence_duration in durations:
    f = lambda x: real_rate_num(x, 1 / measurement_sequence_duration)
    rates = np.logspace(0, 3, 1000)
    plt.loglog(rates, f(rates))
    optimal = 1 / (np.sqrt(3) * measurement_sequence_duration)
    print(measurement_sequence_duration, optimal,  f(optimal))

plt.xlabel('Distance measurement attempts rate $\lambda$ (Hz)')
plt.ylabel('Successful measurements $\lambda\'$ (Hz)')
#plt.title('Measurement rates for various measurements sequence duration')
plt.legend(legends)
plt.grid()
plt.savefig('measurement_rate.pdf')
```


```python

```

2c68c0d37f812f6baea6461d91c103beb5f63426
ipynb
Jupyter Notebook
uwb-beacon-firmware/doc/report/models/Bandwidth in half duplex nodes.ipynb
greck2908/robot-software
2e1e8177148a089e8883967375dde7f8ed3d878b
MIT
2016-10-04T19:59:22.000Z
2020-12-25T18:11:35.000Z
uwb-beacon-firmware/doc/report/models/Bandwidth in half duplex nodes.ipynb
greck2908/robot-software
2e1e8177148a089e8883967375dde7f8ed3d878b
MIT
2016-09-21T21:54:28.000Z
2022-01-26T07:42:37.000Z
uwb-beacon-firmware/doc/report/models/Bandwidth in half duplex nodes.ipynb
greck2908/robot-software
2e1e8177148a089e8883967375dde7f8ed3d878b
MIT
2016-11-07T14:40:16.000Z
2021-11-02T09:53:37.000Z
Qwen/Qwen-72B
1. YES
2. YES