Wireless Sensor Network Protocol

From Glacsweb Wiki
Jump to: navigation, search

                                               Wireless Sensor Network Protocol 

1. Physical Layer:

Bit rate = 10K bit/s (Manchester coding* = 5K bit/s) = 200µs/bit **

Byte time = 0.2ms X 8 = 1.6ms

Packet structure:


Maximum Packet Size = 64 bytes

Packet time for 64 bytes = 64 X 1.6ms = 102.4 ms

      • Packet = (16 x 6 sensor reading per day as default = 96 byte data) + 9 bytes header = 105 byte
      • Packet time = 105 byte x 1.6ms = 168 ms

Note that the actual packet size can be from 9 bytes up to the Maximum size (64)

The Transceiver will be ON when sending only for the period of the actual packet size ( can be from 9 – 64 byte) + the switching settling and preamble time = 130ms max.

 2. MAC/Network Layers and protocols:

2.1 Network overview:


Network Architecture example

General Network Rules:

The master for this network is the Base Station

The network Base Station has full control over 4 independent (slave) TopNodes that it uses to communicate to all the Wireless sensor Nodes

The 4 TopNodes communicate serially (wired RS232 link) to each other and the Base Station using Full Duplex RS232 Box in the Base Station

The rest of the nodes are communicating to the TopNodes and to each other using wireless Ad-hoc networking.

The 4 TopNodes are slaves to the Base station, and it uses them for full control over the network

The 4 TopNodes gather the replies or any broadcast from the Network and send it to the Base Station trough the serial link when the Base Station request it.

The nodes in this network are divided into Hops based on how they communicate to the Base Station TopNodes ? Directly ? or through gateway?, so Hop 0 can communicate to at least one of the TopNodes, Hop 1 can communicate to at least one of the Nodes in Hop 0, Hop 2 can communicate to at least one of the Nodes in Hop 1, and so on….

2.2 Multiple Access:

The network is based on using Time Division Multiple Access (TDMA) where time is split into Frames of a fixed time period and fixed slots within that.

Each Frame consists of number of time slots, this is decided by the base station,

Every node is pre-programmed with an ID that is fixed and assigns it a default slot

Number of Nodes including Top_Nodes (Network capacity) will be sent to the network every time it changes when adding any more Nodes, the number of slots to start with will be according to the actual deployed number of nodes, we will use 35 slots as example in this document

Frame of 35 slots


Each time slot is live for = (102.4 ms (Max packet time) + 10ms preamble + 10ms switching + safety margin = 130 ms.

The frame time = 130 ms X 35 = 4.55 s

      • Packet = (16 x 6 sensor reading per day as default = 96 byte data) + 9 bytes header = 105 byte
      • Slot time = (105 byte x 1.6ms = 168 ms) + 10ms switching + 10ms preamble = 188ms + safety = 200ms
      • Frame time = 200 ms X 25 = 5 s

Slots 34,0,1,2,3 used for the TopNode's downlinks to the Nodes Each TopNode has 1 time slot to transmit and broadcast in, and for the rest of the Frame time slots they are only receiving

Nodes use slots 4 to 33, so this network can accommodate 29 Nodes now, and the number of nodes can be increased if needed even after deployment

2.3 Talking and listening control:

    • Talking = transmitting, Listening = waiting to receive or receiving

1. Each Node talks and listens in specific allocated time slots depending on the network configuration and setup that is controlled by the base station

2. When any of the TopNodes talk in its allocated slot, all the other TopNodes and its gateway and children Nodes are listening.

3. The TopNod is listening all the time and waiting to receive any packets during the frame except when it is talking

4. All the Nodes are slaves to the TopNodes and they will only talk in their time slots, unless it has the permission to talk in any other time slot

2.4 Routing and gateways:

1. The Base Station orders the 4 TopNodes to send various commands to all the Nodes

2. A Node from Hop 0 (that talks directly to a TopNode) may become a gateway (router) to a Node in Hop 1 which can also be a gateway for a Node in Hop 2 and so on……

3. The Base station will allocate Nodes to work as gateways (routers) for other nodes that can talk to the TopNodes directly

4. The gateway assigning and allocation will be based on the radio signal strength between the Nodes (to be implemented?)

5. The algorithm will avoid overloading any of the Nodes with routing process up to specific limits ( 5 now)

6. Nodes DO NOT send packets to each other, the Base only orders a Node to listen to another Node and be its gateway

7. The Nodes DO NOT send its packet to its gateway, but it simply sends, and its gateway simply listens.

2.5 Time Synchronisation:

1. The base station receives the time of day from the TopNodes after waking up from sleep using the serial link before starting synchronising the rest of the network

2. The base station chooses this master synchronisation time according to the TopNode that stayed running the most and that the network was synchronised to last time, also this master time can be initiated by the base station if there are no records of TopNodes synchronisation time

3. TopNodes and base time is synchronised to the selected TopNode time or the base station time if applicable, according to the master time using the serial RS232 link

4. Any Node can not start talking unless it listens to any of the TopNodes or the synchronised Nodes and receives a valid packet to synchronize its time with it. This makes them meet the TDMA scheme.

5. In the Packet header there is an integer value called Ftime, this value is calculated as follows: Ftime = (FrameTime + 10ms preamble + 10ms switching + (1.6ms * (HeaderLength + Payload)).

6. This Ftime value is the value of the Transmitter FrameTime millisecond timer after it sent the packet, and the Receiver received it, so the receiver adjusts its FrameTime millisecond timer with this value, both the sender and receiver are now working with the same value of FrameTime timer and are synchronised with each other.

2.6 The Sensor Nodes network has 2 processes:

1. Network Exploring and configuring, (Direct Echo, Spread Echo, Assign Command Slot, Assign Gateways , Assign Respond Frame,)

2. Daily and maintenance operations, (GetSensorsData, GoToSleep, SetDate, FirmwareRemoteUpdate, etc……………)

First:   Network Exploring and configuring: 

This process is executed:

1. When the Network is started for the first time or been reset

2. When losing more than a certain amount of nodes (2) at one time

3. Every 3 days, looking for Lost Nodes that couldn’t be found before

4. When the Base Station orders the network to so at any time

    • Lost Nodes = Nodes which Couldn’t be found in network explore


1. During this process all the Nodes primary are listening all the time except when it is talking.

2. The Base Station ask the 4 Top Nodes to send DirectEcho command to all the Nodes

3. Every TopNode send the DirectEcho command in its own time slot (original ID) to all the Nodes

4. Every Node hearing the DirectEcho command request will send ACK reply Directly in its own time slot (original ID) in same Frame to the TopNodes reporting that it heard the DirectEcho

5. The TopNodes send this data with the RSSI for these Nodes to the Base Station through the serial link For processing

6. All the Nodes which managed to receive and transmit to the TopNodes are allocated to Hop 0, that contains all the nodes that can talk directly to the TopNodes

7. The Base station processes and stores the data it receives from the TopNodes and looks if there are missing Nodes in the network, (Nodes that previously kept sending corrupt packets due to very week signal strength will be considered as missing also)

8. If there is no missing Nodes this process will end

9. If there are any missing Nodes the Base station will ask the TopNodes to send SpreadEcho commands to all the Nodes

10. The TopNode send SpreadEcho command with 1 parameter:

i. List of all missing Nodes to look for

11. Every Node (all Node in Hop 0) hared the SpreadEcho Command from the TopNode will start to record all the activities around it from the missing Nodes and also send SpreadEcho in its time slot (original ID) at the first chance.

12. Every frame explore a deeper hop in the network

13. The SpreadEcho will keep spreading deeper and deeper in the network Hops till the Base Station ends the command, by sending other commands. (eh? KM)

14. Any node send SpreadEcho will keep listening all the time after that and will catch and record any response from any of the missing Nodes and save it along with the RSSI.

15. After that, every time its time slot (original ID) reached it send spreadecho reply, and keep doing in its time to talk until it receive another command, there is time out based on the maximum number of frames (30 for example).

16. The data included in the spreadecho reply will keep forwarded from nodes in far Hops to Nodes nearer to the TopNodes, and so on until it reach the base station TopNodes

17. after processing the spreadecho replies Any missing Node that did not send any response will be considered as Lost Node and will be scheduled for the next Network Exploring

18. The base station will process all the missing node's responses and will decide the gateway for each of these nodes to talk and listen as required

19. The base station send (AssignCommandSlot) Command to the TopNodes, the TopNodes send this command to all the Nodes, every node that hear this command will echo it to the next Hop

20. The (AssignCommandSlot) Command, will Assign a slot in the super frames to each Node that it will spread and echo any command in when it receives it, this is based on giving the Hop 0 Nodes the early time slots for spreading the command, and the Nodes in Hop 1 the following time slots, and so on, this makes the command heard in all the Hops in the same frame (frame 0).

21. the time required to send a command and receive reply will be = [1 Super command frame + (Number of spreading frames (Hops)] X Frame time 6.5 s

22. To assign the gateway for each Node, the base station will order the TopNode to send packet (AssignGateways) to all the Nodes that contain all the Nodes and there gateways, this command and every command from now on will use the super command frame.

23. The base station will decide also about the Frame that each node will respond when sending any command for all the Nodes (like GetData) as the far Nodes should forwarded or send their data first (in the early reply frames) to the closer nodes, so Nodes in Hop (n) will send the data to Nodes in Hop (n-1) and Nodes in Hop (n-1) will add its data to the same packet and send it to Hop (n-2) and so on until it reach Hop (0) with all the Nodes data then to the base station TopNode

24. To assign the respond frame for each Node, the base station will order the TopNode to send packet (AssignRespondFrame) to all the Nodes that contain all the missing Nodes and it is assigned gateway.

25. By the end of this process each Node will know its status and when to spread any command and its gateway and also the frames and slots it should respond in for commands reply

 Second:    Daily and Custom operations

1. Get the sensor data:

1. This is a daily command (GetSensorsData) that will be sent and spread to all the Nodes using the TopNodes and Gateway Nodes

2. The Nodes will reply back with packets containing the sensors data and date, etc..

3. If the node was lost for some time and it has recorded a lot of data that can not be sent on one packet, The base station will allocate special slots in specific frames to get all this data back, or an entire frame to get this data back (?may assign? KM)

4. This command can be send while the network are awake or scheduled for any time to be executed

2. Set Date:

1. This command (SetDate) is to set the current date and the time

2. This will be sent and spread to all the Nodes using the TopNodes and Gateway Nodes

3. The Nodes will responds with ACK.

4. This command can be send while the network are awake or scheduled for any time to be executed

3. Go To Sleep:

1. This command (GoToSleep) contain the next wake up time and time for sleep, (can be now)

2. This will be sent and spread to all the Nodes using the TopNodes and Gateway Nodes

3. The Nodes will responds with ACK.

4. Firmware Remote Update:

1. This command (FirmwareRemoteUpdate) contain the firmware updates for the Nodes and the required Number of frames for downloading this to the Node memory

5. Star Network back up:

1. This command orders the network to switch from the Multi Hop TDMA system to Star Network

6. Number of sensor reading per day for each individual probe :

1. This command orders the individual network Nodes to record and read the sensor and process the data, by number of times per day specified individually for each Node, (4 or 6 or 12 or 24 or 48) per day.

7. Change network capacity :

1. this Command is to change number of nodes (capacity of the network), in case more Nodes are added to the network

Copy Right: University of Southampton, Glacsweb, Ahmed Elsaify