# 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
If all of the transponder slots were available, the delay that needed to sent an IU will be \(\tau_{IU}=\frac{N_{B}}{\lambda_{G}}\); however, in the cognitive environment, some slots are useless because they are used by PUs, and free slots are partially used by the SU to run the detection algorithm for checking the slot status, as described in Section 3. When place sending has tokens, transition \(\mathtt{End}\) is enabled; during the enabling period, the time advances, and the transition will fire after \(\tau_{IU}\) time instants. Sometimes, the transition is disabled because either the checking algorithm found the slot busy (token in place wait), or it found the slot erroneously free and the SU transmission collided with the PU transmission (token in place \(\mathtt{b}_{\mathsf{transm}}\); we assumed that the SU application is able to detect collisions). During the disabling time intervals, the passed amount of time has to be remembered, and the time progress has to start from this latter value. To this aim, we set the _preemptive resume_ memory policy (_prs_) of the NMSPNs [52] to the transition \(\mathtt{End}\) that is coherent with the SU behavior, otherwise the firing delay would not reflect the real SU activity. Furthermore, we used three inhibitor arcs to suspend the enabling of \(\mathtt{End}\) in the relevant states mentioned above. The remaining part of the NMSPN selects the state of the current slot. When the system starts, seven tokens are in place starting, and one of the two transitions primary and secondary will be enabled according to the values of their associated enabling functions (Table 2). If place sending is empty, primary will fire, moving one token to the place busy. This enables the timed transition \(\mathtt{T}_{\mathtt{slot}}\), a deterministic transition whose delay is equal to the slot time (\(\tau_{I}\)). During this time interval, both the transitions primary and secondary are disabled. When the time slot expires, \(\mathtt{T}_{\mathtt{slot}}\) fires and the token moves to the place last. Conversely (if place sending is not empty), when the transition secondary fires, one token is placed into the place attempt and another into the place activity. The latter is used to inhibit the firing of transitions primary and secondary until the current time slot expires. A token in attempt means that the slot status checking algorithm has started (the transition \(\mathtt{test}\) is enabled). The detection algorithm will use a fraction \(f_{a}\) with \(0<f_{a}<1\) of the time slot to run; thus, we set \(\mathtt{test}\) as a deterministic transition with parameter \(f_{a}\cdot\tau_{I}\). The firing of \(\mathtt{test}\) moves the token to place \(\mathtt{chk}\), enabling one of the two pairs of immediate transitions \(\mathtt{chk}\mathtt{T}_{\mathsf{CS}}\) and \(\mathtt{chk}\mathtt{F}_{\mathsf{CS}}\) (the green couple in Figure 5) and \(\mathtt{chk}\mathtt{T}_{\mathsf{CS}+\mathsf{PS}}\) and \(\mathtt{chk}\mathtt{F}_{\mathsf{CS}+\mathsf{PS}}\) (the light blue couple in Figure 5) according to the values of their associated enabling functions (Table 2), i.e., according to the current category of i-th time slot. Transitions \(\mathtt{chk}\mathtt{T}_{\mathsf{CS}}\) and \(\mathtt{chk}\mathtt{F}_{\mathsf{CS}}\) fire with probability \(P_{s-CS}\) and \(1-P_{s-CS}\), respectively. Similarly, if we are managing a circuit and packet switching time slot, the transitions \(\mathtt{chk}\mathtt{T}_{\mathsf{CS}+\mathsf{PS}}\) and \(\mathtt{chk}\mathtt{F}_{\mathsf{CS}+\mathsf{PS}}\) are enabled; the transition \(\mathtt{chk}\mathtt{T}_{\mathsf{CS}+\mathsf{PS}}\) will fire with probability \(P_{s-CS+PS}\), whereas \(\mathtt{chk}\mathtt{F}_{\mathsf{CS}+\mathsf{PS}}\) with probability \(1-P_{s-CS+PS}\). The firing of one of the two transitions \(\mathtt{chk}\mathtt{F}_{\mathsf{CS}}\) or \(\mathtt{chk}\mathtt{F}_{\mathsf{CS}+\mathsf{PS}}\) means that the slot is busy with the PU; the token will be moved to the place wait, and the timed transition \(\mathtt{delay}\) will be enabled.