# Weighted-CAPIC Caching Algorithm for Priority Traffic in Named Data Network
## 4 Weighted Cache Based on Popularity and Class (Weighted-CAPIC) Algorithm  
The utility function for content without content class distinction was carried out by [PERSON] et al. [7]. In this section, we develop this equation to accommodate multiclass content. Internet traffic has different requirements; therefore, we should provide different treatment for each class of traffic. We derived the utility function formula for multiclass content to obtain the relationship between weight and cache hit ratio. This was necessary to determine the proper treatment for the priority content class. The utility function for multiclass content uses the utility relationship to the hit probability for each content class, \(d\), which can be written as in Equation (1)  
\[U_{d}(p_{d})= \begin{cases}\omega_{d}\frac{p_{d}}{1-\gamma},\gamma\geq 0\text{ and } \gamma\
eq 1\\ \omega_{d}.\log_{p_{d}}\end{cases}  \tag{1}\]  
where:  
\(p_{d}\) = hit probability for content class \(d\)  
\(U_{d}(p_{d})\) = utility for class \(d\) with a hit probability \(p_{d}\)  
\(\omega_{d}\) = weight of class \(d\)  
To maximize the utility of the content store, we can write the Equation (2)  
\[\max_{p_{d}}\sum_{d=1}^{D}U_{d}(p_{d}) \tag{2}\]  
Since there are \(D\) number of content classes and we used three content classes with different requirement as in Table 1, it can be written that the relationship between the portion of each class, \(c_{d}\), and the total size of content storage, \(C\), is as Equations (3) and (4). \[c_{1}+c_{2}+c_{3}=C \tag{3}\]  
and  
\[\sum_{i=1}^{c_{1}}r_{i1}+\sum_{i=1}^{c_{2}}r_{i2}+\sum_{i=1}^{c_{3}}r_{i3}\leq D \tag{4}\]  
Hit probability of class \(d\) with cache proportion \(c_{d}\) and using LFU cache replacement can be defined as Equation (5). \[p_{d}=\sum_{i=1}^{c_{d}}r_{di} \tag{5}\]  
where:  
\(r_{di}\) = hit probability of content i on class \(d\);  
\(p_{d}\) = hit probability of class \(d\);  
\(c_{d}\) = cache proportion of class \(d\). The constraint for the utility function in the content store that stores multiclass content is as in Equation (6). \[\sum_{d=1}^{D}(p_{d}.N_{d})=C \tag{6}\] \begin{table}
\begin{tabular}{c c c c} \hline
**Class** & **Example** & **Request Duration** & **Request Rate** \\ \hline
1 & Real-time apps & Long (years) & Low–mid \\
2 & User-Generated & Mid (weeks) & Mid \\  & Content (UGC) & & \\
3 & Web access & Mid (weeks) & High \\
4 & email, VoNDN & Short(days) & Not cached \\ \hline \end{tabular}
\end{table} 
Table 1: Class of content. Due to the neutrality for making the utility linear in using \(p_{d}\), we use the value \(\gamma=0\). Therefore, the maximization of utility can be written as Equations (7) and (8). \[max_{p_{d}}\sum_{d=1}^{D}\omega_{d}\frac{p_{d}}{1-\gamma}^{1-\gamma} \tag{7}\]  
\[max_{p_{d}}\sum_{d=1}^{D}\omega_{d}.p_{d} \tag{8}\]  
The number of utilities will be maximized if we set a more significant weight for the class \(d\) with a greater hit probability. When applied to the system, this will cause the maximum overall hit rate in the system. Based on the formula that has been derived from the utility function of multiclass content, the total utility will be maximized if we give the most significant weight to the priority class with the highest hit probability. Weighted-CAPIC adds this concept to Dynamic-CAPIC from previous research. We add the weight parameter for determining the cache portion of each class, where \(\omega_{d}\) is the weight for class \(d\). The Weighted-CAPIC formula determines the cache portion for class \(d\), as in Equation (9). The Weighted-CAPIC formula ensures that the weight is assigned to the class that requires it according to real-time conditions. The cache portion of one class can change over time, and the Weighted-CAPIC formula assigns a certain weight to the class according to what it needs in a certain real-time period. These algorithms can be implemented in the NDN mobile node because every router node can run this algorithm individually without coordinating with other nodes.