Implementing Wireless Sensor Network

Couple of months ago had an opportunity to implement a Wireless Sensor Network to implement building environment monitoring system. One of the major difficulty encountered while implementing a wireless sensor network using the MicaZ platform was the relative lack of documentation available to implement the network and for coding. After trying a bunch of technologies and methodologies ended up with an implementation based of Labview and Crossbow technologies. Here in the blog I have mainly concentrated on the Labview based implementation.

Video of my final project:

Which technology to use to implement WSN?

This is one of the first questions you might need to answer when implementing WSN. This question can be divided mainly into two parts, viz.

a) How to configure the motes?

b) How to display the result from the motes?

How to configure the motes?

As you might be aware the OS used to embed into the motes uses the NesC programming language which is an component-based event driven programming language which can be implemented using the tinyOS platform. NesC can either be installed into the motes by using the open source TinyOS available for free download at http://www.tinyos.net/ or by using the Moteworks platform which is owned by Crossbow(Not sure if this is still supported by them).

You can find information about installing the programming into the motes by using the link below. Please note that for my version of the project I had installed mesh network codes into the motes.

Main page: http://www.tinyos.net/

How to download and install  TinyOS: http://docs.tinyos.net/tinywiki/index.php/Main_Page

Source code hosting: http://code.google.com/p/tinyos-main/

NesC tutorial:  A link to many tutorials are available at the wiki: http://docs.tinyos.net/tinywiki/index.php/Main_Page

My whole project was implemented with the Moteworks package which worked on the Windows platform. The main reason I did this is because I  wanted the display to be in the windows platform and hence didn’t want to shift between Linux and Windows for installation and running. Please note that Moteworks was owned by Crossbow.

b) How to display the result from the motes?

This was the trickier part for me because I wanted to get the implementation on the windows platform. There are many platforms that are available in linux that can give a decent display which works on the Java programming language. For my display I used Labview to get the raw packets from the motes as a packet (array) and separated the various mote packets with node id as the primary key. Separating motes with node id as the unique id is useful as we can then easily separate data when scaling the system. You might also need to write individual codes to display the various sensor packets; for me personally had to do a lot of trial and error to get this right.

Steps involved where:

1) Connect the programming board with the motes attached into into the USB port.

2) Install the simulator which allows us to access the USB device(assuming that the WSN programming board has USB port) the same way as a COM port in your pc. The simulator is available for download at  http://www.ftdichip.com/Drivers/VCP.htm .

3) Download and install NI Visa from the link http://search.ni.com/nisearch/app/main/p/bot/no/ap/tech/lang/en/pg/1/sn/catnav:du,n8:3.1637,ssnav:sup/

4) National Instruments provides a set of libraries which will help you get the wireless sensor network up and running soon. You can download the libraries from here : http://sine.ni.com/apps/utf8/niid_web_display.download_page?p_id_guid=1FB66B354ED149C7E0440003BA230ECF

The detailed steps for downloading and installing the above library can be found here : http://digital.ni.com/public.nsf/allkb/FD238ED75B22740B86257315004E35FE .

6) When all the above steps are completed make the connection of  the sensor network as you desire and select the appropriate com port for input in the vi. Usually there will be one virtual port for programming the motes and another one for getting data from the programming board. For example for programming the motes we can use com2 and for receiving signal it would be com3.

After installing the above you can either use the downloaded libraries or use raw data from the motes and display the data, here the former option is useful if you already have the libraries for the said motes and the later can be used if you plan to use motes or sensor board in a non-traditional way.In my case for the implementation the hardware I used was MIB520(programming board), MICAz mote(node), MTS310(sensor) and MDA300(sensor).

 

In short the flow of data where as follows:

Sensors -> Motes (hopping b/w them) -> Base node -> Programming Board -> USB port -> NI Visa  -> Differentiate b/w packets -> Display results.

 

Hope this helped.  Have fun!

Convert EBCDIC to ASCII in C#

Attached is the C# code to convert byte array in EBCDIC form to ASCII. fileData is the input argument byte array in EBCDIC form.

Using System.Text

public string convertFromEBCDICToASCII(byte[] fileData)
{
Encoding ascii = Encoding.ASCII;
Encoding ebcdic = Encoding.GetEncoding(“IBM037″);
//Encoding ebcdic = Encoding.UTF32;
byte[] convertedByte = Encoding.Convert(ebcdic, ascii, fileData);
return Encoding.ASCII.GetString(convertedByte);
}

 

Reference:

The .net library : http://msdn.microsoft.com/en-us/library/system.text.encoding.aspx

WiFi Cracking- WEP and WPA-PSK Cracking

This is part of the material I made for the security class. The camtasia video of it in youtube got 46 views in 2 days, so I guess this will be something people will be interested in. Do drop  a comment.

Here materials are presented as a ppt and 2 camtesia screen video, one each for WEP and WPA-PSK.

Requirements

The slide gives the basic requirements you need to run Aircrack

In the above the main problem I had was to get the right network interface card. You can get a list of working cards with Backtrack at http://backtrack.offensive-security.com/index.php/HCL:Wireless . In mycase the build in lappy NIC was not supported so had to drop by FRYS and get a Hawking HWUG1 card for 34$(cheaper ones are also available online). Also VMWARE player only supports USB NIC cards, dont forget that.

WEP Cracking

This is as easy as it comes. Its a sure shot way to cracking unlike WPA. Time it takes depends on how much strength you have from the target WiFi router. In case it doesn’t work fast enough there are other ways to get around it(I will try to add those later).

The commands I have used above are.

Please not that things in [] are stuffs you need to fill out for your case and [//   ] is used to give comments.

airmon-ng

airodump-ng wlan0 [//here wlan0 is the network card name]Your browser may not support display of this image.

airodump-ng –w [filename] –bssid [bssid] –c[channel number] wlan [//again wlan is the card name and bssid in the router MAC or Base Station ID]

aircrack-ng –a 1 –b [bssid] [filename] [//here filename is the .cap file that you created above like wep.cap etc]

Explanation of the commands.

Airmon-ng: airmon-ng is a bash script designed to turn wireless cards into monitor mode. It autodetects which card you have and run the right commands.

Airodump-ng : airodump-ng is a packet capture tool for aircrack-ng. It allows dumping packets directly from WLAN interface and saving them to a pcap or IVs file.

Airocrack-ng: aircrack-ng is a 802.11 WEP / WPA-PSK key cracker. It implements the so-called Fluhrer – Mantin – Shamir (FMS) attack, along with some new attacks by a talented hacker named KoreK. When enough encrypted packets have been gathered, aircrack-ng can almost instantly recover the WEP key

Hope rest of the stuff is clear from the video.

WPA-PSK Cracking

The requirements are same as the one given in the slide above.

Please note that here I have 2 connections in my lappy 1 through the lappy Windows NIC and the other through the USB Backtrack NIC. You need to obtain the handshake which is transferred only when some one logs in to the router. Here for the purpose of demonstration I have connected into the targeted router using my Lappy Windows NIC.

Also here cracking is done by using a dictionary, so the chances of cracking depends on the strength of the words in the dictionary. Check this site out -> http://www.wpacracker.com/gate/select . They claim they can crack the password the password in about 20 minutes if you upload the pcap file and give bssid. Ofcourse they do it for a fees.

Attached below is the video.

Hope the rest is clear from the video.

Follow

Get every new post delivered to your Inbox.