• No results found

Control and data packet structures

PoRAP Design and Implementation

5.6 PoRAP Implementation

5.6.4 Control and data packet structures

Two packet formats are required in PoRAP. The control packet is used in the control and setup phase. It contains essential information for transmission power adaptation and time synchronisation. The data packet is used to deliver the sensed phenomenon to the base station. Details of both packet structures are given in this section.

A) Control packet

The control packet structure is shown in Figure 5.15.

Figure 5.15: Control packet structure

The control packet consists of 5 fields. The first byte, base_id, represents the base station’s address. The address can be assigned at installation time. The no_alloc_slot demonstrates the number of allocated slots and is stored in an 8-bit field. Slot length is contained in the 16-bit slot_length. The time when the first data slot is started is demonstrated in the 16-bit

142

slot_start. Finally, the tx_adapt[s] is used to notify the sources whether transmission power adaptation is required.

The default payload size in the message_t abstract data structure is set to 28 bytes. Declaration of a larger payload size in the Makefile is required for larger payload. However, the maximum payload for the CC2420 is approximately 117 bytes. According to Figure 5.15, the former fields take 6 bytes. The size of tx_adapt[s] depends upon the number of sources which are capable of communicating with the base station directly. Therefore, c in Figure 5.16 is equal to (47 + [((s – 1) / 4) + 1] * 8) where s represents the number of sources. The “/” is the division operator where the remainder is discarded. The structure of tx_adapt[s] is given in Figure 5.16.

Figure 5.16: Structure of tx_adapt[s]

where p indicates the number of allocated bytes. According to Figure 5.16, two bits are arranged for a source and therefore one byte supports four sources. There are four possible patterns of two bits for the notification of transmission power adaptation and three of these are summarised in Table 5.2.

Table 5.2: Three possible patterns for transmission power (TX) adaptation

Pattern Meaning

00 RSSI is in the range, keep TX the same

01 RSSI is higher than required, decrease TX power 10 RSSI is lower than required, increase TX power

The comparison of the RSSI measures is the key to transmission power adaptation. For example, an increase in TX is requested if the observed RSSI is lower than required. The power is retained if the measured RSSI is in the desired RSSI range. The base station sets these particular bits to ‘00’. The data packet structure is illustrated in the next section.

B) Data packet

The sources transmit their data packets to the base station within assigned data slots. The data packet structure is shown in Figure 5.17.

Figure 5.17: Data packet structure

The data packet consists of 2 fields. The 8-bit source_id field represents the sensor address which is defined at the installation time. Finally, the data is stored in data[q] where q is the number of bytes used for storing data. The width of data field is defined by the application. Therefore, d can be represented by (47 + (8 * q)).

5.7 Conclusion

This chapter has described PoRAP design and implementation. Several functional requirements are outlined in order to address which components are required. PoRAP adopts the measurement- based approach to determine the current link quality by means of RSSI and the schedule-based approach to access and employ the shared wireless medium. The transmission power is adapted based upon the current link quality. A lower power can be used while the data loss is minimised. Major sources of energy wastage such as collision can be avoided and the idle listening can be also minimised.

In PoRAP, a fixed set of sources is determined and they are controlled by their base station. Several models used for estimating sending and receiving delays together with a guard length are proposed. These models are proposed by looking at the experimental results obtained in Chapter 4. A frame is used to represent communication in PoRAP and consists of one control slot followed by data slots. The base station broadcasts a control packet within the control slot. The duration of the next control packet broadcast can be computed by looking at the included scheduling information in the control packet. The sources thus know when they should restart their radios.

PoRAP consists of two main components including a base station and sources which operate together in order to collect the physical data from the phenomenon. The application always specifies its requirement in terms of reliability in which minimization of data loss is often required. PoRAP is implemented by using TinyOS 2.0.2. Some existing components provided by TinyOS can be modified to achieve the goals. For example, the radio-related components have some interfaces and commands which make RSSI measurement and transmission power adaptation

144

feasible. Alarm and Timer components can be used for scheduling the communication. A timer instance is used by the source for timing the waiting interval. It is started after the control packet is received. Another instance is started after the data is sent. The base station module is an enhancement of the existing BaseStation utility application in TinyOS. The enhancements include control transmission, RSSI measurement, notification bit settings and packet broadcast scheduling.

Two packet structures are used in PoRAP. The control packet is always broadcast by the base station at the maximum power level. After data reception, the base station compares the observed RSSI to the bounds and determines the power level to signal the source. Only two bits are used for signaling to each source the amendment to the current power level. Scheduling information is also included in the control packet. After the control packet is received by the source, the payload is read and the source sets its scheduling parameters and adjusts the power for the next communication cycle. The next frame begins after all sources complete their transmissions.

Chapter 6