Task #1194
closedPIT on NameTree
100%
Description
Implement PIT API over NameTree.
- Establish one-to-many relationship between NameTree entry and PIT entry
- PIT entry has a pointer to the NameTree entry with same Name.
- NameTree entry has a collection of pointers to PIT entries. Selectors must differ among those PIT entries.
- Pit::insert inserts a NameTree entry, and attaches fib::Entry onto NameTree entry.
- Pit::remove detaches fib::Entry from NameTree entry, but does not necessarily delete the NameTree entry.
- Pit::findAllDataMatches uses relevant features in NameTree API to find all Interests that can be satisifed by a Data; its return type should be iterable of pit::Entry.
Updated by Haowei Yuan almost 11 years ago
- Status changed from New to In Progress
I have a question about the function description, and I would like to see if you have some preferences.
- Pit::remove detaches fib::Entry from NameTree entry, but does not delete the NameTree entry.
Assuming this is the last PIT stored in this Name Prefix Entry (same as NameTree entry), after deleting this PIT, this NPE will be empty (useless).
Then is it PIT's responsibility to remove this NPE later, or it is the NameTree's responsibility to remove this NPE?
1) In the first case, the PIT could call NameTree.deletePrefix(Name) later, or
2) In the second case, the PIT calls the NameTree.deletePIT(), which then locates the NPE, and calls NPE.deletePIT() to remove the PIT. Then the NameTree.deletePIT() checks if this NPE can be deleted, if so, it will delete this NPE.
Updated by Junxiao Shi almost 11 years ago
I suggest to have a NameTree::deleteIfEmpty(name_tree::entry& entry)
method which deletes the entry if there is nothing attached and there is no children.
Updated by Haowei Yuan almost 11 years ago
I have added the function deleteNPEIfEmpty(NamePrefixEntry * npe) to the NameTree, which deletes npe if it is empty, and it also follows the parent pointers to remove qualified parent NPE(s).
So currently to delete a PIT/FIB/Measurement, the following steps need to be performed
Lookup the name prefix and get the corresponding NPE via npe = nt->lookup(name)
Delete the corresponding fields via npe->deletePIT/FIB/Measurement(PIT/FIB/Measurement)
Explicitly call the nt->deleteNPEIfEmpty(npe) to clean the empty NPE.
We could add APIs. such as deletePIT, deleteFIB, to the Name Tree if the above three steps are tedious.
Updated by Junxiao Shi almost 11 years ago
It's fine to have all necessary steps inside Pit::remove
method.
The caller (forwarding) only needs to call Pit::remove
.
Updated by Haowei Yuan almost 11 years ago
Got it. The other thing is do we want to have an Interest table (like CCNx does), which is indexed by the Interest (or full name, i.e., Name + selectors), and each hash bucket stores a pointer to the corresponding PIT Entry. Alternatively, the PIT lookup will be:
Lookup PIT Interest's Name in Name Tree (just 1 hash lookup with the full name without selectors), and get its Name Tree Entry
Get the list of PIT Interests from the Name Tree Entry and then compare and find the PIT Entry being queried.
Updated by Junxiao Shi almost 11 years ago
This is a trade-off between memory and lookup efficiency.
I think there won’t be lots of Interests with same Name but different Selectors, so I prefer not to have an Interest table.
Ultimately it’s assignee’s decision.
Updated by Haowei Yuan almost 11 years ago
Sure, I think we could leave this issue open for now, and consider it as an optimization option.
Updated by Haowei Yuan almost 11 years ago
Is the mock design for PIT/FIB/Measurement complete (i.e., could forward packets correctly)? If so, I would suggest to keep both the name-tree based implementation and the mock design in each PIT/FIB/Measurement function.
In each function, the results from these two implementations should be compared before it is returned. This way, we would be able to detect the bugs in the code easily. After the code becomes stable, we could remove the mock design code.
What do you think?
Updated by Junxiao Shi almost 11 years ago
Mock implementations are incomplete, and incorrect in some cases.
NameTree based implementation SHOULD replace mock implementations.
Correctness is guaranteed by unit testing.
Use caution when you need to modify or remove an existing test case.
Updated by Haowei Yuan over 10 years ago
Will InRecord and OutRecord be updated per packet? And when will they be modified? An example with Interest or Data packet will be really helpful. Thanks.
Updated by Junxiao Shi over 10 years ago
InRecord is updated in incoming Interest pipeline. OutRecord is updated in outgoing Interest pipeline. Both are updated per packet.
This task should not change any public fields of pit::Entry.
This task can add a pointer to name_tree::Entry inside pit::Entry, but such field shall be private, and NameTree can be made a friend.
Updated by Haowei Yuan over 10 years ago
So should the nonce value be checked for each Interest packet (in the insert function? )? or there are functions in other parts of the project that handles it.
If it is the first case, then the return value of the Pit::insert() function will need to be changed to cover the case that there is a nonce match.
Updated by Junxiao Shi over 10 years ago
Pit::insert should create pit::Entry according to Interest Name and Selectors. It should not add InRecord, and should not look at Nonce.
Updated by Haowei Yuan over 10 years ago
Another question about the pit::remove(shared_ptrpit::Entry) function:
Currently, to get the NameTree Entry (which implements the deletePitEntry() function), we need to get the given pit::Entry's name, and then perform a lookup on NameTree first. The reason is that the PIT Entry doesn't keep a pointer to the NameTree Entry. I am wondering if the future work will add some pointer there (such as Task #1202: shortcuts between FIB, PIT, Measurements), or it could be added now, i.e., a pointer to its NameTree Entry.
Currently, there is no return value for remove(), so is it guaranteed that the pit::Entry in the argument is always a valid one?
Updated by Haowei Yuan over 10 years ago
Just to add another question, in the PIT mock design, it seems that findAllDataMatches compares only Names, and Interest selectors are not used. Should we do the same thing for the NameTree-based coding?
Mock design:
shared_ptr<pit::DataMatchResult> result = make_shared<pit::DataMatchResult>();
for (std::list<shared_ptr<pit::Entry> >::const_iterator it = m_table.begin();
it != m_table.end(); ++it) {
shared_ptr<pit::Entry> entry = *it;
if (entry->getInterest().matchesName(data.getName())) {
result->push_back(entry);
}
}
return result;
Updated by Haowei Yuan over 10 years ago
- % Done changed from 0 to 80
I found it out, matchesName() actually handles selectors. : )
Updated by Junxiao Shi over 10 years ago
If you find it more convenient to work on #1202 concurrently, I have no objection. Suggested API is put in #1202.
Pit::remove
should be renamed to Pit::erase
per CodeStyle amended rule 26.
The argument must be valid, but you don't have to check whether it exists in PIT.
Interest::matchesName can process Selectors, but it cannot handle implicit digest correctly.
ndn-cpp-dev Bug #1298, when resolved, shall contain necessary functions to help implict digest handling here.
Updated by Haowei Yuan over 10 years ago
- Status changed from In Progress to Code review
Updated by Junxiao Shi over 10 years ago
- Status changed from Code review to Closed
- % Done changed from 80 to 100