Wednesday, 21 May 2014

Implementing Spread Spectrum Communication in Matlab



DSSS  is  a  wireless  analog  encoding  scheme  based  on  a  technique   spread  spectrum.  
It represents each data bit by multiple bits in the transmitted signal using a chip code/spreading code. The spreading code spreads the signal across a wider frequency band in direct proportion to the length of the chip code. 

Task 1: Study and implement the  matlab functions and show the output:
Hadamard:
This MATLAB function returns the Hadamard matrix of order n.
Syntax:
Hadamard(n) % n n must be an integer and n, n/12 or n/20 must be a power of 2.
Command: Hadamard(4);
Output: 
     1     1     1     1
     1    -1     1    -1
     1     1    -1    -1
     1    -1    -1     1
randperm
It stands for random permutation
Syntax:
P = randperm(n); % returns a row vector containing a random permutation of the integer from 1 to n inclusive.
P= randperm(n,k) % return a row vector containing k unique integers selected randomly from 1 to n inclusive. 
Command: 
randperm(7);
output:  6     3     7     5     1     2     4
Command:
Randperm(7,3);
Output:
                     6     2     7

randint
It generates a matrix of uniformly distributed random integers.
Syntax:
Out= randint % generate either 0 or 1
Out = randint(n) % generate a matrix of order nxn containing randomly 0’s and 1’s.
Out = randint(n,m,range)% generates a matrix of order nxm, if rg is 0 it will generate matrix containing all zeros, otherwise it will have integer containing in the specified range.
Command:   randint(2,2,9)
                  Output:8     4
              4     2
biterr
It computes the number of bit errors and bit error rate(BER).
Syntax:
 [number, ratio]= biterr(x,y) % compare the unsigned binary representation of each element of x matrix with that of y matrix.
[number, ratio]= biterr(x,y,k) % it considers that elements of x and y have k bits.
[number, ratio]= biterr(x,y,k,flg) % flg can be ‘overall’ (element by element comparison), ‘rsow_wise’  (compare nth row of x with nth row of y) and ‘column_wise’. 
[number,ratio, individual]= biterr(….) % individual have dimension greater then that of x and y matrix. Each element of individual represent the difference of bits between the corresponding elements of x and y matrix and number of comparisons.
Command:
[number,ratio,individual] = biterr([0;0;0],randi([0 1],3,5));
Output:
number = 2              1              2              1              1       
                 ratio =  2/3            1/3            2/3            1/3            1/3     
                 individual =0              0              0              1              0       
                     1              0              1              0              1       
                     1              1              1              0              0       
bi2de
convert binary vector to decimal equivalent number.
Syntax:
Bin2de(v)
Command:   v=[1 0 1 0 1]
bi2de(v);
Output= 21
bin2gray
Converts binary integer to corresponding  Gray-encoded integer.
Syntax: 
Y= bin2gray(x,modulation,M)
or 
[y,map]= bin2gray(x,modulation,M) 
Code:
% To Gray encode a vector x with a 16-QAM Gray encoded
 % constellation and return its map, use:
 x=randi([0 5],1,100);
 [y,map] = bin2gray(x,'qam',16);
 % Obtain the symbols for 16-QAM
 hMod = modem.qammod('M', 16);
 symbols = hMod.Constellation;
 % Plot the constellation
 scatterplot(symbols);
 set(get(gca,'Children'),'Marker','d','MarkerFaceColor',...
 'auto'); hold on;
 % Label the constellation points according
 % to the Gray mapping
 for jj=1:16
 text(real(symbols(jj))-0.15,imag(symbols(jj))+0.15,...
 dec2base(map(jj),2,4));
 end
 set(gca,'yTick',(-4:2:4),'xTick',(-4:2:4),...
 'XLim',[-4 4],'YLim',...
 [-4 4],'Box','on','YGrid','on', 'XGrid','on');
Output:


de2bi
It converts decimal number to equivalent binary  vector.
Command: de2bi(3)
Output:  1 0 1
gray2bin
Convert Gray-encoded positive integers to corresponding Gray-decoded integers.
Syntax: 
Y= gray2bin(x,Modulation, M);
or
[Y,map]= gray2bin(x,Modulation,M);
Code:
% To Gray decode a vector x with a 16-QAM Gray encoded
 % constellation and return its map, use:
 x=randi([0 15],1,100);
 [y,map] = gray2bin(x,'qam',16);
 % Obtain the symbols for 16-QAM
 hMod = modem.qammod('M', 16);
 symbols = hMod.Constellation;
 % Plot the constellation
 scatterplot(symbols);
 set(get(gca,'Children'),'Marker','d','MarkerFaceColor','auto');
 hold on;
 % Label the constellation points according
 % to the Gray mapping
 for jj=1:16
  text(real(symbols(jj))-0.15,imag(symbols(jj))+0.15,...
  dec2base(map(jj),2,4));
 end
 set(gca,'yTick',(-4:2:4),'xTick',(-4:2:4),...
  'XLim',[-4 4],'YLim',...
   [-4 4],'Box','on','YGrid','on', 'XGrid','on');

Output:



vec2mat
It converts a vector into matrix.
Command: v=[1 2 3 4 5];
 vec2mat(v);
Output: 1    2    3
               4    5    0

Task 2:  Implement DSSS receiver in Matlab and show the complete results:
Matlab code: 
At transmitter side the data=[1 0 1 1 1 1] was encoded as coded=[1 -1 -1 1 -1 1 1 -1 -1 1 1 -1 1 -1 -1 1 1 -1 -1 1 -1 1 1 -1 1 -1 -1 1 -1 1 1 -1 1 -1 -1 1 -1 1 1 -1 1 -1 -1 1 -1 1 1 -1];  by  spread  spectrum technique.
Matlab function for receiver side.
coded=[1 -1 -1 1 -1 1 1 -1 -1 1 1 -1 1 -1 -1 1 1 -1 -1 1 -1 1 1 -1 1 -1 -1 1 -1 1 1 -1 1 -1 -1 1 -1 1 1 -1 1 -1 -1 1 -1 1 1 -1];
ct=hadamard(8);
p=8;
code=ct(p,1:end)';
data=[];
l=length(coded);
for i=1:8:l
    matrix=coded(1,i:i+7);
    original=(matrix*code)/length(code);
    if(original ==-1)
        original=0;
    else
        original=1;
    end
    data=[data original];
    end
Data:    1 0 1 1 1 1
Coded data received from transmitter: 1 -1 -1 1 -1 1 1 -1 -1 1 1 -1 1 -1 -1 1 1 -1 -1 1 -1 1 1 -1 1 -1 -1 1 -1 1 1 -1 1 -1 -1 1 -1 1 1 -1 1 -1 -1 1 -1 1 1 -1
Decoded data at Receiver:  1 0 1 1 1 1
Task 3:  Implement Frequency Hopping Spread Spectrum (FHSS) Transmitter in Matlab and show the complete results.
Frequency-hopping spread spectrum (FHSS) is a method of transmitting radio signals by rapidly switching a carrier among many frequency channels, using a pseudorandom sequence known to both transmitter and receiver. It is used as a multiple access methodin the frequency-hopping code division multiple access (FH-CDMA) scheme
Matlab code for transmitter: 
      clc
clear all
close all 
data=[1 0 1 1 1 1]; 
size=length(data); 
M=2; 
NRZ_signal=[]; %unipolar NRZ signal 
k=[];
for (t=1:size) 
    if (data(t)==0)
        NRZ_signal(t)=-1;
    else
        NRZ_signal(t)=1;
    end
    k=[k NRZ_signal(t)];
end
rand_freq=[2 3 4 5 6 7 8 9];
chip=8;
r=randperm(chip);
t=[];
bpsk_datasig=[];
for b=1:length(k)
   f=rand_freq(r(b));
    fs=50;
    t1=b-1:1/fs:b;
    t2=0:1/fs:1;
    x=cos(2*pi*f*t2);
    y=sin(2*pi*f*t2);
    t=[t t1];
     if (k(b)==1) 
            a=x; 
        else
            a=y;
        end
 bpsk_datasig=[bpsk_datasig a];
end
plot([1:length(bpsk_datasig)], abs(fft(bpsk_datasig)));

capturing data through ethereal


Ethereal:
Ethereal is a network packet analyzer, which captures network packets and displays that packet data detailed as possible. In fact, it’s kind of a measuring tool that tries to measure what is going inside a network cable. It can be downloaded from www.ethereal.org
download ethereal

 Few main uses of Ethereal can be 
1. Network administrators can use it to troubleshoot network problems 
2. Network security engineers use it to examine security problems. 
3. Developers use it to debug protocol implementation. 
4. And we students will learn the basics of computer networks with its help. 

Task 02:
Capture data on the network using all the three auto-stop features i.e:





a) Packets-Based:
No of data packets captured =35 



b) Size-Based: Data captured about 1Mbytes.


  

c) Time Based : Data captured for 30 seconds is ;

  
Task 02: Filter on the capturing process on the basis of ;
Distination IP :
   

Port number : port (80)

  
Task 3 :
SMTP Protocol :

  
Findings:
Packet size = 423 bytes
Header size = 20 bytes
Checksum value = 0x2498 [validation disabled]
Time with refrence to the first packet = 0.12393000 sec
Source IP Address = 82.178.158.19
Destination IP Address = 10.110.160.100
Source MAC address = 7c:ad:74:e4:f6:d0
Destination MAC address = o8:ed:b9:86:6d:
Note, to view the image it is better to download it first.

Introduction to Ethereal

Objectives

What is ethereal and why we study it?
How does ethereal works and what are its main features?
Introduction to ethereal interface and its menu items

Ethereal 

Ethereal is the network packet analyzer, which captures network packets and displays that packet data as detailed as possible. It is kind of measuring tool that tries to measure what is going inside a network cable.

Why Study Ethereal ?

Study of ethereal is important because being a student of data communications one must know how information is transferred between functional units by means of data transmission according to a protocol .Also it helps in knowing how information is transferred in computer networks.

Uses of Ethereal

Network administrator can use it to troubleshoot network problems
Network security engineers use it to examine security problems
Developers use it to debug protocol implementation






Task 1
a)Find the available interfaces on the computer and the IP assigned to each interface.

 

b)Capture packets on a particular interface,find out what protocols have been used,and save them in a file.
Captured the Microsoft interface whose IP Address is 192.168.1.2.
The following are the protocols used:
1)TCP
2)UDP
3)ARP
4)RUDP
 

c) State your findings
The findings are:
1 ) Data can be captured from the wire from a live network connection.
2) Data display can be refined using a display filter.
3) You can capture, filter, and analyze data your network adapter sees -- nothing more and nothing less. Typically it is used to examine what data is being sent to and from your machine. If there's strange network activity going on, wireshark will certainly tell you about it. In that sense, it is a security tool. It's also valuable for debugging software you write yourself that works over the network. 

Thursday, 15 May 2014

Home Automation using GSM and Arduino :






Main purpose is to provide the user with comfort and access to control his devices from anywhere in the world.
  The user can control his home appliances like air conditioners, fans, lights or music systems etc from anywhere in the world by just sending  a simple pre-defined SMS command to a particular number, user received the acknowledgement for his action. User can check the status whether his device is on or off at that moment. 

Automatic gates for his house or garage, IR motion sensors or smoke or fire alarms can also be added to alert the user in case of any emergency situations by SMS  and by using  GPS  it can send  SOS message to rescue teams with exact location. 

Spy Car controlled by Pc :






Radio frequency is used, through pc you establish a connection using hyper terminal and serial cable. And then through hyper terminal you can control the car`s direction and motion.
   Wireless camera is attached to the infront of this car, for spying or monitoring purposes, and an integrated mic is also located inside the camera module, so you can watch and hear the surrounding by an AV receiver.


GSM modem can be introduced and we can control its direction through sms commands, GPS for tracking , different sensors like temperature , smoke radiations etc . an android app can also be developed to control its direction and motion and even watch the video being captured by the wireless camera on the car.

Tiniest Drill

This drill is about the smallest i have ever seen. The word drill in this case is a bit of a hyperbole as it doesn’t actually do any drilling. It will however spin the drill bit upon pressing the trigger, and that’s close enough for us. Plus, who’s ever heard of a drill you can wear as a pendant? That’s pretty sweet!

Thursday, 17 April 2014

hybrid energy system



hybrid system refer to a home wind or solar power system that can be connected to a national grid system,  hybrid system is many advantages over signal power generation because it combine wind, electrical, solar and photovoltaic technologies in a single one.
in many area when the wind pressure is greater in one season and solar is less, or solar is greater and wind is less, etc hybrid system is the best option for these areas, for the time when neither the wind neither the solar system are , most hybrid system provide power through batteries or engine generator using fuels such us diesel etc, if batteries low then generator provide the power.
many system are stand alone system which operate off grade, i.e not connected to any system, to store the power which is produces its advisable to purchase batteries, and a charge controller.power condition equipment , safety equipment , metering and instrumentation.