## 3 Problem Statement
### Calculating Data Freshness  
The proposed method utilizes data freshness calculations within the Named Data Network (NDN)-based ICN-IoT architecture to efficiently manage cached data in response to consumer requests. This approach uses freshness as a primary criterion for determining whether data should be retrieved from cache, forwarded, or replaced, optimizing response times and cache utilization. Each step of the method is described below. **Step 1: Start and Check for Message Type**  
The process begins when the router receives an incoming message, either a data request message or a data response message from a consumer. A data request message specifies a request for specific information while a data response message carries the requested data. The type of message determines the router's subsequent actions. To classify the message, let \(M\) denote the incoming message. The router determines whether \(M\) belongs to the set of data request messages \((\tau)\) or the set of data response messages \((D)\) based on its contents. This classification can be represented by Equation (5):  
\[M=\left\{ \begin{aligned} & Data\ request\ message\ \ if\ M\ \in\ \tau\\ & Data\ Message\ if\ M\ \in\ D\end{aligned} \right. \tag{5}\]  
Here, \(\tau\) represents the set of data request messages, which contain information such as the requested data type, sensor ID, and request time, while \(D\) represents the set of data response messages, which include the actual sensor data. The router determines the set membership \((M\ \in\ \tau\ or\ M\ \in\ D)\) by analyzing specific fields in the message, such as headers or metadata. If \(M\ \in\ \tau\), the router checks its cache for the requested data. If \(M\ \in\ D\), the router evaluates caching decisions based on the recency and validity of the data. **Step 2: Check Cache for Requested Data**  
In the proposed method of this study, the data request message is sent by the client and received by a router along the transmission path. Each request message specifies the sensor number and the data item type (\(R_{\text{type}}\)). For example, the client may request the average temperature of a room over the last 15 min. Here, the \"average temperature over the last 15 min\" corresponds to the data item type (\(R_{\text{type}}\)) while the specific temperature request for a particular room refers to a sensor with a unique identifier. Upon receiving a data request message, the router searches its cache or Content Store (CS) for the requested data. This process determines whether a cache hit (data are found) or a cache miss (data are not found) occurs. The cache status is represented by Equation (6), where \(Cache_{Status}=1\) indicates a cache hit and \(Cache_{Status}=0\) signifies a cache miss:  
\[Cache_{Status}\!=\left\{ \begin{matrix}1&if\ (Sensor\ number,\ data\ type)\ \in\ CS\\ &0&if\ Otherwise\end{matrix} \right. \tag{6}\]  
**Step 3: Calculate Data Freshness**  
If the data are found in the cache, the router calculates the data freshness to verify their validity. Freshness \(V\) is determined by Equation (7):  
\[V=1-\frac{RT-CDTS}{R_{type}} \tag{7}\]  
RT (Request Time) represents the time when a consumer requests data while CDTS (Cached Data Time Stamp) indicates the time when the data are stored in the cache. \(R_{type}\) (Requested Data Type) is a numerical value representing the refresh rate of the requested data type. \(V\) is the freshness score, with values closer to 1 indicating fresher data. If \(V>0\), the data are considered valid and ready to be sent to the consumer. **Step 4: Cache Hit or Cache Miss Decision**  
Depending on the result of the freshness calculation, the router decides whether to deliver the data or forward the request. If \(V>0\), indicating a cache hit with valid data, the router sends the data to the consumer. If \(V\leq 0\), or if the cache does not contain the requested data, a cache miss occurs, and the data request message is forwarded to the next step. The decision to forward is calculated by Equation (8).