# Two-Layer Network Caching for Different Service Requirements
## 3 Model
### Caching Problems
#### 3.3.3 Case 3: Guaranteed Download Time
```
1:functionProcedure4(\(K_{1},\Xi,size(\xi)\forall\xi,W,\{g_{j,\xi}\}\))\(\rightarrow\{q_{i,\xi}\}\)
2:\(content\_index=0\)
3:forall\(i\in\{\) customers\(\}\)do
4:while(layer-1 cache \(free\_space>0\))\(\wedge\)(\(content\_index<C\))do
5:\(\xi^{*}\)\(\leftarrow\)\(argmax\)\(\left(P_{MZ,i}(\xi)\times size(\xi)\right)\)\(\triangleright\) not selectable in the next step
6:\(P_{MZ,i}(\xi^{*})\)\(\leq\) layer-1 cache \(free\_space\)then
7: cache content \(\xi^{*}\) in layer-1 cache, \(q_{i,\xi^{*}=1}\)
8:\(content\_index\)\(\leftarrow\)\(content\_index+1\)
10:\(free\_space\)\(\leftarrow\)\(free\_space-size(\xi^{*})\)
11:endif
12:endwhile
13:endfor
14:endfunction
```

**Code 7** Layer-1 cache population for fixed content size. ### Summary of Algorithmic Approaches

Table 2 recaps the mapping between the problems defined in this paper and the algorithms and procedures defined to solve them. For each problem, we have indicated the equations used to model it, its main distinguishing features, and which algorithm is used to address these features. ## 4 Numerical Results

In this section we present some results of the numerical analysis of the caching problems illustrated above, performed by using a simulator specifically implemented [35]. The simulation general parameters were chosen according to the description of some existing popular content distribution systems [7; 8; 9]: \(C=2000\), \(|K_{2}|=3\), \(W=10\); the size of layer-1 caches was set equal to the size of layer-2 caches; layer-1 caches and layer-2 caches \begin{table}
\begin{tabular}{l l l} \hline
**Problem** & **Problem Features** & **Algorithms** \\ \hline Problem 2: & addressing layer-1 caching in (5) in a basic setting: equal-size items and & Procedure4 in Code 7 \\  & stationary requests pattern & Algorithm1 in Code 1 \\ Problem 3: & addressing layer-2 caching in (6) in a basic setting: equal-size items and & Algorithm2 in Code 1 \\ Problem 4: & addressing layer-2 caching in (14) with variable size items and stationary & Algorithm2 in Code 2 \\  & requests pattern & Algorithm2bás and Procedures1, both in Code 3 \\ Problem 5: & addressing layer-2 caching in (15) with variable size items and stationary & Algorithm3 in Code 4, and \\  & requests pattern, taking advantage of parallel downloading and guaranteeing to complete the download & Procedure2 in Code 5 \\ Problem 6: & addressing layer-2 caching in (16) with variable size items and stationary & Algorithm3 in Code 4, and \\  & requests pattern in a topology with random connections, taking advantage & Algorithm3 in Code 4, and Procedure3 (virtual caches) in Code 6 \\  & within a maximum download time & \\ \hline \end{tabular}
\end{table} 
Table 2: Summary of Problems and relevant Algorithms. are fully connected, that is \(\phi_{i,j}=1\quad\forall i,j\). From the algorithmic viewpoint, this is the most challenging cache interconnection. As for the traffic model, we used \(\alpha=1.3\) and \(q=4\). In the experiments with equal content size, all volumes are normalized to the individual content size. So the size of each item equals 1. In experiments with variable content size, all volumes are normalized to the minimum value. For what concerns the content size, the value range that can be observed in operation is extremely variable. For these experiments we inspired to the typical file size of a movie, which depends on various factors, such as the length, resolution and encoding. In this paper we report the numerical results relevant to a range between 0.5 to 2.5 gigabytes, resulting in a normalized uniform distribution between 1 and 5. Some variations in this range do not significantly change results. In the experiments with a constraint on the link bandwidth, we assumed that \(b_{i,j}/b_{min}=30\) units. In the experiments with stochastic links, we used a probability threshold \(P_{t}=0.8\) and assumed that each link has a probability of being active \(\sigma_{i,j}=0.7\). In order to analyze the proposal in more realistic experiments, we introduced the estimation of the content popularity.