Tuesday, 23 July 2013

Brush up on your foreign-language skills with these apps

Busuu (free): If you’re looking to learn Arabic, Polish, Turkish, Russian or German, Busuu is a free iOS and Android app available in 12 different languages. What is unique about this app is that it directly connects learners with native speakers online.


After you’ve spent time sifting through the 3,000 words and key phrases, you can interact with users to practice what you’ve learned via its video-chat feature and peer-to-peer text corrections. The app also uses audio-visual techniques, with high-quality stock photography that does a good job of creating a clear visual context for the words. The basic version is free, with options to upgrade to the full app.

KTdict+ C-E, Chinese-English dictionary with flashcard trainer
 (free): Whether you create the flashcards or rely on the expert information available through the iOS app, the KTdict is a comprehensive, easy to use Chinese-English dictionary.

Users can search words using English, Chinese characters (simplified and traditional) and Hanyu Pinyin. It includes the data of the renowned CC-CEDICT dictionary, based on HanDeDict, with over 70,000 entries.

The KTdict app is free with ads, with an option to upgrade to an ad-free version for a fee. One of the best parts about this app is that everything is stored on your iOS device, and Internet connection is not required to use it.
Mind Snacks (free): Hola, Campeones de Aplicación! Or, hey, app champs! If you’re looking for a fun and free way to learn a new language, the MindSnacks app uses games to help teach people of all ages. The app consists of different language levels, that are in fact mini-games designed to get you through each learning journey. Each game is designed with a personalized learning algorithm that helps users maximize memorization, retention a nd contextual usage at their own individualized pace.

Through its interactive play, MindSnacks will teach you essential vocabulary and conversation skills. The app is available in a 13 languages, including Spanish, French, Portuguese, Chinese, Japanese, Italian and German. The app is free to download, but you will need to upgrade to a paid account in order to access the entire set of features and lessons.
Sign 4 Me – A Signed English Translator ($9.99): This is not quite a foreign language, but it is a form of language after all. If you’ve ever thought of learning sign language then this iOS app is a good starting point, coming with a broad lexicon to help you along.

The app provides sign-language instruction in 3D, so you can type in sentences, phrases, words and the alphabet that you want the avatar to sign. The avatar then acts out each word for you with subtitles letting you know which one he’s doing. You can also change the speed and camera angle to get a better look at the gestures.

Using your iPhone Siri speech recognition, the Sign 4 Me app can also translate your spoken words into si gned English. The library includes more than 11,500 words.
Babbel (free): Whether you want to learn Polish, Indonesian, or Dutch, Babbel has 11 languages to choose from. The free iOS and Android app blends listening, reading, writing, and speaking.

You can choose the lessons you want to focus on and learn basic or advanced language skills to fit almost any conversation needs. The app even ensures that you’re saying the words correctly with its pronunciation evaluator.

The best thing about Babbel is that it remembers your progress so you can access it from different places with different devices. Users can try Babbel on a free trial and then upgrade varying subscription levels: $12.95 per month; $26.85 every three months; or $44.70 every six months.
Close calls:
VerbalizeIt (free): If you are going abroad, you might want to think twice about leaving home without a translator app. The Ver balizeIt app connects translators around the globe with people struggling with a language. Users choose the language they need translated and after touching a button on the app they are connected to a person on the other end of the phone.

Smartphone owners can download the iOS or Android applications for free, but the cost of the service ranges from $1 to $2 per minute. Non-smartphone users can register to receive a local access phone number.
Jibbigo (free): The iOS and Android app lets users speak a phrase and automatically translates it both in audio and on-screen text. While it does not offer as many languages as Google Translate, it works completely offline. This way you don’t have to worry about not having Internet access or paying for roaming charges while you are in the middle of an unfamiliar land.


Wednesday, 10 April 2013

Free Online Alternatives To Expensive Software


DOCUMENT EDITING
 
Google Docs/Drive
Google Drive provides a feature-rich interface for text, spreadsheets and presentations. You can open documents saved in your Gmail inbox or create a new one online. You can also collaborate real-time with colleagues on a document. All documents are automatically saved in your Google Drive cloud storage space.
 
Microsoft Office Web Apps
Microsoft also offers a free online office suite for SkyDrive users — the interface will be familiar to users of MS Office. You get 7GB of free cloud storage to store your documents. You can create or upload Word, Excel, PowerPoint as well as OneNote files to SkyDrive and edit them. Documents can be shared and you can select which users can edit the document and if it is mandatory for users to sign into their Microsoft account to access the document or not. 
Zoho Docs www.zoho.com
 
Zoho's office suite includes support for MS Word, spreadsheets, presentations as well as databases and reports. Like the other two office suites mentioned above, this one also supports real-time collaboration but in addition offers various other integrated services. With a single account, you get access to mail, chat, calendar/planner, invoice generation, as well as a CRM (customer relationship management) system.
 
VIDEO EDITING
 
Filelab www.filelab.com 
Filelab products work better with Google Chrome and you need to download a free plugin first. Once y ou start, you get support for multiple video formats and HD resolution. It offers all the basic editing controls to trim, cut and merge. You can also add creativity to your video with multiple effects. There are over 50 transition effects available along with the option to overlay one video on top of the other. You can define transparency, add audio tracks and then watch a live preview right in your browser window.

Video ToolBox
This editor supports editing of the most common file formats and also lets you convert from one format to another. You can add watermarks, merge videos, extract audio, take screenshots or remove unwanted parts of a video. It also gives you 1GB of free cloud storage. 
YouTube Editor
Youtube offers a powerful online editor that lets you trim videos, merge multiple videos into one, add transitions, stabilise video or add a soundtrack of your choice. It also automatically suggests corrections and effects if your videos are not up to the mark. 
PHOTO EDITING
 
Photoshop Express
If you need to do just basic image adjustments and manipulation, Adobe's own online photo editor is great. You get basic editing (crop, resize, rotate) as well as a few adjustments (white balance, soft focus, highlight) options. Various effects to enhance the picture are also available. Once done, images can be saved to your computer or shared on Flickr, Facebook or Picasa. 
With this online editor, you can create a new image, upload one from your computer or open any image from a URL. The interface is similar to Adobe Photoshop and you get all the usual tools as well as support for layers. You also get various filter effects, levels, curves and exposure controls. Images can be saved to the computer or to online services like Flickr/Picasa. 
Splashup www.splashup.com 
Splashup has a similar interface to Photoshop. Apart from your PC and from a URL, it also supports importing images from Facebook, Flickr, Picasa, Photobucket and can capture an image from a webcam. Like Pixlr, it lets you work with layers to add various filters. However, it does not have advanced editing options such as levels and exposure control.
 
VARIOUS OTHER FREE TOOLS
 
Music Creation
 
SOUNDATION STUDIO (www.soundation. com) offers advanced tools and effects that you would only get with professional music studio software. You launch the studio right inside your browser window and it also includes over 600 free audio loops and samples that you can start with. A free account lets you save and publish as many songs as you want, but if you want recording, you need one of the paid plans.
 
3D House Planner
 
HOMESTYLER (www.homestyler.com) is a free and easy-to-use house planner. You can use it if you are planning on building a new house or even just redecorating. Homestyler lets you easily create a layout, add furniture, landscaping and experiment with paints, textures and different lighting for your room. You can easily view in 3D and share with friends too. 
PDF Tools
 
A SUITE of no-nonsense PDF tools can be found at www.pdfunlock.com (to remove restrictions from PDFs), www.pdfmerge. com (to merge multiple files into one), www. splitpdf.com (split one file into multiple) and www.pdfprotect.net (add password protection). At www.pdfaid. com, you can choose from a variety of web tools for watermarking, image extraction, rotation, compression and conversion. Note that some of the tools imprint a small PDFAid logo on the final file.
 
Speech To Text
 
RATHER THAN use expensive dictation software, just head to www.talktyper.com. You need to download Google Chrome first because it doesn't work too w ell on other browsers. Make sure your microphone is working and click the green microphone button to start the dictation. It works pretty well if you speak clearly and the conversion to text is almost instantaneous. 
Optical Character Recognition
 
AT www.ocronline.com, you can convert a scanned document, PDF file or an image (JPEG, TIFF, PNG, PDF) to an editable text file. First, complete a quick sign-up. If you are scanning, make sure to do it in 300dpi. Upload your document, select your preferred output format and you're done.

Thursday, 4 April 2013

New Wireless Packet Trace Format in NS2


New Wireless Packet Trace Format can be activated by adding following TCL statement in the simulation script :

$ns_ use-newtrace

The new wireless trace format is as follows:

<tag> <tag_value> [-<subtag> <subtag_value>]

where <tag> is a one-letter or two-letter option tag, indicating the meaning of the following <tag_value>. Optionally, <subtag> is the subtag whose value is specified in <subtag_value>. The list of option tags and sub-tags as well as their meaning is given bellow :


General Information :

-t  Time

Node Information(-N?) :

-Ni  Node ID
-Nl  Trace level : AGT/RTR/MAC 

-Ne  Energy Level
-Nx,-Ny,-Nz,-Nw  Node Cordinates

IP Information(-I?):

-Is  Source Port
-It  Packet Type
-If  Flow ID
-Iv  Time to live
-Id  Destination Port
-Il  Packet size
-Ii  Unique ID

Next Hop (-H?):

-Hs  ID of this node

MAC Level Information(-M?):

-Ms  Source Ethernet Address
-Md  Destination Ethernet Address
-Mt  Ethernet Type
-Ma  Packet Transmission Time

Application information-ARP (-P arp -P?):

 -Ps   Source address
 -Pm  Source MAC address
 -Po   Either "REQUEST" or "REPLY"
 -Pd   Destination IP Address
 -Pa   Destination MAC address

 Application information-CBR (-P cbr -P?):

 -Pi    Sequence number
 -Pf          The number of time this picket has been forwarded
 -Po   Min. number of hops to reach the destination as indicated by GOD. The default value when GOD is not in use is -1

 Application information - TCP(-P tcp -P?):

 -Ps   Sequence number
 -Pf    same as that of CBR
 -Pa   Acknowledge number acknowledgement number
 -Po   same as that of CBR

Consider Following Example for explanation of this Format :

 s -t 31.000000000 -Hs 0 -Hd -2 
-Ni 0 -Nx 19.36 -Ny 17.32 -Nz 0.00 -Ne -1.000000 
-Nl AGT -Nw --- -Ma 0 -Md 0 -Ms 0 -Mt 0
-Is 0.0 -Id 1.0 -It tcp -Il 40 -If 2 -Ii 3 -Iv 32 
-Pn tcp -Ps 0 -Pa 0 -Pf 0 -Po 0


  • At 31 second, this record traces Node 0 at the agent AGT level. 
  • Node 0 is located at the coordinate (19.36,17.32,0). 
  • The reasons string (i.e., -Nw) is empty. 
  • The record does not trace the node energy level (-Ne -1). 
  • The packet is sent from the address 0 port 0 to the node with the address 1 port 0. 
  • The packet type is “tcp” whose size is 40 bytes (i.e., this is the SYN packet). 
  • The flow ID is 2. The packet unique ID is 3. 
  • The time to live is 32.
  • This packet has never been forwarded before. The number of hops to destination as indicated by GOD is zero (i.e., GOD is not active).



Thursday, 13 December 2012

Difference Between Virus,Worms,Trojan and Spyware


We all have heard the terms Virus,Worms,trojans and spyware but only a few of us know the difference between them.We genreally consider everything that is detected by an antivirus as virus but this is not the case.The antivirus not only provides protection against viruses but it also protects us from trojans,worms and spywares.All these can be harmful to your computer hardware and software.Today I will differentiate all these terms from each other .

Ok lets start from the introduction of viruses

Virus :- A virus is a self replicating program that attaches itself to an executable file.When the file is executed the virus automatically gets executed and enters into system memory .Once it enters into system memory it either searches for other files that can be infected or stays in the background and infect the files that are uses the virus infected program.

Worms : Worms are very similar to viruses but differ in way that they donot bind themselves to executable files instead to replicate themselves they uses the network.If you find excessive use of your network bandwidth then you may be infected by a worm.So,a worm donot require a user to execute any file for its execution it can work without user intervention.

Trojan Horse :- A trojan horse is harmful program which may seem harmless to the user before its installation but instead it is programmed or reverse engineered to facilitate unauthorised remote access to the computer.Trojan’s donot replicate themselves.

Spyware :- A spyware is a program that secretly monitor and collects pieces of information.They usually run in stealth mode and cannot be detected easily.Keyloggers is a great example of spyware software.These are not limited to just spying but can also send data to remote computers .

Sunday, 28 October 2012

Apache Hadoop

Hadoop, an Apache open-source project, is a framework written in Java for running applications on large clusters of commodity hardware and incorportates features to manage unstructured, semi-structured, and structured data.It is a collection of open-source components built on top of a distributed file system that was designed specifically for very large-scale data operations.

Apache Hadoop detailed Presentation . Download it here. if you want more material then post comments...

Access Blocked Website from any wifi router of colleges



Spotflux harnesses the power of the cloud to conduct millions of real-time checks for invasive tracking, advertisements, malware, and other bugs that pose a threat to your identity or your data.


1. Just enable spotflux and continue enjoying the internet as you always do.
2. Your internet traffic is encrypted and sent through the spotflux cloud.
3. Spotflux's cloud runs millions of calculations to remove ads, tracking cookies, and other things that follow you around the web.
4. Viruses and malware are zapped and destroyed.
5. The location and identity of your devices are concealed.
6. Your connection to the internet is safer, more private, and unrestricted.



Just Download and Install Spotflux utility to access any website from anywhere.

Sunday, 21 October 2012

Increase Internal Memory of Samsung Galaxy Y


  1.  You will need to root your Samsung Galaxy Y.
  2.  We need to create a partition on your SD Card or your microSD card.
  3.  To create a partition in our microSD Card, we will be needing a free tool called MiniTool.
  4.  After you have download the MiniTool Partition Wizard, install it in your computer and Run MiniTool.
  5. If your microSD card is new then you can proceed with creating a partition. If not, be sure to back up everything in your microSD card. Creating a partition will delete every data in your microSD card.
  6.  Plug your microSD card to your computer. While in MiniTool, right click your microSD card drive and format it. REMEMBER: Be sure it is the correct drive and do this after you have backup every data in your card. Select fat32 as file system, hit ok and hit the apply button found in the upper left corner of MiniTool (the one with the big blue check mark)
  7. After you have formatted it, right click on the microSD drive again and select Move/Resize.The unallocated size will serve as the additional internal memory of your android smartphone. Hit ok after you have set the partition size.
  8. You will see in the MiniTool window an unallocated size in your microSD card.. Right click and create a partition for it, it will be formatted at the same time. Choose EXT3 as its file system. Hit the Apply button again after. Again be sure to hit the big check “Apply” buttonotherwise the changes would not be implemented.
  9. After partition, you will only see the FAT32 portion of the microSD in your Windows Computer. But in Minitool you will see that there is a FAT32 and EXT3 partition. Now your done with the partitioning.
  10. You will also be needing another app called link2sd.
  11. Install link2sd in your smartphone, run link2sd and it will ask you to mount script. Choose ext3 and hit OK
  12. After you have successfully done that, reboot your android smartphone.
  13. Once your phone returns from reboot, Run link2sd, go to its settings and check everything to auto-link. That should do it!

Radio Frequency Identification

Download it here....

Intel 80486 Microprocessor - Report

Intel 80486 Microprocessor report in IEEE format .Download It here.

Power Aware Routing In Wireless Sensor Networks

Download Complete Report and Presentation On Power Aware Routing In Wireless Sensor Networks....

Admission Management System in asp

The Complete Project of Admission Management System developed in asp.net. You can Download it here...

Ad hoc Networks - Complete Report

You can Download Ad hoc Networks : report as well as ppt.

Thursday, 18 October 2012

Ubuntu Install From USB


    Download Syslinux, which is the bootloader we will be using to make the stick bootable. Just get the latest version in zip format, and extract it to the Desktop – right-click, select 7-zip, then extract to syslinux-7.1.1 (or whatever) and then rename that folder to “syslinux”.
    Open a command prompt (on the Start Menu under Accessories, or run “cmd”) and cd to the syslinux folder:
    cd Desktop/syslinux/win32
    Run this command to install the syslinux bootlader to the thumbdrive:
    syslinux -ma f: (where f: is the letter of your USB thumbstick)
    Now we need to extract the Ubuntu ISO – Right click on the ISO file, and select 7-zip/extract to ubuntu-8.04…

Drag all of the files you just extracted from the ISO into the empty USB drive.
Move everything from the isolinux folder into the root of the drive. So, if your USB thumbdrive’s letter is F, as in our earlier example, move all the files from F:\isolinux\ into F:\
Rename the isolinux.cfg file to syslinux.cfg
Eject the drive, insert into the computer you wish to install Ubuntu onto, and boot!


Free Airtel 3G : Working Proxy


Working proxys for Airtel free 3g :-

Home Page :fb.me
Proxy:interrobangpath.org
Port :80

Home Page: fb.me
Proxy: 176.9.126.177
Port: 80

homepage=http://fb.me
proxy=anobrowse.com
port=80

Apn: airtelgprs.com
Port: 80
Proxy: 174.142.196.230
(or)
Apn : airtelgprs.com
Port - 80
Proxy - 69.162.137.227
Homepage : fb.me or live.airtelworld.com
( or )
85.214.50.141
or
66.90.76.90 (Old but working fast)
or
176.31.222.34 (Old but working)
Homepage:  fb.me or any free site.

Facebook, YouTube and Many more Now With Free Airtel 3G


1. First Activate 3G and Balance should be less than 5.
2.change proxy settings in Firefox:
Proxy:  208.77.23.4
Port : 80
3. Change Home Page to : http://fb.me/index.php
4. open home page and Enter any URL in that page only.

Free Internet on Airtel 3G

  1. First Activate 3G and Balance should be less than 5.
  2. Change proxy settings in Firefox:
    Proxy: 150.161.2.9
    Port : 80
  3. Change Home Page to :  http;//59.160.229.40/~mgr/proxy.php
  4. Open home page and Enter any URL in that page only.

Tuesday, 16 October 2012

Sliding Window Protocols using C



#include<fstream.h>
#include<stdio.h>
#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<process.h>
void receiver(char a,int& flag)
{

fstream fil;
fil.open("Z:\write.txt",ios::in|ios::app);
cout<<"\nThe receive bit is :"<<a;
fil<<a;
flag=1;
fil.close();
getch();

}
void sender()
{
int flag=0;
fstream f;
f.open("Z:\send.txt",ios::in|ios::app);
char a=1;
while(!f.eof())
{
     f>>a;
     cout<<"\nsending bit is:";
     cout<<a;
     receiver(a,flag);
     if(flag==0)
     {
getch();
exit(0);
     }
     cout<<"\nacknowledgement complete NEXT BIT :\n";
     flag=0;
}
}
void main()
{
clrscr();
remove("Z:\CN\write.txt");
sender();
getch();
}

/* OUTPUT:
sending bit is:G
The receive bit is :G
acknowledgement complete NEXT BIT :

sending bit is:O
The receive bit is :O
acknowledgement complete NEXT BIT :

sending bit is:O
The receive bit is :O
acknowledgement complete NEXT BIT :

sending bit is:D
The receive bit is :D
acknowledgement complete NEXT BIT :

sending bit is:M
The receive bit is :M
acknowledgement complete NEXT BIT :

sending bit is:O
The receive bit is :O
acknowledgement complete NEXT BIT :

sending bit is:R
The receive bit is :R
acknowledgement complete NEXT BIT :

sending bit is:I
The receive bit is :I
acknowledgement complete NEXT BIT :

sending bit is:N
The receive bit is :N
acknowledgement complete NEXT BIT :

sending bit is:G
The receive bit is :G
acknowledgement complete NEXT BIT :

*/
                                                                             
                                                                             
                                                                             
                                                                             
                                                                             
                                                                             
                                                                             
                                                                             
                                                                             
                                                                             
                                                                             
                                                                             
                                                                             
                                                                             

Socket Programming in C

Client :-


#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <netdb.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <sys/socket.h>

#define PORT 3400 // the port client will be connecting to

#define MAXDATASIZE 100 // max number of bytes we can get at once

int main(int argc, char *argv[])
{
    int sockfd, numbytes;
    char buf[MAXDATASIZE];
    struct hostent *he;
    struct sockaddr_in their_addr; // connector's address information

    if (argc != 2) {
        fprintf(stderr,"usage: client hostname\n");
        exit(1);
    }

    if ((he=gethostbyname(argv[1])) == NULL) {  // get the host info
        perror("gethostbyname");
        exit(1);
    }

    if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
        perror("socket");
        exit(1);
    }

    their_addr.sin_family = AF_INET;    // host byte order
    their_addr.sin_port = htons(PORT);  // short, network byte order
    their_addr.sin_addr = *((struct in_addr *)he->h_addr);
    memset(&(their_addr.sin_zero), '\0', 8);  // zero the rest of the struct

    if (connect(sockfd, (struct sockaddr *)&their_addr, sizeof(struct sockaddr)) == -1) {
        perror("connect");
        exit(1);
    }

    if ((numbytes=recv(sockfd, buf, MAXDATASIZE-1, 0)) == -1) {
        perror("recv");
        exit(1);
    }

    buf[numbytes] = '\0';

    printf("Received: %s",buf);

    close(sockfd);

    return 0;
}

Server :-


/*erver.c -- a stream socket server demo
*/

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/wait.h>
#include <signal.h>

#define MYPORT 3400    // the port users will be connecting to

#define BACKLOG 10     // how many pending connections queue will hold

/*void sigchld_handler(int s)
{
    while(waitpid(-1, NULL, WNOHANG) > 0);
}*/

int main(void)
{
    int sockfd, new_fd;  // listen on sock_fd, new connection on new_fd
    struct sockaddr_in my_addr;    // my address information
    struct sockaddr_in their_addr; // connector's address information
    socklen_t sin_size;
    struct sigaction sa;
    int yes=1;

    if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
        perror("socket");
        exit(1);
    }

  /*  if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)) == -1) {
        perror("setsockopt");
        exit(1);
    }*/

    my_addr.sin_family = AF_INET;         // host byte order
    my_addr.sin_port = htons(MYPORT);     // short, network byte order
    my_addr.sin_addr.s_addr = INADDR_ANY; // automatically fill with my IP
    memset(&(my_addr.sin_zero), '\0', 8); // zero the rest of the struct

    if (bind(sockfd, (struct sockaddr *)&my_addr, sizeof(struct sockaddr)) == -1) {
        perror("bind");
        exit(1);
    }

    if (listen(sockfd, BACKLOG) == -1) {
        perror("listen");
        exit(1);
    }

    /*sa.sa_handler = sigchld_handler; // reap all dead processes
    sigemptyset(&sa.sa_mask);
    sa.sa_flags = SA_RESTART;
    if (sigaction(SIGCHLD, &sa, NULL) == -1) {
        perror("sigaction");
        exit(1);
    }
*/
    while(1) {  // main accept() loop
        sin_size = sizeof(struct sockaddr_in);
        if ((new_fd = accept(sockfd, (struct sockaddr *)&their_addr, &sin_size)) == -1) {
            perror("accept");
            continue;
        }
        printf("server: got connection from %s\n",inet_ntoa(their_addr.sin_addr));
      /*  if (!fork()) { // this is the child process
            close(sockfd); // child doesn't need the listener*/
            if (send(new_fd, "Hello, world!\n", 14, 0) == -1)
                perror("send");
            close(new_fd);
            exit(0);
        //}
        close(new_fd);  // parent doesn't need this
    }

    return 0;
}



LEACH in NS2 using Mannasim Frame-work

The code in the editor below shows how to simulate LEACH protocol
using MannaSim patch with ns2. A summary of the simulation settings is
given below:

Area: 500 m X 500m
Duration: 550 sec
# of nodes: 11
# of clusters: 4
New cluster formation interval: 100 sec (fixed)
Initial energy: 10 joules
Disseminating interval: 10 sec
Transmission range: 50 m
Channel type: Wireless
Transport protocol: UDP
Layer: Physical
Antenna: OmniAntenna
Radio Propagation:TwoRayGround
Sensing interval: 5 sec
Data generator type: Temperature
Sensing type: Programmed

The no. of access points has been set to be 0 for our simulation and
all the nodes are static.

The ratio P that has been referred to while describing LEACH in the
theory section is obtained in our case as k/N, where k is the # of
desired cluster heads, and N is the total # of nodes in the network.

Now, answer the following and verify them from the simulation results:

For the given simulation time, how many rounds of cluster formation take place?
What is the number of cluster heads per round?
Does the average number of cluster heads per round equal the desired
number of cluster heads (line #475)? (See the discussion on LEACH in
Theory section)
Vary the number of nodes (line #474) and expected number of cluster
heads (line #475), and once again verify the output


# Generated by MannaSim


puts "Initializing MannaSim Script..."

#Consumo de energia do sensor node - Dados do Mica Motes
set mica(sensing_power) 0.015 ;# i = 5mA, V = 3 --> P = ixV = 15 mW = 0.015 W
set mica(processing_power) 0.024 ;# i = 8mA, V = 3 --> P = ixV = 24 mW = 0.024 W
set mica(instructions_per_second) 8000000 ;# Atmel 128L 8MHZ --> 8MIPS

#Consumo de energia do sensor node - Dados do WINS
set wins(sensing_power) 0.064 ;# 64 mW = 0.064 W
set wins(processing_power) 0.360 ;# 360 mW = 0.360 W
set wins(instructions_per_second) 150000000 ;# Intel StrongArm 1100 133 MHZ --> 150 MIPS

#Seta valores para consumo de energia com o radio
set mica(consumo_transmissao) 0.036 ;#i = 12mA, V = 3 --> P = ixV = 36mW = 0.036W
set mica(consumo_recepcao) 0.024 ;#i = 8mA, V = 3 --> P = ixV = 24mW = 0.024W

set wins(consumo_transmissao)   3.75 ;# 3.75 250m, 0.6 600 mW - 100m
set wins(consumo_recepcao) 1.875 ;# 1.875 250m,  0.3 300 mW

#seta a taxa de transmissao
#Phy/WirelessPhy set  bandwidth_
set mica(taxa_transmissao) 28.8*10e3 ;#28.8 kbps
set wins(taxa_transmissao) 100*10e3 ;#100 kbps

proc setup_mica2 { antenna range }  {
        puts "Setting up mica 2 mote with $antenna and range = $range"      

        Phy/WirelessPhy set Pt_ 0.281838
        Phy/WirelessPhy set freq_ 2.4e09
        Phy/WirelessPhy set L_ 1.0
        Phy/WirelessPhy set lambda_ 0.125
        Phy/WirelessPhy set RXThresh_ [TwoRay 0.281838 [$antenna set Gt_] [$antenna set Gr_] 0.8 0.8 1.0 $range 0.125]
        Phy/WirelessPhy set bandwidth_ 28.8*10e3        ;#28.8 kbps

        Node/MobileNode/SensorNode set sensingPower_ 0.015
        Node/MobileNode/SensorNode set processingPower 0.024
        Node/MobileNode/SensorNode set instructionsPerSecond_ 8000000

}

##########################################
# CONSTANTES
#########################################
# Continuo: 0
# Programada: 1
# Sob Demanda: 2
########################################

proc create_common_app {destination_id disseminating_type disseminating_interval} {
    global val
    #puts "executing create_common_app\n"
    if { $val(commonApp) == "Application/SensorBaseApp/CommonNodeApp/LeachApp" } {
          if { $val(n_ch) == 0 } {
                   puts "NO CLUSTER HEADS HAS BEEN DEFINED! Assuming 20% of common nodes."
                   set val(n_ch) [expr int($val(n_common) * 2 / 10)]
          }
          #puts "Debug: val(n_ch): $val(n_ch)\n";
          set app_ [new $val(commonApp) $val(nn) $val(n_ch) [expr sqrt($val(x) * $val(x) + $val(y) * $val(y))]]
    } else {
          set app_ [new $val(commonApp)]
          $app_ set destination_id_ $destination_id
    }
    $app_ set disseminating_type_ $disseminating_type
    $app_ set disseminating_interval_ $disseminating_interval
    return $app_
}

set val(commonApp) "Application/SensorBaseApp/CommonNodeApp"
set val(chApp)     "Application/SensorBaseApp/ClusterHeadApp"
set val(apApp)     "Application/AccessPointApp"

proc create_cluster_head_app {destination_id disseminating_type disseminating_interval} {
    global val
    set app_ [new $val(chApp)]
    $app_ set destination_id_ $destination_id
    $app_ set disseminating_type_ $disseminating_type
    $app_ set disseminating_interval_ $disseminating_interval
    return $app_
}

proc create_access_point_app {outside_network} {
    global val
    set app_ [new $val(apApp)]
    $app_ set outside_network_ $outside_network
    return $app_
}

proc create_temp_data_generator {sensing_interval sensing_type avg_measure std_deviation maximumTemperatureAllowedValue} {
    set temp_gen_ [new DataGenerator/TemperatureDataGenerator]
    $temp_gen_ set sensing_interval_ $sensing_interval
    $temp_gen_ set sensing_type_ $sensing_type
    $temp_gen_ set avg_measure $avg_measure
    $temp_gen_ set std_deviation $std_deviation
    $temp_gen_ set maximumTemperatureAllowedValue_ $maximumTemperatureAllowedValue
    return $temp_gen_
}

proc create_data_generator {generator sensing_interval sensing_type avg_measure std_deviation maximumTemperatureAllowedValue} {
    set temp_gen_ [new DataGenerator/$generator]
    $temp_gen_ set sensing_interval_ $sensing_interval

    if {$sensing_type=="continuous"} {
          $temp_gen_ set sensing_type_ 0
    } elseif {$sensing_type=="programmed"} {
          $temp_gen_ set sensing_type_ 1
    } elseif {$sensing_type=="on demand"} {
          $temp_gen_ set sensing_type_ 2
    } else {          
          $temp_gen_ set sensing_type_ $sensing_type
    }
    $temp_gen_ set avg_measure $avg_measure
    $temp_gen_ set std_deviation $std_deviation
    $temp_gen_ set maximumTemperatureAllowedValue_ $maximumTemperatureAllowedValue
    return $temp_gen_
}

proc create_common_node { iniEnergy x y z father_addr start stop } {
    global val ns_ node_ topo udp_ app_ gen_ contador_nodos rng trace

    if { [llength $start] == 0 }  {
            set start [expr $val(start) + [$rng uniform 0 1]]
            set stop $val(stop)
    }

    $ns_ node-config -sensorNode ON \
        -adhocRouting $val(rp) \
        -llType $val(ll) \
        -macType $val(mac) \
        -ifqType $val(ifq) \
        -ifqLen $val(ifqlen) \
        -antType $val(antenna) \
        -propType $val(prop) \
        -energyModel $val(en) \
        -phyType $val(netif) \
        -channelType $val(chan) \
        -topoInstance $topo \
        -agentTrace $trace(agent) \
        -routerTrace $trace(router) \
        -macTrace $trace(mac) \
        -rxPower 0.024 \
        -txPower 0.036 \
        -initialEnergy $iniEnergy \
        -movementTrace $trace(movement)

        set node_($contador_nodos) [$ns_ node]
        $node_($contador_nodos) random-motion 0

        $node_($contador_nodos) set X_ $x
        $node_($contador_nodos) set Y_ $y
        $node_($contador_nodos) set Z_ $z

        puts "* Node [$node_($contador_nodos) node-addr] = $contador_nodos created in ($x, $y, $z)"

        set app_($contador_nodos) [create_common_app $father_addr $val(disseminating_type) $val(disseminating_interval)]

        if { $val(leach) == 1 } {
              set agent [new Agent/RCAgent]

              $agent set sport_ 0
              $agent set dport_ 0

              $node_($contador_nodos) attach $agent 0
              $app_($contador_nodos) attach-agent $agent

              $agent add-ll [$node_($contador_nodos) set ll_(0)] [$node_($contador_nodos) set mac_(0)]
        } else {
                set udp_($contador_nodos) [new Agent/UDP]
                $node_($contador_nodos) attach $udp_($contador_nodos) $val(port)
        }
        $node_($contador_nodos) add-app $app_($contador_nodos)

        set processing_($contador_nodos) [new $val(processing)]

        $app_($contador_nodos) node $node_($contador_nodos)

        if { $val(leach) != 1 } {
                $app_($contador_nodos) attach-agent $udp_($contador_nodos)
        }

        $app_($contador_nodos) attach-processing $processing_($contador_nodos)
        $processing_($contador_nodos) node $node_($contador_nodos)

        for { set i 0 } { $i < [llength $start] } { incr i } {
                $ns_ at $start "$app_($contador_nodos) start"
        }

        for { set i 0 } { $i < [llength $stop] } { incr i } {
                $ns_ at $stop "$app_($contador_nodos) stop"
        }

        #[create_temp_data_generator  5.0 0 27.0 10.0 50]
        set gen_($contador_nodos) $val(data_generator)

        $app_($contador_nodos) attach_data_generator $gen_($contador_nodos)

        incr contador_nodos

}

proc create_cluster_head_node { iniEnergy x y z father_addr start stop } {

        global val ns_ node_ topo udp_ app_ gen_ contador_nodos rng trace

        if { [llength $start] == 0 }  {
                set start [expr $val(start) + [$rng uniform 0 1]]
                set stop $val(stop)
        }

        $ns_ node-config -sensorNode ON \
            -adhocRouting $val(rp) \
            -llType $val(ll) \
            -macType $val(mac) \
            -ifqType $val(ifq) \
            -ifqLen $val(ifqlen) \
            -antType $val(antenna) \
            -propType $val(prop) \
            -energyModel $val(en) \
            -phyType $val(netif) \
            -channelType $val(chan) \
            -topoInstance $topo \
             -agentTrace $trace(agent) \
            -routerTrace $trace(router) \
            -macTrace $trace(mac) \
            -rxPower 0.024 \
            -txPower 0.036 \
            -initialEnergy $iniEnergy \
            -movementTrace $trace(movement)

        #puts "Debug Cluster head iniEnergy: $iniEnergy\n";

        set node_($contador_nodos) [$ns_ node]
        $node_($contador_nodos) random-motion 0


        $node_($contador_nodos) set X_ $x
        $node_($contador_nodos) set Y_ $y
        $node_($contador_nodos) set Z_ $z

        puts "* Cluster head [$node_($contador_nodos) node-addr] = $contador_nodos created in ($x, $y, $z)"

        set udp_($contador_nodos) [new Agent/UDP]
        set app_($contador_nodos) [create_cluster_head_app $father_addr $val(disseminating_type) $val(disseminating_interval)]

        $node_($contador_nodos) attach $udp_($contador_nodos) $val(port)
        $node_($contador_nodos) add-app $app_($contador_nodos)

#CN#        set processing_($contador_nodos) [new $val(processing)]

        $app_($contador_nodos) node $node_($contador_nodos)
        $app_($contador_nodos) attach-agent $udp_($contador_nodos)

#CN#        $app_($contador_nodos) attach-processing $processing_($contador_nodos)
        $processing_($contador_nodos) node $node_($contador_nodos)

        for { set i 0 } { $i < [llength $start] } { incr i } {
                $ns_ at $start "$app_($contador_nodos) start"
        }

        for { set i 0 } { $i < [llength $stop] } { incr i } {
                $ns_ at $stop "$app_($contador_nodos) stop"
        }

#CN#        set gen_($contador_nodos) $val(data_generator)
#CN#        $app_($contador_nodos) attach_data_generator $gen_($contador_nodos)

        incr contador_nodos

}

proc create_access_point { iniEnergy x y z start stop} {
        global ns_ val node_ app_ udp_ contador_nodos topo trace rng

        if { [llength $start] == 0 }  {
                set start [expr $val(start) + [$rng uniform 0 1]]
                set stop $val(stop)
        }

        $ns_ node-config -sensorNode ON \
            -adhocRouting $val(rp) \
            -llType $val(ll) \
            -macType $val(mac) \
            -ifqType $val(ifq) \
            -ifqLen $val(ifqlen) \
            -antType $val(antenna) \
            -propType $val(prop) \
            -energyModel $val(en) \
            -phyType $val(netif) \
            -channelType $val(chan) \
            -topoInstance $topo \
             -agentTrace $trace(agent) \
            -routerTrace $trace(router) \
            -macTrace $trace(mac) \
            -rxPower 0.5 \
            -txPower 0.5 \
            -initialEnergy $iniEnergy \
            -movementTrace $trace(movement)

        #puts "Debug AP iniEnergy: $iniEnergy\n";

        set node_($contador_nodos) [$ns_ node]
        $node_($contador_nodos) random-motion 0
        set app_($contador_nodos) [create_access_point_app [$node_(0) node-addr]]

        if { $val(leach) == 1 } {
              set agent [new Agent/RCAgent/LeachAgent]

              $agent set sport_ 0
              $agent set dport_ 0

              $node_($contador_nodos) attach $agent 0
              $app_($contador_nodos) attach-agent $agent

              $agent add-ll [$node_($contador_nodos) set ll_(0)] [$node_($contador_nodos) set mac_(0)]
        } else {
              set  udp_($contador_nodos) [new Agent/UDP]
              $node_($contador_nodos) attach $udp_($contador_nodos) $val(port)
              $app_($contador_nodos) attach-agent $udp_($contador_nodos)
        }
        $node_($contador_nodos) set X_ $x
        $node_($contador_nodos) set Y_ $y
        $node_($contador_nodos) set Z_ $z

        puts "* Access point [$node_($contador_nodos) node-addr] = $contador_nodos created in ($x, $y, $z)"

        for { set i 0 } { $i < [llength $start] } { incr i } {
                $ns_ at $start "$app_($contador_nodos) start"
        }

        for { set i 0 } { $i < [llength $stop] } { incr i } {
                $ns_ at $stop "$app_($contador_nodos) stop"
        }

        incr contador_nodos

}

###
# Grid distribution.

proc get_next_x {} {

        global val
        set aux [expr int(sqrt($val(nn)))]
        return [expr (($contador_nodos) % $aux) * $val(x) / ($aux - 1)]

}

proc get_next_y {} {

        global val
        set aux [expr int(sqrt($val(nn)))]
        return [expr (($contador_nodos) / $aux) * $val(y) / ($aux - 1)]

}

####
# Calculating the receiving threshold (RXThresh_ for Phy/Wireless)
# Wei Ye, weiye@isi.edu, 2000

proc Friis { Pt Gt Gr lambda L d} {
  set M [expr $lambda / (4 * 3.14159265359 * $d)]
  return [expr ($Pt * $Gt * $Gr * ($M * $M)) / $L]
}

proc TwoRay { Pt Gt Gr ht hr L d lambda } {
        set crossover_dist [expr (4 * 3.14159265359 * $ht * $hr) / $lambda]

        if { $d < $crossover_dist } {
                return [Friis $Pt $Gt $Gr $lambda $L $d]
        } else {
                return [expr $Pt * $Gt * $Gr * ($hr * $hr * $ht * $ht) / ($d * $d * $d * $d * $L)]
       }
}

###

proc set_default_settings {} {

        global val

        ####
        # Default network settings
        set val(antenna) "Antenna/OmniAntenna"
        Antenna/OmniAntenna set X_ 0 ;
        Antenna/OmniAntenna set Y_ 0 ;
        Antenna/OmniAntenna set Z_ 1.5 ;
        Antenna/OmniAntenna set Gt_ 1.0 ;
        Antenna/OmniAntenna set Gr_ 1.0 ;

        ###

        # Using Mica 2 Mote settings


        set val(range) 100
        setup_mica2 $val(antenna) $val(range)
        set val(bandwidth) [Phy/WirelessPhy set bandwidth_]
        set val(mac)    Mac/802_11
        set val(ifq)    Queue/DropTail
        set val(ifqlen) 200
        set val(ll) LL
        set val(rp) "LEACH"


        # Configuration adjustment

        if { $val(rp) == "LEACH" } {

                set val(rp) DumbAgent
                set val(leach) 1

                if { $val(ll) != "RCALinkLayer" } {
                        puts "LEACH requires RCALinkLayer! Forcing it!!!"                   
                        set val(ll) RCALinkLayer
                }

                if { $val(netif) != "Phy/WirelessPhy/LeachWirelessPhy" } {
                        puts "LEACH requires LeachWirelessPhy! Forcing it!!!"
                        set val(netif) Phy/WirelessPhy/LeachWirelessPhy
                }

                if { $val(mac) != "Mac/Sensor" } {
                        puts "LEACH requires Mac/Sensor! Forcing it!!!"
                        set val(mac) Mac/Sensor
                }

                set val(port) 0

                Agent/RCAgent set sport_           $val(port)
                Agent/RCAgent set dport_           $val(port)
                Agent/RCAgent set packetMsg_       0
                Agent/RCAgent set distEst_         0
                Agent/RCAgent set packetSize_      0

                RCALinkLayer set delay_            25us
                RCALinkLayer set bandwidth_        [Phy/WirelessPhy set bandwidth_]
                RCALinkLayer set off_prune_        0
                RCALinkLayer set off_CtrMcast_     0
                RCALinkLayer set macDA_            0
                RCALinkLayer set debug_            0
        } else {
                set val(leach) 0
        }
        if { $val(rp) == "DIRECTED DIFFUSION" } {
                set val(rp) "Directed_Diffusion"
        }       
}

set val(father_addr) 0 
set val(port)   2020

set val(netif)  Phy/WirelessPhy

set_default_settings

# Global network settings
set contador_nodos 0
set val(chan)   Channel/WirelessChannel

# Propagation
set val(prop)   Propagation/TwoRayGround

# Energy model
set val(en) EnergyModel/Battery

# Nodes
set val(n_pas)  0
set val(n_common) 11
set val(n_ch) 4
set val(nn) [expr $val(n_pas) + $val(n_common) + $val(n_ch)]

puts "\nNodes count:"
puts " - $val(n_pas) access points"
puts " - $val(n_common) common nodes"
puts " - $val(n_ch) cluster heads"
puts " - $val(nn) nodes"
puts " - $val(rp) routing protocol"
puts " - $val(ll) link layer"
puts " - $val(netif) network interface"

# Scenario size
set val(x)  500.0
set val(y)  500.0

puts "\nScenario size: $val(x) x $val(y)"

set val(start)  0.0
set val(stop)   [expr $val(start) + 550.0]

set ns_     [new Simulator]


# Trace
puts "\nUsing trace.tr as trace file"
set traceFile   [open trace.tr w]
$ns_ trace-all $traceFile
$ns_ use-newtrace

set trace(mac) ON
set trace(router) ON
set trace(agent) ON
set trace(movement) ON


set topo    [new Topography]
$topo load_flatgrid $val(x) $val(y)
create-god $val(nn)
set rng [new RNG]
$rng seed [clock seconds]

#-------------------------------------------------------------------------------------------



# Creating an access point
puts "Creating an access point..."

set_default_settings


# Using Mica 2 Mote settings

puts "Using mica 2 mote settings"
set val(range) 100
setup_mica2 $val(antenna) $val(range)
set local(x) 50.0
set local(y) 50.0
set local(z) 0.0
set local(start) ""
set local(stop) ""
set local(energy) 100.0
set val(apApp) Application/AccessPointApp/AccessPointLeachApp

create_access_point $local(energy) $local(x) $local(y) $local(z) $local(start) $local(stop)



# Creating common node
puts "Creating common node..."

set_default_settings


# Using Mica 2 Mote settings
puts "Using mica 2 mote settings"

set val(range) 100
setup_mica2 $val(antenna) $val(range)

# Disseminating settings
set val(disseminating_type) 0       ;# Programmed
puts "Setting disseminating type to programmed"
set val(disseminating_interval) 10.0
puts "Setting disseminating interval: $val(disseminating_interval)"

set local(start) ""
set local(stop) ""
set local(energy) 10.0
set local(father_addr) $val(father_addr)

set val(processing) Processing/AggregateProcessing
set val(data_generator) "[create_data_generator {TemperatureDataGenerator} {5.0} {programmed} {25.0} {5.0} {30.0}]"


for { set common_node_i 0 } { $common_node_i < 10 } { incr common_node_i } {
    set local(x) [$rng uniform 0.0 $val(x)]
    set local(y) [$rng uniform 0.0 $val(y)]
    set local(z) 0.0

    set val(commonApp) Application/SensorBaseApp/CommonNodeApp/LeachApp
    create_common_node $local(energy) $local(x) $local(y) $local(z) $local(father_addr) $local(start) $local(stop)
}


$ns_ at [expr $val(stop)] "flush stdout"
$ns_ at [expr $val(stop)+0.0001] "finish"


proc finish {} {
    global ns_ traceFile namtrace tempoInicio val

    $ns_ flush-trace
    #    close $namtrace
    $ns_ halt
    $ns_ flush-trace
    #$ns_ nam-end-wireless $val(stop)
    close $traceFile
    #close $namtrace
    flush stdout

    exit 0
}

puts "Starting Simulation..."
$ns_ run