1 Introduction

Recent advancement of the wireless sensor network (WSN) encourages to work in the field of railway track condition monitoring system (RTCMS). Specifically, this field can be called a railway sensor network (RSN). In recent years, increased demand for railway services has attracted the researchers to work in the field of RTCMS to maintain the railway services more secure, reliable, and safe [1,2,3,4,5,6,7,8,9]. A WSN can be efficiently used for railway monitoring application (RMA). The sensor network can be used to identify the major faults by continuously capturing the data from the railway track [1]. The data from the sensors may be generated continuously or periodically, or sometimes it can be event-driven. The sensor nodes which generate continuous monitoring data traffic, consume higher energy with respect to the event or periodic monitoring data traffic. Therefore, the data traffic generation in railway monitoring can be classified into two categories. First one is event-driven monitoring (e.g. pore pressure, temperature [2], water content [3]) and another one is continuous monitoring (e.g. acoustic emission [4, 5], accelerometer [6, 7] and strain gauge [8, 9]). The energy demand of the sensor network is one of the major issues while designing and implementing WSN for RMA. The major sources of unnecessary energy consumption are idle listening, control frame overhead, overhearing, and collision [10]. Trans-receiver radio of sensor node operates in four different modes viz. transmit mode, receive mode, idle mode, and sleep mode [11]. Nodes should remain in sleep mode for the maximum duration so that their energy demand remains low. However, there is a trade-off between energy demand and the delay [12]. Various MAC protocols are proposed by the researchers to optimize the performance of WSN [10,11,12,13,14,15,16,17]. Broadly, the WSN MAC protocols are divided into two major categories i.e. contention-based MAC protocols and scheduled based MAC protocols. Contention-based MAC protocols e.g. carrier sense multiple access (CSMA), consume more energy than scheduled based MAC protocols and are suitable for low and medium data traffic applications [18]. The major drawbacks of these protocols are collision, overhearing, and idle listening. Energy-efficient MAC protocols such as sensor MAC (S-MAC) and its variants work efficiently for WSN, but their latency is very high [10]. The improvements have been done by various researchers [12, 19,20,21,22]. However, they are suitable for very low data traffic applications. The good thing about the contention-based MAC protocols is that they have high scalability as compared to schedule based MAC protocols [18]. Schedule based MAC protocols are used for moderate to high traffic loads in a homogeneous network. It provides a collision-free environment and no overhearing. Various works have been reported for TDMA and its variants [13, 15, 20, 23]. In most of the earlier reported works, the focus was to reduce energy demand and delay. In railway monitoring applications, few sensors generate continuous traffic when the train passes form the track (e.g. accelerometer). Hence, traffic is classified as medium to high traffic load as the data generated by the sensor at the rate of 25 kbps [14]. BMA in its current form is not suitable for railway applications. It is only suitable for low to medium data traffic conditions. As per the application requirement, Shafiullah et al. proposed a new energy-efficient wireless MAC protocol E-BMA for railway monitoring application [14]. However, the major drawback of E-BMA MAC protocol is that the transmission latency of E-BMA is approximately two times higher w.r.t. TDMA, EA-TDMA, and BMA. Tolani et al. proposed adaptive-BMA (ABMA) MAC protocol to further reduce energy consumption. The energy consumption of ABMA is less than E-BMA. However, the maximum transmission latency of ABMA increases more than E-BMA. Therefore, both E-BMA and ABMA are not suitable for time-restrictive data traffic applications. In railway monitoring application, few sensors generate event-driven emergency data which requires the time-bound data transmission. To overcome the issue, in the present work, a new protocol is proposed for RMA. In the proposed protocol, the features of both TDMA and BMA have been merged that reduce energy consumption without compromising the maximum transmission latency. The proposed work concentrates on the major issue of handling the two types of traffic generation viz. continuous and event-driven/periodic monitoring. In RMA, when the train passes from the track, both continuous and event/periodic monitoring sensors are activated. Otherwise, only event/periodic monitoring sensors are activated. Therefore, the traffic load changes dynamically from low-to-high and high-to-low. Our proposed ASHMAC protocol can handle such traffic load situations with low transmission latency as it includes the features of both TDMA and BMA. In addition, a comparison has been done among the proposed protocol and other MAC protocols that are dedicated to RMA for a real traffic environment. Both analytical and simulation models are developed for the proposed protocol to compare the performance with the existing MAC protocols.

The novelty of the proposed work can be defined as follows:

  • A post-set-up-phase is introduced between the set-up phase and the steady-state phase to characterize the sensor nodes into continuous and event-monitoring nodes. The post-set-up phase is a bit-map based arrangement used for characterizing the nodes.

  • Unlike the BMA, E-BMA, TDMA, and EA-TDMA, in the proposed ASHMAC protocol, each session is divided into two sub-sessions.

  • Sub-Session-1 follows TDMA for continuous monitoring nodes i.e. the nodes that utilize the slot in each session. Sub-session-2 follows BMA for event-monitoring nodes i.e. the nodes that not need slot in each session.

  • The analytical model is developed for the performance analysis of the proposed ASHMAC protocol.

  • The analytical model of TDMA, EA-TDMA, BMA, and E-BMA has been regenerated for the performance analysis of the continuous and event-monitoring data traffic generation.

  • Unlike the previously reported works, in the proposed protocol, experimental analysis has been done using the prototype model (using Arduino and Raspberry-Pi Boards).

Fig. 1
figure 1

Operational Diagram of TDMA [13], EA-TDMA [15], BMA [16] and E-BMA [14]

The rest of the paper is presented as follows. Section 2 describes the comparative study of scheduled based MAC protocol. Section 3 describes the problem statement. Section 4 discusses the proposed protocol. Section 5 discusses analytical and simulation modeling. Section 6 discusses the results and performance analysis. Finally, Sect. 7 concludes the major research findings of the proposed work.

2 Comparative study of schedule based MAC protocols

Various scheduled based MAC protocols have been discussed in this section for comparative analysis of our proposed protocol. G. Pei et al. presented a low power TDMA protocol for large WSN [13]. There are two common phases in cluster-based MAC protocols. The first phase is the set-up phase or cluster formation phase and the second one is a steady-state phase as shown in Fig. 1. TDMA is suitable for high traffic conditions. For low data traffic conditions, TDMA suffers the serious drawback of inefficient energy consumption of non-source devices i.e. the devices that have no data to transmit.

To overcome the problems of TDMA, J. Li et al. presented bit-map-assisted (BMA) energy-efficient MAC protocol, which performs better for low and medium traffic conditions [16]. BMA is a schedule based MAC protocol, which reduces the unnecessary energy consumption of non-source node and cluster head (CH) node (i.e. energy wastage due to idle listening). The operational diagram of BMA is shown in Fig. 1. The set-up phase of BMA is similar to the TDMA protocol whereas the steady-state phase is quite different from TDMA [13]. The steady-state phase starts with a contention access period, which is further divided into mini control slots. Each sensor node (SN) gets its mini control slot and transmits a 1-bit control message to the CH node during its allotted time slot. BMA consists of a larger contention period as compared to TDMA, which causes unnecessary overhead at high traffic loads where the data transmission is almost certain. Therefore, for high data traffic applications, BMA is not a suitable protocol.

To avoid the unnecessary wastage of energy due to idle listening, Shafiullah et al. [15] developed an energy-efficient EA-TDMA protocol. EA-TDMA operational diagram is shown in Fig. 1. In this protocol, every node wakes-up in its allotted time slot and checks its buffer. If the buffer is empty, the node turns ‘OFF’ its radio immediately and goes in sleep mode, which saves fair amount of energy. However, the CH keeps its radio turn ‘ON’ for the full duration. Hence, the major energy wastage occurs due to the CH node. To overcome the contention overhead problem due to high data traffic conditions in BMA, Shafiullah et al. proposed a new energy-efficient wireless MAC protocol named E-BMA [14] for RMA. E-BMA consumes less energy than BMA even at high data traffic load conditions. However, the maximum transmission latency of E-BMA is approximately two times higher w.r.t. BMA, EA-TDMA, and TDMA. Therefore, E-BMA is not suitable for time-constraint data traffic applications. The operational diagram of E-BMA is shown in Fig. 1. Ayona et al. proposed a time-adaptive bit-map-assisted (TA-BMA) MAC protocol to make E-BMA more energy efficient. However, TA-BMA compromises with the transmission latency [25]. Alvi et al. proposed a scalable energy-efficient TDMA based MAC protocol to handle diverse data traffic, but the performance is not compared with E-BMA protocol [23]. Debasis et al. proposed the bit-map-assisted energy-efficient medium access control (BEE-MAC) protocol to reduce energy consumption [26]. In the BEE-MAC protocol, the transmission schedule is broadcasted in each round, which reduces the energy consumption. However, BEE-MAC also compromises with the maximum transmission latency [26]. Saurabh et al. proposed a hybrid bitmap-assisted MAC protocol for the vehicular ad-hoc network (VANET) to reduce the packet overhead by using fixed-size bitmap [30]. Tolani et al. proposed the ABMA MAC protocol in which two bits control field is used for the reservation of data slots and piggybacking [27]. ABMA reduces energy consumption, but it further increases the maximum transmission latency more than E-BMA. Tolani et al. proposed the duty cycle enabled energy-efficient bit-map-assisted (DCE-EBMA) MAC protocol in which adaptive duty cycle method is used for E-BMA MAC protocol to further reduce energy consumption [28]. However, duty cycle method increases the maximum transmission latency multiple times. To overcome the issues, we have proposed a new energy-efficient hybrid MAC protocol (ASHMAC) that has been discussed in Sect. 4.

3 Problem statement

As per the railway application requirement, TDMA and EA-TDMA are suitable for high traffic conditions or continuous monitoring data traffic applications. On the other hand, BMA performs better for event-driven data traffic applications [16, 18, 23, 27]. However, in WSN based railway monitoring environment, the sensor nodes generate both types of traffic [31]. Both types of sensors (continuous and event-driven) are controlled by the same cluster head. In these types of railway traffic situations, none of the TDMA, EA-TDMA, and BMA performs optimally. BMA wastes bit mapping period unnecessarily for the continuous monitoring nodes. The performance of TDMA and EA-TDMA degrades due to event-driven nodes, where non-source event-driven nodes waste time slot unnecessarily in idle listening. The operational diagram of TDMA, EA-TDMA, BMA, and E-BMA are shown in Fig. 1.

Although, E-BMA and ABMA reduces energy consumption but compromises with maximum transmission latency and are not suitable for time-constraint data traffic transmission. In the present work, we have proposed a hybrid protocol that handles such real traffic situations more efficiently than the existing MAC protocols for RMA. In the proposed protocol, which is an extension of BMA, different types of traffic generating nodes are handled separately. Each session is divided into two sub-sessions i.e. Sub-Session-1 and Sub-Session-2 as shown in Fig. 2. The former is reserved for continuous monitoring nodes and the latter is reserved for event-driven nodes. The detailed discussion of the proposed protocol has been done in section 4. Our contribution to the present work can be summarized as follows:

  • A hybrid protocol is proposed i.e. ASHMAC, to efficiently handle low, medium, and high traffic load conditions for RMA.

  • ASHMAC handles continuous-monitoring and event-monitoring nodes separately in an energy-efficient manner, which improves its performance w.r.t. other protocols.

  • The proposed protocol reduces energy-consumption and transmission latency by optimum utilization of the channel.

  • The proposed protocol can handle dynamic changes more efficiently i.e. low-to-high and high-to-low traffic load with low transmission latency.

  • The comparison of the proposed protocol with other MAC protocols has been done in terms of energy consumption and maximum transmission latency.

4 Application specific hybrid MAC protocol

Fig. 2
figure 2

Operational diagram of ASHMAC

The operational diagram of the proposed ASHMAC protocol is shown in Fig. 2. The operation can be divided into multiple rounds. TDMA and BMA features are used for continuous monitoring nodes and event-driven nodes respectively. For this purpose, CH categorizes the nodes into event-driven and continuous monitoring nodes. A new phase is introduced between the set-up and steady-state phase called the post-setup phase. Both cluster formation and CH selection take place in the set-up phase. The operation of the set-up phase is similar to the LEACH (low energy adaptive clustering hierarchy) protocol [17]. In the post-set-up phase, all the nodes keep their radios ‘ON’ and wait for their scheduled slot. These are bit-map-assisted slots. Each node gets its specific slot and transmits a 1-bit control message in its scheduled slot if it is a continuous monitoring node. Otherwise, the scheduled slot remains empty. After getting the information from all N devices, the CH has complete knowledge of continuous monitoring and event-driven nodes. CH broadcasts the information of sub-frame allotment in each session and allows the slots to the continuous monitoring nodes. The operation is divided into the multiple rounds and each round consists of k sessions. Each session is further divided into two sub-sessions. The first sub-session (Sub-Session-1) is allotted to the continuous monitoring nodes and second sub-session (Sub-Session-2) is allotted to the event-driven nodes. Continuous monitoring nodes get their scheduled slot allotment in the post-set-up phase. Similar to the TDMA, there is no repeated contention phase in a single round for continuous monitoring nodes. Each node wakes up in its scheduled time slot. The node transmits the data and stays in sleep mode for the remaining duration of the session. Therefore, Sub-Session-1 has only data slots for continuous monitoring nodes without the contention phase. Sub-Session-2 is allotted for event-driven nodes. In each session, the Sub-Session-2 is started with the contention phase. Similar to the BMA, if the node has data to transmit then all the event-driven nodes keep their radios ‘ON’ during contention phase and transmit 1-bit control message in its scheduled slot. Otherwise, its scheduled slot remains empty. An event-driven node, which has data to transmit, is called a source node. After the contention phase, CH has complete information about the nodes that have data to transmit. The CH broadcasts a transmission schedule for the source nodes. After receiving CH message, each node wakes up in its scheduled slot and transmits the data. For the rest of the session, they turn ‘OFF’ their radio and remain in sleep mode. After the data transmission of all event-driven source nodes, system proceeds in the idle period and all the devices turn ‘OFF’ their radio during this period. Similar to the BMA, a data transmission period can be varied in different sessions. However, combined sum of data transmission period and the idle period is fixed and constant. Therefore, the size of Sub-Session-2 is fixed which implies that the size of the complete session is also fixed. Finally, after completion of the session, a new session is started with Sub-Session-1 and the whole process is repeated. Analytical and Simulation models are developed and analyzed for TDMA [13], EA-TDMA [15], BMA [16], E-BMA [14] and our proposed protocol ASHMAC. Energy consumption and latency are considered as the performance parameter.

5 Analytical and simulation modeling

To prove the superiority of ASHMAC, we have compared its performance with the existing wireless MAC protocols for RMA [14]. The analytical model of TDMA, EA-TDMA, BMA, and E-BMA are regenerated for the present scenarios [13,14,15,16]. It is assumed that a cluster network has already been formed. Energy consumption and latency are analyzed for all other phases excluding the set-up phase. \(\aleph\) numbers of nodes are considered in WSN where one of them is CH and all remaining are sensor nodes (i.e. non-CH). If non-CH nodes are denoted by N, then \(\aleph =N+1\). Out of N non-CH nodes, m nodes are continuous monitoring nodes and rest \((N-m)\) nodes are event-driven nodes. Continuous monitoring nodes generate real-time traffic whereas event-driven nodes generate traffic only at the specific occurrence of an event. Therefore, it is uncertain that SNs have data to transmit in every session or frame. In a WSN scenario, it is assumed that there are k sessions and in a specific session, there are n source nodes, which generate event-driven traffic out of the total \((N-m)\) event-driven nodes. The remaining nodes are non-source nodes. Thus, at any event, if a node has data to transmit then it can be considered as Bernoulli trial [16]. If p is the probability of a node having data to transmit, then the number of event-driven source nodes is given by

$$\begin{aligned} n=(N-m)p \end{aligned}$$
(1)

The analytical model of TDMA, EA-TDMA, BMA, and E-BMA are already derived in the previously reported works [13,14,15,16]. However, for the comparison of the proposed protocol with previously reported works, the scenarios are considered for event-driven and continuous monitoring applications. Therefore, the analytical model of TDMA, EA-TDMA, BMA, and E-BMA are regenerated for our proposed analysis. Energy consumption and latency analysis for all protocols i.e. TDMA, EA-TDMA, BMA, E-BMA, and ASHMAC are discussed in the next subsections. All the parameters used in the analysis are given in Table 1.

Table 1 Symbols used in analysis of WSN scenario

5.1 TDMA protocol

5.1.1 Energy consumption of TDMA protocol

TDMA cycle starts with contention period during which all the nodes keep their radio ‘ON’ and CH assigns a time slot for data transmission to all the non-CH nodes. CH broadcasts a control message and all the nodes receive it. Therefore, energy consumption by CH node is \(P_tT_c\) and total energy consumption by non-CH nodes is \(NP_rT_c\). Energy consumption in contention period is given by

$$\begin{aligned} E_{TDMA-CONT-Total}=P_tT_c+NP_rT_c \end{aligned}$$
(2)

All the notations pertaining to TDMA are given in Table 2. After contention period, the data transmission period starts which is further divided into frames. Each frame has N number of slots for N non-CH nodes. Each node transmits data in its allotted time slot in each frame, and during the rest of the period, its radio remains ‘OFF’. Therefore, energy consumed by the CH node to receive the data packet is \(P_rT_d\) and energy consumption to transmit the data packet by each node is \(P_tT_d\). The continuous monitoring m nodes generate traffic in each frame, whereas n out of \((N-m)\) nodes generates event-driven traffic. So, the expected numbers of event-driven source nodes are \((N-m)p\) and event-driven non-source nodes are \((N-m)(1-p)\). Source nodes transmit the data packet and non-source nodes remain in idle state during their allotted slots. Therefore, the total expected energy consumption for transmission of packet by the non-CH nodes in each frame is given by, \((mP_tT_d + (N-m)pP_tT_d +(N-m)(1-p)P_iT_d)\) and total expected energy consumption for receiving the packets by CH node in each frame is given by, \((mP_rT_d + (N-m)pP_rT_d + (N-m)(1-p)P_iT_d)\). Total energy consumption in the transmission mode is given by

$$\begin{aligned} E_{TDMA-TRANS-Total}&= mP_tT_d+(N-m)pP_tT_d \\&\quad +(N-m)(1-p)P_iT_d \\&\quad +mP_rT_d+(N-m)pP_rT_d \\&\quad +(N-m)(1-p)P_iT_d \end{aligned}$$
(3)

In each round, there are k frames. Therefore, average energy consumption per round in TDMA protocol is given by

$$\begin{aligned} E_{TDMA}&= P_tT_c+NP_rT_c+k(mP_tT_d \\&\quad +(N-m)pP_tT_d+(N-m)(1-p)P_iT_d \\&\quad +mP_rT_d+(N-m)pP_rT_d+(N-m)(1-p)P_iT_d) \end{aligned}$$
(4)
Table 2 Symbols used in analytical modeling of TDMA

5.1.2 Transmission latency of TDMA protocol

Maximum transmission latency can be derived from the frame cycle as shown in Fig. 1, which is given by

$$\begin{aligned} L_{TDMA}=\frac{T_c+NkT_d}{k} \end{aligned}$$
(5)

5.2 EA-TDMA protocol

5.2.1 Energy consumption of EA-TDMA protocol

Similar to the TDMA protocol, energy consumption of EA-TDMA protocol in contention period is given by,

$$\begin{aligned} E_{EA-TDMA-CONT-Total}=P_tT_c+NP_rT_c \end{aligned}$$
(6)

All the notations pertaining to EA-TDMA are given in Table 3.

Table 3 Symbols used in analytical modeling of EA-TDMA

Data transmission period starts after the contention period. In the data transmission period, each node wakes up in their scheduled time slot and checks their buffer. If the nodes have no data to transmit, they turn ‘OFF’ their radio immediately. Energy consumption of the nodes which have no data transmit is given by \(P_eT_e\) (where \(T_e < T_d\)). Energy consumption of all other nodes is similar to the TDMA. Therefore, energy consumption of EA-TDMA is given by

$$\begin{aligned} E_{EA-TDMA-TRANS-Total}&= mP_tT_d \\&\quad +(N-m)pP_tT_d+(N-m)(1-p)P_eT_e \\&\quad +mP_rT_d+(N-m)pP_rT_d \\&\quad +(N-m)(1-p)P_iT_d \end{aligned}$$
(7)

In each round, there are k frames. Therefore, average energy consumption per round in EA-TDMA protocol is given by

$$\begin{aligned} E_{EA-TDMA}&= P_tT_c+NP_rT_c+k(mP_tT_d+(N-m)pP_tT_d \\&\quad +(N-m)(1-p)P_eT_e+mP_rT_d+(N-m)pP_rT_d \\&\quad +(N-m)(1-p)P_iT_d) \end{aligned}$$
(8)

5.2.2 Transmission latency of EA-TDMA protocol

Maximum transmission latency of EA-TDMA is same as TDMA as shown in Fig. 1, which is given by

$$\begin{aligned} L_{EA-TDMA}=\frac{T_c+NkT_d}{k} \end{aligned}$$
(9)

5.3 BMA protocol

5.3.1 Energy consumption of BMA protocol

In BMA, each cycle is divided into contention phase and data transmission phase. In contention phase, all the nodes turn ‘ON’ their radios. Contention phase of BMA is divided into N control slots. Each source node transmit control packet in their scheduled slot and all other nodes remain in idle mode. The m continuous monitoring nodes and \((N-m)p\) event monitoring nodes are source nodes. All the remaining nodes are non-source nodes. After the contention slots, CH broadcasts the information of the reserved data slots. Energy consumption of BMA during contention phase is given by

$$\begin{aligned} E_{BMA-CONT-CH}&= mP_rT_c+(N-m)pP_rT_c \\&\quad +(N-m)(1-p)P_iT_c+P_tT_{ch} \end{aligned}$$
(10)
$$\begin{aligned} E_{BMA-CONT-NCH}&=NP_rT_{ch}+m(P_tT_c+(N-1)P_iT_c) \\&\quad +(N-m)p(P_tT_c+(N-1)P_iT_c) \\&\quad +(N-m)(1-p)(P_iT_c+(N-1)P_iT_c) \end{aligned}$$
(11)
$$\begin{aligned} E_{BMA-CONT-Total}&=P_tT_{ch}+mP_rT_c+(N-m)pP_rT_c \\&\quad +(N-m)(1-p)P_iT_c+NP_rT_{ch} \\&\quad +m(P_tT_c+(N-1)P_iT_c) \\&\quad +(N-m)p(P_tT_c+(N-1)P_iT_c) \\&\quad +(N-m)(1-p)(P_iT_c+(N-1)P_iT_c) \end{aligned}$$
(12)

All the notations pertaining to BMA are given in Table 4.

Table 4 Symbols used in analytical modeling of BMA

After the contention period, data transmission period starts. In data transmission period, each source node sends the data packet in their scheduled slot. All the non-source nodes keep their radio ‘OFF’ during this session.

$$\begin{aligned} E_{BMA-TRANS-Total}&=mP_rT_d \\&\quad +(N-m)pP_rT_d+mP_tT_d+(N-m)pP_tT_d \end{aligned}$$
(13)

Each round comprised of k sessions, average energy consumption per round in BMA protocol is given by

$$\begin{aligned} E_{BMA}&=(P_tT_{ch}+NP_rT_{ch}+mP_rT_c+(N-m)pP_rT_c \\&\quad +(N-m)(1-p)P_iT_c+m(P_tT_c+(N-1)P_iT_c) \\&\quad +(N-m)p(P_tT_c+(N-1)P_iT_c) \\&\quad +(N-m)(1-p)(P_iT_c+(N-1)P_iT_c)+mP_rT_d \\&\quad +(N-m)pP_rT_d+mP_tT_d+(N-m)pP_tT_d)k \end{aligned}$$
(14)

5.3.2 Transmission latency of BMA protocol

Maximum transmission latency can be derived from the frame cycle as shown in Fig. 1, which is given by

$$\begin{aligned} L_{BMA}=NT_c+T_{ch}+NT_d \end{aligned}$$
(15)

5.4 E-BMA protocol

5.4.1 Energy consumption of E-BMA protocol

E-BMA cycle starts with the contention phase. Source nodes, which have not reserved data slot in their preceding data packet, they send a control message in their respective contention slot. The non-source nodes and piggybacked nodes keep their radios ‘OFF’ during the entire contention period. The probability of a data packet not being piggybacked is \(p(1-p)\). Continuous monitoring nodes (m nodes) generate traffic in each session. Therefore, they are piggybacked in their preceding data slots by keeping their radios ‘OFF’ in their respective contention slots. Moreover, CH remains in idle mode during these contention slots. After the contention slots, CH broadcasts the information of reserved data slots to the nodes who had demanded the reservation. Energy consumption in a contention phase of E-BMA is given by

$$\begin{aligned} E_{E-BMA-CONT-CH}&=mP_iT_c+(N-m)p(1-p)P_rT_c \\&\quad +(N-m)(1-p(1-p))P_iT_c+P_tT_{ch} \end{aligned}$$
(16)
$$\begin{aligned} E_{E-BMA-CONT-NCH}&=NP_rT_{ch}+(N-m)p(1-p)(P_tT_c \\&\quad +(N-1)P_iT_c) \end{aligned}$$
(17)
$$\begin{aligned} E_{E-BMA-CONT-Total}&=mP_iT_c+(N-m)p(1-p)P_rT_c \\&\quad +(N-m)(1-p(1-p))P_iT_c \\&\quad +NP_rT_{ch}+(N-m)p(1-p)(P_tT_c \\&\quad +(N-1)P_iT_c)+P_tT_{ch} \end{aligned}$$
(18)

All notations pertaining to E-BMA are given in Table 5.

Table 5 Symbols used in analytical modeling of E-BMA

After the contention period, data transmission period starts. Each source node sends the data packet in their allotted data slot. All the non-source nodes keep their radio ‘OFF’ in session duration. As reported in the [14] that piggybacking requires only 1-bit extra space in the data packet, which is negligible w.r.t. the packet size. The expected energy consumption in transmission is given by

$$\begin{aligned} E_{E-BMA-TRANS-Total}&=mP_rT_d+(N-m)pP_rT_d \\&\quad +mP_tT_d+(N-m)pP_tT_d \end{aligned}$$
(19)

Each round comprised of k sessions, average energy consumption per round in E-BMA protocol is given by

$$\begin{aligned} E_{E-BMA}&=(mP_iT_c+(N-m)p(1-p)P_rT_c \\&\quad +(N-m)(1-p(1-p))P_iT_c+NP_rT_{ch} \\&\quad +(N-m)p(1-p)(P_tT_c+(N-1)P_iT_c) \\&\quad +P_tT_{ch}+mP_rT_d+(N-m)pP_rT_d \\&\quad +mP_tT_d+(N-m)pP_tT_d)k \end{aligned}$$
(20)

5.4.2 Transmission latency of E-BMA protocol [14]

Maximum transmission latency can be derived from the frame cycle as shown in Fig. 1. Each data packet has to wait for one additional frame duration before being transmitted. Therefore, the average maximum transmission latency is given by

$$\begin{aligned} L_{E-BMA}=T_{ch}+2(T_c+T_d)N \end{aligned}$$
(21)

5.5 ASHMAC protocol

5.5.1 Energy consumption of ASHMAC protocol

A new phase is introduced in ASHMAC between steady state and set-up phase called post-set-up phase. In all the previous protocols, we had excluded the energy calculations of set-up phase. The same has been done here as well. After the set-up phase, post-set-up phase starts with mini control. Similar to the set-up phase, the post-set-up phase is also repeated after each round. All the devices turn ‘ON’ their radios during the post-set-up phase. Each device transmits control message in their scheduled time slot and remains in idle mode for \((N-1)\) slots. Control message consists of a flag bit. Continuous monitoring nodes set it to ‘1’ and event-driven nodes set it to ‘0’. After completion of N control slots, CH has information of all the continuous monitoring and event-driven nodes. Therefore, CH broadcasts a message to all the devices for the separate sub-session division of the continuous monitoring and event-driven nodes. CH also provides the slot-allotment for Sub-Session-1 to continuous monitoring m nodes (see Fig. 2.). Energy consumption in post-set-up phase is given by

$$\begin{aligned} E_{ASHMAC-Post-Setup-CH}&=NP_rT_c+P_tT_{cho}\end{aligned}$$
(22)
$$\begin{aligned} E_{ASHMAC-Post-Setup-NCH}&=N(P_tT_c \\&\quad +(N-1)P_iT_c+P_rT_{cho})\end{aligned}$$
(23)
$$\begin{aligned} E_{ASHMAC-Post-Setup-Total}&=NP_rT_c+P_tT_{cho}+N(P_tT_c \\&\quad +(N-1)P_iT_c+P_rT_{cho}) \end{aligned}$$
(24)

All the notations pertaining to ASHMAC are given in Table 6.

Table 6 Symbols used in analytical modeling of ASHMAC

After the post-set-up phase, steady-state phase starts which is further sub-divided into several sessions. Here, each session has two sub-sessions. In Sub-Session-1, each continuous monitoring node transmits its data to the CH node in its scheduled time slot. All the event-driven nodes keep their radio ‘OFF’ during the Sub-Session-1. Energy consumption in Sub-Session-1 is given by

$$\begin{aligned} E_{ASHMAC-SS-1-CH}=mP_rT_d \end{aligned}$$
(25)
$$\begin{aligned} E_{ASHMAC-SS-1-NCH}=mP_tT_d \end{aligned}$$
(26)
$$\begin{aligned} E_{ASHMAC-SS-1-Total}=mP_tT_d+mP_rT_d \end{aligned}$$
(27)

Sub-Session-2 starts with contention phase similar to the BMA, which is repeated in each Sub-Session-2. All the continuous monitoring nodes keep their radios ‘OFF’ during Sub-Session-2. There are \((N-m)\) event-driven nodes. Therefore, contention phase consists of \((N-m)\) control slots. For the contention phase of Sub-Session-2, all event-driven nodes turn ‘ON’ their radios. Each event-driven node transmits a control packet in their scheduled slot if they have data to transmit else they remain in idle mode. For the rest \((N-m-1)\) slots, source nodes remain in idle mode. Energy consumption in contention phase of Sub-Session-2 is given by

$$\begin{aligned} E_{ASHMAC-SS-2-CONT-CH}&=(N-m)pP_rT_c+P_tT_{ch} \\&\quad +(N-m)(1-p)P_iT_c \end{aligned}$$
(28)
$$\begin{aligned} E_{ASHMAC-SS-2-CONT-NCH}&=(N-m)p(P_tT_c+(N-m-1)P_iT_c) \\&\quad +(N-m)(1-p)((N-m)P_iT_c) \\&\quad +(N-m)P_rT_{ch} \end{aligned}$$
(29)
$$\begin{aligned} E_{ASHMAC-SS-2-CONT-Total}&=(N-m)pP_rT_c+P_tT_{ch} \\&\quad +(N-m)p(P_tT_c+(N-m-1)P_iT_c) \\&\quad +(N-m)(1-p)((N-m)P_iT_c) \\&\quad +(N-m)P_rT_{ch}+(N-m)(1-p)P_iT_c \end{aligned}$$
(30)

The data transmission period starts after the contention period, and each source node sends the data packet in its allotted data slot. All the non-source nodes keep their radios ‘OFF’ during a Sub-Session-2 similar to the BMA. Energy consumption in transmission phase of Sub-Session-2 is given by

$$\begin{aligned} E_{ASHMAC-SS-2-TRANS-CH}&=(N-m)pP_rT_d \end{aligned}$$
(31)
$$\begin{aligned} E_{ASHMAC-SS-2-TRANS-NCH}&=(N-m)pP_tT_d \end{aligned}$$
(32)
$$\begin{aligned} E_{ASHMAC-SS-2-TRANS-Total}&=(N-m)pP_tT_d+(N-m)pP_rT_d \end{aligned}$$
(33)

Each round comprised of k sessions, average energy consumption per round in ASHMAC protocol is given by

$$\begin{aligned} E_{ASHMAC}&=NP_rT_c+P_tT_{cho}+N(P_tT_c+(N-1)P_iT_c \\&\quad +P_rT_{cho})+k((N-m)pP_rT_c+P_tT_{ch} \\&\quad +(N-m)p(P_tT_c+(N-m-1)P_iT_c) \\&\quad +(N-m)(1-p)((N-m)P_iT_c) \\&\quad +(N-m)P_rT_{ch}+(N-m)(1-p)P_iT_c \\&\quad +(N-m)pP_tT_d+(N-m)pP_rT_d) \end{aligned}$$
(34)

5.5.2 Transmission latency of ASHMAC protocol

Maximum transmission latency can be derived from the frame cycle as shown in Fig. 2, which is given by

$$\begin{aligned} L_{ASHMAC}=T_{ch}+(N-m)T_c+NT_d+\frac{NT_c+T_{cho}}{k} \end{aligned}$$
(35)

6 Results and performance analysis

6.1 Analytical and simulation analysis

The performance of proposed protocol ASHMAC is compared with the other MAC protocols in terms of energy consumption and transmission latency. The ZigBee-enabled 2.4 GHz CC2420 RF transceiver [24, 29] is used for the analytical and simulation analysis. The comparison chart for different radios is given in Table 7. For 250 kbps data rate the CC2420 radio consumes less power for transmitting and receiving the packet. In addition, CC2420 radio is used as a standard radio in various simulation platforms e.g. Castalia (OMNet++), NetSim, NS2. The only drawback of CC2420 is that the idle power consumption of CC2420 is more than MC13202. For comparison of our proposed protocol with other protocols on same simulation platform, we have used the same energy node model as reported in [14]. The power consumption in transmitting, receiving and idle mode is 50 mW, 54 mW and 54 mW, respectively as given in Table 7 [29]. These power ratings are comparable to CC2420 RF transceiver specification. The data rate is 25 kbps and control packet size is 5 bytes as reported in [14]. For simplicity \(T_e=T_d/5\), \(P_e=P_i\). Broadcast-control-slot in case of ASHMAC is larger (\(T_{cho}=2T_{ch}\)). Comparative analysis has done on MATLAB platform. For comparative analysis, five cases are considered for energy efficiency and two cases are considered for maximum transmission latency.

Table 7 Characteristics of typical radios used by the sensor nodes [29]

6.1.1 Energy efficiency

Case 1: In this case, analytical and simulation analysis has been done for all five protocols as mentioned above. In this scenario, the total number of nodes is \(\aleph =15\) and non-CH nodes are \(N=14\) (where four nodes are continuous monitoring nodes i.e. \(m=4\) and rest are event monitoring nodes). Each round consists of 20 frames i.e. \(k=20\), and data packet size is 200 bytes. In this case, the transmission probability of the event monitoring nodes is varying from 0.0 to 1.0. Energy consumption variation versus probability is plotted in Fig. 3. At \(p=0\), no event monitoring node generates traffic i.e. \(n=0\). In this case, the transmission traffic is only due to the continuous monitoring nodes \((m=4)\). The graph shown in Fig. 3 reveals that for \(p<0.8\), our proposed protocol consumes less energy than EA-TDMA, TDMA, and BMA MAC protocols.

Fig. 3
figure 3

Analytical and Simulation results of data generation probability versus energy consumption for N = 14, k = 20

Case 2: In this case, it is assumed that \(p=0.2\), \(k=20\) frames/round and data packet size is 200 bytes. The total number of non-CH nodes are varied from \(N=7\) to 35 (where m varied from 2 to 10 and rest event monitoring nodes varied from 5 to 25). Energy consumption versus total number of nodes is plotted in Fig. 4, which reveals that ASHMAC performs better than BMA, TDMA and EA-TDMA for different cluster sizes.

Fig. 4
figure 4

Analytical and Simulation results of number of nodes versus energy consumption for p = 0.2, k = 20

Case 3: In this situation, it is assumed that the total number of non-CH nodes are \(N=14\), the probability of event generated traffic \(p=0.2\) and data packet size is 200 bytes. Number of frames per round (k) is varied from 10 to 100. Both analytical and simulation results show that ASHMAC consumes less energy than BMA, TDMA and EA-TDMA as shown in Fig. 5.

Fig. 5
figure 5

Analytical and Simulation results of number of rounds versus energy consumption for N = 14, p = 0.2

Case 4: In this experiment, it is presumed that the total number of non-CH nodes are \(N=14\), the probability of event generated traffic \(p=0.2\) and number of frames per round (k) is 20. Data packet size is varied from 50 to 250 bytes. Both analytical and simulation results show that ASHMAC consumes less energy than BMA, TDMA and EA-TDMA as shown in Fig. 6.

Fig. 6
figure 6

Analytical and Simulation results of data packet size versus energy consumption for N = 14, k = 20, p = 0.2

Case 5: In this case, continuous monitoring nodes vary whereas event-monitoring nodes remain fixed. This experiment is performed to analyze the performance of heavy traffic load due to continuous monitoring nodes. Therefore, the total number of non-CH nodes is varied from \(N=7\) to 15 (where m varied from 2 to 10). For this experiment, \(p=0.2\), data packet size is 200 bytes, \(k=20\) frames/round. The performance is analyzed for different cluster sizes and different data packet sizes. Analytical and simulation results show that ASHMAC consumes less energy than TDMA, EA-TDMA, BMA and equivalent to E-BMA as shown in Fig. 7.

Fig. 7
figure 7

Analytical and simulation results of no. of continuous monitoring nodes versus energy consumption

6.1.2 Transmission latency

Maximum transmission latency is modeled, analyzed and simulated for TDMA, EA-TDMA, BMA, E-BMA and ASHMAC for different cluster sizes and different data packet sizes.

Case 1: In this case, number of nodes are varied from \(N=7{-}35\) (\(m=2{-}10\)). It is assumed that data packet size is 200 bytes and \(k=20\). Both analytical and simulation results show that the maximum transmission latency of E-BMA is approximately double than ASHMAC, TDMA, EA-TDMA and BMA as shown in Figs. 8 and 9 respectively.

Fig. 8
figure 8

Analytical results of transmission latency versus total number of nodes

Fig. 9
figure 9

Simulation results of transmission latency versus total number of nodes

Case 2: In this case, the data packet size is varied from 50 to 250 bytes. It is assumed that \(N=14\) (\(m=4\)) and \(k=20\). Both analytical and simulation results show that maximum transmission latency of E-BMA is approximately double w.r.t. ASHMAC, TDMA, EA-TDMA and BMA as shown in Figs. 10 and 11 respectively. In the case of E-BMA, the maximum transmission latency is double due to one extra frame delay in transmission.

Fig. 10
figure 10

Analytical results of transmission latency versus data packet size

Fig. 11
figure 11

Simulation results of transmission latency versus data packet size

Table 8 Records of passing of the train from the track

6.2 Experimental analysis

In the previously reported works, only analytical and simulation analysis has been done by the researchers for MAC layer modeling. Real-time experimental analysis is quite difficult. Because real-time scenario depends upon various other modules and protocols. The recorded data in the real-time scenario depends upon various parameters e.g. terrain profile, noise in detection of sensor data, environmental noise, etc. The real-time scenario depends upon some other analyses which are based on different other fields i.e. detection and estimation, duty cycle algorithms, clustering algorithms, intra-cluster, and inter-cluster communication, etc. These analyses are out of the scope from the present discussion on the MAC layer protocol. Therefore, we have developed a prototype for a railway condition monitoring system for analysis of our proposed MAC layer protocol. Data records of Varanasi station (State:Uttar Pradesh, Country: India) have been taken from 4th June 1:00 P.M. to 5th June 1:00 P.M. as given in Table 8. Four Arduino Uno boards are used as sensor nodes (i.e. SN-1, SN-2, SN-3, and SN-4) and one Raspberry Pi board is used as a CH node. NRF24L01 module is used as a transreceiver device. All the data sensed by the sensor nodes are transmitted to the CH node. SN-1 consists of an accelerometer sensor (ADXL-345) and shock-sensor (KY-002). SN-2 consists of temperature sensor DS18B20 and SN-3 consists of temperature and humidity sensor (DHT-11). SN-4 consists of a shock sensor (KY-002) and a tilt sensor (KY-020). When the train passes from the track, it activates the shock sensor, and hence SN-1 and SN-4 activates their accelerometer sensor and tilt sensor respectively. Accelerometer sensor (SN-1) collects the data for every pass of the train for 100 seconds with 100 Hz frequency. SN-1 transmits data in a bulk of 8 units with a packet size of 100 bytes. Each unit consists of x, y, and z positions. Similarly, SN-2 senses the temperature at every 30 seconds, and SN-3 senses the humidity at the same rate. SN-4 senses the tilt on the track at every passing of the train. Accelerometer (ADXL-345) data recorded by SN-1 is given in Fig. 12 for 10:05 P.M. to 10:40 P.M. Six trains pass from the track and their acceleration is recorded. Similarly, SN-2 and SN-3 record temperature and humidity data, respectively. The prototype model of the experimental set-up is shown in Fig. 13. Arduino boards are used for the sensor nodes and the raspberry-pi board is used for CH node. Sensor nodes transmit the data to the CH node using the NRF24L01 trans-receiver. The total number of transmitted and received packets (data and control packets) by the sensor nodes and cluster head node are given in Fig. 14 for TDMA, EA-TDMA, BMA, E-BMA, and ASHMAC protocols. BMA and E-BMA transmit more number of control packets w.r.t. other protocols. In the analytical and simulation analysis, the energy consumption model is developed for the single cycle of each protocol. But, in the experimental model, WSN is analyzed for 24 hours. Therefore, for efficient analysis, the duty cycle approach is necessary for such real-time data traffic environment. A low duty cycle consumes less energy, but causes buffer-overflow and hence, throughput reduces. Therefore, in the present analysis, the optimum duty cycle is considered for the analysis purpose. As shown in Fig. 15 that below 17% of duty cycle performance degrades, buffer-overflow increases, and hence throughput decreases. Therefore, in the present work, a 17% duty cycle is taken as optimum value.

Fig. 12
figure 12

Accelerometer recorded data from ADXL-345 for X-axis, Y-axis and Z-axis

Fig. 13
figure 13

Block diagram of experimental set-up

Fig. 14
figure 14

Number of control and data packets transmitted by various protocols

Fig. 15
figure 15

Buffer-overflow versus duty cycle

Figure 16 shows that the energy consumption of ASHMAC is quite less than TDMA, EA-TDMA, and BMA MAC protocols and approximately equal to the E-BMA MAC protocol. Figure 17 shows that the maximum transmission latency of ASHMAC is quite lesser than E-BMA. Therefore, the optimal performance of our proposed protocol is much better than existing MAC protocols.

Fig. 16
figure 16

Experimental results of energy consumption

Fig. 17
figure 17

Experimental results of maximum transmission latency

From the above analysis, overall summary of the results is as follows:

  • In all the cases, ASHMAC is more energy-efficient than TDMA, EA-TDMA, and BMA for low, medium, and high traffic but slightly less energy efficient than E-BMA.

  • In terms of transmission latency, ASHMAC is far better than E-BMA.

  • Overall optimized performance of ASHMAC is much better than BMA, TDMA, EA-TDMA, and E-BMA.

  • For the validation of the simulation and analytical results, an experimental prototype model has also been developed. The experimental results prove the validity of our proposed model.

7 Conclusion

An improved application-specific hybrid medium access control (ASHMAC) protocol is proposed for railway monitoring applications. The ASHMAC saves unnecessary energy loss, which occurs in the BMA MAC protocol for continuous monitoring nodes due to the contention period. It also saves unnecessary wastage of energy, which occurs in TDMA MAC protocol for event-driven nodes due to reservation of data slots to the non-source nodes. Comparative performance analysis is done with other existing MAC protocols. ASHMAC is a hybrid MAC protocol that includes the features of both TDMA and BMA. Simulation and analytical models have been developed and proposed for ASHMAC protocol and its performance is compared with TDMA, EA-TDMA, BMA, and E-BMA protocols. The results show the effectiveness of the proposed protocol for both event-driven and continuous monitoring applications. Analytical and simulation results show that ASHMAC performs better than TDMA, EA-TDMA, and BMA for low and medium traffic in terms of energy efficiency. The drawback of ASHMAC is that it is slightly less energy efficient than E-BMA. However, the transmission latency of E-BMA is around two times higher than ASHMAC. Therefore, the overall optimal performance of ASHMAC is better than the other mentioned protocols for low, medium, and high data traffic applications. In the future, we plan to extend our work by hybridization of EA-TDMA/E-BMA instead of TDMA/BMA. E-BMA consumes less energy than BMA even at high data traffic load conditions. However, E-BMA follows piggybacking for reservation of consecutive data slots which is significantly challenging to implement in hybrid MAC protocol.