## 3 Problem Statement
### Calculating Data Freshness
Forward = 1 means the data request message is forwarded while Forward = 0 indicates the data are sent directly to the consumer:  
\[Forward\!=\left\{ \begin{matrix}1&if\ Cache_{status}=0\ or\ V\leq 0\\ &0&Otherwise\end{matrix} \right. \tag{8}\]  
**Step 5: Check for Data with a Matching Sensor Number and Type in the Cache**  
When a data message is received, the router first checks whether the cache already contains data with the same sensor number and data type. This is expressed by Equation (9). If \(Duplicate_{Check}=1\), the old data are removed and the new data are cached; otherwise, the router proceeds to the next step. \[Duplicate_{Check}\!=\left\{ \begin{matrix}1&if\ (Sensor\ number,\ data\ type)\ \in\ CS\\ &0&Otherwise\end{matrix} \right. \tag{9}\]  
**Step 6: Check for Empty Space in the Cache**  
If no duplicate data are found, the router checks if there is space in the cache for the new data. Cache space is represented by Equation (10). If \(Cache_{Space}=1\), the new data are cached; if \(Cache_{Space}=0\), the router moves to the next step:  
\[Cache_{Space}\!=\left\{ \begin{matrix}1&if\ available\ space>0\\ &0&Otherwise\end{matrix} \right. \tag{10}\]  
**Step 7: Check for Expired Data in the Cache**If the cache is full, the router checks for expired data by calculating the time validity of cached entries. Time validity is calculated by Equation (11):  
\[\mathit{Time}_{validation}=1-\frac{NDTS-CDTS}{NDtype} \tag{11}\]  
\(NDTS\) (_New Data Time Stamp_) represents the time when new data become available for caching, \(CDTS\) (_Cached Data Time Stamp_) indicates the time when the data were originally stored in the cache, and \(NDtype\) (_New Data Type_) reflects the refresh rate of the new data type. If \(Time_{validation}\ \leq\ 0\), the cached data are deemed expired and removed to accommodate the new data. **Step 8: Remove Data with the Lowest Freshness Score if No Expired Data are Found**  
If no expired data exist, the router calculates the freshness score \(V(i,j)\) of all cache entries and removes the data with the lowest score to cache the new data. The overall validity score is calculated by Equation (12):  
\[\mathrm{V(i,j)}=(\alpha\times F_{Rate})+((1-\alpha)\times Time_{validation}) \tag{12}\]  
\(V(i,j)\) represents the combined freshness and validity score, where \(\alpha\) is a weighting coefficient that balances the importance of freshness and validity in the calculation. Additionally, \(\alpha\) is considered a network-specific constant because its value is chosen based on the specific characteristics and requirements of the network environment, such as the frequency of data updates, the priority of real-time data, or the caching strategy employed. For example, in networks where data freshness is critical, \(\alpha\) may be set closer to 1 to provide further weight to freshness. Conversely, in scenarios where data validity or historical relevance is more important, \(\alpha\) may be set closer to 0 to emphasize validity. The freshness rate \(F_{Rate}\) is calculated by Equation (13):  
\[F_{Rate}=\frac{SRN}{TR} \tag{13}\]  
Here, the same request number \((SRN)\) represents the count of requests made specifically for a particular data type while total requests \((TR)\) denotes the overall number of requests during the observation period. A _higher F_ value indicates that the data type is more frequently requested, making it more likely to be prioritized for caching. This systematic process ensures that only the most relevant and up-to-date data are retained in the cache, optimizing resource utilization and enhancing response times for consumers in the ICN-IoT network. Algorithm 1 shows the proposed method pseudocode. ```
START //Step 1: Check for Message Type
1. RECEIVE M //Incoming message
2. IF M \(\in\) r THEN //If M is a data request message
3. MESSAGE_TYPE + \"REQUEST\"
4. ELSE IF M \(\in\) D THEN //If M is a data response message
5. MESSAGE_TYPE + \"RESPONSE\"
6. ELSE
7. RETURN \"Invalid Message\"
```
**Algorithm 1**Cont. ``` //Step 2: Check Cache for Requested Data

8.