看了一个下午，终于明白了Tinyos下的Message packet ——TOS_Msg其实就是用typede声明的一个结构体，完整的说明在头文件AM．h这个文件里面找到。以下是TOS_Msg的结构：
typedef struct TOS_Msg
/* The following fields are transmitted/received on the radio. */
int8_t data[TOSH_DATA_LENGTH]; //TOSH_DATA_LENGTH=29
/* The following fields are not actually transmitted or received
* on the radio! They are used for internal accounting only.
* The reason they are in this structure is that the AM interface
* requires them to be part of the TOS_Msg that is passed to
* send/receive operations.
The addr field specifies the destination address (a moteID or the broadcast address). The group field specifies a channel for motes on a network. If a mote receives a packet with a different group ID, the packet is dropped. The type field specifies which handler to be called at the AM level when a packet is received. The length field specifies the length of the data portion of the TOS_Msg. Packets have a maximum payload of 29 bytes. The data portion consists of an array of 29 bytes (as specified by TOSH_DATA_LENGTH). The unsigned two byte field crc follows. When sending, the crc is incrementally calculated as each byte of the packet is transmitted.
So, the maximum length of a transmitted TOS_Msg is 36 bytes (addr(2 bytes) + type(1 bytes) + group(1 bytes) + length(13 bytes) + data(29 bytes) + crc(2 bytes) = 36 bytes).
• sendingNode (2 bytes) – the node that has sent the packet.
• originNode (2 bytes) – the node that generated the packet.
• seqNo (2 bytes) – the sequence number of the packet.
• hopCount (2 bytes) – the number of hops the packet has travelled.
• data (8 bytes) – the payload field of length 21 bytes.
posted on 2005-08-11 18:45 记忆中的深蓝
阅读(1939) 评论(6) 编辑 收藏 引用