Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Stack Organization

Overview

Protocol layers are wired together to form a stack. Click on the image to the right to see the stack organization diagram of the OpenWSN protocol stack. Send functions are used to push packets down the stack; Receive functions to pull them up. The bytes of a packet live in the OpenQueue component. A packet is a variable of type OpenQueueEntry_t and is defined in openwsn.h; components pass a pointer to an OpenQueueEntry_t variables in the Send and Receive functions.

OpenQueueEntry_t and metadata

An OpenQueueEntry_t consists of the actual bytes in the packet, plus a number of metadata fields. Metadata is used for an upper (resp. lower) layer to set parameters a lower (resp. upper) layer will need, when sending a packet down (resp. up) the stack. One example is that the MAC layer sets l1_channel to instruct the driver about which channel it needs to transmit the packet on. Another example is that RPL layer specifies l2_nextORpreviousHop, indicating to the MAC layer to which neighbor this packet needs to go.

...

  • creator indicates the component which created this packet, i.e. which requested an unused OpenQueueEntry_t to the OpenQueue component. When sending a packet down the stack, the convention is that only the creator of a packet can free that packet, i.e. instruct the OpenQueue component it doesn't need it anymore. Typically, OpenQueueEntry_t variables will be created by all application-layer component when sending a packet, or by the drivers when receiving.
  • owner indicates the components which currently holds the packet. The convention is that a component can only change the content of an OpenQueueEntry_t if it is currently the owner.
  • The packet part of the OpenQueueEntry_t holds the actual bytes of the packet. Because OpenWSN does not allow for dynamic memory allocation, packet is the maximal allowed size. payload is a pointer to the first used by in packetlength indicates how many bytes are used.

Adding/removing protocol headers

When a component requests an unused OpenQueueEntry_t from the OpenQueue component, payload points to the end packet and length is zero. If a components needs to add n bytes of data to the packet pkt, it calls:

...

No Format
packetfunctions_reserveHeaderSize(msg,sizeof(tcp_ht));

Story of a packet

This section tells the story about what each layer does in the OpenWSN implementation, including which layers read and write metadata. There are two parts: one which details what happens when a packet is generated at the application layer, and travels down the stack until the drivers; one the other way.

...