120 likes | 319 Views
Lab6. Objectives: Route Control Interface Understand XMesh transport services Upstream Upstream with end-to-end acknowledgement Downstream Downstream with end-to-end acknowledgement Note: we’ll not cover services 3 and 4; if you’d like to understand them, read “MoteWorks getting started”.
E N D
Lab6 Objectives: Route Control Interface Understand XMesh transport services Upstream Upstream with end-to-end acknowledgement Downstream Downstream with end-to-end acknowledgement Note: we’ll not cover services 3 and 4; if you’d like to understand them, read “MoteWorks getting started” WSN Training: XMesh Services
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(); WSN Training: XMesh Services
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 WSN Training: XMesh Services
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. WSN Training: XMesh Services
XMesh Service Identifier: AM type • Predefined AM types • QoS Service Types: • UPSTREAM • UPSTREAM_ACK • DOWNSTREAM • 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. WSN Training: XMesh Services
End-to-end acknowledgement • Source code: • under /MoteWorks/apps/tutorials/lesson_5 • What does it do? • send upstream packet (from nodes to base station), requesting end-to-end ack • Use XMesh UpstreamAck service wirings and APIs • Yellow LED toggles when an acknowledgement message is received back from the base station WSN Training: XMesh Services
Required Hardware and PC Setup • Three MICA Motes: MICA2 (MPR4x0) or MICAz (MPR2600) • One sensor or data acquisition board: MTS300 or MTS310, MDA100 is OK too • One gateway board: MIB510, MIB520, or MIB600 and the associated hardware (cables, power supply) for each • A Windows PC with MoteWorks installed WSN Training: XMesh Services
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]; } Top-level configuration The only change to the configuration file is the addition of the ReceiveAck interface wiring. WSN Training: XMesh Services
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(); … Top-level Module Switch service type to MODE_UPSTREAM_ACK Add handling of end-to-end acknowledgement received from base station. WSN Training: XMesh Services
Compile & flash motes • Compile with designated radio frequency in MakeXbowlocal and typing make <platform> • Or by typing make <platform> route,hp • Program the remote nodes by typing make <platform> reinstall,1 <programmer>,com# • Compile and program a separate base station with XMeshBase by typing make <platform> install,0 <programmer>,com# WSN Training: XMesh Services
Visualize traffic • 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. WSN Training: XMesh Services
What you need to do? • Finish Lab 6 (posted in HuskyCT) WSN Training: XMesh Services