Title: SYNC for MOTES
1SYNC for MOTES
2Backgroup info. about Active Message
- Motes use Active Messages Layer to communicate
each other. - The advantage of the Active Message Layer is that
it tranfers user data with hander name and a data
payoff. When the message arrive at the
destination, it trigger the hander to handle the
data immediately, which can eliminates buffering
difficulties, reduce network congestion and
ensure perfomance. - At one node, the Active Messages Layer can only
handle a single message at a time. It is the
appliation developer duty to cooperate
transmissions in different modules to avoid
coflicts. - The Active Messages Layer cant receive a message
while a transmission in progrogress. - The packet size in TinyOS is fixed, 38
bytes/packet. It is about 40ms from requesting
to transmit the first bit to the reply of the
tramission the last bit in one node. About
78ms to finish a packet transmissioin between
two nodes. - (I am not sure about those data, I got them from
the documents of TinyOS.)
3Backgroup info. about Radio Comm.
- All the motes use the same radio channel for
communication. - It means that if two motes want to send a
message by Radio at the same - time, one will failed.
- There are a scheme CSMA (Carrier Sense Multiple
Access) to solve communication conflict. - Implement by diffierent kinds components in
TinyOS, they are - RADIO_BYTE, SEC_DEC_RADIO_BYTE,
SEC_DEC_RAIO_BYTE_SIGNAL, - In each RADIO_BYTE components
4Backgroup info. about Radio Comm.(cont).
- It is said there is another scheme to solve radio
comm. channel conflict - It is implemented by MAC Layer.
- When a conflict happen, it just report the
busy status to the appliction, and - let application handle this situation, droping
the message or re-transmitiing. - (But I am not sure about it)
- If we use CSMA scheme, channel capacity is about
25 packet/s. - channel utilization is up to 70.
- So if we use the RADIO_BYTE components, we dont
need consider conflicts in the application level.
5Commucation Structure
- We suse a self-defined component MSG_TO_MFG to
communicate between Motes by Radio Channel. - We use another self-defined component
GENERIC_BASE_UART to communicate between IPQ/PC
by serial Ports
6MSG_TO_RFM
- This module is changed from the modules
INT_TO_RFM and RFM_TO_LEDS . This module can send
by TOS_Msg out by accepting a TOS_COMMAND
MSG_TO_RFM_OUTPUT(TOS_MsgPtr msg), using the
Active Message Channel 4. And When a message
coming from the Active Message Channel 4, it can
also signal an event MSG_TO_RFM_MSG_ACCEPT(TOS_Ms
gPtr msg) to the upper component. If you want to
use another Active Message Channel, not 4, you
can modify the file MSG_TO_RFM.desc. - include modulesGENERIC_COMM
- This component is built on the shared componet
GENERIC_COMM. - GENERIC_COMM use a system radio byte level
componet SED_DEC_RADIO_BYTE_SIGNAL for radio
communication, so we dont need consider channel
conflicts between motes.
7GENERIC_COMM
- include modules AM_STANDARD
- UART_PACKET
- UART
- CRCPACKETOBJ_SIGNAL SEC_DED_RADIO_BYTE_S
IGNAL - RFM
- RANDOM_LFSR
- ADC
8GENERIC_BASE_UART
- It is a generic base to communicate between PC
and mote using UART. It accepted a command
GENERIC_BASE_UART_OUTPUT(TOS_MsgPtr data) to send
a data packet by serial port - And when a data packet arrived from serial port,
it signal a Event GENERIC_BASE_UART_DATA_READY(TOS
_MsgPtr data) - (I just write this commponent last night. And it
have been tested until now.) - include modules UART_PACKET
- UART
9Other components needed
- One very important component we need is CLOCK.
- We use it the set the clock for the whole
application. - The another usefule components is LEDS, which is
used for debugging. - The sensor componets, MIC, SOUNDER, PHOTO, ,
will be used in the data collection, which are
not used in the sync. Module. - Maybe sometimes we will use the sounder componet
for debugging.
10SYNC_MSG_TYPE
- define USER_DATA 0
- define ROUND_DELAY 1
- define ACK_ROUND_DELAY 2
- define RET_IPAQ_DELAY 3
- define SUB_MAX_DELAY 4
- define RET_SUB_DELAY 5
- define TMOSM_STARTUP_1 6
- define TMOSM_STARTUP_2 7
- define CLOCK_SYNC_1 8
- define CLOCK_SYNC_2 9
- define ERR_REPORT 10
11IMPORTANT ASSUMPTIONs
- In order to ensure a channel Slience period to
ensure sync-msg-communication, we define a global
varaible SILIENCE_PERIOD for each mote node. - In each mote node, except for the synchronization
module, every other module should check
SILENCE_PERIOD 0 before it send out a message. - A fixed time(about 100ms to 200ms) before initial
sync or re-synce time, we set the SILENCE_PERIOD
1. So after about(50 t100ms), there will be no
message be sent out in this mode mode. - For the slience peroind is about 100 ms or more,
we should take a longer re-sync period, maybe 5
seconds. Or the clock synchronization will
consume a lot of cpu time - The data use in this design document should be
tested and get a proper value later.
12Initial Clock Synchronizatioin for iPAQ
START
Send ? back to master node with RET_IPAQ_DALAY
Take a timestamp T1
Send ROUD_DELAY msg to master mote
Sleep for t time
Wait for ACK_ROUND_DELAY msg from the master
node
Send TMOSM_STARTUP_1 to the master Node
Received ACK_ROUND_DELAY
TIME_OUT
NO
Sleep for ?ipaq
Yes
Yes
Take a time stamp T2, get ?temp T1 T2
abort
Set the local time to zero
Repeat above steps 3 times, get ?
average(?temp)
END
Wait for master mote to report its ?max for
comm. cost between motes
Received SUB_MAX_DELAY Msg?
TIME_OUT
NO
Yes
Yes
recieved ?max sub_max_delay ?ipaq ? ?max
abort
13Initial Clock Synchronizatioin for Master Node
START
Take a time stamp Tk, 2 Get ?rep the time
between node k receving ROUND_DELAY and sending
ACK_ROUND_DELAY
RECEIVE msg from iPAQ through GNERIC_BASE_UART
MSG ROUND_DELAY?
Yes
?temp Tk,2 Tk, 1 - ?rep Repeat this
round-trip several 3 times ?k
average(?temp) ?worstk max(?temp) ?max
max(?i)
Send ACK_ROUND_DELAY back to iPAQ cnt cnt 1
Send ACK_ROUND_DELAY back to iPAQ cnt cnt 1
cnt 3?
No
Repeat this round-trip 3 times
Global varibale SLIENCE_PERIOD 1 For each node
in the group, take a time stamp Tk, 1 .
Broadcast ROUND_DELAY msg with GROUP_ID
Send msg SUB_MAX_DELAY msg to iPAQ with the
value ?max Send msg RET_SUB_DELAY with
?k,?worstk.?max to the mote node K
Warit for ACK_ROUND_DELAY msg
Received ACK_ROUND_DELAY
TIME_OUT
NO
to be continued
Yes
14Initial Clock Synchronizatioin for Master
Node(cont.)
Wait msg from iPAQ through GNERIC_BASE_UART
No
MSG RET_IPAQ_DELAY
Yes
Record the delay ?
No
MSG TMOSM_STARTUP_1
Broacast TMOSM_STARTUP_1
be idle for ?/2 then set clock as 0
be idle for t 50 ms time
Broadcast TMOSM_STARTUP_2
Be idle for ?max
Yes
Global varibale SLIENCE_PERIOD 0
END
15Initial Clock Synchronizatioin for slave Node
START
No
MSG TMOSM_STARTUP_1
MSG TMOSM_STARTUP_2
No
Global varibale SLIENCE_PERIOD 1
Yes
Yes
RECEIVE msg from the radio channel
Abort
Set the local clock as 0
Group_id LOCAL_GROUP
Wait for TMOSM_STARUP_2
Yes
No
MSG TMOSM_STARTUP_2 Group_id LOCAL_GROUP
MSG ROUND_DELAY
Wait for time out ( ?max t ?worst/2)
Yes
No
No
Yes
Send ACK_ROUND_DELAY back to the MASTER
Yes
Yes
No
Set the local clock as t ?k/2
MSG RET_SUB_DELAY
No
be idle for ?max - ?k/2
Yes
Record ?k,?worstk.?max
SLIENCE_PERIOD 0
END
16Re-synchronizatioin for iPAQ
Time for re-sync?
Send CLOCK_SYNC msg to master node with local
stamp
END
17re-synchronizatioin for master mote
Note 1p is the maximum devation possibility
between master and slave notes. We havent got
the time until now. ? is the max length of period
, after which no message, except for the sync
msg, can be send out from this node. We assume
it 40 ms here. Note 2 For the slience peroind
is about 100 ms or more, we should take a longer
re-sync period, maybe 5 seconds. Or the clock
synchronization will consume a lot of cpu time.
Receive CLOCK_SYNC from iPAQ?
No
Yes
this_diff local_stamp iPAQ stamp diff
average(this_diff)
Time Tnr?
local stamp local stamp diff
Broacast CLOCK_SYNC_1
Time Tnr - p - ??
be idle for t time
Broadcast LOCAL_SYNC_2
Yes
SLIENCE_PERIOD 1
Be idle for ?max/2
Global varibale SLIENCE_PERIOD 0
18re-synchronizatioin for slave mote
Time Tnr - p - ??
No
Wait for time out ( 2 p ? t ?worst/2
?worst/2)
Msg CLOCK_SYNC_2?
No
No
Yes
SLIENCE_PERIOD 1
Go to the step
yes
Wati for the sync msgs
Wait for CLOCK_SYNC_2
Group_id LOCAL_GROUP?
No
Wait for time out ( t ?worst/2)
Msg CLOCK_SYNC_2 groupid LOCAL_GROUP
No
Yes
No
Msg CLOCK_SYNC_1
Yes
Yes
this_diff2 local_stamp master stamp diff2
average(this_diff) Local stamp local stamp -
diff2
Yes
this_diff1 local_stamp master stamp diff1
average(this_diff) Local stamp local stamp -
diff1
Report error(opt.)
Be idle for (?max - ?k) /2
SLIENCE_PERIOD 0