# An Efficient Relayed Broadcasting Based on the Duplication Estimation Model for IoT Applications
## 3 Duplication Suppression and Re-Queuing
### The Implementation of the Proposed Mechanism  
We can implement the overall proposed mechanism as is illustrated in the state diagram in Figure 8. A frame can have the five logical states: null, enqueued, transmitted, deleted, and wait for re-queuing; several operations can be performed depending on the frame state as follows:  
1. The null state: This is either the initial or final state of the frame: the former is the state when node \(i\) has not yet received frame \(F_{i,j}\) whereas the latter is when it has finished all of the operations for this frame. If an unidentified frame \(F^{*}\) arrives at the node, function receive(\(F^{*}\)) is invoked to identify frame \(F^{*}_{i,j}\) by checking its sequence number. Function isCheckIN(\(F^{*}_{i,j}\)) returns true if the frame has already been enqueued more than once. If frame \(F^{*}_{i,j}\) is a new frame (i.e., isCheckIN(\(F^{*}_{i,j}\)) is false), then the frame is enqueued and its duplication counter is initialized to 1. Moreover, function check_IN(\(F_{i,j}\)) indicates that the frame whose sequence number is \(j\) has entered the transmission buffer. After performing these operations, the state of the frame is switched to the enqueued state. Two initialized variables \(x_{i,j}\) and \(\rho_{i,j}\) denote the random variable and the duplication ratio, respectively, and they are used to determine whether the frame \(F_{i,j}\) in the transmission buffer is deleted or not after entering to the enqueued state.
2. The enqueued state: In this state, the frame waits in the buffer for transmission and its state is changed to either the transmitted or deleted state. If the backoff counter becomes 0 and frame \(F_{i,j}\) remains in the buffer, it is transmitted by the Send(\(F_{i,j}\)) function. If the node receives another frame \(F^{*}_{i,j}\) that is a duplicate (i.e., isDUP(\(F^{*}_{i,j}\)) is true), it discards \(F^{*}_{i,j}\) and updates the corresponding \(c_{i,j}\), \(x_{i,j}\), and \(\rho_{i,j}\). Moreover, the node deletes frame \(F_{i,j}\) waiting for transmission in the buffer depending on \(x_{i,j}\) and \(\rho_{i,j}\) (i.e., duplication ratio \(DR_{i}(c_{i,j})\)) using the Delete(\(F_{i,j}\)) function. Please note that the re-queued frame may also be deleted or transmitted again depending on the duplication ratio. Meanwhile, when function Send(\(F_{i,j}\)) or Delete(\(F_{i,j}\)) is called, the state of frame with the sequence number \(j\) is changed from \(F_{i,j}\) to \(F^{\prime}_{i,j}\), and \(x_{i,j}\) and \(\rho_{i,j}\) are initialized to 0.
3. The transmitted and deleted states: If the state transition from the transmitted or deleted to the wait for re-queuing state has never happened (i.e., isCheckOUT(\(F^{\prime}_{i,j}\)) is false), the re-queuing process is initiated by function Start_Timer(\(F^{\prime}_{i,j}\)) and function check_OUT(\(F^{\prime}_{i,j}\)) indicates that the frame whose sequence number is \(j\) has been transmitted or deleted at least once. If isCheckOUT(\(F^{\prime}_{i,j}\)) is true, no further operation is performed on the frame and the state is changed to null.
4. The wait for re-queuing state: In this state, the re-queuing procedure controls the frame \(F^{\prime}_{i,j}\) (a copy of \(F_{i,j}\)). After the frame observation period has expired (i.e., timeout(\(F^{\prime}_{i,j}\)) is true), the state is switched to either enqueued or null depending on the value of \(\Delta_{i,j}\). If \(\Delta_{i,j}<0\), the frame \(F^{\prime}_{i,j}\) is re-queued to obtain a secondary transmission opportunity; otherwise, the node completes all of the operations for this frame. On receiving the ADF, the node discards it and updates \(c_{i,j}\).