Friday, July 31, 2009

Hello,
I have done a program to measure Temperature readings in Castalia

My project name is 'senseReading'

same thing in /src/Node/Application/
senseReading 1 folder created
copy paste all files from /src/Node/Application/templateApplication to /src/Node/Application/senseReading folder
replace " template " name by " senseReading " as we did that day...
and after that change to /Simulation directory
create one /Simulation/senseReading directory
copy paste 2 files from any of the folder (omnetpp.ini and run script[e.g. runSimpleAggreagation])

change in omnetpp.ini
change application name by "senseReading_applicationModule"
application ID by "senseReading"
then u can change some parameters if u want from Omnetpp.ini file...

after that MOST IMPORTANT THING:

1. Open /config/makemake.config file...
2. edit 38th line in that... ALL_WSN_INCLUDES =

-I$(SRCDIR)/Node/Application/senseReading

3. edit at the end of file..

cd $(SRCDIR)/Node/Application/senseReading && $(MAKEMAKE) $(OPTS) -n -r -I$(SRCDIR)/helpStructures -I$(SRCDIR)/Node/Application -I$(SRCDIR)/Node/Application/commonIncludeFiles -I$(SRCDIR)/Node/Sensor_Device_Manager -I$(SRCDIR)/Node/Resource_Manager -I$(SRCDIR)/Node/Communication/Network -I$(SRCDIR)/Node/Communication/Network/multipathRingsRouting

4. then close the file...

then do...

1] make clean
2] ./makemake
3] make

and run the program as...
go in /Simulation/senseReading program/
./runSenseReading

I m sending u a zip file which contains
i] /Simulation/senseReading FOLDER
ii] /src/Node/Application/senseReading FOLDER
iii] /config/makemake.config FILE

place those at correct place.. and try to simulate...

Enjoy..

Saturday, April 4, 2009

MIT click Router Configuration

Hello Friends....
If u want to forward the packets coming to your machine to other machine in your machine by MIT Click Router.
Then Here is the code...
Initially U have to install the MIT Click Router.
Follow these steps....

Download tar file (click-1.6.0.tar.gz) from http://read.cs.ucla.edu/click/download
• % tar xzvf click-1.6.0.tar.gz
• % cd click-1.6.0
• % ./configure –disable=nsclick –enable=userlevel –disable=linuxmodule
• % cd click-1.6.0/userlevel
• % make
• % ./click /root/Click-MIT-router/click-1.6.0/conf/test.click
This command executes simple router configuration program, if installed properly we see the output as follows:
ok: 40 | 45000028 00000000 401177c3 01000001 02000002 13691369
ok: 40 | 45000028 00000000 401177c3 01000001 02000002 13691369
ok: 40 | 45000028 00000000 401177c3 01000001 02000002 13691369
ok: 40 | 45000028 00000000 401177c3 01000001 02000002 13691369
ok: 40 | 45000028 00000000 401177c3 01000001 02000002 13691369

/* If u get output what is above then u have done with the first step....*/

Now the file to send the packets coming to your machine to another machine.

ForwardYourPacketsToOtherMachine.click

//Define the variables that used in the program//

define(
$DEV eth0,
$SRC_ADDR 10.6.21.209, //Change this address by your address
$DST_ADDR 10.6.21.207, //Change this address by ur neighbor's address
$IP_ETHER 0x0800,
$SRC_ETHER 00:1c:c0:a7:82:04, //Change by your hardware address
$DST_ETHER 00:1c:c0:a7:82:0a //Change by your neighbor's H/W address
);
//Take the queue for storing the packets to send to the eth0 interface with new destination and source address//

Put_to_dev_q :: Queue(5000);

//Take the input packet form the eth0 device | Syntax: FromDevice(Device) //

FromDevice($DEV)
-> Classifier(12/0800) //Classify the incoming ethernet packets payload is IP packet or something other packet
-> Print("OLD ETHER") //Print this Ethernet packet with label "OLD ETHER"
-> EtherEncap($IP_ETHER, $SRC_ETHER, $DST_ETHER) //Put 0x0800 in type/length field of ethernet packet and source H/W
-> Print("NEW ETHER") //and dest H/W address as given to this function
-> IPAddrPairRewriter(pattern 10.6.21.209 10.6.21.207 0 0) //It will add source IP and Destination IP address which has come on
-> IPPrint("NEW IP") //0 input Port and going on 0 output port & print this IP Packet
-> Put_to_dev_q; //put this packet to the queue to send this to eth0 device for tx.


Put_to_dev_q
->ToDevice($DEV); //Transmit the packet from the eth0 device...

/* END of Program*/
The hardware address can be seen in Linux Machine by "ifconfig" command
in Windows "ipconfig -all" command

Run this program as ...
Go in the folder Click/userlevel there is a binary file named "click"

./click your/programs/path

e.g.

./click ~/ClickExamples/ForwardYourPacketsToOtherMachine.click



Kepp Enjoying ......

Friday, February 13, 2009

Simple code for Dijkastra algorithm implementation in C

Hello friends ...
See this code for Dijkastra Algorithm implemetation in C language....

sourcefile: DIJKSTRA.c
inputfile: topologyfile.txt

How to run In linux...

compiling file....
$gcc DIJKASTRA.c -o DJ

running file....
$gcc DJ topologyfile.txt

source code:DIJKASTRA.c
/***************************************************************************/
#include 
 < 
stdio.h
 > 

#include
 < 
stdlib.h
 > 

#define INFY 1000



int dist[50], Q[50], sdata[50], sQ[50], dist_between[50][50];
int k,N;

/*------------------------------------------------------------------------
* sortQ - function to sort the Q for getting the vertex with least dist[]
*------------------------------------------------------------------------
*/
void sortQ (int k)
{
int i,j,temp;
for( i = 0;i
 < 
N-k; i++)
{
for( j = i+1;j
 < 
N-k; j++)
{
if(sdata [i]
 > 
sdata[j])
{
temp = sdata[j];
sdata[j] = sdata[i];
sdata[i] = temp;
temp = sQ[j];
sQ[j] = sQ[i];
sQ[i] = temp;
}
}
}
}



/*------------------------------------------------------------------------
* shortetPath - finding single source shortest path from given source.
*------------------------------------------------------------------------
*/
void shortestPath(int source)
{
const int size=N;
int previous[size],v;
int temp,least,i,j,u=size; /*u value is set to N that is no. of nodes this is neccessary*/
int alt,t,b;
int uindex[size],m,l,flag;

for(i = 0 ;i
 < 
N ;i++)
uindex[i] = N;

for(v = 0;v
 < 
N; v++)
{
dist[v] = INFY;
previous[v] = -1;
Q[v] = v;
}
dist[source] = 0;

k = 0; /*while Q is not empty....*/
while(k
 < 
N)
{
m = 0;
for(j = 0;j
 < 
N; j++)
{
flag = 0; /*scan j value in uindex array if it is there dont put in sdata array*/
for(l = 0;l
 < 
N; l++)
{
if(uindex[l] == j)
{
flag = 1;
break;
}
}
if(flag == 0)
{
sdata[m] = dist[j];
sQ[m] = j;
m++;
}
}
sortQ(k);
u = sQ[0];
uindex[k] = u;
k++;

for(i = 0;i
 < 
N; i++)
{
if(dist_between[source][i] != 1000 || dist_between[source][i] != 0) /* Not infinity and not self node*/
{
if(dist[u]+dist_between[u][i]
 < 
dist[i])
{
dist[i] = dist[u]+dist_between[u][i];
previous[i] = u;
}
}
}
}

printf("S-----
 > 
D Dst Prnt");
for( i = 0;i
 < 
N; i++)
{
b = previous[i];
printf("\n%d-----
 > 
%d %d %d ",source ,Q[i] ,dist[i] ,Q[i]);
for(t = 0;t
 < 
N; t++)
{
if(b != -1)
{
printf("
 < 
-----%d",b);
b = previous[b];
}
}
}
printf("\n");
}


/*------------------------------------------------------------------------
* main - Getting input and output files from user
*------------------------------------------------------------------------
*/

int main(int argc, char * argv[])
{

int i=0,j=0,v1,v2,delay,speed,in;
char *topofile,*connfile,*routefile,*forwardfile,*pathfile;
FILE *tf=NULL,*cf=NULL,*rf=NULL,*ff=NULL,*pf=NULL;

topofile=argv[1];
printf("%s\n",topofile);
/*connfile=argv[2];
routefile=argv[3];
forwardfile=argv[4];
pathfile=argv[5];*/


tf=fopen(topofile,"r");
fscanf(tf,"%d",&N);

const int size=N;
for(i=0;i
 < 
N;i++)
{
for(j=0;j
 < 
N;j++)
{
if(i!=j)
dist_between[i][j]=INFY;
else
dist_between[i][j]=0;
}
}
while(!feof(tf))
{
fscanf(tf,"%d",&v1);
fscanf(tf,"%d",&v2);
fscanf(tf,"%d",&delay);
fscanf(tf,"%d",&speed);
dist_between[v1][v2]=delay;
dist_between[v2][v1]=delay; /*As the link is bidirectional*/
i++;
}



for(in=0;in
 < 
N;in++)
{
shortestPath(in);
printf("\n-------------------------------------------\n");
}

return 0;
}

/******************************************************************************/

topologyfile.txt

7
0 1 6 1
0 2 5 1
0 3 5 1
1 4 4 1
2 4 3 1
1 2 2 1
2 3 2 1
3 5 2 1
4 6 3 1
5 6 3 1

you can change the topology file as a input of new topology...
and this program does not uses Queue structure....
for deleting least dist[] value node...
so not complicated....
Hello freinds...
See this Guitar chords for the song...
Meri Maa..
from the Film Dasvidaniya

\**************************************************************************\
C' :same C chord but with diffrent strok pattern UP UP DOWN
i.e. total G C' as
DOWN s UP s DOWN s UP UP DOWN
-------------G----------------- ---------C-----------
s:space.....

start G C' G C' G C'

CHORUS:

Ma, Meri Ma, Pyaari MA, Mumma
G C' G C' G C' G C'
oo REpeat


Haathon ki lakeerein badal jayengi
G -------------------------D ---- C
Gum ki yeh zanjeerien pighal jayengi
G --------------------------D----- C
HO khuda pe bhi asar
G-------------------- D
tu duao ka hai Ghar
G-----------------D

CHORUS

yu to mein sabse nyaaraa hu
G -------------------D --------G
tera maa, mein dulaaraa hu
G -----------------D ---------G
(REpeat above 2 lines but add 'par' in the start of 2nd line)


Duniya mein jine se zyada uljhan hai ma
G -------------------------------C-----------D
tu hai amar ka jahaa
G ----------------D
tu gussa karti hai bada achha lagta hai
G--------------------D--------------------- G
tu kaan pakadti hai bada zor se lagta hai meri maa
G----------------------- D ------------------------D

CHorus

Remaining is the same....
Enjoy buddy.....