| 1 | [[Include(WikiToC)]] |
| 2 | |
| 3 | == Basic usage == |
| 4 | |
| 5 | === Description === |
| 6 | In this tutorial we'll demonstrate how to navigate from the COSMOS sandbox to a single SDR on a node and run an application to read samples from the SDR. |
| 7 | |
| 8 | === Prerequisites === |
| 9 | In order to access the test bed, create a reservation and have it approved by the reservation service. Access to the resources are granted after the reservation is confirmed. Please follow the process shown on [wiki:CosmosOverview/Workflow the COSMOS work flow page] to get started. |
| 10 | |
| 11 | === Resources required === |
| 12 | This tutorial can be run from sb1.cosmos-lab.org using one SDR - either a PCIe-based USRP 2974 or the network based N310. |
| 13 | |
| 14 | === Tutorial Setup === |
| 15 | |
| 16 | Follow the steps below to gain access to this console and set up your node with an appropriate image. |
| 17 | |
| 18 | {{{#!td colspan=2 |
| 19 | 1. Sign up for a [https://cosmos-lab.org/portal-2/ COSMOS account]. |
| 20 | 2. [GettingStarted#MakeaReservation Create a resource reservation] for sandbox 1. |
| 21 | 3. Once reservation is approved, [wiki:GettingStarted#LogintoyourReservation login into the console]. |
| 22 | 4. Use OMF commands to [GettingStarted#ControlResourceswithOMF load baseline-uhd.ndz image] on your resource. Based on the type of SDR used follow the corresponding column. |
| 23 | }}} |
| 24 | |- |
| 25 | {{{#!td align=left style="background: #abd" |
| 26 | USRP2974 |
| 27 | }}} |
| 28 | {{{#!td align=left style="background: #acd" |
| 29 | N310 |
| 30 | }}} |
| 31 | |- |
| 32 | {{{#!td style="background: #abd" |
| 33 | {{{#!shell |
| 34 | omf load -i baseline-uhd.ndz -t sdr2-s1-lg1 |
| 35 | }}} |
| 36 | }}} |
| 37 | {{{#!td style="background: #acd" |
| 38 | {{{#!shell |
| 39 | omf load -i baseline-uhd.ndz -t srv1-lg1 |
| 40 | }}} |
| 41 | }}} |
| 42 | |- |
| 43 | {{{#!td colspan=2 |
| 44 | 5. Once the node is successfully imaged, turn it on and check the status. |
| 45 | }}} |
| 46 | |- |
| 47 | {{{#!td align=left style="background: #abd" |
| 48 | USRP2974 |
| 49 | }}} |
| 50 | {{{#!td align=left style="background: #acd" |
| 51 | N310 |
| 52 | }}} |
| 53 | |- |
| 54 | {{{#!td style="background: #abd" |
| 55 | {{{#!shell |
| 56 | omf tell -a on -t sdr2-s1-lg1 |
| 57 | omf stat -t sdr2-s1-lg1 |
| 58 | }}} |
| 59 | }}} |
| 60 | {{{#!td style="background: #acd" |
| 61 | {{{#!shell |
| 62 | omf tell -a on -t srv1-lg1 |
| 63 | omf stat -t srv1-lg1 |
| 64 | }}} |
| 65 | }}} |
| 66 | |- |
| 67 | {{{#!td colspan=2 |
| 68 | 6. After giving it some time to power up and boot, ssh to the node |
| 69 | }}} |
| 70 | |- |
| 71 | {{{#!td align=left style="background: #abd" |
| 72 | USRP2974 |
| 73 | }}} |
| 74 | {{{#!td align=left style="background: #acd" |
| 75 | N310 |
| 76 | }}} |
| 77 | |- |
| 78 | {{{#!td style="background: #abd" |
| 79 | {{{#!shell |
| 80 | ssh root@sdr2-s1-lg1 |
| 81 | }}} |
| 82 | When opening a terminal into console.sb1.cosmos-lab.org [wiki:/UserGuide/RemoteAccess/SshTunnel set up a tunnel] from localhost:5002 to sdr2-s1-lg1.sb1.cosmos-lab.org:9002. This will be used by the web app to connect to a server running on the USRP 2974(Krypton)'s host. |
| 83 | }}} |
| 84 | {{{#!td style="background: #acd" |
| 85 | {{{#!shell |
| 86 | ssh root@srv1-lg1 |
| 87 | }}} |
| 88 | When opening a terminal into console.sb1.cosmos-lab.org [wiki:/UserGuide/RemoteAccess/SshTunnel set up a tunnel] from localhost:5002 to srv1-lg1.sb1.cosmos-lab.org:9002. |
| 89 | This will be used by the web app to connect to a server running on the srv1-lg1. |
| 90 | }}} |
| 91 | |
| 92 | === Experiment Execution === |
| 93 | |
| 94 | ==== Configure and detect the radio ==== |
| 95 | |
| 96 | The USRP 2974 is a PCIe based SDR while the N310 is network based. The instructions are slightly different for setting up communications to each type of SDR. Please follow the appropriate column. |
| 97 | |
| 98 | {{{#!td align=left style="background: #abd" |
| 99 | USRP2974 |
| 100 | }}} |
| 101 | {{{#!td align=left style="background: #acd" |
| 102 | N310 |
| 103 | }}} |
| 104 | |- |
| 105 | {{{#!td style="background: #abd" |
| 106 | * The USRP 2974 requires a PCIe driver to control the FPGA with the embedded PC. In the provided images, this will load automatically on boot. If it has issues, you can run it manually via |
| 107 | {{{#!shell |
| 108 | systemctl restart niusrprio.service |
| 109 | }}} |
| 110 | |
| 111 | Detailed steps for driver installation and radio detection are on the [Resources/Notes/KryptonUsage Krypton usage page]. There is also a trouble shooting section at the bottom on that page to update the Krypton's internal firmware if necessary. |
| 112 | |
| 113 | * Run ''uhd_find_devices' and check if the X310 is detected |
| 114 | {{{#!shell |
| 115 | uhd_find_devices --args="type=x300" |
| 116 | }}} |
| 117 | |
| 118 | * Use the ''uhd_usrp_probe'' command to get more details on the x300. Specifying ''resource=rio0'' ensures only the directly connected radio is probed, instead of the radios on the network. |
| 119 | {{{#!shell |
| 120 | uhd_usrp_probe --args="resource=rio0,type=x300" |
| 121 | }}} |
| 122 | |
| 123 | }}} |
| 124 | {{{#!td style="background: #acd" |
| 125 | * The N310 requires a network interface for control. Setting up this interface is done with the standard network tools. Detailed instructions are provided on the [wiki:Resources/Notes/N310Usage N310 usage page]. |
| 126 | |
| 127 | * Display all the network interfaces |
| 128 | {{{#!shell |
| 129 | ifconfig -a |
| 130 | }}} |
| 131 | * Configure the interface and network buffers |
| 132 | {{{#!shell |
| 133 | ifconfig eno1 10.115.1.1 netmask 255.255.0.0 mtu 8000 |
| 134 | sysctl -w net.core.wmem_max=62500000 |
| 135 | sysctl -w net.core.rmem_max=62500000 |
| 136 | }}} |
| 137 | |
| 138 | |
| 139 | * Run ''uhd_find_devices' to find all the network based SDRs |
| 140 | {{{#!shell |
| 141 | uhd_find_devices --args="type=n3xx" |
| 142 | }}} |
| 143 | |
| 144 | * Use the ''uhd_usrp_probe'' command to get more details. |
| 145 | {{{#!shell |
| 146 | uhd_usrp_probe --args="mgmt_addr=10.113.2.1,addr=10.115.2.1" |
| 147 | }}} |
| 148 | |
| 149 | |
| 150 | }}} |
| 151 | |
| 152 | |
| 153 | |
| 154 | |
| 155 | |
| 156 | ==== Configure and run the application ==== |
| 157 | * Go back to SandBox1 console, download the application source code from the attachment section below and copy it to the SDR. |
| 158 | {{{#!shell-session |
| 159 | username@console:~$ wget https://wiki.cosmos-lab.org/raw-attachment/wiki/Tutorials/Wireless/BasicUsage/spectrum_view.tar.gz |
| 160 | username@console:~$ scp spectrum_view.tar.gz root@sdr2-s1-lg1:~/ |
| 161 | }}} |
| 162 | |
| 163 | * Untar the source code. |
| 164 | {{{#!shell-session |
| 165 | root@sdr2-s1-lg1:~# tar -zxvf spectrum_view.tar.gz |
| 166 | root@sdr2-s1-lg1:~# cd SPECTRUM_VIEW |
| 167 | }}} |
| 168 | |
| 169 | * Please refer to the README file in SPECTRUM_VIEW directory for instructions on compiling and running the application. Before compiling install a few required libraries. |
| 170 | {{{#!shell-session |
| 171 | root@sdr2-s1-lg1:~/SPECTRUM_VIEW# apt update |
| 172 | root@sdr2-s1-lg1:~/SPECTRUM_VIEW# apt-get -y install libboost-all-dev liblog4cxx-dev cmake libfftw3-dev libxml2-dev libpopt-dev libsqlite3-dev pkg-config libxml2-utils gnulib |
| 173 | }}} |
| 174 | |
| 175 | |
| 176 | * Now compile and make the websocket library. |
| 177 | {{{#!shell-session |
| 178 | root@sdr2-s1-lg1:~/SPECTRUM_VIEW# make websock |
| 179 | }}} |
| 180 | |
| 181 | * Lastly compile the application - this will generate the executable ''app_read_sdr_samples'' that reads samples from the SDR. |
| 182 | {{{#!shell-session |
| 183 | root@sdr2-s1-lg1:~/SPECTRUM_VIEW# make |
| 184 | }}} |
| 185 | |
| 186 | * Run the application - this will start a server that listens for commands to configure the radio and stream received spectrum samples. |
| 187 | {{{#!shell-session |
| 188 | root@sdr2-s1-lg1:~/SPECTRUM_VIEW# ./app_read_sdr_samples |
| 189 | . INFO 21:17:51.808 (main.cpp:649) - Starting command server at 5180 |
| 190 | INFO 21:17:51.808 (main.cpp:171) - Starting websock server at 9002 |
| 191 | ..... |
| 192 | }}} |
| 193 | |
| 194 | |
| 195 | ==== Visualize spectrum samples ==== |
| 196 | * Download the spectrum visualizer web client to your desktop. It is all in another zip file - ''spectrum_view.zip''. Unzip this folder and open ''spectrum_view.html'' in a Chrome browser. |
| 197 | |
| 198 | When the viewer is first opened, the page display should be similar to the following |
| 199 | || [[Image(wiki:Tutorials/Wireless/BasicUsage:basic_usage_spectrum_view_1.png, width=500px)]] || |
| 200 | |
| 201 | {{{#!td align=left style="background: #abd" |
| 202 | USRP2974 |
| 203 | }}} |
| 204 | {{{#!td align=left style="background: #acd" |
| 205 | N310 |
| 206 | }}} |
| 207 | |- |
| 208 | {{{#!td align=left style="background: #abd" |
| 209 | * Set the localhost field to ''localhost:5002''. (Recall from the set up section to create a tunnel from localhost:5002 to sdr2-s1-lg1.sb1.cosmos-lab.org:9002 since the ''app_read_sdr_samples'' application has a websock server listening on that address:port.) |
| 210 | |
| 211 | Set the device type field to ''type=x300''. |
| 212 | }}} |
| 213 | {{{#!td align=left style="background: #acd" |
| 214 | * Set the localhost field to ''localhost:5002''. (Recall from the set up section to create a tunnel from localhost:5002 to srv1-lg1.sb1.cosmos-lab.org:9002 since the ''app_read_sdr_samples'' application has a websock server listening on that address:port.) |
| 215 | |
| 216 | Set the device type field to ''type=n3xx''. |
| 217 | }}} |
| 218 | |
| 219 | |
| 220 | |
| 221 | Click the ''connect'' button once and a "Websocket Connection" statement should be output by the application. |
| 222 | |
| 223 | Now click on ''make'' to create a device handle. |
| 224 | |
| 225 | The RF radio parameters are already populated with default values for 2.4 GHz WIFI band. To view other active spectrum bands change the RATE, FREQ, GAIN fields. |
| 226 | |
| 227 | || RF Parameter || value || description || |
| 228 | || RATE || 25e6 || Sampling rate || |
| 229 | || FREQ || 2400e6 || Center frequency || |
| 230 | || GAIN || 30 || Receive gain || |
| 231 | Then click on ''Submit'' to update the SDR. |
| 232 | |
| 233 | Click on the ''Halted'' button to begin streaming samples from the radio to the browser. The button should change to ''Running'. This should display the spectrum if all went well. |
| 234 | || [[Image(wiki:Tutorials/Wireless/BasicUsage:basic_usage_spectrum_wifi_sb1.png, width=500px)]] || |
| 235 | |
| 236 | |
| 237 | ==== Troubleshooting ==== |
| 238 | * Check the troubleshooting section in the [https://wiki.cosmos-lab.org/wiki/Resources/Notes/KryptonUsage Krypton usage page] for common errors. |