Version 26 (modified by 10 years ago) ( diff ) | ,
---|
Spectrum sensing with USRP2
Table of Contents
- SDR Tutorials
Description
In this tutorial we'll use the USRPs on the grid for FFT-based spectrum sensing. Each USRP (centered on a frequency with specified bandwidth) will collect data into an OML server for post processing. For details on available USRP2s on the grid, please check inventory status.
Hardware / Software Resources utilized
- Grid nodes with a USRP2 connect via Ethernet.
- ubuntu-12-04-uhd.ndz: disk image loaded onto nodes. This image has all the precompiled - software required to configure the USRPs and analyze recorded data. The USRP2's interface with the node is already configured.
- spectrum: application on node to set up & collect data from USRP2 and send to OML server / local file for recording in database file.
- spectrum_console: application on console to configure & initiate spectrum sense application on node.
- Orbit's Arbitrary Waveform Injection System: used to inject noise or simple signal into RF environment. More information of this generator can be found here.
Set up
- To get started first make a reservation on the Orbit Scheduler for using the Grid.
- After logging into grid console, make sure all nodes are turned off
nilanjan@console.grid:~$ omf tell -a offh -t system:topo:n210
- Verify state of node before continuing. Make sure all nodes are in the POWEROFF state.
nilanjan@console.grid:~$ omf stat
- Image nodes
nilanjan@console.grid:~$ omf load -i ubuntu-12-04-uhd.ndz -t system:topo:n210 -r 20
- After nodes are imaged, verify that nodes are in POWEROFF state. Otherwise issue the following to turn them off for a reboot
nilanjan@console.grid:~$ omf tell -a offh -t system:topo:n210
- Turn nodes back on and verify they are in POWERON state
nilanjan@console.grid:~$ omf tell -a on -t system:topo:n210
- Before proceeding, download the spectrum console application code to your local directory. This is the application that will invoke the application to configure the USRP on the nodes.
- Compile the application code.
nilanjan@console.grid:~/UHD/SPECTRUM/w$ g++ spectrum_console.cpp -lboost_program_options-mt -loml2 -o spectrum_console
Spectrum sensing with multiple nodes at different frequencies
- To view the available parameters for the console application
nilanjan@console.grid:~/UHD/SPECTRUM/w$ ./spectrum_console --help
- The first run will demonstrate how to use the sensing application on multiple nodes centered at different frequencies. In this case we will not inject noise into the environment. Check the following page to view nodes corresponding to usrp n210.
In this case we'll be sensing on node3-3, node8-8, node13-13 on the frequencies 5.0 GHz, 5.1 GHz, 5.2 GHz respectively.
Sampling rate option (—rate 8e6) yields a bandwidth of 4MHz.
The fft size (—num-bins 1024) corresponds to a 1024 point fft.
The time option (—time 5) runs the application for 5 seconds. Since the —oml file option is used the collected data will be store on the node locally.
nilanjan@console.grid:~/UHD/SPECTRUM/w$ ./spectrum_console --rate 8e6 --num-bins 1024 --time 5 --oml file --node node3-3,node8-8,node13-13 --freq 5.0e9,5.1e9,5.2e9
- The recorded spectrum data is stored in a file under the root directory on each of the nodes. Copy that data file from the node to the console and check the contents. Each node will have its own file: /root/spectrum_nodex-y.
The following will copy the data collect from node3-3 to the console.nilanjan@console.grid:~/UHD/SPECTRUM/w$ scp root@node8-8:/root/spectrum_node8-8 .
- The contents of the file is very long and is in a database format. The full contents of an example run can be view here.
- Plot of the noise floor at 5.0GHz, 5.1GHZ and 5.2 GHz is shown below.
Frequency detection with multiple nodes
- This will demonstrate using the waveform generator to create a signal at 5.002 GHz and using the USRPs to detect & record the signal. From the grid console enter the following to configure & run the waveform generator at 5.002 GHz with a -1 dBm power level.
nilanjan@console.grid:~/UHD/SPECTRUM/w$ wget -qO- http://instrument1.orbit-lab.org:5054/interference/initialize OK nilanjan@console.grid:~/UHD/SPECTRUM/w$ wget -qO- http://instrument1.orbit-lab.org:5054/interference/set?frequency=5.002\&power=-1 OK nilanjan@console.grid:~/UHD/SPECTRUM/w$ wget -qO- http://instrument1.orbit-lab.org:5054/interference/start OK
- Now use the node3-3, node8-8 and nod13-13 to record data at frequency 5.0 GHz with a sampling rate of 8e6.
nilanjan@console.grid:~/UHD/SPECTRUM/w$ ./spectrum_console --rate 8e6 --num-bins 1024 --time 5 --oml file --node node3-3,node8-8,node13-13 --freq 5.0e9
- After the application as completed turn off the waveform generator.
nilanjan@console.grid:~/UHD/SPECTRUM/w$ wget -qO- http://instrument1.orbit-lab.org:5054/interference/stop OK
- As before each node will have it owns data file. At zip file with this data can be downloaded here.
- The extracted data and plot of the signal detection is shown below.
Spectrum sensing code
- The spectrum sensing code interfacing with the USRP is located in the node under the following directory: /root/uhd/host/examples/ - the two files of interest are CWriteOML_spectrum.h and spectrum.cpp. This version of the code uses an FFT to detect spectrum activity. This code can be modified/tweaked for testing other sensing schemes as well.
Logging spectrum data directly to an OML server
- Spectrum data can also be logged directly to an OML server. In the above examples the data was recorded to a local file stored on the node itself. To log directly to an oml sever, run the spectrum_console application with the —oml option specified with an ip-address:port-number of the oml server. The following would record to the oml-server running on the grid console:
nilanjan@console.grid:~/UHD/SPECTRUM/w$ ./spectrum_console --rate 8e6 --num-bins 1024 --time 5 --oml oml:3003 --node node3-3,node8-8,node13-13 --freq 5.0e9
- The data is recorded in the database file /var/lib/oml/spectrum_measurement.sq3 on the grid console. The content of the file can be viewed using the following command:
nilanjan@console.grid:~/UHD/SPECTRUM/w$ sqlite3 /var/lib/oml2/spectrum_measurement.sq3 ".dump"
- When logging to an oml sever the magnitude value of the fft bins are stored in binary format. The first entry of the db file is shown below. So when dumping the file contents the ftt bins data is shown as consecutive ascii representation of the binary floating point numbers.
PRAGMA foreign_keys=OFF; BEGIN TRANSACTION; CREATE TABLE _senders (name TEXT PRIMARY KEY, id INTEGER UNIQUE); INSERT INTO "_senders" VALUES('nodeW\_',1); INSERT INTO "_senders" VALUES('nodeW^LE',2); INSERT INTO "_senders" VALUES('nodeWì{',3); CREATE TABLE _experiment_metadata (key TEXT PRIMARY KEY, value TEXT); INSERT INTO "_experiment_metadata" VALUES('start_time','1355941828'); CREATE TABLE "spectrum_packet_info" (oml_sender_id INTEGER, oml_seq INTEGER, oml_ts_client REAL, oml_ts_server REAL, "sampling" INTEGER, "cfreq_MHz" REAL, "gain_dB" INTEGER, "FFTLength" INTEGER, "FFTNum" TEXT, "FFTBins" BLOB); INSERT INTO "spectrum_packet_info" VALUES(1,1,0.180260999826714,0.201296,16000000,5000000000.0,15,1024,'---',X'AB4F0E403E00A33B99BE813BBFFB263C5291023B1AB5373C6E78403C1E29E43B6D15333C0635323C28D0213C0529BF3BF3D51C3CCF13A23BDF10C43B4B15013C98007E3A1421903BDAFE003C28B54D3BD4390E3C0C6BF33B1AD60C3CD1D3503CF9ADBD3B3CE4453C4C608C3B6554B73B7ED8263B3DDEBF3B81E30E3C22203B3BA0511B3C2C85B43BB30B243C9F4D153C1B7FD33A7D26113C1960D53BE08CB23BD3F6503C227CC83B0F7D9A3B6043473C7101463CDDE1123CB096A63BFE82953B02867F3BB569103C4966FD3B5DE73E3C1CD4863B6C2ED73B1A14E13AB530983B315CC93BB2A6163BCC92B23B8F95653B1148043CB8A0D33A057E133C0C7D843B3A360F3C6B4D7C3BB2259A3AE4D26B3B03D4F83B2173C83B45E8BF3B3B5DA03B990FA33B4AB29B3B5B719C3A541B8B3B3E2B703C09378C3B36A3F53B310DFB3BB666803AD1E09D3BA202323C233B2E3CCD174A3B57398A3BEA6BB63BCE4B383BBA6CDF3B3836863C6F1A093C9BC7D63B9D7CA63B94ECCB3A5119193C6097A33BAEDAD83B26C50C3C6E7B723B7DA2973BDDF7033C5018203B3552A13B39BBFA3B2FAF153C9743073C19BD563CFD8F803C1A06093B5A4E8D3A28829C3BFB03593C5F77A93B0305423C9785963B13A0513CD9CD263B181DB83B4400C93B51FF043CF12CE13AD8E6BF3B68ED193B9FFBEA3B0B9B103BEF834F3ADA74BF3BEEB1963BDE87513C4968B73B1B5A483B63550D3C3218893B33F0E03B4EBE113C48A71D3C00F23F3C26930B3C6AECB43B7A56E33B7256353C0C90A43B02CCA23BC730603B1435C83B06418E3B9CCBC43A0E25223B876D093CD3280C3B70F2923B571B883BD49A2E3C7144943C9215433C1CDA393C769EC63B8254143BB18D8C3BEA4E9F3B62D10F3C6183073C5948B03BC64C123CA572173C94C1DD3AB32BC73B05DB973BF8BABC3B5184AC3B1A8C123CDE6FD33B5027423B18731B3C2447D73B9F44D03BB0DB163C7ACEDE3B8D85CE3B27A39C3B4F300B3C020DC73AF5ABA33B303B113BEF4E323B30AD3A3B4595D439955FB03B5087A23BD23A7B3BFC380A3BB8CA293BDC2E013C81EA3D3C4A3AD43999CF193CC283423B6B97283B9D3CFC3B7705203CB1DAB83BF32D7A3BA191193B3D970A3CE6CF6E3B2E58453BED5B2C3C4DB43F3BC81B953B64DC9D3BEB991B3C3E72B13B25D0463C2F06E43B9CEBEF3B0AB0273C195C043C55D0563BFD62723B3153CE3BBC20373CC592843BEA77433B65E4FA3BD21B8D3B6620733B9A2FA53B03A49F3B736CA53A05D5E43A9398533BA8E2163C7EA4983B098D153C65AB173B5556A53AC9211C3C0074DD3B318B003C4283F23BB0CF883BD6C5123BB9E23D3B9A6DFD3B073C043CC831203C50AD133B536A8F3BC9A2223C0049A33B9A09BE3AF970413BE9D4C13B61F6003B8698633B827A883B3AFA923BD87A8B3B6B5AE23A239EF33A32D1C23B7CC8633B2F294C3B39EF853B45AE5D3BF9D7A63B4ECDEC3A2A08023BAB46EE3BC04FE93BEC49C63B17F1983B0D045F3BDEBBDC3BA121C33B5FFCC73BE8752A3C3560D33B6D03A93BC7714D3BB03B9C3B60D9233CA8101F3CA54AAA3BD4888C3AA773713B1D17BD3A1A81913B6796DA3B8E15C33BF63EF13B19BA0C3CD260C43A553D113BE747893B2AB18B3BBA61373C127BEE3BD954893B1AA50C3BA5E4823BFC46213B3D511B3C0A61DF3A650B0D3C6022D63B5DEEA53B298BCD3BED4C223B08F3023C2BFF9D3B827A363C1FE6AF3B7B07243A4EE69E3AA4B74F3A60CB923BF541833BA43B093CDD7D593B0E7CBC3B2B00CD3B9056913B16462B3BED3A793B8F16643BE9EEE93B067CD93B86F07A3A8302073BEC6F973B6955C93B019B6F3B846A8A3B6510D33B9F8E5F3B3FFEAC3B50FE993BC36F853B64AFAE3A2867813B1919233C5D8D8A3BAE08E539D5C7003B44AABF3A2AA40F3A14EDD13B8AF59B3BD1712C3B6C16143C7E67F13B72A6CB3B82B3E83B7CAC903B4E910C3C7308913B7E251D3CCCD0C03A45F06A3BF1959B3B844A003B8B4EED3B172E7B3BCE2F893B4132F43B4DA7C13BB96EC83B275C1B3C3AA0453B24FFEC3AD89CB13B90556A3B61C8C43B1124D43B965E0F3CC607AD3B350A963B1188053B9A4D683C5C08563B8650143C6C868F3B70F8973B5EE1033CD091263CBE76DF3BACC2AE3B24AAE43BAA3B063C69F0853ADAEA423C60DC393AB8DC133B07DF153BD2DE0B3CCCB5313CD3263E3B9D98803BD1DC583BCDEAD83B252DB13BD6D9BF3BE9055B3BEBA1AD3BA3F9063C5C337B3B54C8C53B33AA9F3BD422483BB24C1F3C31D5D93B72B2A63B5120F23AC6949B3A14DB143C30617F3B835AA13BCE3CED3B2891E73B9A8AA73B90D2BB3B39F0D03A1C8B6E3B289BBA3B23FD033CDF1E9B3BDBF4AA3BFBBC813BBF91983B3ECD693A3EEA8C3B6C79CC3BCBAE1D3B8863BE3BD65A893BBAC8EB3B5C05243B0CB58C3BB3E4A03B2E147A3A7CBD513A8EBBE13AB784A63B6E1F0C3B2271F83B0BC3A73B2322D73BB2C9A53B8B52F03A4BBC173B5195473B6C1E423AF0A13A3BF705B83B55F7AD3AD775B83BC476E13B6291963B533ED53BDF66AF3A268E223B2EB2913B34957E3BEE10B03BD644E93AEA8FA53B27FBDD3A4F06A23B959F373B17E8943BB79A893B6631093B2BE5113BE87B813BBED2373B7BE0A73B9925103B26B9DF3ADB54103B98AAA33BFFFF2A3B3FB8C73BD92F213B673D593BF85DAC3AC6F0973B9187623BB0C5603B4128993AE94E4D3B5C2AD13B4586433B79947E3BBF26EB3B7132053BA068403A7CE8933BEC69113B44FEF73A537FD83A74A46A3AA169CF3AFFD0523B67FBC73B6E60B23B20BE6D3B4A954D3B17942C3B2FAFA63BADC0623B8DA4043B6C3DDC3B5DA0A23A52D7693B18BB143B64E21C3BA4F29F3BC7C2E53AC4F5D93B2317083B654A293B386DA93BA4252F3BDE484D3B636E263BB8358B3BE53D933B8C99463BC591A03B70E20B3BBC85053B66A57D3B8015A039572E133BF060963B3B7B163C49A8933AB279FD3B57068A3BB695783BC9F89D3B22ED943B9D9BCA3BED77163C1216CB3BDE61D63B8493453BCBE2AB3BFAE6D23BA501143B8BA3B63B4F55BD3BF5F7E53BE911A33B1611443BB69B253B4E1D4E3BC303033C668A803BF4884D3C876CA33BA0A1963A0771AB3BCA77FA3A2217933AB831273B4D19D73B1A946C3BF851923B66FE893B42CE903BD512FA3B3F5ACB3B44D8903B5599013C653E853AA4140D3BB913693BA167E13B55B0563B4ED9013C11CF963B65F9923B9916D23ACD26983BA166863BBDBE0C3CE2263C3B2097773B4210843B7994D83BD90C373B439724399768F83BF5FE8A3B450BAE3B758B463B93980C3B55D3343B70B9E93A251A853B27D0F43BDBD2A63B7F7B1F3CF12E353C4B00293C4ECEC73B99D24A3BB8CEA93B654E943B3EE95F3BA2A0373B2FC5CA3BB8A0C43A7FCF233BB44F2C3B4702803B3D4B3D3BF5F5093B9BA9EE3B0E48403B28A5BF3B27DFE73B607CC53A3422D83B40B1043C15ED9D3BBB91A43B602F363B02E8EF3AA2BCC43B012AAD3BA732493C144A143C58D6583C06D5133C41FE5F3B08A3F83AC8089B3BA453803B5BD9153C087DB43A4835043CDF6A0A3CBB3CB13B1FFF513B5552903B27B52E3CAB7C0E3C8232953B288CA63B2C6F843B779DFD3B29F0EB3BA340F83B364F6A3B9F90863B2D732A3B4589C83B4874AA3B3597DB3B8159E53AF65CB93B99F0F33BFC6E2E3B9E40543B43F5193C5AC9DD3A4443423BDA678C3ABD38043CB0B1323C4CEA0F3C41FB5F3B149E793B66B39F3B88DAE83B1344273BCDC2033C9697C13B15740D3CD6F9823B776FBE3B8833D83BA44ED73BEA990B3B8629D53A444AB33B72A82D3BE7201C3C8F7CBD3B763E313C6C616E3B52B5A23B477A563B7AA6C03B371A103CCB22F33B177FD23BAFB5833B79B4563CD697CE3B8A4C563CDBEEBB3BB2DEA93BFD98CD3B03BD773BEAEA923BB979E73B562FC73B8F08043CF146C23BE18DAD3BA5EBBC3A9A46D33B1C67B73B6156DD3B19F9D93A685C213C868A573C7144823B11678B3B0CC50A3C54B9C63B164EC43BB9F0E23BFE83693B8580073C9BB8DC3BBE74593BA80C713B3CD3EB3BD87C983B895D903BD9B18D3BD462D33BE8EEE73B9691403B576BE83B5B4AC63A97B0003B8186283C200CB33B26BCC23BAD419D3BC645DE3B6280CE3B8C2CF63A4186233BF4B7983B4A03E83B1F1FD33BCD5FB93BAD3D923BCE3F353C92B90B3C147C1C3C64042E3C5582E03BB569493BC363AC3BA995753BE679343C05E6ED3B15DF723BBED6EF3B86E99D3B7629EB3B0CEEB83B5976FA3B37E9313B45D4103B0C0EF33B3F20643C40F3103C6EA5223B333E503B9471E83BEF35053C9C3D1D3CC7A72C3C571CFD3B19AF353B58BEE63BE853353CFC8EA73B62F7763ACF90353CA3BFCB3B321F963B033E813CB4D7873B20990C3CBB5AC93BE18DEF3B4BBE633B27F8DA3AFD7BF93AB171523CF823153C4A74CB3B72DF273CBC93B63B49C8EC3B8A90C13B855D2C3B84E91D3C87D6E639326A543B919E2D3C9297523A07F8483C80FDC63B0319E73B2511353CA59B013B1FFCF33A726B323C29DF5E3A954B9B3BC0230C3C31A7AE3BC9C8013C1074003C9D51463C2D4A933B3AEC5E3C1EBBAE3BF81F813BA9B91D3C4C582D3C411B1D3CD082E23B8566AB3B23DC053C1921CC3B5031C23B263F873C6D73123C1BDA003C4362D83B8DCC403CEF6A0C3C8EC0D23BD937CE3B7558FD3BDC13B93B42F9953B598A163C7265493C6E67083C9913AE3B9C2C533C15349B3B8454993B1A69683BE7351D3BEB3C0E3CF1F1183C52EF363CA454163BA36DF63A3E56743B48577C3BBD7AFB3B52AF923BA4AA133BB80C5C3BF03CB13B962F573CC7D31A3B6C1D783C4BDA403C22DDCE3BD3B0983B1677713B59170C3B143E0C3B269EE33BFEC29A3B63D6D73AC50F5D3A2E960C3B50F3A43B3452083CCB32A33B422EC73B6BD1453C357A413B05F0F33B5BECC03BC28CCD3AA2C9D73BC8AF1B3B9DF7C13B34A3333C73B4963B25950E3CAC6F0B3C92E1223C8FD3C83B76B5113C06C2013CBE241C3C5A2D263B8DBE9B3B14131E3C2C80073A944BB13BC262A63B6E4E013CACEF053CA4B9F13B9D5D7C3C8174FA3BBFFA4D3C9AB7673B243FAB3BAC9CA43B7E604B3CD50B893BB29F453C06578D3B019EE13AB624B33B5EFF013C2639203CE002D13B03238C3B8AB8713BB492A23BC2EE4E3C3D36DA3B81B7953B10C5403C42AAB33B15B8763B0B929E3BEE35093CD495B83B810FC33BF2AA5E3B352FF63B5F93823B76DABC3B7A505B3C83A5953BF4FAAF3B7D8A1D3B93CA933B4D7ADD3B4B75EE3BCEFC603BE50AC73ACCE8463BB88C3A3CDB05EB3A58AA403CA6076C3CEC2F013C16182D3CB528113CB53B193B4F90F33B04EE163C3CC5733B7C36A13BF5086D3B18BD253C8794AE3CEECC883CE8476B3CFECFB93B5FB4E53B8EDA923B59FF3A3CA2E4DD3B94FD893B80C1053C31B81C3CF3F7C63B564A1C3C5FABBE3B25E3043CC21CDE3BADA8103B85682A3BF464853B35409A3B79092B3C9505CC3BF8C6583C5336273CC357363BEC7FFD3B2101313C5E8D223CBC42023BD45EF23B13E12D3C7AD7B03B12A0AC3A8E15543C3D7D493C16815B3BE1C4323CE57B343C5841E43AD894563CCF69B03BC8C1863BD20B253C54640E3CF126F23A8D4A1F3C7D9E163C3D93C63BD05F883B45EA183C741DF13BFE3FE93B49896E3C2AEFC83B');
Attachments (11)
- spectrum_measurement_node8-8 (24.6 MB ) - added by 12 years ago.
- noise_floor.png (715.4 KB ) - added by 12 years ago.
- f5.002.png (659.3 KB ) - added by 12 years ago.
- spectrum_console.cpp (5.4 KB ) - added by 12 years ago.
- CWriteOML_spectrum.h (5.2 KB ) - added by 12 years ago.
- spectrum.cpp (9.9 KB ) - added by 12 years ago.
- s1.png (44.8 KB ) - added by 9 years ago.
- s2.png (44.9 KB ) - added by 9 years ago.
- signal.png (204.0 KB ) - added by 9 years ago.
- fReconFDSignal.m (240 bytes ) - added by 9 years ago.
- readWiserdFile.m (675 bytes ) - added by 9 years ago.
Note:
See TracWiki
for help on using the wiki.