# Highest Cost First-Based QoS Mapping Scheme for Fiber Wireless Architecture
## 4 Proposed QoS Mapping Schemes for FiWi Testbed
When the maximum cost value is met, the algorithm always searches the specific P value for TCONT queues and saves data into the selected queue according to the transfer method. ```
Input: T := T \(\epsilon\) (T\({}_{\text{XPPON}}\)), cost\({}_{\text{Max}}\) := -1, dataPkt:= arrival data packet Output: Select a transfer (t) method with the highest cost (J) value. 1 t_selected: = Null // the selected transfer method
2 for each t \(\epsilon\) T do
3 Get priority (P) value of dataPkt
4 If (P) value is met then
5 If J(t, P) > cost\({}_{\text{Max}}\) then
6 cost\({}_{\text{Max}}\) = J(t, P)
7 t_selected = t
8 End
9 End
10 End
11 return t_selected
```  
**Algorithm 1** The pseudo-code of highest cost first (HCF). In the algorithm, line 1 defines one variable for keeping the current selected transfer method. The for loop between lines 2 to 10 checks all transfer methods in the set T. Line 3 obtains the P-value of the data packet. Line 4 is executed if P is met. The highest cost value (t) is used to transfer the user traffic J(t, P). Line 5 is used to check condition If J(t, P) value is higher than the current maximum value (costMax). The J(t, P) value is assigned to the current costMax value at line 6. (t) is the currently selected transfer method at line 7 when all the approaches of T are checked at once. The transfer method will be selected with the highest cost value and packets are then queued in one specific FIFO queue of ONU, and later, the same packet is transmitted via US traffic to the OLT under the DBA controller. The user's data packet is not selected for a specific QoS queue when the selected transfer method (t_selected) is null. The time complexity of the proposed mapping algorithm is O(n). During the initialization phase of our testbed, OLT assigns one specific allocation id to a specific TCONT of an ONU. Figure 6 shows the working of our simulation with the help of a flowchart. The first wireless node generates data packets and runs wireless distributed channel schemes as described in the previous section. When a packet arrives at ONU via the wireless access point, then ONU converts each packet according to the QoS mapping algorithm (i.e., highest cost first algorithm), as discussed above in the previous paragraph. The ONU scheduler generates upstream traffic after every 125 \(\upmu\)s frame duration, which is also known as the DBA cycle time. ONU fills the buffer occupancy report (BOR) of each TCONT, identified by a unique allocation id, according to the amount of allocated bandwidth to specific TCONT in time, as shown in Equation (5), where N(t, t + 125 \(\upmu\)s) denotes fresh arriving traffic stream into buffer during time interval t, t + 125 \(\upmu\)s for an upstream report (USR) time. Lastly, USR is encapsulated into the XGEM frame and sent to OLT by ONU in US traffic. \[\text{USR(t)}=\left(\text{BOR(t)}+\text{N(t, t+125 $\upmu$s)}\right)\div 125\ \upmu\text{s} \tag{5}\]  
OLT extracts to the XGEM frame as the XGEM frame arrives at OLT. OLT looks to the buffer-occupancy report and stores it for the next cycle. OLT executes the immediate allocation with a colorless grant (IACG) algorithm as a DBA scheme in every 125 \(\upmu\)s to allocate the grant size of each TCONT or allocation id. IACG [25] utilizes accessible byte counters just as down counters to immediately assign bandwidth grant, sized according to respective TCONT queues depending upon whether the down counters have terminated or not. Also, OLT assigns bandwidth grant sizes to those allocation ids/TCONTs whose request sizes are greater than their current grant sizes assigned by DBA. Lastly, OLT broadcasts BWMap into the DS frame to ONUs.