README.md 9.54 KB
Newer Older
Francois TABURET's avatar
Francois TABURET committed
1
# General
yilmazt's avatar
yilmazt committed
2
This is an RF simulator that allows to test OAI without an RF board. It replaces an actual RF board driver.
3

yilmazt's avatar
yilmazt committed
4
As much as possible, it works like an RF board, but not in real-time: It can run faster than real-time if there is enough CPU, or slower (it is CPU-bound instead of real-time RF sampling-bound).
laurent's avatar
laurent committed
5

laurent's avatar
laurent committed
6 7 8 9 10 11
It can be run either in:

- "noS1" mode: the generated IP traffic is sent and received between gNB and UE IP tunnel interfaces ("oaitun") by applications like ping and iperf
- "phy-test" mode: random UL and DL traffic is generated at every scheduling opportunity 


Francois TABURET's avatar
Francois TABURET committed
12
# build
laurent's avatar
laurent committed
13

14
## From [build_oai](../../../doc/BUILD.md) script
yilmazt's avatar
yilmazt committed
15
The RF simulator is implemented as an OAI device and always built when you build the OAI eNB or the OAI UE.
laurent's avatar
laurent committed
16

yilmazt's avatar
yilmazt committed
17
Using the `-w SIMU` option it is possible to just re-build the RF simulator device. 
laurent's avatar
laurent committed
18

19 20
Example:
```bash
21 22 23 24 25 26 27 28 29
./build_oai --UE --eNB
Will compile UE
Will compile eNB
CMAKE_CMD=cmake ..
No local radio head and no transport protocol selected
No radio head has been selected (HW set to None)
No transport protocol has been selected (TP set to None)
RF HW set to None
Flags for Deadline scheduler: False
yilmazt's avatar
yilmazt committed
30 31
......................
......................
32
Compiling rfsimulator
yilmazt's avatar
yilmazt committed
33
Log file for compilation has been written to: /usr/local/oai/rfsimu_config/openairinterface5g/cmake_targets/log/rfsimulator.Rel15.txt
34 35 36
rfsimulator compiled
......................
......................
37 38 39
```

## Add the rfsimulator after initial build
yilmazt's avatar
yilmazt committed
40
After any regular build you can compile the device from the build directory:
laurent's avatar
laurent committed
41
```bash
yilmazt's avatar
yilmazt committed
42
cd <path to oai sources>/openairinterface5g/cmake_targets/ran_build/build
laurent's avatar
laurent committed
43 44
make rfsimulator
```
yilmazt's avatar
yilmazt committed
45
This is equivalent to using `-w SIMU` when running the `build_oai` script.
laurent's avatar
laurent committed
46 47

# Usage
yilmazt's avatar
yilmazt committed
48 49 50
To use the RF simulator add the `--rfsim` option to the command line. By default the RF simulator device will try to connect to host 127.0.0.1, port 4043, which is usually the behavior for the UE.

The RF simulator is using the configuration module, and its parameters are defined in a specific section called "rfsimulator".
51 52 53 54

| parameter            | usage                                                                                                             | default |
|:---------------------|:------------------------------------------------------------------------------------------------------------------|----:|
| serveraddr           | ip address to connect to, or "enb" to behave as a tcp server                                                      | 127.0.0.1 |
yilmazt's avatar
yilmazt committed
55
| serverport           | port number to connect to or to listen on (eNB, which behaves as a tcp server)                                    | 4043 |
56 57
| options              | list of comma separated run-time options, two are supported: `chanmod` to enable channel modeling and `saviq` to write transmitted iqs to a file | all options disabled  |
| modelname            | Name of the channel model to apply on received iqs when the `chanmod` option is enabled                           | AWGN |
yilmazt's avatar
yilmazt committed
58
| IQfile               | Path to the file to be used to store iqs, when the `saviq` option is enabled                                      | /tmp/rfsimulator.iqs |
59
        
yilmazt's avatar
yilmazt committed
60
Setting the env variable RFSIMULATOR can be used instead of using the serveraddr parameter; it is to preserve compatibility with previous version.
laurent's avatar
laurent committed
61

62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
## How to use the RF simulator options

Add the following options to the command line to enable the channel model and the IQ samples saving for future replay:
```bash
--rfsimulator.options chanmod,saviq
```
or just:
```bash
--rfsimulator.options chanmod
```
to enable the channel model. 

set the model with:
```bash
--rfsimulator.modelname AWGN
```

Example run:

```bash
sudo RFSIMULATOR=server ./nr-softmodem -O ../../../targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpn300.conf --parallel-config PARALLEL_SINGLE_THREAD --rfsim --phy-test --rfsimulator.options chanmod --rfsimulator.modelname AWGN 
```

laurent's avatar
laurent committed
85
## 4G case
86

yilmazt's avatar
yilmazt committed
87
For the UE, it should be set to the IP address of the eNB. For example:
88
```bash
89
sudo RFSIMULATOR=192.168.2.200 ./lte-uesoftmodem -C 2685000000 -r 50 
90
```
yilmazt's avatar
yilmazt committed
91
For the eNB, use a valid configuration file setup for the USRP board tests and start the softmodem as usual, **but**, adding the `--rfsim` option.
laurent's avatar
laurent committed
92
```bash
93
sudo RFSIMULATOR=enb ./lte-softmodem -O <config file> --rfsim
laurent's avatar
laurent committed
94
```
yilmazt's avatar
yilmazt committed
95

yilmazt's avatar
yilmazt committed
96
Except this, the UE and the eNB can be used as if the RF is real. noS1 mode can also be used with the RF simulator.
97

yilmazt's avatar
yilmazt committed
98
If you reach 'RA not active' on UE, be careful to generate a valid SIM.
laurent's avatar
laurent committed
99 100 101
```bash
$OPENAIR_DIR/targets/bin/conf2uedata -c $OPENAIR_DIR/openair3/NAS/TOOLS/ue_eurecom_test_sfr.conf -o .
```
102

laurent's avatar
laurent committed
103
## 5G case
104

yilmazt's avatar
yilmazt committed
105 106 107
The 5G RF simulator will be aligned with the 4G as the efforts for merging the 5G specific branches into the develop make progresses.

After regular build, add the simulation driver (do not use ./build_oai -w SIMU until 4G and 5G branches are merged).
laurent's avatar
laurent committed
108 109 110 111
```bash
cd ran_build/build
make rfsimulator
```
112

laurent's avatar
laurent committed
113
### Launch gNB in one window
114

laurent's avatar
laurent committed
115
```bash
Gabriele Perrone's avatar
Gabriele Perrone committed
116
sudo RFSIMULATOR=server ./nr-softmodem -O ../../../targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpn300.conf --parallel-config PARALLEL_SINGLE_THREAD --rfsim --phy-test
laurent's avatar
laurent committed
117
```
118

laurent's avatar
laurent committed
119
### Launch UE in another window
120

laurent's avatar
laurent committed
121
```bash
122
sudo RFSIMULATOR=<TARGET_GNB_INTERFACE_ADDRESS> ./nr-uesoftmodem --rfsim --phy-test --rrc_config_path .
laurent's avatar
laurent committed
123
```
124 125 126

Notes:

Gabriele Perrone's avatar
Gabriele Perrone committed
127
1. <TARGET_GNB_INTERFACE_ADDRESS> can be 127.0.0.1 if both gNB and nrUE executables run on the same host, OR the IP interface address of the remote host running the gNB executable, if the gNB and nrUE run on separate hosts
128 129 130 131 132 133 134
2. the --rrc_config_path parameter SHALL specify where the 2 RAW files are located (`rbconfig.raw` and `reconfig.raw`).
   - If you are running on the same machine and launched the 2 executables (`nr-softmodem` and `nr-uesoftmodem`) from the same directory, nothing has to be done.
   - If you launched the 2 executables from 2 different folders, just point to the location where you launched the `nr-softmodem`:
     * `sudo RFSIMULATOR=<TARGET_GNB_INTERFACE_ADDRESS> ./nr-uesoftmodem --rfsim --phy-test --rrc_config_path /the/path/where/you/launched/nr-softmodem`
   - If you are not running on the same machine or launched the 2 executables from 2 different folders, you need to **COPY** the 2 raw files
     * `scp usera@machineA:/the/path/where/you/launched/nr-softmodem/r*config.raw userb@machineB:/the/path/where/you/will/launch/nr-uesoftmodem/`
     * Obviously this operation SHALL be done before launching the `nr-uesoftmodem` executable.
Gabriele Perrone's avatar
Gabriele Perrone committed
135
3. to enable the noS1 mode --noS1 and --nokrnmod 1 options should be added to the command line
136

137

yilmazt's avatar
yilmazt committed
138
In the UE, you can add `-d` option to get the softscope.
laurent's avatar
laurent committed
139

Gabriele Perrone's avatar
Gabriele Perrone committed
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154
### Testing IP traffic (ping and iperf)

```
ping -I oaitun_enb1 10.0.1.2 (from gNB mchine)
ping -I oaitun_ue1 10.0.1.1 (from nrUE mchine)
``` 

```iperf (Downlink):
Server nrUE machine: iperf -s -i 1 -u -B 10.0.1.2
Client gNB machine: iperf -c 10.0.1.2 -u -b 0.1M --bind 10.0.1.1
```

```iperf (Uplink):
Server gNB machine: iperf -s -i 1 -u -B 10.0.1.1
Client nrUE machine: iperf -c 10.0.1.1 -u -b 0.1M --bind 10.0.1.2
Gabriele Perrone's avatar
Gabriele Perrone committed
155
Note: iperf tests can be performed only when running gNB and nrUE on separate hosts. 
Gabriele Perrone's avatar
Gabriele Perrone committed
156 157
```

yilmazt's avatar
yilmazt committed
158
### Store and replay
159

yilmazt's avatar
yilmazt committed
160
You can store emitted I/Q samples. If you set the option `saviq`, the simulator will write all the I/Q samples into this file. Then, you can replay with the executable `replay_node`.
161

yilmazt's avatar
yilmazt committed
162 163
First compile it like other binaries:
```bash
164 165
make replay_node
```
yilmazt's avatar
yilmazt committed
166
You can use this binary as I/Q data source to feed whatever UE or gNB with recorded I/Q samples.
167

yilmazt's avatar
yilmazt committed
168
The file format is successive blocks of a header followed by the I/Q array. If you have existing stored I/Q, you can adapt the tool `replay_node` to convert your format to the rfsimulator format.
169

yilmazt's avatar
yilmazt committed
170
The format intends to be compatible with the OAI store/replay feature on USRP.
171

172
### Channel simulation
173

yilmazt's avatar
yilmazt committed
174 175 176
When the `chanmod` option is enabled, the RF channel simulator is called.

In the current version all channel parameters are set depending on the model name via a call to:
177
```bash
yilmazt's avatar
yilmazt committed
178 179
new_channel_desc_scm(bridge->tx_num_channels,
                     bridge->rx_num_channels,
yilmazt's avatar
yilmazt committed
180
                     <model name>,
yilmazt's avatar
yilmazt committed
181 182 183
                     bridge->sample_rate,
                     bridge->tx_bw,
                     0.0, // forgetting_factor
yilmazt's avatar
yilmazt committed
184 185
                     0,   // maybe used for TA
                     0);  // path_loss in dB
186
```
yilmazt's avatar
yilmazt committed
187
Only the input noise can be changed on command line with the `-s` parameter.
188

yilmazt's avatar
yilmazt committed
189
With path loss = 0 set `-s 5` to see a little noise. `-s` is a shortcut to `channelmod.s`. It is expected to enhance the channel modelization flexibility by the addition of more parameters in the channelmod section.
laurent's avatar
laurent committed
190

191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234
Example to add a very small noise:
```bash
-s 30
```
to add a lot of noise:
```bash
-s 5
```

Example run commands:
```bash
sudo RFSIMULATOR=server ./nr-softmodem -O ../../../targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpn300.conf --parallel-config PARALLEL_SINGLE_THREAD --rfsim --phy-test --rfsimulator.options chanmod --rfsimulator.modelname AWGN 

```
# Real time control and monitoring

Add the `--telnetsrv` option to the command line. Then in a new shell, connect to the telnet server, example:
```bash
telnet 127.0.0.1 9090
```
once connected it is possible to monitor the current status:
```bash
channelmod show current
```

see the available channel models:
```bash
channelmod show predef
```

or modify the channel model, for example setting a new model:
```bash
rfsimu setmodel AWGN
```
setting the pathloss, etc...:
```bash
channelmod modify <channelid> <param> <value>
channelmod modify 0 ploss 15
```
where:
```bash
<param name> can be one of "riceanf", "aoa", "randaoa", "ploss", "offset", "forgetf"
```

yilmazt's avatar
yilmazt committed
235 236
# Caveats
Still issues in power control: txgain, rxgain are not used.
237