ZigBee/802.15.4 Sniffer

This is a simple ZigBee sniffer application which can dump raw data from any zigbee transmitter in 2.4 GHz and will work in the default channel set while compiling. The purpose is to demonstrate how to use sniffers.

Platform tested
MicaZ and TelosB ( Should work with Imote also)
Interfaces needed
Boot : To boot up the device
Leds : To indicate data capture
Receive : To capture the packet (provided by CC2420ReceiveC)
SplitControl : To control the radio
CC2420PacketBody : For reading the packet header
To run the program, assuming that you are using telosb , type in the shell/command prompt
java net.tinyos.tools.PrintfClient -comm serial@/dev/ttyUSB0:telosb


SniffC.nc
----------------
#include "printf.h"
module SniffC
{
uses
{
interface Boot;
interface Leds;
interface Receive as Rx;
interface SplitControl as RadioControl;
interface CC2420PacketBody as CPacketBody;
}
}
implementation
{
event void Boot.booted()
{
call RadioControl.start();
}
event void RadioControl.startDone(error_t err)
{
}
event void RadioControl.stopDone(error_t err)
{
}
event message_t* Rx.receive(message_t*msg,void*payload,uint8_t len)
{
uint8_t i;
cc2420_header_t *h=call CPacketBody.getHeader(msg);
for(i=0;ilength;i++)
printf("%u",msg->data[i]);
printf("\n");
printfflush();
call Leds.led1Toggle();
return msg;
}
}


SniffAppC.nc
------------------
configuration SniffAppC
{
}
implementation
{
components CC2420ReceiveC as CCC, LedsC, MainC, SniffC, CC2420CsmaC as CCS,CC2420PacketC as CCP;
SniffC.Boot->MainC;
SniffC.Leds->LedsC;
SniffC.Rx->CCC;
SniffC.CPacketBody->CCP;
SniffC.RadioControl-> CCS;
}


Makefile
COMPONENT=SniffAppC
CFLAGS+= -I$(TOSDIR)/lib/printf
CFLAGS += -DCC2420_NO_ACKNOWLEDGEMENTS
CFLAGS += -DCC2420_NO_ADDRESS_RECOGNITION
CFLAGS += -DENABLE_SPI0_DMA
include $(MAKERULES)

6 comments:

kunal said...

I am looking for an easy to use GUI for NS2 for simulating wireless networks.Any suggestion or help will be highly appreciated.

Gireesan said...

@kunal
First of all, I never like the idea of simulator especially ns-2.
General comment, there is no use of GUI for simulations except in testing the parameters with 2-3 nodes.

Still need that, buy Qualnet or Opnet

Anonymous said...

hi,,
i ve been looking on a guideline to install Avrora but using windows.
i would like to ask,,if you have the experience installing avrora with windows.

Gireesan said...

@anonms
I thought Java programs works seamlessly.

DineshKumar said...

Hi,
I have a question, i want to know the printf statement output. where i would get printed??

Gireesan said...

@dinesh
in console!!!
there is a separate post on how to use it...
pls check the prev posts