Presentation is loading. Please wait.

Presentation is loading. Please wait.

Feb 2007WSN Training: MICA2/z Radio Stack1 MoteWorks Radio Stack Objectives  Background  Radio Stack API  MICA2 radio stack  MICAz radio stack  Configure.

Similar presentations


Presentation on theme: "Feb 2007WSN Training: MICA2/z Radio Stack1 MoteWorks Radio Stack Objectives  Background  Radio Stack API  MICA2 radio stack  MICAz radio stack  Configure."— Presentation transcript:

1 Feb 2007WSN Training: MICA2/z Radio Stack1 MoteWorks Radio Stack Objectives  Background  Radio Stack API  MICA2 radio stack  MICAz radio stack  Configure radio stack at Compile time  Lab: Radio enable your Sensor Applications and XSniffer GUI

2 WSN Training: MICA2/z Radio Stack2 Feb 2007 Background The Radio Stack provides a packet interface for single hop transmission. Compared to the ISO modle, the Radio Stack consists of a subset of the Data Link Layer and the Physical Layer. XMesh consists of the network layer and directly interfaces to the Radio Stack. Physical Data Link Network XMesh Radio Stack

3 WSN Training: MICA2/z Radio Stack3 Feb 2007 Background The main features of the Radio Stack include:  Frame transmission / reception  Error checking  Address filtering  Link Level acknowledgements  Synchronization  Multiplexing single radio between multiple application users  CSMA/CA (carrier sense multiple access / collision avoidance)  Platform support for Mica2 and derivatives (<1 GHz ISM)  Platform support for MicaZ and derivatives (2.4 GHz ISM)

4 Feb 2007WSN Training: MICA2/z Radio Stack4 Radio Stack API Objectives  Send interface  Receive interface  Addressing  TOS_Msg  Buffer Management  AM Types

5 WSN Training: MICA2/z Radio Stack5 Feb 2007 Send Interface interface SendMsg { /** * Send a Message to address. * @param addresss desitantion address * @param length number of bytes of the.data field in msg that needs to be transmitted * @param msg ptr to a TOS_Msg that holds the packet in the.data portion * @retrun result_t SUCCESS if packet queued for transmission */ command result_t send(uint16_t address, uint8_t length, TOS_MsgPtr msg); /** * Send complete * @param msg ptr to the TOS_Msg that was just sent * @param success was the packet sent successfully * @return result_t SUCCESS */ event result_t sendDone(TOS_MsgPtr msg, result_t success); }

6 WSN Training: MICA2/z Radio Stack6 Feb 2007 Receive Interface interface ReceiveMsg { /** * Packet Received * @param m ptr to the TOS_Msg that was just received * @return TOS_MsgPtr a fresh pointer to a buffer that is passed back */ event TOS_MsgPtr receive(TOS_MsgPtr m); }

7 WSN Training: MICA2/z Radio Stack7 Feb 2007 Node Addressing Every node in a network must have a unique address  Analogous to an IP address  Must be no longer than 16 bits  Node 0 is conventionally used to denote the Base station  Certain nodes address are special and should not be assigned to a real node Special Nodes Addresses  TOS_UART_ADDR  Macro expands to 0x007F  This address denotes the UART channel  TOS_BCAST_ADDR  Macro expands to 0xFFFF  This address denotes a broadcast over the radio  TOS_LOCAL_ADDRESS  A variable which holds the node id assigned

8 WSN Training: MICA2/z Radio Stack8 Feb 2007 TOS_Msg – a Data Structure That Encapsulates a Packet TOS_Msg is a general data structure for representing packets in TinyOS. TOS_Msg allocates space for a packet by holding a char array called data whose length is determined at compile time by the TOSH_DATA_LENGTH symbol. The length of this field must not be less that the longest packet in the application. The only field in TOS_Msg that is writable by the user is the data array holding the packet. All other fields must not be modified by the user. Fields in the extra section hold useful information such as packet rssi and crc.

9 WSN Training: MICA2/z Radio Stack9 Feb 2007 TOS_Msg Mica2 (MoteWorks/tos/types/am.h) #define TOSH_DATA_LENGTH 29 typedef struct TOS_Msg { uint16_t addr; uint8_t type; uint8_t group; uint8_t length; int8_t data[TOSH_DATA_LENGTH]; uint16_t crc; // CRC //Extra uint16_t strength; // RSSI uint8_t ack; // link-level uint16_t time; uint8_t sendSecurityMode; uint8_t receiveSecurityMode; } TOS_Msg; Transmitted Can be defined at compile time Only field that user can Modify. Only field that user can Modify.

10 WSN Training: MICA2/z Radio Stack10 Feb 2007 TOS_Msg MicaZ (MoteWorks/tos/platforms/micaz/am.h) #define TOSH_DATA_LENGTH 29 typedef struct TOS_Msg { uint8_t length; uint8_t fcfhi; uint8_t fcflo; uint8_t dsn; uint16_t destpan; uint16_t addr uint8_t type; uint8_t group; int8_t data[TOSH_DATA_LENGTH]; //Extra uint16_t strength; // RSSI uint8_t lqi; // LQI bool crc; // CRC on RCB uint8_t ack; // link-level uint16_t time; } TOS_Msg; Transmitted Can be defined at compile time Only field that user can Modify. Only field that user can Modify.

11 WSN Training: MICA2/z Radio Stack11 Feb 2007 Buffer Management If buffers are need, it must be allocated by the user.  Since TOS_Msg encapsulates a packet, buffers are declared in units of TOS_Msgs  Buffers are typically allocated at COMPILE time When using the send and receive interface, buffer ownership alternates between application and messaging layers Send message  Active message (AM) layer “owns” the TX buffer once called  User must NOT modify buffer until.sendDone event from AM layer Receive event  AM layer passes a RX message buffer pointer  User must return a valid “free” buffer pointer for the next received message

12 WSN Training: MICA2/z Radio Stack12 Feb 2007 Message Buffer Exchange TX Side AM Component gets ownership of TXBuffer until Signals Transmission has completed RX Side Event Handler gets RXBuffer. Returns a buffer for next RX message. TX Component AM Component RX Event Handler return (&RXBuffer) Signal.Rcv(&RXBuffer).sendDone(&TXBuffer).send(&TXBuffer)

13 WSN Training: MICA2/z Radio Stack13 Feb 2007 AM Layer (Motivation) Network Level Isolation It is often necessary to deploy multiple networks on the same physical radio channel. Even though these networks are sharing the same physical medium, they need to behave in software as if they are isolated from each other. This is done with GROUP ID. Node Level Isolation Every node typically has only 1 radio. However each node will need to run different services that needs to send and receive different packets. Each service doesn’t need to receive packets meant for other services. As a result, there needs to be a multiplexing mechanism similar to ports in the IP space which allows filtering packets to the intended receivers on a single node. This is accomplished with AM TYPE.

14 WSN Training: MICA2/z Radio Stack14 Feb 2007 AM Protocol (outgoing) Radio Stack AM 1 AM 2 The Send Interface provided by the radio stack has a parameter for the AM Type AM n... Packet Once sent each packet is tagged With the AM type used to send it AM 1 AM 2 To send a packet with a specific AM Type, the user wires to a send Interface with the desired AM Type as the parameter

15 WSN Training: MICA2/z Radio Stack15 Feb 2007 AM Protocol (incoming) Radio Stack On reception, packets are routed according to the tagged AM Type. AM 1 AM 2 AM n... Packet AM 1 AM 2 Users that wire to the Receive interface with a specific AM Type will be signaled when a packet of that AM Type is received. Incoming packet will Always be tagged with an AM Type

16 WSN Training: MICA2/z Radio Stack16 Feb 2007 GenericComm configuration GenericComm { provides { //Start and Stop the Radio Stack interface StdControl as Control; // The interface are as parameterised by the active message id interface SendMsg[uint8_t id]; interface ReceiveMsg[uint8_t id];.

17 WSN Training: MICA2/z Radio Stack17 Feb 2007 TOS_MsgPtr received(TOS_MsgPtr packet){ uint16_t addr = TOS_LOCAL_ADDRESS; counter++; if (packet->crc == 1 && packet->group == TOS_AM_GROUP && (packet->addr == TOS_BCAST_ADDR || packet->addr == addr)){ uint8_t type = packet->type; TOS_MsgPtr tmp; tmp = signal receiveMsg.receive[type](packet); if (tmp) packet = tmp; } // if valid packet return packet;} AMStandard: Receiving Messages Check GroupID, Node Address Signal the assigned AM Handler Use the returned buffer for next Msg

18 WSN Training: MICA2/z Radio Stack18 Feb 2007 WARNING The Radio Stack which includes the AM layer is used by the XMesh Networking Layer. Unless you understand how to share usage of the Radio Stack with XMesh you will break the system. Option for correct usage would be. 1.Only use XMesh APIs without touching the Radio Stack APIs 2.Only use Radio Stack APIs without using any XMesh services.

19 Feb 2007WSN Training: MICA2/z Radio Stack19 MICA2 Radio Stack Objectives  Radio Features  Module Design  Send/Recv Message Flow and Call Stack  Basic State Machine  Packet Structure

20 WSN Training: MICA2/z Radio Stack20 Feb 2007 MICA2: CC1000 Radio Byte Level Radio  Radio accepts data byte by byte  Packet information handled in software  Frequency shift keying with Manchester encoding Power On/Off  Sleep current: ~2  A  Frequency stable: 2 msec  Radio Signal Strength (RSSI Valid): ~250  sec  Receiver Packet Acquire Time: ~750  sec SPI data port interrupt triggers every 8 bit times = 416  s  While the radio is on, data streams in to the ATmega128L at this rate

21 WSN Training: MICA2/z Radio Stack21 Feb 2007 MICA2 Radio Stack in TinyOS AM CC1000Control SpiByteFifoRandomLFSRADC Control (Freq, power, etc) CC1000RadioIntM Wires the control and data paths: Implementation hidden from app CC1000RadioC Send(TOSMsg)Receive Event(TOSMsg) UART Generic Comm Application Sample RSSI Bus-level control of CC1000 Radio Chip Hardware Specific

22 WSN Training: MICA2/z Radio Stack22 Feb 2007 MICA2: CC1000 SendMsg Flow 1.Message travels down stack (GenericComm -> CC1000RadioIntM)  Build header: Source address, AM ID, address  Hand off to hardware level Radio registers 2.Random delay (up to 15 packet times) 3.Check for clear channel (CSMA) 4.Turn on transmitter & send pkt over SPI Port  18 byte preamble (10101 pattern) & frame Sync  TOS message (34 bytes) & CRC (2 bytes) 5.Wait for acknowledgement (optional) 6.Turn off transmitter & signal TX Done event to application AM CC1000RadioIntM CC1000RadioC Generic Comm Send out byte by byte Application Send Command (TOSMsg)

23 WSN Training: MICA2/z Radio Stack23 Feb 2007 MICA2: CC1000 ReceiveMsg SPI port interrupt handler  Search for the preamble: 101010…  Wait for frame sync word 1.Assemble TOS packet 2.Check CRC and reject if bad 3.Route to Active Message handler 4.Check group ID 5.Send acknowledgement (optional) 6.Signal application ReceivedMsg event AM CC1000RadioIntM CC1000RadioC Generic Comm Received Byte Interrupt Application Receive Event(TOSMsg)

24 WSN Training: MICA2/z Radio Stack24 Feb 2007 CC1000RadioM State Machine 1.Idle 2.Rx Related:  Sync  Packet Assemble 3.Tx Related:  Collision Sense  Preamble  Sync  Packet  CRC  Flush  Done

25 WSN Training: MICA2/z Radio Stack25 Feb 2007 MICA2 TinyOS Message Packet Structure Bytes 211129 (Default, but variable length) Destination Address AM Type AM Group Length Data Payload TinyOS Header

26 Feb 2007WSN Training: MICA2/z Radio Stack26 MICAz Radio Stack Objectives  Radio features  Module Design  Basic Send/Receive Operation  Packet Structure

27 WSN Training: MICA2/z Radio Stack27 Feb 2007 MICAz: CC2420 Radio Packet Level Radio  Hardware accepts data as full packets and has a packet buffer  Direct sequence spread spectrum  O-QPSK modulation  127 bytes maximum (data plus overhead) CC2420 SendMsg 1. Message travels down stack ( GenericComm -> CC2420RadioM )  Builds IEEE802.15.4 MAC Header  Hand off to hardware level Radio TX FIFO 2.Random delay (up to 15 packet times) 3.Check for clear channel (CSMA = carrier sense multiple access) 4.Wait for acknowledgement (optional) 5.Signal sendDone event to application

28 WSN Training: MICA2/z Radio Stack28 Feb 2007 MICAz Radio Stack in TinyOS AM CC2420ControlM HPLCC2420CRandomLFSRHighSpeedTimer CC2420RadioM CC2420RadioC Send(TOSMsg)Receive Event(TOSMsg) UART Generic Comm Application Hardware Specific SPIByte Read/write CC2420 registers/commands Transfer to/from TXFIFO/RXFIFO Atmega128 is the SPI master

29 WSN Training: MICA2/z Radio Stack29 Feb 2007 MICAz: CC2420 Radio (cont’d) CC2420 ReceiveMsg  Radio interrupt upon detection of MAC header  Read packet from RXFIFO  Read frame type  Acknowledge –Verify matches TX sequence number –Signal client application with TOSMsg.ack=TRUE  Data Frame –Group ID, AM type, payload –Signal strength –Signal client application with TOSMsg

30 WSN Training: MICA2/z Radio Stack30 Feb 2007 MICAz TinyOS Message Packet Structure Bytes 1212211variable LengthFCFSeqNo Dest Pan ID Destination Address AM Type AM Group Data Payload FCF are packet types 1.Data 2.Acknowledgements

31 Feb 2007WSN Training: MICA2/z Radio Stack31 Configuring Radio Stack at Compile Time Objectives  Frequency  Power  Group  Node Id

32 WSN Training: MICA2/z Radio Stack32 Feb 2007 Compile-time Radio Stack Configuration platform mica2 micaz mica2dot freq(MHz) 903904…926 433433.5…434.5 315 24052410…2480 Uses command line “extras” in: MoteWorks/make/avr/ make freq, power, power(dB) min-20 -1005 max10

33 WSN Training: MICA2/z Radio Stack33 Feb 2007 Settings: Radio Frequency Any “Central Frequency” channel preset can be assigned by passing in MHz to the make tool: make micaz freq,2455  Above example will compile to use 2.455 GHz No overlaps with 802.11

34 WSN Training: MICA2/z Radio Stack34 Feb 2007 802.15.4 and 802.11b Spectrum Relationship 2405 MHz 5 MHz Spacing 802.15.4: Ch. 11 to Ch. 26 Co-exists with WiFi, Bluetooth  Channel selection is important 2 MHz 2480 MHz 22 MHz 2412 MHz2437 MHz 802.11: Ch. 1 to Ch. 11 2425 MHz2462 MHz Ch. 15Ch. 20 2475 MHz2450 MHz 25 MHz Spacing Note: Channels 25, 26 are non-overlapping Ch. 1 Ch. 25Ch. 26 Ch. 6 Ch. 11

35 WSN Training: MICA2/z Radio Stack35 Feb 2007 Settings: Radio Power RF Power controls how “loud” the radio transmits  Measured in decibels ranging from -20dB to +10dB Dynamic RF power level  e.g., command result_t setRFPower(uint8_t power); Static RF power level  Edit the MakeXbowlocal file  For CC1000: CFLAGS += -DRADIO_XMIT_POWER=0xFF  For CC2420: CFLAGS += -DCC2420_TXPOWER=0xFF

36 WSN Training: MICA2/z Radio Stack36 Feb 2007 Settings: Group IDs (Review) Nodes only communicate within a common Group ID and is determined in Makexbowlocal file or during build time Example: Assign your group ID to be 125 (hex 7d)  The line below would be used in the MakeXbowlocal file  To override the default value, you can add the word “ group ” followed by a comma and then a hexadecimal number (up to two bytes) DEFAULT_LOCAL_GROUP=0x7d make group,

37 Feb 2007WSN Training: MICA2/z Radio Stack37 Lab: MyApp_Sensor, part 2 -- RF Objectives  Enabling MyApp_Sensor to send sensor data over the radio  Using XSniffer to view data sent over the radio

38 WSN Training: MICA2/z Radio Stack38 Feb 2007 MyApp_Sensor – Sending Data Over The Air With a slight modification MyApp_Sensor can be altered to send the message packet over the Mote radio to another Mote plugged into a base station Change line 96 of the code in MyApp_SensorM.nc  from this  to this if (call SendMsg.send(TOS_UART_ADDR,sizeof(XDataMsg),&msg_buffer) != SUCCESS) if (call SendMsg.send(TOS_BCAST_ADDR,sizeof(XDataMsg),&msg_buffer) != SUCCESS)

39 WSN Training: MICA2/z Radio Stack39 Feb 2007 MyApp_Sensor – Sending Data Over The Air if (call SendMsg.send(TOS_BCAST_ADDR,sizeof(XDataMsg),&msg_buffer) != SUCCESS) The SendMsg.send command uses the first parameter to decide where the message packet should be sent Changing from TOS_UART_ADDR to TOS_BCAST_ADDR tells the communications component to send the message through the radio instead of the UART.  TOS_BCAST_ADDR actually sends the message to any Mote within RF range, i.e., broadcasts the message.  If we want to send the message specifically to the base station we can set this parameter value to 0  A Mote plugged into a gateway board and intended to function as a base station must always have a node id of 0.

40 WSN Training: MICA2/z Radio Stack40 Feb 2007 MyApp_Sensor -- Single Mote TX and XSniffer First, flash your new remote Mote. 1.Install MyApp_Sensor (with modifications) on one Mote  Use Programmer’s Notepad  Select Tools > shell and type in the dialog box make install,1, or COM 2.Remove the Mote from the programming board, plug one of the sensorboards (MDA100, MTS300 or MTS310) onto that Mote  Make sure it has batteries and turn it on.  You should see all three LEDs blinking every second.

41 WSN Training: MICA2/z Radio Stack41 Feb 2007 MyApp_Sensor – Single Mote TX and XSniffer XSniffer is a way to eavesdrop on messages sent over the Mote radios. It doesn’t participate in the network. The radio is in receive mode only. 3.Install the XSniffer application onto another Mote a.Plug in a second Mote to the programming board b.Open /MoteWorks/apps/general/XSniffer c.Load the TOSBase.nc application from /MoteWorks/apps/general/XSniffer using Programmers Notepad 2 make install,0, or COM

42 WSN Training: MICA2/z Radio Stack42 Feb 2007 Startup XSniffer – Viewing Packet Traffic 4.Start the XSniffer GUI by clicking on the XSniffer icon on your desktop. 5.Configure it to your gateway.  MIB510: Select COM port and click start  MIB520: Select the higher of the two COM ports, (i.e., the data communications COM port) and click start.  MIB600: Must start XServe, change baud rate of port 10002, then connect XSniffer to localhost using port 9001. See next slide for details.

43 WSN Training: MICA2/z Radio Stack43 Feb 2007 Now Watch The Packets Fly 5.Connect XServe to XSniffer application. (A must for MIB600 users. An option for MIB510 and MIB520 users.) If using a MIB510 or MIB520 xserve –s=COM –b=115200 If using a MIB600  Set port 10002 to 115200 baud via Device Manager. (Don’t forget to switch it back when finished.)  Must connect through XServe  Don’t forget to switch it back later. xserve –i= :10002 –b=115200 6.Then connect XSniffer to XServe: Click on “TCP Socket”  For host: localhost  For port: 9001 Remember: For MIB520, the COM port is the higher of the two COM ports

44 WSN Training: MICA2/z Radio Stack44 Feb 2007 XSniffer – Screen Shot of the Log Tab Orange = health packet Aqua = Sync packet Red = Route update packet Legend Yellow = Undefined AM type Pale Turq = Ack Downstrm Steel Blue = Data Upstrm Green = Base station messages See next slide for complete legend to coloring

45 WSN Training: MICA2/z Radio Stack45 Feb 2007 XSniffer Options Tab – Packet Coloring Guide

46 Feb 2007WSN Training: MICA2/z Radio Stack46 Q & A: MoteWorks Radio Stack Objectives  Background  MICA2 radio stack  MICAz radio stack  Configure radio stack at Compile time  TinyOS Radio API, Active Message Interface  Lab: Radio enable your Sensor Applications Physical Data Link MAC LLC

47 Feb 2007WSN Training: MICA2/z Radio Stack47 Supplemental / Extra Slides

48 WSN Training: MICA2/z Radio Stack48 Feb 2007 1.Background, Where is the radio stack located 1.What services does it provide 2.Feature set (things that it does for you) 3.Interfaces for starting and stopping the radio stack 4.Go over split-phase, send + recv 5.AM Type 6.Interface Sends to both UART and Radio 7.Configuring the Radio Stack 2.Theory of Operation on the CC1000 1.Hardware 2.Packet Format 3.Radio Stack Structure 4.State Machine 5.Message Flow??? 3.Theory of Operation on the CC2420 1.Hardware 2.Packet Format 3.Radio Stack Structure 4.State machine 5.Message Flow???

49 WSN Training: MICA2/z Radio Stack49 Feb 2007 Active Messaging Flow AM Type similar to IP Port Different AM Types supply different network services Active Message algorithm:  Sender’s TOS Message specifies:  AM# (Message Type)  Destination Address  Receiver’s Message filtered for:  GroupID & Node Address  Packets are routed via AM parameterized interface to appropriate Message Event handler

50 WSN Training: MICA2/z Radio Stack50 Feb 2007 Sending a Message – Application Send Request Example: XSensorMTS300/XSensorMTS300M.nc Start background task to send message Boolean to ensure last send completed

51 WSN Training: MICA2/z Radio Stack51 Feb 2007 Communicating between Nodes Message Flow 1.Fill a Message buffer with Data to send 2.Specify node address to receive the message 3.Specify Message Type (AM Number) 4.Lock Message buffer during.send operation Buffering the incoming message 5.Processing the message on reception

52 WSN Training: MICA2/z Radio Stack52 Feb 2007 Background Physical Data Link MAC LLC Care must always be taken when comparing wireless sensor networks to the wired TCP/IP world. If analogies were made between the MoteWorks radio stack and the OSI model, the radio stack would be composed of the Physical Layer, and a subset of the Data Link layer.

53 WSN Training: MICA2/z Radio Stack53 Feb 2007 TOSMsg Supplemental info Strength  RSSI on receive  LowPower RadioStack:  On send, overloaded to specify the preamble length  (Long, Short, or Standard) ACK  Whether transmission was acknowledged by the receiver Time  Place holder for time stamp on receive


Download ppt "Feb 2007WSN Training: MICA2/z Radio Stack1 MoteWorks Radio Stack Objectives  Background  Radio Stack API  MICA2 radio stack  MICAz radio stack  Configure."

Similar presentations


Ads by Google