## 4 Implementation Details
### Generating Heterogeneous Arrivals  
The arrival patterns for CBR and Poisson arrivals (with exponentially distributed inter-arrivals) have been generated using the Algorithm 1. The values of instants at which arrival occurs are stored in arrays and then subsequently used for calculations of delay and PDR. Following MAC schemes at high level have been studied and implemented in this paper:  
1. First Come First Serve (FCFS)  
The delay analysis has been performed when no priority was assigned to any of the traffic types. The packets which are generated first, transmit first regardless of their type. This is the simplest case and was implemented to validate the performance improvement brought by FROG-MAG. Implementation of this scheme along with the delay calculation for each traffic type has been described in Algorithm 2. 1. Prioritization without Fragmentation  
In this scheme, the packets have been prioritized but fragmentation of low priority packets is not implemented. The high priority packets are transmitted first, even when there are low priority packets present in queue. However, the high priority traffic cannot interrupt the ongoing transmission of low priority packets. This scenario illustrates the concept of assigning preemptive priority as defined by the previous studies, and for the sake of implementation, the fragment size for low priority is kept as 1 (so that full packets is transmitted). Implementation of this scheme is similar to the one depicted in Algorithm 3 for the case when fragment size becomes equal to packet size (which would imply that complete packet is sent as a single fragment/no fragmentation applied). 1. FROG-MAC (Prioritization using Fragmentation)  
Finally, the preliminary version of the fragmentation-based protocol FROG-MAC has been implemented, where the low priority packets have been fragmented; the high priority traffic can thus interrupt and access the medium to begin its transmission. It has been assumed that the instants at which regular and emergency packets are generated by each node are known by every node in the network. The implementation of fragmentation scheme for low priority data has been described in Algorithm 3. 1. Initialize variables: * Total number of \(\mathbf{Nodes}=100\); \(\mathbf{CBR\_msg\_interval}=60\) s; \(\mathbf{EXP\_msg\_interval}=120\) s; \(\mathbf{Sim\_Dur}=6000\) s.
2. Calculate number of CBR events in one node for entire Simulation duration * \(\mathbf{CBR\_events}=\mathbf{Sim\_Dur}/\mathbf{CBR\_msg\_interval}\)
3. Calculate number of EXP events in one node for entire Simulation duration * \(\mathbf{EXP\_events}=\mathbf{Sim\_Dur}/\mathbf{EXP\_msg\_interval}\)
4. Initialize variable \(\mathbf{node}=1\) and a 2D-array \(\mathbf{CBR\_arrials}\) * Initialize \(i=1\). * If \(i\) is greater than \(\mathbf{CBR\_events}\) goto step 4-c. * \(\mathbf{CBR\_arrials}\) * \(\mathbf{CBR\_arrials}\) * Increment \(i\). * Goto step 4-b. * Increment \(\mathbf{node}\). * If \(\mathbf{node}\) is greater than total number of Nodes goto step 5, else goto step 4-a. 5. Initialize \(\mathbf{node}=1\) and a 2D-array \(\mathbf{EXP\_arrials}\) * Generate random exponential series \(\mathbf{exp\_rand}\): (mean = \(\mathbf{EXP\_msg\_interval}\)) of \(\mathbf{EXP\_events}\). * Initialize \(i=1\). * If \(i\) is greater than \(\mathbf{EXP\_events}\) goto step 5-d. * \(\mathbf{EXP\_arrials}\) (node, i) = \(\mathbf{EXP\_arrials}\) (node, i-1) + \(\mathbf{exp\_rand}\) (i). * Increment \(i\). * Goto step 5-c. * Increment \(\mathbf{node}\). * If \(\mathbf{node}\) is greater than total number of Nodes goto step 6, else goto step 5-a. ```
1. Sort the 2D-array CBR arrivals in ascending order and convert it into a 1-D array CBR arrivals
2. SetTotal_CBR_events = elements in CBR arrivals. 3. Sort the 2D-array EXP arrivals in ascending order and convert it into a 1-D array EXP arrivals
4. SetTotal_EXP_events = elements in EXP arrivals. 5. SetDelay = propagation time + packetization time
6. Initialize variables Pointer,temp = 0; \(i=0;j=0\).