blob: 989a595f8b7efc91d6e84d6d57d281793fe09de2 [file] [log] [blame]
Alexander Afanasyeve6852122013-01-21 11:54:47 -08001.. _content store:
2
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -08003NFD's Content Store
4++++++++++++++++++++
Alexander Afanasyeve6852122013-01-21 11:54:47 -08005
spirosmastorakis2c9c0052016-10-31 13:51:14 -07006The Contest Store (CS) is implemented as a set of :ndnsim:`CS entries <nfd::cs::EntryImpl>`),
7ordered by the full data name including the implicit digest. To manage entries, CS adopts a cache policy interface (:ndnsim:`nfd::cs::Policy`), invoked any time a CS entry is added, removed, updated, or used.
Alexander Afanasyeve6852122013-01-21 11:54:47 -08008
Alexander Afanasyev25e4d8f2019-07-29 13:44:04 -04009The supported cache replacement policies are the following:
Alexander Afanasyeve6852122013-01-21 11:54:47 -080010
spirosmastorakis2c9c0052016-10-31 13:51:14 -070011+----------------------------------------------+----------------------------------------------------------+
12| **NFD's Content Store Policies** |
13+----------------------------------------------+----------------------------------------------------------+
14| ``nfd::cs::lru`` | Last Recently Used (LRU) |
15+----------------------------------------------+----------------------------------------------------------+
16| ``nfd::cs::priority_fifo`` | Priority-Based First-In-First-Out (FIFO) |
17+----------------------------------------------+----------------------------------------------------------+
18
19For more detailed specification refer to the `NFD Developer's Guide
20<https://named-data.net/wp-content/uploads/2016/03/ndn-0021-6-nfd-developer-guide.pdf>`_, section 3.3.
21
22
Alexander Afanasyev24810922019-02-10 22:06:43 -050023To control the maximum size and the policy of NFD's Content Store use ``StackHelper::setCsSize()`` and
24``StackHelper::setPolicy()`` methods:
Alexander Afanasyeve6852122013-01-21 11:54:47 -080025
26 .. code-block:: c++
27
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -080028 ndnHelper.setCsSize(<max-size-in-packets>);
spirosmastorakis2c9c0052016-10-31 13:51:14 -070029 ndnHelper.setPolicy(<replacement-policy>);
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -080030 ...
31 ndnHelper.Install(nodes);
Alexander Afanasyeve6852122013-01-21 11:54:47 -080032
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -080033Examples:
Alexander Afanasyeve6852122013-01-21 11:54:47 -080034
spirosmastorakis2c9c0052016-10-31 13:51:14 -070035- To set CS size 100 on node1, size 1000 on node2, and size 2000 on all other nodes.
36 LRU replacement policy for node 1, priority FIFO for the rest:
Alexander Afanasyeve6852122013-01-21 11:54:47 -080037
38 .. code-block:: c++
39
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -080040 ndnHelper.setCsSize(100);
spirosmastorakis2c9c0052016-10-31 13:51:14 -070041 ndnHelper.setPolicy("nfd::cs::lru");
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -080042 ndnHelper.Install(node1);
43
44 ndnHelper.setCsSize(1000);
spirosmastorakis2c9c0052016-10-31 13:51:14 -070045 ndnHelper.setPolicy("nfd::cs::priority_fifo");
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -080046 ndnHelper.Install(node2);
47
48 NodeContainer allOtherNodes;
49 for (NodeList::Iterator i = NodeList::Begin(); i != NodeList::End(); ++i) {
50 if (*i != node1 && *i != node2) {
51 allOtherNodes.Add(*i);
52 }
53 }
54 ndnHelper.Install(allOtherNodes);
55
spirosmastorakis2c9c0052016-10-31 13:51:14 -070056- To effectively disable NFD content store an all nodes
57
Alexander Afanasyev25e4d8f2019-07-29 13:44:04 -040058 Minimum allowed value for NFD content store maximum size is 1.
spirosmastorakis2c9c0052016-10-31 13:51:14 -070059
60 .. code-block:: c++
61
62 ndnHelper.setCsSize(1);
63 ...
64 ndnHelper.Install(nodes);
65
66
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -080067CS entry
68~~~~~~~~
69
70The Data packet, along with other necessary fields, are stored in a CS entry. Each entry
71contains:
72
73- the Data packet
74- flag indicating whether the Data packet is unsolicited
75- the timestamp at which the cached Data becomes stale
76
Alexander Afanasyev25e4d8f2019-07-29 13:44:04 -040077Misc
78~~~~
79
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -080080- Get aggregate statistics of CS hit/miss ratio (works with any policy)
Alexander Afanasyeve6852122013-01-21 11:54:47 -080081
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -080082 The simplest way tro track CS hit/miss statistics is to use :ndnsim:`CsTracer`, in more
83 details described in :ref:`Metrics Section <cs trace helper>`.
Alexander Afanasyeve6852122013-01-21 11:54:47 -080084
85 .. code-block:: c++
86
Spyridon Mastorakis460f57c2014-12-17 00:44:14 -080087 CsTracer::InstallAll("cs-trace.txt", Seconds(1));