# 5G Models

> **IMPORTANT!** The colors of each segment reflect the status *per* characteristic not the global status of this segment. If a segment is overloaded the text "overload" is shown.

This module allows to add transmission models to each segment of the map to accommodate different behaviors of wireless network transmission technologies. It enables the developer to define different models for **Latency**, **Bandwidth** and **Drop Rate** (called *characteristics*), for **Upload** and **Download** and for every **Segment**.

Whenever one of the characteristic for a client is requested every other characteristic is evaluated to check if one of them is overloaded such that no connection is possible. The thresholds for the overload are defined in [`FiveGTopologyDatabase.Entry`](https://dev.kom.e-technik.tu-darmstadt.de/gitlab/simonstrator/simonstrator-peerfactsim/blob/nr/monitoring-model/src/de/tud/kom/p2psim/impl/topology/views/fiveg/ModelBasedSegmentDatabase.java#L182)

## Configuration / Setup

The models are enabled by changing the `Database` of the `FiveGTopologyView` to `ModelBasedSegmentDatabase`. For a minimal config the `ModelBasedSegmentDatabase` needs at least a model for each characteristic. Therefore, the models are passed to the database. Each model has its specific defaults described [here](#models). In addition to that every model has parameters for `direction` (*UPLOAD*, *DOWNLOAD* or **BOTH**), `parameterType` (*BANDWIDTH*, *LATENCY* and *DROPRATE*), `segmentID` (to which segmentID this model is applied - **-1** means that it is applied to every segment) and debug (TRUE or **FALSE**). **Bold** values mark the defaults.

## Examples

> **IMPORTANT!** For every characteristic there needs to be one and *only one* default model.

### General Setup

Here the general setup for the model based segments is shown. The models are placed inside the database element.

```xml
<View class="de.tud.kom.p2psim.impl.topology.views.FiveGTopologyView" phy="UMTS" cloudGroups="Cloud">
  <Database class="de.tud.kom.p2psim.impl.topology.views.fiveg.ModelBasedSegmentDatabase" enableVis="$ENABLE_VIS" gridSize="$CELL_GRID_SIZE">
    <!-- Place model definitions here -->
  </Database>
</View>
```

### A default constant model for every characteristic

```xml
<Model class="de.tud.kom.p2psim.impl.topology.views.fiveg.models.ConstantModel" c="300" parameterType="BANDWIDTH" />
<Model class="de.tud.kom.p2psim.impl.topology.views.fiveg.models.ConstantModel" c="5" parameterType="LATENCY" />
<Model class="de.tud.kom.p2psim.impl.topology.views.fiveg.models.ConstantModel" c="0.1" parameterType="DROPRATE" />
```

For every segment the bandwidth is 300 kBit/s, the latency 5 ms and drop rate is 1% (0.1) in both directions.

### Advanced setup

```xml
<Model class="de.tud.kom.p2psim.impl.topology.views.fiveg.models.ConstantModel" c="300" parameterType="BANDWIDTH" direction="UPLOAD" />
<Model class="de.tud.kom.p2psim.impl.topology.views.fiveg.models.ConstantModel" c="10" parameterType="BANDWIDTH" direction="DOWNLOAD" />
<Model class="de.tud.kom.p2psim.impl.topology.views.fiveg.models.LogarithmicModel" a="3" b="10" c="-5" d="-10" parameterType="LATENCY" />
<Model class="de.tud.kom.p2psim.impl.topology.views.fiveg.models.ExponentialModel" parameterType="DROPRATE" />
<Model class="de.tud.kom.p2psim.impl.topology.views.fiveg.models.CutoffModel" parameterType="BANDWIDTH" segmentID="123" debug="TRUE" />
```

Every segment has 300 kBit/s upload bandwidth and 10 kBit/s download bandwidth with a constant model. The latency of every segment is equal for up- and download and is based on a logarithmic model with $`a=3`$, $`b=10`$, $`c=-5`$ and $`d=-10`$. A default exponential model is applied on the latency. At last there is a cut-off model for the bandwidth for the segment with the ID `123`. It also shows the debug graph.

## Models

* [Constant](#constant)
* [Linear](#linear)
* [Exponential](#exponential)
* [Logarithmic](#logarithmic)
* [Cut-Off](#cut-off)

### Constant

![](https://dev.kom.e-technik.tu-darmstadt.de/gitlab/simonstrator/simonstrator-peerfactsim/raw/nr/monitoring-model/src/de/tud/kom/p2psim/impl/topology/views/fiveg/models/img/constant.png)

$`c(u)=C`$

> The constant model applies the the same constant value `c` to the selected characteristic regardless of the number of hosts in the segment.

*Model-specific Parameters*:

`c` the constant value (*default* `0`)

### Linear

![](https://dev.kom.e-technik.tu-darmstadt.de/gitlab/simonstrator/simonstrator-peerfactsim/raw/nr/monitoring-model/src/de/tud/kom/p2psim/impl/topology/views/fiveg/models/img/linear.png)

$`lin(u)=a*u+b`$

*Model-specific Parameters*:

`a` the slope (*default* `1`)  
`b` y-axis intersection (*default* `0`)

### Exponential

![](https://dev.kom.e-technik.tu-darmstadt.de/gitlab/simonstrator/simonstrator-peerfactsim/raw/nr/monitoring-model/src/de/tud/kom/p2psim/impl/topology/views/fiveg/models/img/exponential.png)

$`exp(u)=a*e^{c(u-d)}+b`$

*Model-specific Parameters*:

`a` scaling factor (*default* `1`)  
`b` y-axis offset (*default* `0`)  
`c` exponent scaling (*default* `1`)  
`d` x-axis offset (*default* `0`)

### Logarithmic

![](https://dev.kom.e-technik.tu-darmstadt.de/gitlab/simonstrator/simonstrator-peerfactsim/raw/nr/monitoring-model/src/de/tud/kom/p2psim/impl/topology/views/fiveg/models/img/logarithmic.png)

$`log(u)=a*ln(c(u-d))+b`$

*Model-specific Parameters*:

`a` scaling factor (*default* `1`)  
`b` y-axis offset (*default* `0`)  
`c` logarithm scaling (*default* `1`)  
`d` x-axis offset (*default* `0`)

### Cut-Off

![](https://dev.kom.e-technik.tu-darmstadt.de/gitlab/simonstrator/simonstrator-peerfactsim/raw/nr/monitoring-model/src/de/tud/kom/p2psim/impl/topology/views/fiveg/models/img/cutoff.png)

$`cut(u)=a*\theta(c(u-d))+b`$

> The cut-off model is based on the [Heaviside step function](https://en.wikipedia.org/wiki/Heaviside_step_function).

*Model-specific Parameters*:

`a` scaling factor (*default* `1`)  
`b` y-axis offset (*default* `0`)  
`c` scaling (*default* `1`)  
`d` x-axis offset (*default* `0`)