Distributed RF Measurement in GSM

 

Final Report

 

 

 

 

 

 

 

"I pledge my honor that I have abided by the Stevens Honor System"

 

Group # 11:

Christian Budiarjo _____________________________

Kristen Daly __________________________________

Michelle Teixeira_______________________________

David Toner___________________________________

 

Date:

May 2, 2006

 

Advisor:

Prof. Uf Tureli

 

Coordinator:

Prof. Bruce McNair


 

 

Table of Contents                                                                                                      Page #

 

  1. Abstract                                                                                                          3
  2. Acknowledgements                                                                                        4
  3. Implemented Prototype                                                                                 5 - 9
    1. Introduction                                                                                        5         
    2. Prototype Specification                                                                      6
    3. Prototype Performance and Evaluation                                            8         
  4. Financial Analysis                                                                                          10
  5. Project Schedule                                                                                            11
  6. Conclusion                                                                                                      11
  7. References                                                                                                     12       
  8. Appendices                                                                                                     13-33

A1. Matlab Code                                                                                           13

A2. Results                                                                                                     28

A3. Gantt Chart                                                                                             33


Abstract

With the evolution of new wireless technology, a host of intelligent devices will begin to interact with users and communicate with each other.  Unfortunately, the resources to support open access to the spectrum do not exist.  This accessibility does not exist for two reasons.  Firstly, the licensing process for every device will prove to be tedious and expensive.  Secondly, it is not feasible to grant access to all mobile devices at every existing location.

            These limitations have been an obstacle to wireless application developers.  Since these spectrums are already licensed, their availability is limited.  However, they are not being completely used.  Furthermore, since the license holders have complete control over the band, other users cannot use the spectrum.  This control limits bandwidth and scalability.  Therefore, the goal of our project is to design and implement a system that can gather statistical information about the spectrum to determine the channel usage and to offer suggestions on how to reuse it given how quickly channels come in and out of use.

In our project, we examined the RF bands that one might use to have a cellular phone conversation with in Hoboken or lower Manhattan.  These bands are host to the GSM air interface and are located around 900 MHz.  Presently in the RF research community, there is a lot of interest in dynamic spectrum allocation, where quiet channels can be seized whenever they are available in space.  From our findings it is clear that fixed allocation isn't the optimal way to use the spectrum.  Future radio systems require that RF resources be allocated dynamically. 

This project takes distributed RF measurements and further discusses the next step which is proper usage. In our research project we used COM Blocks, which are cheap and light, instead of a sophisticated spectrum analyzer which is expensive and bulky.  Our findings have implications on how we need to consider spatiality in the design of our frequency reuse and allocation schemes.  How can the unused channels be identified in real time, seized and then given up when need be.  Seeing the channels use patterns and examining the stills captured from moments in time it is clear that there is much that needs to be done to coordinate multiple radios attempting the dynamically contend for resources.

Acknowledgements

The team would like to thank Prof. Tureli for being our Senior Design Advisor, for his incredible ideas regarding our project, and for all of his technical advice.  We would also like to thank him for providing us with the lab space and lab equipment to implement our project.  We would also like to thank Prof. Tureli's PhD student, Nilay Shah and Theodoros Kamakaris from WiNSeC, for their help and time in understanding the main objectives of our project, as well as helping us to further understand Communication Theory enabling us to have a productive Senior Design Project.

 


Implemented Prototype

Introduction

            Spectrums are divided into chunks in time and frequency.  Existing spectrums have many constraints.  This means that we need to find ways of sharing and reusing spectrums.  One of the ways we intend to do this is through multiple access based on coding in GSM.  Frequency reuse or spatial allocation has always attempted to make good use of frequency in space.  Wireless systems must reuse frequency assignments and be ingenious about how to get the most out of a limited resource.   

The goal of our project is to design and implement a system that can gather information about the spectrum usage in 3D.  We will use ComBlocks, which are cheap and light, instead of a sophisticated spectrum analyzer which is too expensive and not mobile.  We will be taking data for frequency bands that are currently being used for cellular telephony as well as the interface standards used on these frequencies, namely GSM.

            In the initial stage of our project we had to decide which frequency ranges to look at as well as where we would collect data.  Because we were limited to GSM in the range 800 – 1000 MHz, we chose to observe Cingular which is in the range 869 – 879 MHz in Hoboken.  In order to get a three dimensional picture of Cingular's spectrum we chose various locations on Stevens' campus.

            In the first phase of our project we had to get the ComBlocks connected to the local area network, as well as the MATLAB code working in conjunction with the ComBlocks.  Once we were able to connect the ComBlocks to the LAN and get the MATLAB code running, we had to verify that the data was legitimate.  This phase of the project was expected to be the most difficult phase of the project, and it was.  With the help of WiNSeC, we were able to complete this phase.

            The second phase of the project was to evaluate all the data collected as a whole and make some conclusions, as well as make adjustments to where and how we collected data.  Once we collected data at the different locations on Stevens’s campus we decided to collect data in Manhattan well, to get a broader look at the spectrum.

 

 

Prototype Specification

The requirements of our project are to share and reuse the spectrum in an efficient way.  There are two major phases of this project.  The first part of the project involves monitoring the spectrum for free and unused channels.  The second phase of our project involves analyzing the received signals from the ComBlocks to be able to suggest a more optimal way to utilize the spectrum.

The COM Block system is optimal for the purposes of this project for several reasons.  The main advantage of the COM Block system is its portability.  Our entire system weighed only a few pounds and was small enough to be set up in various locations.  This gave a distinct advantage over more bulky spectrum analyzers.  This allowed the group to take data measurements throughout the Stevens campus as well as in Manhattan.  Additionally, the COM Blocks are a good choice economically because the team only needed to purchase modules for the specific task at hand.  Furthermore, the COM Block system is compatible with the Stevens-issued laptops that everyone in the group owns.  In the end, all that the group needed in order to collect data was a laptop, the COM Block, and a working network connection.       

 

System Parameters:

            The hardware and software used in this project along with their specifications are as follows:

 

Software: MATLAB—Version 7.0: estimated lines of code: 2000

 

Hardware: A computer with the following configurations:

            Intel® Xeon™ Processor 2.80GHz, 1MB L2 Cache

Microsoft® Windows® XP Professional SP2 with media

1GB, DDR2 SDRAM Memory, 400MHz, ECC (2 DIMMS)

80GB SATA, 7200 RPM Hard Drive with Data Burst Cache™ without RAID

 

There is one test bed hardware configuration that we used to gather data readings for the project.  For the cellular band, the three ComBlock modules required are Com 3005, Com 8002 and Com 5002.  Each ComBlock measures 3 inches by 3 inches.  The voltage in is 5volts DC.  Figures 1 and 2 show our experimental setup.

 

·       COM-3005

COM-3005 is a Cellular band [800 - 1000 MHz] receiver. Its sensitivity is -56 dBm, has 8 preset frequencies, and can be tuned over the entire spectrum in steps of 100, 31.25, or 25 kHz.  It has a selectable internal 10 MHz or external ADC sampling clock, and SMA connectors

 

·       COM-8002

COM-8002 is a Speed Data Acquisition Module. It has 256 Mega Bytes of storage and a maximum sampling rate of 40 MHz.  It acts as a data logger, analyzer, and an RF signature capturing device. 

 

·       COM-5002

COM-5002 is a LAN interface.  It provides high-speed network interface for data transfer and monitoring and control of ComBlock assemblies.

 

Figure 1.   Configuration used for the actual test bed

 

Figure 2.  Block Diagram

 

Prototype Performance and Evaluation

            The ComBlock set up was used with a program called ComBlock Control Center, which allowed us to connect our computer to COM 5002 through a Local Area Network (LAN).  Once connected to the ComBlocks, MATLAB 7.1 was used control them, monitoring and collected data in the Cellular band.

            To test whether or not the ComBlocks are connected to the computer through the LAN, the computer and ComBlocks had to first be connected with a serial cable.  Once connected a free IP address must be given to the COM 5002, which was found by doing a simple ping test.  After an IP address is assigned to COM 5002, the computer will find the ComBlocks on the LAN. 

            Once the ComBlocks and computer are connected through the LAN, the code is run using MATLAB.   To verify that the data collected is legitimate, data was collected in multiple locations and compared to each other.  Another simple method used to verify the data was by making a cell phone (which uses CDMA) call close to the ComBlock antenna.  If the cell phone call was visible in the data (see Figure 9 & 10 in A2) then the data being collected is legitimate.

            Our initial data was taken in the Burchard wireless lab (see Figure 1 & 2 in A2).  The lower section of the graph shows the Power Spectral Density (PSD) of the frequency range 869 MHz to 880 MHz.  The upper half of the section shows usage of the band (time vs. frequency).  The red portions represent used channels, while the yellow portions represent unused channels.  The next location data was taken at was in the Computer Center, which is located in the basement of the library (see Figure 3 & 4 in A2).  The graphs from the Computer Center show much less usage compared to the graphs from the Burchard wireless lab.   These results verified that the data being collected was legitimate because we expected that the signal in the basement in the library would be weaker than the signal in the Burchard wireless lab which would cause less usage.  The next location data was taken at was Cliff Street dormitory (31st floor) in lower Manhattan (see Figure 5 & 6 in A2).  The graphs from Cliff St. show a huge increase in usage compared to the graphs from the Burchard wireless lab and Computer Center.  These results also verified that the data being collected was legitimate because we expected that the signal would be strong and that there would be a lot of used channels due to the large population in Manhattan.  The last location data was taken was Jacobus lounge (see Figure 7-10 in A2).  Figures 9 & 10 show Verizon, which use CDMA, cell phone calls being made in the vicinity of the antenna.  These results also verified that the data being collected was legitimate because they show the difference between CDMA and TDMA calls, which are that the band is wider and the division isn't in time.

            As a whole, the data shows the difference that three dimensional location makes to the channel usage.  The Computer Center and Burchard wireless lab are only a couple of hundred feet apart yet a device in each location see very different band usage.  These results show how important location is to dynamic spectrum allocation.

 


Financial Budget:

 

Materials and Parts:                                                                                              Budget:

 

Receiver ComBlock Assembly:

 

RF Receiver--COM3005                                                                                             $345

RF Receiver--COM3006                                                                                             $345

High Speed DAQ--COM8002                                                                                     $345

Network Interface--COM5002                                                                                    $295

 

Computers and Laptop                                                                                               $0

Development Software (Matlab)                                                                                $0

 

Test Equipment:

 

Tektronix WCA230A

Wireless Communication Analyzer                                                                                 N/A

 

 

Labor Cost:

4 Engineers working at $20.00 per hour per person

Each engineer working 4 hrs a week for 28 weeks

$2240 per engineer

 

Total Labor Cost:                                                                                                      $8960

 

Total Financial Budget                                                                                           $10,290

 

 


Project Schedule—Refer to the Gantt Chart in the Appendix

Conclusion

Spread spectrum technology has become very popular and widespread in wireless communications.  GSM is a spread-spectrum system based on time division in combination with frequency hopping.  GSM has proven itself as a more efficient technology than previous systems that did not use spread spectrum.  In GSM each user has their own spreading codes which reduce interference. 

Our project took a look at the way the spectrum that we use every day is being managed as a precious resource.  There is only a very finite amount of frequencies suitable for wireless radio transmission.  Therefore the future of wireless will be limited by Spectrum-availability.  In the U.S. the Federal Communications Commission (FCC) is the government agency responsible for setting the policies regarding use of the radio frequencies.  Currently, the FCC has a system, first formulated in the 1920's, where by different bands are assigned to different services and licenses are required to operate in those bands.     As our findings showed the system in place leaves much of the spectrum quiet. 

Getting in and using the quiet channels would mean more bandwidth could be squeezed out of the same range of frequencies.  But different channels are quiet in different places.  An intelligent piece of radio equipment would keeps itself updated about the available radio frequency resources in its vicinity.  This idea is that of the Cognitive radio (CR).  Cognitive radio proposes itself as a solution for unlocking the potential capacity in the radio spectrum that has gone unused. At present there are no commercially available cognitive radios on the market although there are prototypes being worked on.

Cognitive radio would be able to sense its environment and location and then alter its power, frequency, modulation and other parameters in order to dynamically reuse the available spectrum.  One of the most basic of its functions would therefore be to take a reading of the airwaves in its surrounding space similar to the data readings we gathered in this project.  

 

     

References

Books:

Haykin, Simon. Communication Systems 4th ed. New York: John Wiley & Sons

Inc., 2001.

Stremler. Introduction to Communication Systems 3rd ed. Prentice Hall

 

Electronic sources:

COM Block. www.comblock.com

http://www.comblock.com/com8002.htm

http://www.comblock.com/com5001.htm

http://www.comblock.com/com3005.htm

http://www.commsdesign.com/printableArticle/www.eet.com/showArticle.html

 

Efficient Spectrum Sharing

http://www.citris-uc.org/people/corporate/pages/infineon/infoday2004/6Nikolic.pdf

 

US Spectrum Requirements and Trends

http://www.ntia.doc.gov/openness/sp_rqmnts/sharing7.html

 

Spread Spectrum Multiple Access

http://www.columbia.edu/~rdg74/ee6713/Spread_Spectrum.PDF

 

The Principal of Spread Spectrum Communications

http://cas.et.tudelft.nl/~glas/ssc/techn/techniques.html

 

The ABCs of Spread Spectrum -- A Tutorial

http://sss-mag.com/ss.html

 

GSM 

http://www-128.ibm.com/developerworks/wireless/library/wi-what2/

 

Appendix

 

A1. MATLAB CODE

 

Note: The distributed spectrum code is a property of Winsec.  Any unauthorized use is considered illegal.

 

1. Main Online Code

 

%**********************************************************************************

%*****************************required files***************************************

%   pnet.dll

%   com_connect

%   com_config

%   com_upload

%   com_download

%   com_plot

%   com_save

%   com_chfreq

 

function com_online()

clc;

%close all

clear all

warning off

%savefile=['c:\data\data\' datestr(now,30) '.mat'];

%save(savefile);

pnet('closeall');

 

%**********************************************************************************

%*****************************parameters*******************************************

 

comblockip = ['155.246.68.65'];

%comblockip =['155.246.68.67';'155.246.68.68'];

%comblockip =['155.246.68.66';'155.246.68.67';'155.246.68.68'];

%comblockip = ['155.246.68.65';'155.246.68.66';'155.246.68.67';'155.246.68.68'];

samples = 1.80e+5/1.25;        %this is # of bytes/1.25 please make multiple of 800

frequency = [2420e+6];           %edit frequency Put the center frequnecy of cingular in cellular band

%frequency = [2425e+6 ,2465e+6];           %edit frequency

%frequency = [2100e+6 ,2150e+6 ,2200e+6 ,2250e+6 ,2300e+6 ,2350e+6 ,2400e+6 ,2450e+6];

agc = [112 0 0 0];          %(0-255,1)set AGC  [0db-0 10db-85 20db-112 30db-132 40db-158 50dB-180 60dB-208]

attn = [20 0 0 0];         %(0-60,10)for proper plotting adjust according to the agc setting for dB

%**********************************************************************************

%**********************************************************************************

 

%***************************initialization*****************************************

sigport = 1028;

dataport = 1024;

delay = 0.1;

 

%*************************connection and configuration*****************************

for i=1:size(comblockip,1)

    [sockid1(i)] = com_connect(comblockip(i,:));

end

rcvn=length(sockid1);

com_config(sockid1, frequency, samples, delay, rcvn);

 

for i=1:rcvn,

    sockid2(i) =pnet('tcpconnect',comblockip(i,:),dataport);

end

pause(1)

 

%**********************************main loop***************************************

counter = 0;

while counter < 100000

tic

    counter = counter+1;

    %****************************frequency scanning********************************

    signal = [];

    for index=1:length(frequency)

        com_chfreq(sockid1, index, delay, rcvn);

        

        %**************************signal monitoring*******************************

        com_upload(sockid1,delay,samples,agc);

        sig = com_download(sockid1,sockid2,delay,samples,rcvn,agc);

        signal = [signal ; sig];

%        signal = [signal ; com_correction(sig,comblockip)];

    end

%    signal_c=com_correction(signal);

    %**************************end of frequency scanning***************************

       

    %******************************data capturing**********************************

       

    %com_save(signal,savefile);

       

    %****************************data visualization********************************

    pkts = [];

%     for i=1:rcvn

%         pkts = com_pktdetect(signal(i,:),i);

%         com_plotmpath(signal(1,:),frequency,1,attn(i),pkts,i);

%         pause(.1)

%     end

    com_plot(signal,frequency,rcvn,attn,pkts);

       

    %***********************end of signal monitoring*******************************

    clear signal

toc

end

 

%*******************************end of main loop***********************************

 

pnet('closeall');

 

2. Upload Code

 

function com_upload(sockid1,delay,samples,agc)

 

%upload data to comblock

% for i=1:length(sockid1)

%     pnet(sockid1(i),'printf','@002SRG1609\n');

% end

% pause(delay/length(sockid1));

% for i=1:length(sockid1)

%     pnet(sockid1(i),'printf',['''@002SRG18' dec2hex(agc(i),2) '\n''']);

% end

% for i=1:length(sockid1)

%     pnet(sockid1(i),'printf','@002SRG1605\n');

% end

% pause(delay/length(sockid1));

% for i=1:length(sockid1)

%     pnet(sockid1(i),'printf',['''@002SRG18' dec2hex(agc(i),2) '\n''']);

% end

for i=1:length(sockid1)

    pnet(sockid1(i),'printf','@002SRG1602\n');

end

pause(delay/length(sockid1));

for i=1:length(sockid1)

    pnet(sockid1(i),'printf',['''@002SRG18' dec2hex(agc(i),2) '\n''']);

end

pause(samples*1.25/100e+6)

 

 

3. Channel Frequency Code

 

function com_chfreq (sock, index, delay, rcvn)

 

if index==1

    for i=1:rcvn

        pnet(sock(i),'printf','@003SRG0600\n');

    end

elseif index==2

    for i=1:rcvn

        pnet(sock(i),'printf','@003SRG0620\n');

    end

elseif index==3

    for i=1:rcvn

        pnet(sock(i),'printf','@003SRG0640\n');

    end

elseif index==4

    for i=1:rcvn

        pnet(sock(i),'printf','@003SRG0660\n');

    end

elseif index==5

    for i=1:rcvn

        pnet(sock(i),'printf','@003SRG0680\n');

    end

elseif index==6

    for i=1:rcvn

        pnet(sock(i),'printf','@003SRG06A0\n');

    end

elseif index==7

    for i=1:rcvn

        pnet(sock(i),'printf','@003SRG06C0\n');

    end

elseif index==8

    for i=1:rcvn

        pnet(sock(i),'printf','@003SRG06E0\n');

    end

end

pause(delay);

 

for i=1:rcvn

    pnet(sock(i),'printf','@003SRG3501\n');

end

pause(delay);

 

 

4. Configuration Code

 

function com_config(sock, frequency, samples, delay, rcvn)

 

scan=zeros(1,8);

for i=1:length(frequency)

    scan(i)=frequency(i);

end

 

%set frequency

if (scan(1)~= 0)

    freq = dec2hex(scan(1),8);

    for i=1:rcvn

        pnet(sock(i),'printf',['@003SRG00' freq(7:8) '\n']);

    end

    pause(delay);

    for i=1:rcvn

        pnet(sock(i),'printf',['@003SRG01' freq(5:6) '\n']);

    end

    pause(delay);

    for i=1:rcvn

        pnet(sock(i),'printf',['@003SRG02' freq(3:4) '\n']);

    end

    pause(delay);

    for i=1:rcvn

        pnet(sock(i),'printf',['@003SRG03' freq(1:2) '\n']);

    end

    pause(delay);

end

 

if (scan(2)~= 0)

    freq = dec2hex(scan(2),8);

    for i=1:rcvn

        pnet(sock(i),'printf',['@003SRG07' freq(7:8) '\n']);

    end

    pause(delay);

    for i=1:rcvn

        pnet(sock(i),'printf',['@003SRG08' freq(5:6) '\n']);

    end

    pause(delay);

    for i=1:rcvn

        pnet(sock(i),'printf',['@003SRG09' freq(3:4) '\n']);

    end

    pause(delay);

    for i=1:rcvn

        pnet(sock(i),'printf',['@003SRG10' freq(1:2) '\n']);

    end

    pause(delay);

end

 

if (scan(3)~= 0)

    freq = dec2hex(scan(3),8);

    for i=1:rcvn

        pnet(sock(i),'printf',['@003SRG11' freq(7:8) '\n']);

    end

    pause(delay);

    for i=1:rcvn

        pnet(sock(i),'printf',['@003SRG12' freq(5:6) '\n']);

    end

    pause(delay);

    for i=1:rcvn

        pnet(sock(i),'printf',['@003SRG13' freq(3:4) '\n']);

    end

    pause(delay);

    for i=1:rcvn

        pnet(sock(i),'printf',['@003SRG14' freq(1:2) '\n']);

    end

    pause(delay);

end

 

if (scan(4)~= 0)

    freq = dec2hex(scan(4),8);

    for i=1:rcvn

        pnet(sock(i),'printf',['@003SRG15' freq(7:8) '\n']);

    end

    pause(delay);

    for i=1:rcvn

        pnet(sock(i),'printf',['@003SRG16' freq(5:6) '\n']);

    end

    pause(delay);

    for i=1:rcvn

        pnet(sock(i),'printf',['@003SRG17' freq(3:4) '\n']);

    end

    pause(delay);

    for i=1:rcvn

        pnet(sock(i),'printf',['@003SRG18' freq(1:2) '\n']);

    end

    pause(delay);

end

 

if (scan(5)~= 0)

    freq = dec2hex(scan(5),8);

    for i=1:rcvn

        pnet(sock(i),'printf',['@003SRG19' freq(7:8) '\n']);

    end

    pause(delay);

    for i=1:rcvn

        pnet(sock(i),'printf',['@003SRG20' freq(5:6) '\n']);

    end

    pause(delay);

    for i=1:rcvn

        pnet(sock(i),'printf',['@003SRG21' freq(3:4) '\n']);

    end

    pause(delay);

    for i=1:rcvn

        pnet(sock(i),'printf',['@003SRG22' freq(1:2) '\n']);

    end

    pause(delay);

end

 

if (scan(6)~= 0)

    freq = dec2hex(scan(6),8);

    for i=1:rcvn

        pnet(sock(i),'printf',['@003SRG23' freq(7:8) '\n']);

    end

    pause(delay);

    for i=1:rcvn

        pnet(sock(i),'printf',['@003SRG24' freq(5:6) '\n']);

    end

    pause(delay);

    for i=1:rcvn

        pnet(sock(i),'printf',['@003SRG25' freq(3:4) '\n']);

    end

    pause(delay);

    for i=1:rcvn

        pnet(sock(i),'printf',['@003SRG26' freq(1:2) '\n']);

    end

    pause(delay);

end

 

if (scan(7)~= 0)

    freq = dec2hex(scan(7),8);

    for i=1:rcvn

        pnet(sock(i),'printf',['@003SRG27' freq(7:8) '\n']);

    end

    pause(delay);

    for i=1:rcvn

        pnet(sock(i),'printf',['@003SRG28' freq(5:6) '\n']);

    end

    pause(delay);

    for i=1:rcvn

        pnet(sock(i),'printf',['@003SRG29' freq(3:4) '\n']);

    end

    pause(delay);

    for i=1:rcvn

        pnet(sock(i),'printf',['@003SRG30' freq(1:2) '\n']);

    end

    pause(delay);

end

 

if (scan(8)~= 0)

    freq = dec2hex(scan(8),8);

    for i=1:rcvn

        pnet(sock(i),'printf',['@003SRG31' freq(7:8) '\n']);

    end

    pause(delay);

    for i=1:rcvn

        pnet(sock(i),'printf',['@003SRG32' freq(5:6) '\n']);

    end

    pause(delay);

    for i=1:rcvn

        pnet(sock(i),'printf',['@003SRG33' freq(3:4) '\n']);

    end

    pause(delay);

    for i=1:rcvn

        pnet(sock(i),'printf',['@003SRG34' freq(1:2) '\n']);

    end

    pause(delay);

end

 

for i=1:rcvn

    pnet(sock(i),'printf','@003SRG0400\n');

end

pause(delay);

 

for i=1:rcvn

    pnet(sock(i),'printf','@003SRG0600\n');

end

pause(delay);

 

for i=1:rcvn

    pnet(sock(i),'printf','@003SRG3501\n');

end

pause(delay);

 

 

%set upload length

start = floor((rand*(256000000-samples*1.25))/100)*100;

lent = samples*1.25;

upstart = dec2hex(start,8);

len = dec2hex(lent,8);

 

for i=1:rcvn

    pnet(sock(i),'printf',['@002SRG00' upstart(7:8) '\n']);

    %pnet(sock(i),'printf',['@002SRG0000\n']);

end

pause(delay);

for i=1:rcvn

    pnet(sock(i),'printf',['@002SRG01' upstart(5:6) '\n']);

    %pnet(sock(i),'printf',['@002SRG0100\n']);

end

pause(delay);

for i=1:rcvn

    pnet(sock(i),'printf',['@002SRG02' upstart(3:4) '\n']);

    %pnet(sock(i),'printf',['@002SRG0200\n']);

end

pause(delay);

for i=1:rcvn

    pnet(sock(i),'printf',['@002SRG03' upstart(1:2) '\n']);

    %pnet(sock(i),'printf',['@002SRG0300\n']);

end

pause(delay);

for i=1:rcvn

    pnet(sock(i),'printf',['@002SRG04' len(7:8) '\n']);

    %pnet(sock(i),'printf',['@002SRG04E0\n']);

end

pause(delay);

for i=1:rcvn

    pnet(sock(i),'printf',['@002SRG05' len(5:6) '\n']);

    %pnet(sock(i),'printf',['@002SRG05FF\n']);

end

pause(delay);

for i=1:rcvn

    pnet(sock(i),'printf',['@002SRG06' len(3:4) '\n']);

    %pnet(sock(i),'printf',['@002SRG06FF\n']);   

end

pause(delay);

for i=1:rcvn

    pnet(sock(i),'printf',['@002SRG07' len(1:2) '\n']);

    %pnet(sock(i),'printf',['@002SRG070F\n']);   

end

pause(delay);

 

%set download length

for i=1:rcvn

    pnet(sock(i),'printf',['@002SRG08' upstart(7:8) '\n']);

end

pause(delay);

for i=1:rcvn

    pnet(sock(i),'printf',['@002SRG09' upstart(5:6) '\n']);

end

pause(delay);

for i=1:rcvn

    pnet(sock(i),'printf',['@002SRG10' upstart(3:4) '\n']);

end

pause(delay);

for i=1:rcvn

    pnet(sock(i),'printf',['@002SRG11' upstart(1:2) '\n']);

end

pause(delay);

for i=1:rcvn

    pnet(sock(i),'printf',['@002SRG12' len(7:8) '\n']);

end

pause(delay);

for i=1:rcvn

    pnet(sock(i),'printf',['@002SRG13' len(5:6) '\n']);

end

pause(delay);

for i=1:rcvn

    pnet(sock(i),'printf',['@002SRG14' len(3:4) '\n']);

end

pause(delay);

for i=1:rcvn

    pnet(sock(i),'printf',['@002SRG15' len(1:2) '\n']);

end

pause(delay);

 

 

5. Connect Code

 

function [socketid] = com_connect(ipaddr)

 

port=1028;

fid =pnet('tcpconnect',ipaddr,port);

if fid==-1,

   disp 'Cant connect to comblocks!';

   return;

else

    socketid = fid;

end

 

delay = 0.06; %60ms delay

no_comblocks = 0;

 

pnet(fid,'printf','@111SAC000\n'); pause(delay);

pnet(fid,'printf','@111MFW0\n');pause(delay);

pnet(fid,'printf','@000SAC001\n');pause(delay);

pnet(fid,'printf','@001GMI\n');pause(delay);

s=pnet(fid,'readline');

if(~isempty(s))

   no_comblocks = no_comblocks + 1;

end

 

pnet(fid,'printf','@001MFW1\n');pause(delay);

pnet(fid,'printf','@000SAC002\n');pause(delay);

pnet(fid,'printf','@002GMI\n');pause(delay);

 

pnet(fid,'setreadtimeout',.5);

 

if(pnet(fid,'readline') ~= '')

    no_comblocks = no_comblocks + 1;

else

    pnet(fid,'printf','@001MFW2\n');pause(delay);

    pnet(fid,'printf','@000SAC002\n');pause(delay);

    pnet(fid,'printf','@002GMI\n');pause(delay);

    pnet(fid,'setreadtimeout',.5);

    s=pnet(fid,'readline');

    if(~isempty(s))

        no_comblocks = no_comblocks + 1;

    else

        pnet(fid,'printf','@001MFW4\n');pause(delay);

        pnet(fid,'printf','@000SAC002\n');pause(delay);

        pnet(fid,'printf','@002GMI\n');pause(delay);

        pnet(fid,'setreadtimeout',.5);

        s=pnet(fid,'readline');

        if(~isempty(s))

           no_comblocks = no_comblocks + 1;

        end

    end

end

 

 

pnet(fid,'printf','@001MFW4\n'); pause(delay);

pnet(fid,'printf','@002MFW1\n');pause(delay);

pnet(fid,'printf','@000SAC003\n');pause(delay);

pnet(fid,'printf','@003GMI\n');pause(delay);

s=pnet(fid,'readline');

if(~isempty(s))

   no_comblocks = no_comblocks + 1;

else

    pnet(fid,'printf','@002MFW2\n');pause(delay);

    pnet(fid,'printf','@000SAC003\n');pause(delay);

    pnet(fid,'printf','@003GMI\n');pause(delay);

    pnet(fid,'setreadtimeout',.5);

    s=pnet(fid,'readline');

    if(~isempty(s))

        no_comblocks = no_comblocks + 1;

    else

           pnet(fid,'printf','@002MFW4\n');pause(delay);

           pnet(fid,'printf','@000SAC003\n');pause(delay);

           pnet(fid,'printf','@003GMI\n');pause(delay);

           pnet(fid,'setreadtimeout',.5);

           s=pnet(fid,'readline');

           if(~isempty(s))

               no_comblocks = no_comblocks + 1;

           end

    end

end

if(no_comblocks == 3)

    disp(['Receiver detected @' ipaddr]);

else

    disp(['Receiver not detected @' ipaddr]);

end

 

 

  1. Download Code

 

function [sig] = com_download(sockid1,sockid2,delay,samples,rcvn,agc)

 

for i=1:rcvn

    pnet(sockid2(i),'setreadtimeout',(samples*1.25/60000));

    pnet(sockid1(i),'printf','@002SRG1606\n');

    pause(delay);

    pnet(sockid1(i),'printf',['''@002SRG18' dec2hex(agc(i),2) '\n''']);

    data = pnet(sockid2(i),'readunpacked',(samples*1.25) ,'uint8');

    data = [data 512*(ones(1,samples*1.25))];

    data = data(1:samples);

    data = reshape(data',2,samples/2);

    signal = j*double(data(1,:)) + double(data(2,:));

    clear data

    sig(i,:) = signal - mean(signal);

end

 

 

  1. Plot Code

 

function com_plot(signal,frequency,rcvn,attn,pkts)

 

figure(1)

f = length(frequency);

n = length(signal)/10000;

 

Fs = 40000000;

nfft = 4096;

cal = 2^19;

location = ['Receiver 1';

    'Receiver 2';

    'Receiver 3';

    'Receiver 4'];

time = datestr(now,30);

if rcvn>1

    for i=1:rcvn

        sg=[];

        pg=[];

        Fn=[];

        Fg=[];

        for index=1:f

            [B,F,T]=specgram(signal((index-1)*rcvn+i,:),nfft,Fs);

            B = 5*log10(abs(fftshift(B,1))/cal^4)+attn(i);

            sg = [sg;B];

            Fn = [Fn;((F+frequency(index)-Fs/2)/1000000)];

            clear F B

            for m=1:n

                a=((m-1)*length(signal)/n)+1;

                b=((m)*length(signal)/n);

                sig=signal((index-1)*rcvn+i,a:b);

                [Pxx(:,m),F]=pwelch(sig-mean(sig),[],[],nfft,Fs);

            end

            P=10*log10(max(fftshift(Pxx/cal),[],2))+attn(i);

            pg = [pg;P];

            Fg = [Fg;((F+frequency(index)-Fs/2)/1000000)];

            clear F P

        end

        %one=[max(max(sg)) min(min(sg)) max(max(sg))-min(min(sg)) mean(mean(sg))]

        %two=[max(pg) min(pg) max(pg)-min(pg) mean(pg)]

       

        subplot('position',[((1/rcvn)*(i-.90)) .27 ((1/rcvn)-.05) .66]),imagesc(Fn,T*1000,sg',[attn(i)-122 attn(i)-90]), title([location(i,:) ' ' time]),ylabel('time (ms)');

        subplot('position',[((1/rcvn)*(i-.90)) .07 ((1/rcvn)-.05) .2]),plot(Fg,pg),axis([(frequency(1)-Fs/2)/1000000 (frequency(f)+Fs/2)/1000000 attn(i)-115 attn(i)-55]), ylabel('PSD (dBm)'),xlabel('frequency in MHz (10kHz resolution)');

       

        clear sg pg Fn Fg

    end

else

    sg=[];

    pg=[];

    Fn=[];

    Fg=[];

    for index=1:f

        [B,F,T]=specgram(signal(index,:),nfft,Fs);

        B = 5*log10(abs(fftshift(B,1))/cal^4)+attn(1);

        sg = [sg;B];

        Fn = [Fn;((F+frequency(index)-Fs/2)/1000000)];

        clear F B

        for m = 1:n

            a=((m-1)*length(signal)/n)+1;

            b=((m)*length(signal)/n);

            sig=signal(index,a:b);

            [Pxx(:,m),F]=pwelch(sig-mean(sig),[],[],nfft,Fs);

        end

        %         if (size(pkts,1) > 0 & f==1)

        %             for m = 1:size(pkts,1)

        %                 if (pkts(m,2)-pkts(m,1)) > 16384

        %                     [Pxx(:,m),F]=pwelch(signal(index,(pkts(m,1)+1):pkts(m,2)),[],[],nfft,Fs);

        %                 else [Pxx(:,m),F]=-1000;

        %                 end

        %             end

        %             [Pxx(:,m+1),F]=pwelch(signal(index,:),[],[],nfft,Fs);

        %         end

       

        P=10*log10(max(fftshift(Pxx/cal),[],2))+attn(1);

        pg = [pg;P];

        Fg = [Fg;((F+frequency(index)-Fs/2)/1000000)];

        clear F P

    end

   

    if (size(pkts,1) > 0 & f==1)

        pkts = reshape(pkts',1,size(pkts,1)*size(pkts,2));

        for i=1:length(pkts)

            dex = ceil((1+pkts(i)*size(sg,2))/length(signal))%ceil((pkts(i)*2+1)/nfft);

            sg(:,dex) = max(max(sg))*ones(size(sg,1),1);

        end

        size(sg)

    end

subplot('position',[.07 .27 .83 .66]),imagesc(Fn,T*1000,sg',[attn(1)-122 attn(1)-90]), title([location(1,:) ' ' time]),ylabel('time (ms)');

subplot('position',[.07 .07 .83 .2]),plot(Fg,pg),axis([(frequency(1)s/2)/1000000frequency(f)+Fs/2)/1000000 attn(1)-115 attn(1)-55]), ylabel ('PSD (dBm)'),xlabel ('frequency in MHz (10kHz resolution)');

clear sg pg Fn Fg

end

 

%print(1, '-dpng', '-r0', 'C:\MATLAB7\work\SOM\web\spectrum\spectrum.png');

%eval(['print(1, ''-dpng'', ''-r0'', ''c:\data\data\' time '.png'');']);

%eval(['saveas(1, ''c:\data\data\' time '.fig'', ''fig'');']);