1. Introduction
To solve the problem of low transmission efficiency and the security of traditional TCP/IP networks [
1], some scholars have put forward a content-centered network architecture (ICN) [
2]. As one of the most promising technical solutions to realize ICN, NDN performs routing with content name identifiers, which fully embodies the characteristics of information-centric networks, and the routing nodes have cache capacity [
3]. The content requester sends an interest packet with the content name, and the source server or routing node in the network that has cached the content can return the data packets along the reverse path of the interest packets. The forwarding processing logic of two different types of packets is realized through three tables: content store (CS), pending interest table (PIT), and forwarding information base (FIB). The ubiquitous in-network cache of NDN can reduce server load and the response time of user requests. Therefore, a reasonable caching strategy has become one of the critical issues in NDN research and dramatically affects the efficiency of content distribution [
4].
An efficient NDN cache strategy includes a cache-placement policy and a cache-replacement strategy. The former determines
where to cache the content, and the latter determines
which content to replace first [
5]. The default cache-placement policy of NDN is leave cache everywhere (LCE) [
6], which is a simple algorithm that can effectively improve the speed of content distribution and retrieval. However, it will bring many redundant copies in the network, which cannot fully use cache. Refs. [
7,
8] show that the default request pattern obeys Zipf-like distribution, meaning that a few popular contents can satisfy most user requests. Storing popular content at the edge of the network can enable most users to hit the cached copies, which can minimize the delay of content download and improve the cache diversity of the whole network [
9]. Bernardini proposed most popular content (MPC) [
10], which sets a static threshold in advance, queries the popularity of content when it arrives, and caches the content whose popularity exceeds the threshold. Yu [
11] proposes a caching policy based on content popularity and router level, which stores content with a high popularity level in routers close to users. Many research papers proposed cache-optimization strategies based on content popularity. However, most of them did not consider the dynamic and spatial content requests and used static popularity thresholds, which could not reflect the differences in network traffic in different periods. The most representative cache-replacement strategies of NDN are least recently used (LRU) [
12], least frequently used (LFU) [
13], and SIZE [
14]. However, LRU and LFU only consider the content’s last request time and historical request times; they cannot accurately predict the probability that the content will be requested again in the dynamic network. The SIZE strategy prioritizes replacing data with large bytes, but it may cause low-value, small-byte data to remain in the cache for a long time, reducing the cache utilization. The algorithms mentioned above that use a single factor to determine the data to be removed from the cache have been unable to adapt to diverse network requirements.
NDN breaks the original data producer-driven data consumption service model into a receiver-driven model based on publishing (producer)/subscribe (consumer). The naming method of content identification by name realizes the transmission mechanism of separating content location and identification and solves the mobility problem of NDN. Its unique named data-based network layer allows the NDN to forward named data requiring a completely different packet-processing logic than current IP protocol-oriented network devices [
15]. However, current network architectures and devices are primarily IP-centric, with solidified data plane functionality, and existing hardware and software technologies make content-centric network deployments problematic [
16]. NDN routers are primarily software-based, with poor portability and limited performance for routers optimized for specific hardware platforms [
17,
18,
19].
The advent of fully programmable switches [
20,
21] and high-level programming languages [
22] has solved the problem of poor scalability of traditional switches. Nick McKeown proposed programming protocol-independent packet processors (P4) [
23] and the corresponding forwarding model [
24,
25] that allows administrators to customize the packet-forwarding behavior of switches and improve the programmability of data plane and the flexibility of packet processing. Signorello proposed NDN.P4 [
26], which first implemented the native NDN packet parsing and forwarding function in the software switch [
27] by using P4_14 [
28]. Rui Miguel [
29] extended NDN.P4 by using the P4_16 version [
30] and realized the in-network caching function of NDN by software. However, the above research only implements the basic functionality of NDN in the programmable data plane and does not deploy the associated cache-optimization strategies. Using programmable switching devices to analyze and process data packets has become a significant development trend in the network. To adapt to the dynamic network with frequently changing user requests and solve the problems of slow user response and low cache hit ratio, the main research works are as follows.
We propose a dynamic popularity cache-placement policy (DPCP) that considers the number of content requests in the current cycle and the popularity of the previous cycle to calculate the latest popularity and use the addition increase and multiplication reduction (AIMR) algorithm to dynamically adjust the popularity threshold according to the node cache space occupation, which only caches the content whose popularity exceeds the threshold to improve the cache utilization.
We propose a cache-replacement strategy based on replacement value (RVCS), which comprehensively considers the last request time, popularity, and transmission cost to calculate the replacement value of cached content and moves the content with the lowest replacement value out of the cache space.
We deploy the cache-optimization policy proposed in this paper in a real network containing programmable devices and use a programmable language to process interest and data packets. Experimental results show that the proposed strategy can effectively improve the cache hit ratio and reduce the average routing hops compared with the traditional cache strategy.
2. Related Work
Caching in the node, also known as in-network caching, can separate the content from the producer and reduce the overhead of the producer. Providing multiple copies of the same content in the network can also avoid single points of failure and reduce network load and data transmission latency. Thus, the effective management of caching resources to improve the caching performance of the system has become the focus of NDN research [
31,
32].
In terms of cache-placement strategy, the default cache-placement strategy of NDN is LCE [
6], which is the main idea of making every node on the return path cache the content. However, this strategy causes most of the content to be replaced before the user requests it again, which reduces the cache hit ratio. Refs. [
7,
8] show that user requests in NDN obey a Zipf-like distribution, and most requests tend to focus on a few popular contents. Caching content with high popularity can enable most users to hit cache copies and improve cache space utilization. Therefore, aiming to improve the performance of in-network caching, some studies have proposed a caching algorithm based on content popularity. Bernardini [
10] proposed MPC, which only caches the content whose popularity exceeds the threshold. Yu [
11] proposed an in-network caching strategy based on content popularity and router level (CPRL), which caches the content according to its popularity level on the corresponding router to reduce redundant data. Naeem [
33] proposed a new content-caching mechanism named the compound popular content caching strategy (CPCCS), which improves the distribution of content by choosing the appropriate cache location for different popular content. Gui [
34] proposed a cache-placement strategy based on compound popularity (content popularity and node popularity); this scheme aims to enhance the reuse rate of data packets by jointly considering the content popularity and the node popularity over a period of time. Yin [
35] proposed a popularity-aware in-network caching policy (Pop), which can perceive the popularity of content without additional hardware and traffic overhead and realize the optimal caching of network content in edge networks with limited resources. Rashid [
36] proposed coupling parameters to optimize content placement (COCP). The proposed approach considers the request rate, distance, and available cache space, and a balanced cache space of the routing path was constructed. The content was cached in an appropriate location to minimize content redundancy and network performance. However, the above research only set a static popularity threshold or counted the total number of content requests without considering the changes in content in different periods, which cannot reflect the local differences in network traffic.
LRU [
8] and LFU [
9] are the most commonly used cache-replacement strategies. LRU adopts the least recently used strategy, which always replaces the content that has not been requested for the longest time, and thinks that the recently requested data has a higher probability of being requested in the future. Ran [
37] proposed a caching replacement policy based on content popularity (CCP), which moves the least popular content out of the cache when the data packet arrives. Chen [
38] proposed a LUV-Path policy that takes the distance between the current node and the source server as a factor affecting the value of the content; the greater the distance, the higher the value of the content, and it replaces the low-value content when replacement occurs. Chootong [
39] proposed a content popularity-based cache-replacement policy, which calculates popularity based on the hit ratio, recent request interval, and the number of requests of cached content, and replaces the least popular content each time. Liu [
40] proposed a new intra-network cache-replacement strategy, which integrates evaluating the popularity of caching contents and the betweenness of the nodes in the network topology. This strategy achieves the best performance of cache replacement in the network by weighing the importance of each node and the popularity of cache content in the domain. Alzakari [
41] proposed the randomized least frequently used cache-replacement strategy (randomized LFU), which uses the calculation of a frequency over a certain period to determine where the old chunk should be replaced with the new data chunk. Alahmadi [
42] proposed an enhanced time and frequency cache-replacement strategy (ETFCR), which used cache hit frequency and cache retrieval time to select evicted data chunks. However, this policy uses a single factor to determine cache-replacement content that no longer satisfies the diverse network requirements.
With the rapid development of fully programmable switches and high-level programming languages, the analysis and processing of NDN packets using programmable switching devices have become the development trend of the current network [
43]. Based on the problem of content redundancy caused by the current caching mechanism [
44], this paper proposes a caching optimization strategy based on dynamic popularity and replacement value. It deploys it on a programmable data plane. In terms of cache placement, when a data packet arrives at a node for the first time, the content is cached regardless of its popularity. If the data packet does not arrive for the first time, the latest popularity of the content is calculated by considering the popularity of the content in the last cycle and the total number of requests in this cycle, and the threshold size is dynamically adjusted by the AIMR algorithm according to the space occupation. Only the content whose popularity exceeds the current threshold is cached, and the content with high request probability in the future is cached as much as possible. When the cache space is complete, three main factors affect the replacement value of the cached content: the last request time, popularity, and transmission cost. We use the replacement value function to calculate the replacement value of the cached content and save the content with a high value to improve the cache performance.
3. Method Design
Aiming to improve the cache hit ratio and reduce the average routing hops of requests, this paper proposes a cache-optimization strategy based on dynamic popularity and replacement value. When the cache space is not entire, the content arrives at the node for the first time and is directly stored in the node; if the content does not arrive for the first time, we compare the popularity of the arrived content with the current threshold, and decide whether to cache the content. To make full use of the cache space, the cache threshold is set to 0 at the initial stage, and all the content that arrives will be cached. When the cache space is entire, the popularity threshold is set as the average of the popularity of the cached content, and the non-popular content is filtered. When cache replacement occurs, the cache threshold is automatically increased by 1; if cache replacement does not occur many times in a row, the popularity threshold will be lowered dynamically according to the proportion of popular content in the cache. When the content in the cache needs to be replaced, the content popularity, the last request time, and the transmission cost are used to calculate the replacement value and the content with a low replacement value in the cache is preferentially replaced. This optimization strategy can dynamically update the popularity of the content, store popular content in time according to the user requests, and replace the content with low replacement value. It can reduce the network traffic overhead, improve cache utilization, and reduce the average routing hops.
Figure 1 shows the optimized control flow of the ingress pipeline based on the existing NDN.P4_16 [
45], and we have added two new tables, the content popularity table (CPT) and the content record table (CRT), to the existing data structure. The
crt_table marks whether the content arrives for the first time, and if it is the first time, the content is directly cached; otherwise, we query the information in
cpt_table to calculate the content popularity, and if the popularity is higher than the current threshold, the content is cached. Otherwise, we only perform the forwarding operation.
Algorithm 1 shows the packet process of the ingress pipeline. A packet arrives at the routing node, initializes the intrinsic metadata field, and the programmable parser parses the packet. The packet type is determined based on the
packetType field in the header of the parsed packet, and different types of packets are handled differently.
Algorithm 1. The packets process of the ingress pipeline |
Input: Interest/Data packets |
Output: Forwarding action |
initialize metadata; parse packet; name_hash = hash(c1, c2, c3, c4, c5); ifpacketType==0x05then //Interest packet lookup CS; if CS hits then set the output port as the cache port; elif have PIT entry then //cache miss update CPT.count; exact match FIB; if have a FIB entry then forwarding Interest packet; else drop packet; else update PIT entry; end if ifpacketType==0x06then //Data packet lookup PIT; if no PIT entry then //no Interest request drop packet; elif isInCrt==0 then //content arrives for the first time caching packet; else lookup CPT and compute Pr; if Pr > Pth then caching packet; else drop packet; forwarding packet; clear PIT entry; end if
|
If packetType==0x05, it means that an interest packet with the specified name arrived at the node. We query the CS table to determine if there is a cached copy of the request and return the packet if the cache has a cached copy of the requested content. Otherwise, we query the PIT to determine if the content has already been requested and update the request count in the CPT. If the PIT is not hit, we look up the FIB to determine the content producer that can satisfy the request and follow the matching action to forward or discard the interest packet. A total timer is set in the node to update the content popularity of the CPT record according to a fixed duration period.
If packetType==0x06, it indicates that the content producer or other node cache returned a data packet with the specified name content. The node first queries the PIT to determine whether the content has been requested. It does not hit the PIT, which means that no consumer has requested the content, and then it discards the data packet. Otherwise, the CRT is querying to ascertain whether the content is the first arrival, and if it is the first arrival, the content is cached in the CS. Otherwise, the popularity of the content is calculated by using the popularity calculation function based on the information recorded in the CPT and compared to the current threshold; the content is cached if it exceeds the threshold. The content with the lowest replacement value in the cache is replaced if the cache is complete.
3.1. Dynamic Popularity Cache-Placement Policy
The content requested by consumers in the NDN network is provided by the source service or the cache of a node on the request path [
46], so caching popular content on the node can significantly improve the efficiency of user retrieval and cache hits. The content that arrives for the first time may be pre-popular, and users may request the content multiple times within a period. To reasonably cache the content according to the heat information, it is cached in CS when it arrives for the first time. The requested content arrives at the routing node. The latest popularity is calculated by combining the number of requests in the current cycle and the popularity of the previous cycle. The cache threshold is adjusted according to the occupancy of the node cache space, and only the content whose popularity is higher than the current threshold is cached.
3.1.1. Node Structure
Popularity can effectively reflect the popularity of users’ requests for content, and using popularity as a basis for caching can more accurately predict the possibility of subsequent requests. User requests are temporally and spatially differentiated, resulting in constant changes in content popularity. For example, certain content is less requested by users in the early stage, and its popularity is low. However, as the requests for the content increase over time, the popularity of the content increases. Thus, user request behavior can dynamically influence the popularity of content.
Considering the dynamic change of user requests and the variability of content popularity in different periods and autonomous domains, this paper adds a CPT and a CRT to the original NDN node structure to describe the change in cached content popularity. The node and forwarding structure are shown in
Figure 2.
CPT stores the current popularity information of all pending interest packets in a triplet <Content name, Popularity, Count>. The Popularity records the current popularity of the content, and Count records the number of requests for the content in the cycle. CRT marks whether the current content has arrived for the first time in <Content name, Flag>, where Flag = 1 means that the content has already arrived at the node; it is not newly generated content.
3.1.2. Popularity Calculation
The packet arrives for the first time, and we add an entry corresponding to the content name in CPT. To accurately predict future requests, a timer is set in the router node, and fixed cycle duration to count the number of times that content name is requested in each cycle. By using the exponentially weighted moving average (EWMA) [
47], the latest popularity of the content is calculated based on the popularity of the content in the previous cycle and the number of requests in the current cycle. The popularity calculation algorithm of content
r is shown in Equation (1):
Pr[
i] is the content popularity of
r at the
ith cycle,
Nr[
i−1] denotes the number of requests in the (
i − 1)th cycle,
α is the weight coefficient, and
T is the update cycle duration. It can be seen from Equation (2) that the weight coefficient is a positive correlation with
T, and
c is the proportional coefficient of
α and
T. We extend Equation (1) as shown in Equation (3):
As can be seen from Equation (3), the popularity is dynamically changed by the request behavior. To accurately predict the next phase of content requests, Equation (1) considers the number of content requests and previous popularity. As time changes, the previous popularity of content has less and less influence on the popularity, which can better highlight the trend of content request changes.
3.1.3. AIMR Algorithm
Most popularity-based cache-placement strategies are based on static popularity thresholds without considering the locality of consumer requests and differences in different periods. The network traffic of the same node may fluctuate significantly in different periods. Therefore, the core algorithm of DPCP is AIMR, which can dynamically adjust the popularity thresholds of nodes according to the content heat and cache capacity in the current node.
The AIMR algorithm specifies that popularity greater than a threshold value is high popularity content (HPC); otherwise, it is identified as less popularity content (LPC). The cache-replacement flag Flagre is set to identify whether a cache replacement has occurred in CS. Flagre = 0 means no cache replacement has occurred, and conversely means that a cache replacement has occurred. The variable Nre indicates the number of consecutive times that cache replacement has not occurred and is refreshed when a cache replacement occurs. The AIMR algorithm is divided into three main phases.
- 2.
When the cache space is complete, the mean value of content popularity in CS is used as the initial value of the threshold:
If the popularity
Pr of the arriving content r exceeds the threshold
Pth, the content is cached into the CS, and the threshold is added by 1. The content is forwarded directly to the next node if the popularity is less than the threshold:
- 3.
When no cache replacement occurs in a certain number of requests by the node, the threshold is reduced according to the popular content stored in the node. The maximum tolerance number is set to k, and when no cache replacement occurs for k consecutive times, the prevalence threshold is reduced in proportion to the number of HPCs stored in the node:
Nh is the number of HPCs in the node, and N is the total amount of content stored in CS.
3.2. Replacement Value Cache-Replacement Strategy
With the increase in user requests and the dynamic changes of the requested content, the stored content needs to be replaced when the cache space is entire. An efficient cache-replacement strategy can improve the hit rate of data requests in the network at edge nodes. In order to solve the problem of high response delay caused by the traditional cache-replacement strategy, RVCS comprehensively considers the popularity of the cached content, the last request time, and the transmission cost, calculates the replacement value of the cached content, and replaces the content with the lowest value. The lowest content is moved out of the cache.
As shown in
Figure 3, RVCS adds the new field
hops in the data packet structure, which records the hop count of content from the source server to the current node. The larger the number of hops, the higher the transmission cost of the content, so replacing the content far away from the source server in the replacement process should be avoided. The transmission cost is calculated as shown in Equation (8):
Cr is the transmission cost of the content, and Prt denotes the transmission cost per hop of the content r.
Set a timestamp for each content in the cache space to record the last accessed time. Assuming that the last request time of content
r is
Tr and the current time is
Tcur, the request time interval of content r is Δ
tr:
Δ
tr is smaller, indicating that the content request frequency in this cycle is higher, the content popularity is high, and the content replacement value mainly depends on the content popularity. Δ
tr is larger, demonstrating that the content request frequency is low in this cycle, and the popularity of content decreases; the transmission cost of content is the main factor that affects the replacement value. Combined with the above analysis, the replacement value function of the content is as shown in Equation (10):
It can be seen from Equation (10) that if the content is frequently requested, the time interval Δtr will be smaller, and the popularity will have a greater impact on the result in the replacement value function. On the contrary, the larger the time interval Δtr, the fewer times the content r is requested, and then the replacement value is more affected by the transmission cost. The algorithm uses the time interval between requests for content as a weighting factor, which can adjust the popularity of the content and the proportion of transmission cost in the replacement value function in real time. It can not only cache the content with high popularity but keep the content with high transmission cost.
4. Performance Evaluation
This section evaluates the performance of the proposed cache-optimization strategy. The experimental topology and the benchmark policy are introduced, and the performance evaluation metric is defined. Based on the final results of the experimental implementation, the cache-optimization strategy designed in this paper is compared and analyzed with the benchmark policy in terms of different evaluation metrics.
To make the experimental results more illustrative, this paper adopts the experimental topology in [
10], shown in
Figure 4, which simulates the complex mesh topology commonly used in current networks, which usually exists in large mesh networks. Three NDN autonomous domains are connected to the core network through three backbone polymorphic network units, which form a full-mesh network and are controlled by an inter-domain controller. The switch adopts ZHAOXIN LDS-RBY-S2, and the inter-domain and intra-domain controller use ONOS distributed controllers to realize the centralized control and flow table distribution. The network bandwidth of the core network is 100 Gbps, and the bandwidth of each autonomous domain connected through the core network is 10 Gbps. To save hardware costs and space occupied by the physical platform, both autonomous domains 2 and 3 use a combination of virtual and physical nodes to form a network.
The parameters used during the experiments are shown in
Table 1. Although [
7,
8] indicate that the request pattern of users obeys the Zipf distribution, the distribution of user requests is not exactly the same in different scenarios. Moreover, the caching capacity of the nodes is a crucial factor in impressing the caching performance. Similar to other schemes [
33,
48,
49,
50], we evaluate the performance of the cache-optimization strategy proposed in this paper by using the Zipf distribution parameter and node caching capacity as variables. The caching capacity of a node is defined as a percentage of the total amount of content. For example, when the caching capacity is 0.20, and the total amount of content is 1000, the node can cache 200. Assume that the total number of different types of content in the experiment is 1000, the refresh period is 10 s, the consumer request rate is 40 pkts/s, and all nodes have the same caching capacity.
The file types requested by NDN hosts in the experimental environment mainly include text (.txt), images (.png), video (.avi), and portable documents (.pdf), etc. Collect the corresponding average routing hops and cache hit ratio in different cache capacity and Zipf distribution parameters after the network initialization.
To verify the performance of the cache-placement policy DPCP, the comparison policy is the classical cache-placement policy LCE and Prob [
48] (the cache probability
p is set to 0.5 to enhance the experimental comparability), and the cache-replacement policy used is LRU. The cache-replacement policy RVCS is compared with FIFO and LRU, which all adopted LCE in the cache-placement policy. We compare DPCP + RVCS, LCE + LRU, Prob + LRU, and LCE + FIFO to verify the performance of the cache- optimization strategy proposed in this paper.
4.1. Average Routing Hops
Average routing hops refer to the average number of routing hops when a user request is responded to in a certain period. It reflects cache availability and redundancy and also reflects the rationality of cache location. The more reasonable the cache location, the smaller the average routing hops and the lower the average access delay of users. The formula for calculating average routing hops is shown in Equation (11):
Int is the set of interest packet requests, Hopi indicates the number of routing hops for which interest packet Inti gets a response, and numInt is the total number of requests.
Figure 5 shows the effect of the Zipf distribution parameter α on the average routing hops to get responses. As seen in
Figure 5, the small distribution parameter α indicates that the distinction between HPC and LPC is not apparent, and the randomness of content requested by users is greater. The traditional caching strategy cannot accurately predict the future content request trend, so most requests can only be responded to by the content server with high routing hops. With the increase of Zipf distribution parameters α, the concentration of user requests is more substantial, and the performance of each strategy is improved. However, the cache-optimization policy proposed in this paper has optimal performance. In particular, when α is 1.2, the DPCP + RVCS strategy has the smallest average routing hops of 1.93, which is 0.51, 0.60, and 0.72 lower compared to LCE + LRU, Prob + LRU, and LCE + FIFO.
Figure 6 shows the effect of node caching capacity on the average routing hops for users to acquire content. With the increase of distribution parameter α, the concentration of user requests is higher, and the cache hit rate of the six strategies is increasing. However, DPCP + RVCS can dynamically adjust the contents of the cache and replace the contents with lower value when the cache is full, so it has the best performance. When the cache capacity is 0.35, the DPCP + RVCS strategy has the smallest average routing hops of 1.62, which is 0.34, 0.22, and 0.30 lower compared to LCE + LRU, Prob + LRU, and LCE + FIFO, indicating that the cache-optimization strategy proposed in this paper can effectively reduce the average routing hops.
4.2. Cache Hit Ratio
The cache hit ratio is a crucial metric for evaluating NDN cache performance. It refers to the response by the in-network cache in which the content is locally cached for a specific period. The higher the cache hit ratio, the lower the response ratio and load on the corresponding source server, and the more significant the network performance improvement. The formula for calculating cache hit ratio is shown in Equation (12):
The set v = {v1, v2,…, vn} represents the n nodes in the topology, and Numi is the number of hits at node i.
Figure 7 shows the impact of the Zipf distribution parameter α on the cache hit ratio. As seen in
Figure 6, when the distribution parameter is small, the content requested by the user is scattered, and the traditional caching scheme cannot predict the content that may be requested in the future; hence the cache hit ratio is poor. As the distribution parameter α increases, the concentration of user-requested content is higher, so the cache hit ratio of all policies keeps increasing, but DPCP + RVCS dynamically caches high popularity content and replaces less valuable content when the cache is full, so it has optimal performance. When the Zipf distribution parameter is 1.5, its cache hit ratio can reach 0.87, improving by 0.11, 0.17, and 0.24 compared with LCE+ LRU, Prob + LRU, and LCE + FIFO.
Figure 8 shows the effect of cache capacity on the cache hit ratio. When the cache space is small, DPCP + RVCS can effectively use the cache space and store the high popularity content in the cache space, while replacing the content with a low replacement value when the cache is complete, which reduces the cache redundancy in the network, so that more user requests are responded in the cache space. However, as the cache capacity increases, other policies can also cache more content, and the gap in the cache hit ratio between different policies gradually decreases; the DPCP + RVCS has the highest hit ratio. In particular, when the cache capacity is 0.55, its corresponding cache hit ratio is as high as 0.76, which is 0.10, 0.09, and 0.12 higher compared to LCE + LRU, Prob + LRU, and LCE + FIFO, respectively.
6. Conclusions
In-network caching can effectively decrease the overhead of content servers, and cached copies of content can also significantly reduce network load and transmission latency when multicast or retransmission occurs due to post-packet loss. To improve the cache hit ratio in NDN and ruduce the average routing hops of user requests, this paper proposes a cache optimization strategy based on dynamic popularity and replacement value. Regarding cache placement, this strategy considers the temporal and regional nature of user requests and periodically updates the popularity of content. The cache threshold is dynamically adjusted according to the node cache occupancy by using the AIMR algorithm. The content whose popularity exceeds the threshold is cached. From the aspect of cache replacement, this strategy comprehensively considers the last request time, popularity, and transmission cost of cached content, uses the replacement value calculation function to calculate the replacement value of cached content, and moves the cached content with the lowest replacement value out of the cache space. To evaluate the performance of the cache-optimization strategy proposed in this paper, we deployed it in a real network containing programmable network devices. In this experiment, the caching performance in average routing hops and cache hit ratio was evaluated. Experimental results show that the caching optimization strategy proposed in this paper is much better than other cache mechanisms.