# srsRAN installation with ZeroMQ(ZMQ)
refer sites:
[srsRAN with ZMQ Virtual Radios](https://docs.srsran.com/en/latest/app_notes/source/zeromq/source/index.html#srsran-with-zmq-virtual-radios)
[srsRAN安装部署(已支持5G NSA, 原srsLTE)](https://blog.csdn.net/BUPTOctopus/article/details/123579962)
[srsRAN Features](https://docs.srsran.com/en/latest/feature_list.html)
## ZeroMQ installation
Because we do not have USRP as RF compoment, we need to install ZMQ first.
On Ubuntu, ZeroMQ development libraries can be installed with:
```
sudo apt-get install libzmq3-dev
```
Next, you need to compile srsRAN (assuming you have already installed all the required dependencies). Note, if you have already built and installed srsRAN prior to installing ZMQ and other dependencies, you will have to re-run the make command to ensure srsRAN recognises the addition of ZMQ.
Put extra attention in the cmake console output. Make sure you read the following line:
```
...
-- FINDING ZEROMQ.
-- Checking for module 'ZeroMQ'
-- No package 'ZeroMQ' found
-- Found libZEROMQ: /usr/local/include, /usr/local/lib/libzmq.so
...
```
## Install srsGUI(optional)
srsGUI is a free and open-source graphics library for SDR using Qt and Qwt. The library provides a number of useful plots for graphing real and complex numbers. Each plot is designed to be frequently updated with new data.
srsGUI is provided under the LGPLv3 license.
Current Features:
* Real plot - simple line plot.
* Complex plot - plot including real, imaginary, magnitude and phase values.
* Scatter plot - 2-D scatter plot for complex-valued data.
* Waterfall plot - includes a line plot and waterfall plot showing past values using a colour legend.
Install the required libraries with:
```
sudo apt install libboost-system-dev libboost-test-dev libboost-thread-dev libqwt-qt5-dev qtbase5-dev
```
Finally, to download and build srsGUI, just run:
```
git clone https://github.com/srsLTE/srsGUI.git
cd srsGUI
mkdir build
cd build
cmake ../
make
make test
sudo make install
```
If you want to activate srsGUI, just modify srsRAN configuration file's [gui] section: enable=true
## UHD 4.1 Installation(optional)
Using package manager
```
sudo add-apt-repository ppa:ettusresearch/uhd
sudo apt-get update
sudo apt-get install libuhd-dev libuhd4.1.0 uhd-host
```
## Install srsRAN Requirement
on Ubuntu, one can install the required libraries with:
```
sudo apt-get install build-essential cmake libfftw3-dev libmbedtls-dev libboost-program-options-dev libconfig++-dev libsctp-dev libtool autoconf libboost-system-dev libboost-test-dev libboost-thread-dev libqwt-qt5-dev qtbase5-dev
```
## Compile and install srsRAN
```
git clone https://github.com/srsRAN/srsRAN.git
cd srsRAN
mkdir build
cd build
cmake ../
make
make test
sudo make install
sudo srsran_install_configs.sh user
```
## Running a full end-to-end LTE network on a single computer
Please refer to ["srsRAN with ZMQ Virtual Radios"](https://docs.srsran.com/en/latest/app_notes/source/zeromq/source/index.html#srsran-with-zmq-virtual-radios)
Before launching the LTE network components on a single machine we need to make sure that both UE and EPC are in different network namespaces. This is because both EPC and UE will be sharing the same network configuration, i.e. routing tables etc. Because the UE receives an IP address from the EPC’s subnet, the Linux kernel would bypass the TUN interfaces when routing traffic between both ends. Therefore, we create a separate network namespace (netns) that the UE uses to create its TUN interface in.
We only require TUN interfaces for the UE and EPC as they are the only IP endpoints in the network and need to communicate over the TCP/IP stack.
We will run each srsRAN application in a seperate terminal instance. Applications such as ping and iperf used to generate traffic will be run in separate terminals.
### Network Namespace Creation
Let’s start with creating a new network namespace called “ue1” for the (first) UE:
```
sudo ip netns add ue1
```
To verify the new “ue1” netns exists, run:
```
sudo ip netns list
```
### Running the EPC
Now let’s start the EPC. This will create a TUN device in the default network namespace and therefore needs root permissions.
```
sudo srsepc
```

### Running the eNodeB
Let’s now launch the eNodeB. We use the default configuration in this example and pass all parameters that need to be tweaked for ZMQ through as command line arguments. If you want to make those persistent just add them to your local enb.conf.
```
sudo srsenb --rf.device_name=zmq --rf.device_args="fail_on_disconnect=true,tx_port=tcp://*:2000,rx_port=tcp://localhost:2001,id=enb,base_srate=23.04e6"
```

### Running the UE
Lastly we can launch the UE, again with root permissions to create the TUN device.
```
sudo srsue --rf.device_name=zmq --rf.device_args="tx_port=tcp://*:2001,rx_port=tcp://localhost:2000,id=ue,base_srate=23.04e6" --gw.netns=ue1
```
The command should start the UE and attach it to the core network. The UE will be assigned an IP address in the configured range (e.g. 172.16.0.2).

### Traffic Generation
To exchange traffic in the downlink direction, i.e. from the the EPC, just run ping or iperf as usual on the command line, e.g.:
```
ping 172.16.0.2
```
In order to generate traffic in the uplink direction it is important to run the ping command in the UE’s network namespace.
```
sudo ip netns exec ue1 ping 172.16.0.1
```
### About srsGUI
If you have enabled srsGUI in srsRAN configuration files, you can see the auto-launched windows of srsenb and srsue.


Known issues
For a clean tear down, the UE needs to be terminated first, then the eNB.
eNB and UE can only run once, after the UE has been detached, the eNB needs to be restarted.
And currently only support a single eNB and a single UE.