Google
 

Sunday, February 11, 2007

OpenWSN Frame/Packet Summary (draft 20070210)

OpenWSN Frame/Packet Summary (draft 20070210)

this document describes the format of frames/packets in the OpenWSN system.

attention: this design may be different from what we have done now. we will adjust our system to the following. however, some detail are still in discussion.

  • OpenWSN PHY Frame (in wireless communication)
This frame is identical with the frame format of IEEE 802.15.4 protocol. It can also be recognized by TI/Chipcon cc2420 ZigBee ready chip. OpenWSN wouldn't introduce new PHY format.

IEEE 802.15.4 PPDU format
[4B Preamble][1B SFD][7b Framelength, 1b Reserved][nB PSDU/Payload]

QQQ: whether the higher 7 bit or lower 7 bit represent framelength? can any one answer me?

Note that the preamble byte and SFD (start of eliminator) will be processed by hardware chips. so the software only need care about the data from frame length byte. so the real OpenWSN PHY frame defined in OpenWSN software is as the following:

OpenWSN PHY format (TOpenFrame type defined in hal_openframe.h):
[7b Framelength, 1b Reserved][nB PSDU/Payload]
here, PSDU(or namely the payload of PPDU)
is essentially the MAC frame.

  • OpenWSN MAC Frame (in wireless communication)
OpenWSN MAC frame is also identical with the format of IEEE 802.15.4 protocol. It can also be recognized by TI/Chipcon cc2420 ZigBee ready chip. OpenWSN wouldn't introduce new MAC format.

attention that OpenWSN MAC format may use the reserved values in IEEE 802.15.4 MAC in the future.

OpenWSN MAC/IEEE 802.15.4 MAC DATA (the payload of PHY frame)

Beacon Frame
[2B Frame Control] [1B Sequence Number][4 or 10 Address][2 Superframe Specification] [k GTS fields][m Padding address fields] [n Beacon payload][2 FCS]

Data Frame
[2B Frame Control] [1B Sequence Number][4 or 20 Address][n Data Payload][2 FCS]

ACK Frame
[2B Frame Control] [1B Sequence Number][2 FCS]

MAC Control Frame
[2B Frame Control] [1B Sequence Number][4 or 20 ADdress][1 Command Type][n Command Payload][2 FCS]

Frame Control
b2b1b0 frame type 000 beacon, 001 data 010 ACK 011 command 100-111 reserved
b12b13 reserved.


One problem puzzled the developer is the format of MAC address. the MAC address varies from 4 byte to even 20 bytes in 802.15.4. The type of address can be decided by the bit settings in Frame Control word in MAC frame.

In the current implementation of OpenWSN, it uses the short address of 802.15.4 MAC only. That is to say, the PAN id, source node id, and destination node id are all 16 bits.

In 802.15.4, the address(unique id) of a device/node, can be 16 bit/2 bytes (short address) or 64 bit/8 bytes (long address). The long 64 bits address is unique in the world. It should be allocated to the device before the device joins the network. While, the short 16 bit address is unique in a specific PAN. So the short address is only meaning full when combining with PAN id together.


However, there's some difference between OpenMAC and 802.15.4.
OpenMAC does more simplifications than 802.15.4 and also add some new features.


- OpenMAC doesn't provide Beacon Frame
- OpenMAC introduce RTS/CTS frame (not implemented till 20070130 in its simple MAC version, but the full version MAC will implement this mechanism)
- OpenMAC adopts the 802.15.4 MAC control frame and extend it to support RTS / CTS frame.
- OpenMAC adopts the 802.15.4 ACK frame. But the software implementation doesn't care this because the ACK frame is processed by cc2420 transceiver chip.


attention:
there's a macro defined in the OpenWSN software: MAC_HEADER_SIZE. this value is 7(???) = 2 frame control + 1 sequence + 4 address bytes (according to the DATA frame only).

  • OpenNET Packet (in wireless communication)
attention: the notation "frame" should be used in PHY/MAC layer (in chinese language, "zhen"). while, in NET and APP layer, you should use "packet". (in chinese language, "fen zu").

OpenNET packet is essentially the payload of the OpenMAC frame.

NET layer also has its address. The NET layer address and MAC layer address are not same. In OpenNET design, every node is assigned a 16 bit unique id (node id) and 16 bit network id (the same as PAN id). So the design can be simplified ---- OpenMAC and OpenNET share the same address fields.

The OpenNET packet:
[4-20B Address] [1B packet control] [1B Command Type] [nB Data]

attention here the "type" byte is the network layer command/packet type. Don't confuse it with MAC layer command. The MAC layer command is used in MAC layer only.

[4-20B Address]
the 4-20B address is shared by OpenMAC frame and OpenNET packet. Due to the complexity address assignment mechanism of MAC address in full version 802.15.4, OpenNET may introduce self-owned address field in the future. But i think it isn't necessary now. So i still let OpenMAC and OpenNET share the same address field.

[1B packet control] = [b7,...b0]
the packet control byte are reserved for future use.

b0 REQUEST flag, default 0
b0 = 0, means this is a RESPONSE packet. the destination node does nothing when it received the packet. this type is usually sent from the sink node to all the other sensor nodes.
b0 = 1 means this is a REQUEST packet. the destination node is required to reply a RESPONSE type packet. this type is often sent from the sensor nodes to the sink nodes.

b1 BROADCASR flag, default 0
b1 = 0, not broadcast
b1 = 1, the current node should broadcast this packet out.

the above attributes can help to implement NET layer protocols such as SPIN.

[1B Command Type] = [b7,...b0]

b7 is used to distinguish whether the command is a OpenWSN system command or user command (namely, application defined command). b7 is 0 for openwsn system command and 1 for application command.

/* system used data types */
#define ODA_TYPE_DEBUG 0x00
#define ODA_TYPE_CONFIGURE 0x01
#define ODA_TYPE_DATA 0x02
#define ODA_TYPE_LOCATION 0x06
#define ODA_TYPE_UPGRADE 0x07
#define ODA_TYPE_PROBE 0x08 // probing neighbor nodes

/* user defined data type
* the developer can add more TYPE defines if necessary. */
#define ODA_TYPE_USER 0x80
#define ODA_TYPE_TEMPSENSOR (ODA_TYPE_USER + 5)
#define ODA_TYPE_VIBSENSOR (ODA_TYPE_USER + 6)
#define ODA_TYPE_STRAINSENSOR (ODA_TYPE_USER + 7)
#define ODA_TYPE_LIGHTSENSOR (ODA_TYPE_USER + 8)
#define ODA_TYPE_OTHER_USER_DEFINED (ODA_TYPE_USER + 100)

attention the values may be adjusted in the near future. however, i'll try my best to make they are stable.



  • OpenWSN UART/SIO Frame (in serial communication)
The serial communication includes UART(such as RS232/485) and USB.
UART frame is quite similar to the wireless PHY frame.

[1B SFD] [1B Length] [nB Payload]

in UART frame, a special byte is used to indicate the start of the frame. attention here OpenWSN uses the technique of ESCAPE character idea to avoid data confilications. The SFD (start of eliminator) byte is used to represent the start of the frame. if there are SFD characters in Length and Payload, then the UART driver will insert another SFD as ESCAPE character.

(??? i have forgot the detail of UART/SIO driver, so this idea need confirmation)

attention that the Payload of the frame is essentially anything. But in our reference implementation of OpenWSN, we makes the "TOpenFrame" describe above as the payload. So the host application can got all the information of the hardware wireless communications. This feature facilitate the developing of host GUI applications.
.

No comments:

Google