# A Petri Net Model for Cognitive Radio Internet of Things Networks Exploiting GSM Bands +
## 4 QoS Evaluation of Secondary User Based on NMSPNs
### The Secondary User Model
We set \(\mathtt{delay}\)as a deterministic transition with parameter \((1-fa)\cdot\tau_{l}\). That is the remaining duration of the time slot. As soon as delay fires, a token will be placed in last and the tokens from activity and wait will be removed. This means that the current time-slot is expired and a new one can start. At the opposite, when one of the two transitions chkTCS and chkTCS+PS fire, it means that the time slot is not busy with a PU, and the token moves to the place free, meaning the SU transmission can start. A token in free enables both the immediate transitions TP and FP; they will fire with probabilities of \(P_{TP}\) and \(P_{FP}=1-P_{TP}\), respectively. \(P_{TP}\) (\(P_{FP}\)) is the probability that the checking algorithm evaluates to a true positive (false positive) result. When TP fires, the token is put in the place transm, i.e., the state where the SU correctly detected a free slot; otherwise, it will be put in btransm, i.e., an error state, because it has been detected as a free slot when busy. The NMSPN will remain in the arrived state until the corresponding enabled transition does not fire; both sent and collision are deterministic transitions whose firing time is set to the remaining slot time, i.e., \((1-f_{a})\tau_{l}\). When sent or collision fires, a token will be placed in last and the tokens from transm/btransm and activity will be removed. This means that the current time slot is expired and a new one can start. When seven tokens are collected in the place last (i.e., all of the seven available traffic time slots in a frame have been managed), the place signaling is enabled. This is a deterministic transition whose firing time is set to the slot time duration \(\tau_{l}\). It was only inserted in order to take into account the one time slot inside the frame used for signaling. As soon as signalling fires, the seven tokens will be moved to the place starting and the managing of a new frame starts. SU Performance Measures  
Despite the fact that more measures could be derived from the proposed SU model, we focus on two of them in this work: queue length distribution (and loss probability) and response time distribution. Because the number of the IU stored in the buffer (also considering the IU under transmission) is given by the number of tokens in the place _sending_, the system queue distribution length is computed by evaluating  
\[P_{q}(i)=P\{i\;\text{IUs are in the system}\}=P\{\#\texttt{sending}==i\} \tag{3}\]  
at a stable state. Loss probability is equivalent to the probability that the system cannot accept any new incoming IU because its buffer is full; thus, it is given by \(P_{l}=P_{q}(N_{B})\). Let us consider the time from the arrival of an IU into the system to the instant that it is completely delivered, denoting it as \(\tau_{r}\). Of course, \(\tau_{r}\) is a r.v., and its cumulative distribution function is defined as \(F_{r}(t)=P\{\tau_{r}<=t\}\). Computation of \(F_{r}(t)\) requires some modification of the model in order to implement the so-called _tagged customer_ method [61], where a _tagged IU_ is chosen and it is observed from its arrival to its delivery. Figure 6 shows the NMSPN used to accomplish this purpose. The performance model is modified by splitting the place sending into two places so as to allow us to distinguish between the tokens already present in the queue (b_sending) and those that arrived after the insertion of the tagged IU (a_sending). The tagged IU is modeled by the place tc_sending; one token in the place means that the tagged IU is waiting to be delivered. During the time it is waiting, new arrived IUs (tokens in a_sending) will not be served thanks to the inhibitor arc from tc_sending to tc_comp; this will only be able to fire when the tagged IU leaves the system. Transition tc_end is identically set to the transition End, modeling the delay of transmitting the tagged IU and also considering the available portion of slots. This model describes the view of the tagged IU at its arrival in the system.