Presentation is loading. Please wait.

Presentation is loading. Please wait.

Feb 2007WSN Training: XMesh Services1 Lab6 Objectives:  Route Control Interface  Understand XMesh transport services 1.Upstream 2.Upstream with end-to-end.

Similar presentations


Presentation on theme: "Feb 2007WSN Training: XMesh Services1 Lab6 Objectives:  Route Control Interface  Understand XMesh transport services 1.Upstream 2.Upstream with end-to-end."— Presentation transcript:

1 Feb 2007WSN Training: XMesh Services1 Lab6 Objectives:  Route Control Interface  Understand XMesh transport services 1.Upstream 2.Upstream with end-to-end acknowledgement 3.Downstream 4.Downstream with end-to-end acknowledgement  Lab: Guaranteed QoS with upstream acknowledgement

2 Feb 2007WSN Training: XMesh Services2 XMesh Advanced Services Objectives:  Route Control Interface  Understand XMesh transport services 1.Upstream 2.Upstream with end-to-end acknowledgement 3.Downstream 4.Downstream with end-to-end acknowledgement  Lab: Guaranteed QoS with upstream acknowledgement  XMesh Health Packets  Extended Low Power Mode (ELP)  Lab: Health Packet

3 WSN Training: XMesh Services3 Feb 2007 RouteControl Interface User can make application level decisions based on network conditions. RouteControl interface extracts information from the routing component. Example Wiring: MyAppM.RouteControl -> XMeshRouter; Example Usage: parent = call RouteControl.getParent();

4 WSN Training: XMesh Services4 Feb 2007 RouteControl Interface Interface: command uint16_t getParent() Description: Returns parent’s address (0xffff for broadcast) Interface: command uint16_t getDepth() Description: Number of hops away the mote is from the base station. Interface: command uint16_t getSender(TOS_MsgPtr) Description: Returns address of the mote that sent the message Interface: command uint8_t getOccupancy() Description: Returns the length of the routing forwarding queue

5 WSN Training: XMesh Services5 Feb 2007 RouteControl Interfaces Interface: command uint8_t getQuality(uint8_t type) Description: Gets a measure of goodness for the current parent. Returns value between 0 to 255, where 255 represents that 100% of messages has been heard.  Type = 1: Send goodness  Type = 2: Receive goodness Interface: command result_t setUpdateInterval(uint16_t Interval) Description: Sets the routing component’s internal route update interval = interval duration in seconds.

6 WSN Training: XMesh Services6 Feb 2007 XMesh Service Identifier: AM type Predefined AM types  QoS Service Types: 1.UPSTREAM 2.UPSTREAM_ACK 3.DOWNSTREAM 4.DOWNSTREAM_ACK Explanation of the predefined AM types  See tos/types/Messages.h for predefined AM types.  All these predefined AM types have been wired to the GenericComm by XMesh  Note: Application must not wire it again.

7 WSN Training: XMesh Services7 Feb 2007 Link Level Retransmission Perform link level retransmission for up to 8 times  Number of retransmission is user configurable.  Empirical result shows 8 is optimal in terms of reliability/energy trade-off Switch parent at 6 th retransmission of upstream packets. Link Level Acknowledgement

8 WSN Training: XMesh Services8 Feb 2007 Upstream Communication Deliver messages up to base station Collection routing to a single point Base node (Network sink) Node sends to parent with lowest cost Server Client

9 WSN Training: XMesh Services9 Feb 2007 Upstream Service API nesC Wiring AppM.MhopSend -> XMeshRouter.MhopSend[appID]; Call send command. call MhopSend.send ( BASE_STATION_ADDRESS, MODE_UPSTREAM, &gMsgBuffer, sizeof(UpStream_t) ); Implement the sendDone event: event result_t Send.sendDone (TOS_MsgPtr pMsg, result_t success) { // clear your flag here return SUCCESS; }

10 WSN Training: XMesh Services10 Feb 2007 Upstream with Acknowledgment Provides Guaranteed Delivery to nearest Base Node Set timeout; retry until end-to-end acknowledgement received Used for critical data Base E2E Ack Server Client

11 WSN Training: XMesh Services11 Feb 2007 Upstream Ack Service API nesC Wiring AppM.MhopSend -> XMeshRouter.MhopSend[appID]; AppM.RcvAck -> XMeshRouter.ReceiveAck[appID]; Call the send command call Send.send ( BASE_STATION_ADDRESS, MODE_UPSTREAM_ACK, &gMsgBuffer, sizeof(UpStream_t) ); Start a timer in sendDone event event result_t Send.sendDone (TOS_MsgPtr pMsg, result_t success) { call TimerAck.start(TIMER_ONE_SHOT, 20); //for HP stack return SUCCESS; }

12 WSN Training: XMesh Services12 Feb 2007 Upstream Ack Service API - continued Receive the end2end Ack event TOS_MsgPtr RcvAck.receive (TOS_MsgPtr pMsg, void* payload, uint16_t payloadLen) { call TimerAck.stop(); // stop the timer return pMsg; } No end2end Ack received event result_t TimerAck.fired() { // make decision as whether to resend the packet // usually increment a counter here // and retry x numbers of time; if ( NUM_RETRY != num_retry++) { // send again } else { // reach retry limit num_retry = 0; } return SUCCESS; }

13 WSN Training: XMesh Services13 Feb 2007 Downstream Communication Deliver messages from client > server > base station node to a node in the network Used for Command and acknowledgement delivery Base Mote Node sends to next hop found in its downstream table Server Client e2e Ack

14 WSN Training: XMesh Services14 Feb 2007 Downstream Use Cases Send from the base station mote: call XMesh downstream service APIs. Send from a server that is connected to a base station mote 1.Constructs the TOS_Msg packet on the server side, according to the API requirement. 2.Send the packet to the base station mote

15 WSN Training: XMesh Services15 Feb 2007 Send from the base mote: Downstream no Ack API nesC Wiring AppM.MhopSend -> XMeshRouter.MhopSend[appID]; Call the send command call Send.send ( Downstream_node_id, MODE_DOWNSTREAM, &gMsgBuffer, sizeof(DownStream_t); Implement the sendDone event: event result_t Send.sendDone(TOS_MsgPtr pMsg, result_t success) { // clear your flag here return SUCCESS; }

16 WSN Training: XMesh Services16 Feb 2007 Send from the Basestation Mote: Downstream Ack API nesC Wiring AppM.MhopSend -> XMeshRouter.MhopSend[appID]; AppM.RcvAck -> XMeshRouter.ReceiveAck[appID]; Call the send command call Send.send(remote_node_id, MODE_DOWNSTREAM_ACK, &gMsgBuffer, sizeof(DownStream_t); Start a timer in sendDone event event result_t Send.sendDone(TOS_MsgPtr pMsg, result_t success) { call TimerAck.start(TIMER_ONE_SHOT, 20); //for HP stack return SUCCESS; }

17 WSN Training: XMesh Services17 Feb 2007 Send from the base mote: Downstream Ack API Receive the end2end Ack event TOS_MsgPtr RcvAck.receive (TOS_MsgPtr pMsg, void* payload, uint16_t payloadLen) { call TimerAck.stop(); // stop the timer return pMsg; } No end2end Ack received event result_t TimerAck.fired() { // make decision as whether to resend the packet // usually increment a counter here // and retry x numbers of time; if ( NUM_RETRY != num_retry++) { // send again } else { // reach retry limit num_retry = 0; } return SUCCESS; }

18 WSN Training: XMesh Services18 Feb 2007 Downstream Service API: Send From the Server Side Put the downstream node id to the address field of the TOS_Msg header  tos_msg.addr = downstream_id; Put 0x0C (downstream no ack) or 0x0E (downstream with ack) into the type field of the TOSMsg header  tos_msg.type = 0x0C; // sending downstream no ack Initialize length of the application payload  tos_msg.length = len; Copy application data to the packet  memcpy(&tos_msg.data, &app_data, len); Send to base mote  Send_to_serial(&tos_msg); // to serial port or serial forwarder

19 Feb 2007WSN Training: XMesh Services19 Lab: MyApp_MeshAck  Review Moteworks/apps/tutorials/lesson5  Add required end-to-end acknowledgement code  Deploy guaranteed delivery network  Analyze traffic using XSniffer

20 WSN Training: XMesh Services20 Feb 2007 Lab – MyApp_MeshAck Outline Write application to send upstream packet, requesting end- to-end ack  Use of XMesh UpstreamAck service wirings and APIs  Send data packet to base station every minutes, set end-2-end time out as 20 msec (XMesh hp), retransmit for up to 3 times. Test it with XMeshBase application  Use of XSniffer to visualize the data traffic.  Receive upstream packets via Xserve.

21 WSN Training: XMesh Services21 Feb 2007 Lab – MyApp_MeshAck - step 1 Prepare your application  Work on apps/tutorials/lesson_5  The following enhancements have been made:  Code modified to use the MOTE_UPSTREAM_ACK transport mode to request an acknowledgement back from the base station  Yellow LED toggles when an acknowledgement message is received back from the base station  Please note that we have intentionally taken out the end2end retransmission code, it is part of your exercise to fill in the time- out based retransmission.  Hints: 1.Start a one-shot timer at the sendDone event 2.Stop the timer at the reception of the end2end packet 3.Schedule retransmission at the timer.fired event

22 WSN Training: XMesh Services22 Feb 2007 Lab: MyApp_MeshAck MyApp_MeshAck.nc  The ReceiveAck interface is required to implement an event callback function that will be generated by XMesh when the acknowledgment message has arrived from the base station. configuration MyApp_MeshAck { } implementation { //… MyApp_MeshAckM.RouteControl -> MULTIHOPROUTER; MyApp_MeshAckM.Send -> MULTIHOPROUTER.MhopSend[AM_XMULTIHOP_MSG]; MyApp_MeshAckM.ReceiveAck -> MULTIHOPROUTER.ReceiveAck[AM_XMULTIHOP_MSG]; MULTIHOPROUTER.ReceiveMsg[AM_XMULTIHOP_MSG] -> Comm.ReceiveMsg[AM_XMULTIHOP_MSG]; } The only change to the configuration file is the addition of the ReceiveAck interface wiring.

23 WSN Training: XMesh Services23 Feb 2007 Lab: MyApp_MeshAck MyApp_MeshAckM.nc  The first change is the transport mode of MODE_UPSTREAM_ACK. This tells XMesh to send an acknowledgement message back to the message originator when the message is received at the base station.  The second change is the addition of the ReceiveAck.receive event function. This is the event called by XMesh when the acknowledgement message has arrived from the base station for the most recently sent message. The yellow LED is toggled upon receiving this acknowledgment message. void task SendData() { … if (call Send.send(BASE_STATION_ADDRESS, MODE_UPSTREAM_ACK, &msg_buffer, sizeof(XDataMsg)) != SUCCESS) … event TOS_MsgPtr ReceiveAck.receive(TOS_MsgPtr pMsg, void* payload, uint16_t payloadLen) { call Leds.yellowToggle(); … Add handling of end-to-end acknowledgement received from base station. Switch service type to MODE_UPSTREAM_ACK

24 WSN Training: XMesh Services24 Feb 2007 Lab – MyApp_MeshAck - step 2 1.Compile with designated radio frequency in MakeXbowlocal and typing make Or by typing make route,hp 2.Program the remote nodes with lesson5 by typing make reinstall,1, 3.Compile and program a separate base station with XMeshBase by typing make install,0,

25 WSN Training: XMesh Services25 Feb 2007 Lab – MyApp_MeshAck - step 3 Prepare the base station application with XMeshBase in apps/XMesh/XMeshBase  Compile the code by typing make base route,hp freq,x  Program the base station by typing make reinstall.0,

26 WSN Training: XMesh Services26 Feb 2007 Lab – MyApp_MeshAck, Step 4 Visualize the traffic in the Mesh: Use the XSniffer GUI.  Program a mote with application (TOSBase) found in MoteWorks/apps/general/XSniffer.  Start XSniffer GUI, connect it to the gateway board with the XSniffer (i.e., TOSBase) mote. Receive upstream packet from your PC  Start XServe  Connect it to the base station mote.

27 WSN Training: XMesh Services27 Feb 2007 XSniffer Color Coding Packets are colored by type  Upstream data = blue  AckDwn = turquoise Also note for next lab  Health = orange

28 Feb 2007WSN Training: XMesh Services28 XMesh Services Objectives:  Health statistics  ELP  Lab: View health packets in XSniffer

29 WSN Training: XMesh Services29 Feb 2007 Health Statistics Health Packet  Sensor network health monitoring  Field debugging Can be configured to send out periodic health packets  Application can enable/disable the health packet on the fly  Default health packet interval is 60 seconds for high power, 10 minutes for low power.  API usage  To enable health packet, set health packet interval to 60 seconds call health_packet(TRUE, 60);  To disable health packet call health_packet(FALSE, 60);

30 WSN Training: XMesh Services30 Feb 2007 Health Packet types Two types of health packets 1.Neighbor health  Contains RSSI, link quality, cost of each neighbor etc 2.Statistics health  Contains the following information:  number of packets generated locally  number of packets forwarded  number of packets dropped  number of packets retransmitted  voltage reading  sequence number

31 WSN Training: XMesh Services31 Feb 2007 Health Packet Interval Only one health packet is sent every interval Alternates between statistics packet and neighbor packet Then neighborhood packets cycle through neighbor list until all neighbors in table are described. Defaults:  Each neighborhood packet has room for three (3) neighbors  Neighborhood table has fifteen (15) entries. Health Int Statistics Pkt Neigh1-3 4-6Statistics Pkt

32 WSN Training: XMesh Services32 Feb 2007 Health Packet Structure Health Packet Header Bytes: 50/74112102 TinyOS Header XMesh Header XHealth Header type_nodeversiontype…CRC Health Payload Data Fields Description uint8_t type_nodeThis is for backward compatibility. The value of the first 4 bits for XMesh2 will always be 0xF. Any other value means this is an XMesh1 health packet. uint8_t versionThis is the health packet version number. In XMesh2 the version number is 0x20 uint16_t typeThe value of this field indicates if the packet is a statistics packet or a neighbor packet. Statistic packets have a type of 0x01 and neighbor packets have a type of 0x02

33 WSN Training: XMesh Services33 Feb 2007 Health Payload – Statistics Packet TypeData FieldsDescription uint16_t seq_numThis is the sequence number of the health packet. uint16_t num_node_pktsNumber of application packets that have been generated locally. uint16_t num_fwd_pktsNumber of radio packets that the mote has forwarded in the mesh. uint16_t num_drop_pktsNumber of radio packets that the mote has dropped due to failed link level retransmissions. uint16_t num_rexmitsThis is the number of times that the message was re-transmitted. uint8_t battery_voltageBattery reading. uint16_t power_sumPower statistics for the low power radio stack (not used) uint8_t rsvd_app_typeReserved Crossbow field for identifying sending application. hn_quality nodeinfoA record containing information about the link to the present parent uint16_t node_id Parent’s ID uint8_t link_quality Link quality to parent (high 4 bits send quality and low 4 bits receive quality). uint8_t hop_count The number of hops the parent is from the base station uint8_t radio_link_indicator The rssi or lqi value of the parent

34 WSN Training: XMesh Services34 Feb 2007 Neighborhood Health Packet TypeData Fields Description uint8_t type_node This field is in the Health header. The bottom 4 bits will contain the number of neighbors sent in the packet. hn_quality nodeinfoRecords containing information about the link quality of the neighbor. Each record consist of the following elements: uint16_t node_id Parent’s ID uint8_t link_quality Link quality normalized to 255 (100%). 100% indicates that both the parent and child hear 100% of each other’s messages. uint8_t path_cost Hop count uint8_t radio_link_indicator The rssi or lqi value of the parent

35 Feb 2007WSN Training: XMesh Services35 XMesh Services Objectives:  Health statistics  ELP  Lab: View health packets in XSniffer

36 WSN Training: XMesh Services36 Feb 2007 ELP (Extended Low Power) Locate at the edge of the mesh and sleep most of the time  Need to have a high power node as its parent  Conceptually similar to RFD in ZigBee  50  A on average Doesn’t participate in the routing and forwarding  Not forwarding packets  Broadcast cost as infinity so no one else chooses it as parent

37 WSN Training: XMesh Services37 Feb 2007 Hybrid Star Network with ELP XMesh network using High Power mode for nodes that make up the backbone and Extended Low Power mode for nodes along the edge.

38 WSN Training: XMesh Services38 Feb 2007 ELP Operational Theory  Use health packet to keep in touch with the base station  User has full control on sleep duration (via API)

39 WSN Training: XMesh Services39 Feb 2007 ELP Interfaces ElpControlI interface  enable() Enables ELP mode  disable() Disables ELP mode  isActive() Query if in ELP mode ElpI Interface  route_discover(uint8_t rui) Join within given # of route updates  route_discover_done (bool success, uint16_t parent) Returns result of join attempt  wake() Wake a node into full power  wake_done() Signals node leaves ELP mode  sleep( uint16_t duration, Sleep an ELP node uint16_t health_interval, uint8_t iRetries, uint8_t force_sleep)  sleep_done() Signals sleep interval is over

40 WSN Training: XMesh Services40 Feb 2007 ELP Operational Theory (cont.)

41 Feb 2007WSN Training: XMesh Services41 XMesh Services Objectives:  Health statistics  ELP  Lab: View health packets in XSniffer

42 WSN Training: XMesh Services42 Feb 2007 Lab: Health Packet Start with MoteWorks/apps/examples/XMeshCountsToLeds Enabling Health Packets XMesh exports a command called health_packet that enables health packet reporting during run time: command void health_packet(bool enable, uint16_t interval); if enable is TRUE, the health packet will be sent out periodically every interval seconds. Interval is usually set to several minutes in order not to impact the overall mesh message rate. Typical values for interval are: XMesh-HP : 1 minute or more XMesh-LP : 10 minutes or more

43 WSN Training: XMesh Services43 Feb 2007 Lab: Health Packet -- Overview  EXAMPLE // In the App.nc wiring file add: AppM.health_packet -> XMeshRouter; //In AppM.nc, the user can enable the // health packet reporting: // in the AppM.nc uses{ section add: command void health_packet (bool enable, uint16_t intv); // in the AppM.StdControl.start section add: call health_packet(TRUE, 600); // 10 min interval // This will disable the health packet reporting: call health_packet(FALSE,0);

44 WSN Training: XMesh Services44 Feb 2007 Lab: Health Packet – XMeshCountToLedsM.nc XMeshCountToLedsM.nc  Sends health packet every 30 seconds.  StdControl.start includes code to initiate this  call health_packet(TRUE,30); XMeshCountToLeds.nc  Includes line to wire health_packet command to XMeshRouter  XMeshCountToLedsM.health_packet -> MULTIHOPROUTER;. module XMeshCountToLedsM { provides{ interface StdControl; } uses { interface Timer; interface Leds; interface MhopSend; command void health_packet(bool enable, uint16_t intv); } Application must add the command to control health_packet to the specification block.

45 WSN Training: XMesh Services45 Feb 2007 Lab: Health Packet Prepare the Network 1.Compile MoteWorks/apps/examples/XMeshCountsToLeds 2.Flash XMeshCountsToLeds to Node 1 3.Compile and Flash XMeshBase to Node 0 4.Compile and Flash XSniffer to a third Node View the Health Packets 5.Open XSniffer GUI and view health packets Other things to try 6.Open XServe and view health packets via XMeshBase

46 WSN Training: XMesh Services46 Feb 2007 Lab: Health Packet Use XSniffer GUI through xserve 1.Keep XSniffer node on gateway 2.Connect xserve to gateway. Note: sniffer firmware is at higher baud rate  Using MIB510 type: xserve –s=COM# -b=115200  Using MIB600 type: xserve-i=#.#.#.#  View data via xserve 3.Connect XSniffer GUI to xserve  Select TCP/IP Socket connection  Set host to localhost  Set port to 9001  Click CONNECT  View packets in GUI

47 Feb 2007WSN Training: XMesh Services47 Q & A: XMesh Advanced Services Objectives:  Understand XMesh transport services 1.Upstream 2.Upstream with end-to-end acknowledgement 3.Downstream 4.Downstream with end-to-end acknowledgement  Lab: Guaranteed QoS with upstream ack  XMesh Health Packets  Extended Low Power Mode (ELP)  Lab: Health Packet


Download ppt "Feb 2007WSN Training: XMesh Services1 Lab6 Objectives:  Route Control Interface  Understand XMesh transport services 1.Upstream 2.Upstream with end-to-end."

Similar presentations


Ads by Google