Location_Aware_Routing

Report
專題實作
Location-Aware
Routing
報告者:
陳建隆
指導老師:石貴平 & 張志勇
指導助教:張勝文
組員:
詹翔任 陳廷祥
2005_9_6
關於這次專題實作
• 本組總共完成了五個applications,分別為
App0、App1、App2、App3與App4,它
們都是根據SenseLightToLog修改而得。
• 由於並沒有足夠的MICA2可以實作,而且
也不知道這五個applications是否正確,所
以,以下將用流程圖來做說明。
PC
java net.tinyos.tools.BcastInject
start_sensing 16 100
serial port
封包從serial port透過
RS232送到TOSBase
MICA2
Addr=19
Programming Board
Programmed with TOSBase
Mote 0 收到封包後開始
然後將封包廣播出去 sensing 資料並存到EEPROM
call SendCmdMsg.send( TOS_BCAST_ADDR,
sizeof(struct SimpleCmdMsg), msg );
Mote 2
Mote 0
封包從TOSBase
透過radio送給
Mote 0
MICA2
Addr=20
Programmed with App0
Mote 1
MICA2
Mote 3
MICA2
Addr=21
MICA2
Addr=22
Programmed with App1
Addr=23
Programmed with App2
Programmed with App3
Mote 1,2,3指定Addr
由於這三個封包是相同的所以當
Mote 4
當依序再收到第二、
將封包送給
Mote 4
收到第一個封包後會把
seqno記錄下來
但此三個封包的來源
Addr
Mote 4
call SendCmdMsg.send(
Mote_4,
三個封包時會根據
Mote 4lastSeqno
收到封包後開始
= bmsg->seqno;
都會被記錄下來
MICA2
sizeof(struct
SimpleCmdMsg),
msg );)
if( bmsg->seqno
== lastSeqno
sensing 資料並存到EEPROM
moteAddr[ k ] = data->source;
Addr=24
來判斷是否是已處理過的封包
但不會再把封包傳送出去
k++;
Programmed with App4
Mote 1,2,3 收到封包後開始
sensing 資料並存到EEPROM
PC
java net.tinyos.tools.BcastInject
read_log 24
Mote 0 收到封包後開始處理時
根據
switch (cmd->action){
……
case READ_LOG:
24
封包從serial port透過
RS232送到TOSBase
!= 20
if(cmd->args.rl_args.destaddr ==
TOS_LOCAL_ADDRESS )
}
call LoggerRead.readNext( … );
……
由於 24 != 20
所以不會執行read_log
然後將封包廣播出去
call SendCmdMsg.send( TOS_BCAST_ADDR,
sizeof(struct SimpleCmdMsg),Mote
msg 2
);
serial port
MICA2
Addr=19
Programming Board
Programmed with TOSBase
Mote 0
封包從TOSBase
透過radio送給
Mote 0
MICA2
Addr=20
Programmed with App0
Mote 1
MICA2
Mote 3
MICA2
Addr=21
MICA2
Addr=22
Programmed with App1
Addr=23
Programmed with App2
Programmed with App3
Mote 1,2,3收到
封包後由於
與之前一樣
Mote
1,2,3指定Addr
24 !=
21 所以都不會執行
Mote 4只會收到這三個相同封包的其中一個
將封包送給
24 != 22Mote 4
call
SendCmdMsg.send(
24 == 24Mote_4,
24而且由於
!= 23 read_log
Mote 4
sizeof(struct
SimpleCmdMsg), msg );
所以
Mote 4會執行read_log
MICA2
Addr=24
然後將EEPROM中的16筆資料
Programmed with App4
放進新的封包中準備送出
PC
最後在Cygwin顯示出從Mote 4
的EEPROM所讀到的16筆資料
serial port
封包透過RS232直
Mote 0 收到封包後 接從TOSBase送到
MICA2
serial
port
也不做任何處理
Addr=19
直接把封包傳給TOSBase
Programming Board
call SendLogMsg.send(19,
Mote 1收到封包後 sizeof(struct LogMsg), msg);
然後顯示三個Leds燈
不做任何處理
以表示封包是經由
Mote 1傳送 Leds燈
然後也顯示三個
直接將封包傳給Mote 0
call Leds.yellowOn();
call SendLogMsg.send(MOTE_0,
call Leds.redOn();
sizeof(struct
LogMsg), msg);
call Leds.greenOn();
Mote 2
Programmed with TOSBase
Mote 0
MICA2
Addr=20
Programmed with App0
Mote 1
MICA2
Mote 3
MICA2
Addr=21
MICA2
Addr=22
Programmed with App1
Addr=23
Programmed with App2
Programmed with App3
在將新的封包送出之前
Mote 4會根據
Mote 1,2,3以Addr值愈低者
shortAddr = moteAddr[0]
;
由於Mote表示離
1離Mote
0較近
Mote
0愈近
for(n = 1 ; n < 3; n++){
所以將封包傳給Mote 1
if( (moteAddr[n] !=call
0) &&
(shortAddr >moteAddr[n]) )
SendLogMsg.send(shortAddr,
shortAddr = moteAddr[n]
;
sizeof(struct
LogMsg), &log_msg);
由於moteAddr[n]
的初始值為0
}……
來選擇最短路徑
故 0 必須排除
Mote 4
MICA2
Addr=24
Programmed with App4
Thanks for attentions
Download program into mica2
with address
MIB510=/dev/ttyS<n> make mica2 install.<mote_addr>
<n>: COM(n+1)
Mote address may be any value
EXCEPT two reserved values
TOS_BCAST_ADDR ( 0xffff ):to broadcast to all nodes
TOS_UART_ADDR ( 0x007e ):to send to the serial port
Back
seqno
每執行”net.tinyos.tools.BcastInject”一次即累加
一次 seqno
可到”tools/java/bcast.properties”重新設定此值
Back

similar documents