# Performance Analysis of Cache Based on Popularity and Class in Named Data Network
## 4 Dynamic-CAPIC: Cache Based on Popularity and Class with Dynamic Cache Proportion
### Formulation of Determining the Cache Proportion  
To optimize the network cache hit ratio, the cache size for each content class needs to be specified according to its needs and character. In addition, a caching mechanism capable of providing optimal performance for all content classes and also for the entire system is needed.  
Equation (4) shows that generally, the cache hit ratio is affected by the number of actual requests for the content and the content store's capacity. Therefore, the following mathematical equation is used to determine the important factors for the cache portion of every content class. In this system, three content classes are modeled based on Table 1, which is followed by the use of the Lagrange Multiplier. Based on Equation (4), the cache hit ratio function, called the function \(f\), can be written as follows:  
\[f(c_{1},\ c_{2},\ c_{3})\ \ =\frac{p(1)\cdot\lambda_{1}+p(2)\cdot\lambda_{1}+ \cdot+p(c_{1})\cdot\ \lambda_{1}+p(1)\cdot\lambda_{2}+p(2)\cdot\lambda_{2}+\cdot+p(c_{2})\cdot \lambda_{2}+p(1)\cdot\lambda_{3}+p(2)\cdot\lambda_{3}+\cdot+p(c_{3})\ \lambda_{2}}{\lambda_{1}+\lambda_{2}+\lambda_{3}}\]  
and as in Equation (1),  
\[p\left(i\right)=\frac{\left(i+q\right)^{-\alpha}}{\sum_{i=1}^{N}\left(i+q \right)^{-\alpha}}\]  
The constraint function is written as the function \(g\),  
\[g(c_{1},\ c_{2},\ c_{3}\ )=c_{1}\ +\ c_{2}\ +\ c_{3}\ =C\]  
then the Lagrange function is:  
\[\
abla f(c_{1},\ c_{2},\ c_{3}\ )=\ L\ \cdot\
abla g(c_{1},\ c_{2},\ c_{3}\ )\]  
where:  
Figure 5: Dynamic-CAPIC vs. Static-CAPIC.  
\[c_{2} = \frac{C}{\left(\frac{1}{\frac{\lambda_{2}\sum_{i=1}^{N_{2i}}(0)^{- \alpha}}{\lambda_{1}\sum_{i=1}^{N_{2i}}(0)^{-\alpha}}}+1+\sqrt{\frac{\lambda_{2} \sum_{i=1}^{N_{2i}}(0)^{-\alpha}}{\lambda_{2}\sum_{i=1}^{N_{3}}(0)^{-\alpha}}}\right)} \tag{10}\] \[c_{3} = \frac{C}{\left(\frac{1}{\frac{\lambda_{2}\sum_{i=1}^{N_{2i}}(0)^ {-\alpha}}{\lambda_{1}\sum_{i=1}^{N_{2i}}(0)^{-\alpha}}}+\frac{1}{\sqrt{\frac{ \lambda_{3}\sum_{i=1}^{N_{2i}}(0)^{-\alpha}}{\lambda_{2}\sum_{i=1}^{N_{3}}(0)^ {-\alpha}}}}+1\right)} \tag{11}\]  
Based on Equations (9)-(11), it can be concluded that to maximize the cache hit ratio, the proportion of cache given for each class \(k,c_{k}\), has to be directly proportional to the total content store's size, requests rate, and document population number of its class. The given cache proportion is inversely proportional to other content class's document population number and request rate. This is in accordance with the content population number \(N_{1},\ N_{2}\) and \(N_{3}\). NDN routers can not know \(\lambda_{1},\ \lambda_{2}\) and \(\lambda_{3}\) in real-time, therefore an additional parameter is used to describe these two conditions in real-time. Due to the limitation of the content store's capacity, all the content cannot be cached, therefore, the important ones are selected and stored. Dynamic-CAPIC considers this in the second step of CAPIC, as described in Section 2.2, which determines how much content is worth keeping, in accordance with a certain frequency. For this reason, this research proposes a formula for determining the proportion of storage for \(k\) content classes in Dynamic-CAPIC. This formula includes parameter \(X_{k}\), which represents the frequency of requests and also the amount of variation of content requested in real-time.  
\[c_{k}=\frac{X_{k}\cdot C}{\sum_{i=1}^{k}X_{i}} \tag{12}\]  
where:  
\(X_{k}\) = the number of variations in content class \(k\) that is requested more than a certain Frequency Limit Factor value,  
\(k\) = content class \((k=1,2,3,\dots)\),  
\(c_{k}\) = content store proportion for class \(k\),  
\(C\) = total content store size.