Project

General

Profile

Actions

Task #1194

closed

PIT on NameTree

Added by Junxiao Shi about 10 years ago. Updated about 10 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Tables
Target version:
Start date:
Due date:
% Done:

100%

Estimated time:
9.00 h

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.

Related issues 2 (0 open2 closed)

Blocks NFD - Task #1202: shortcuts between FIB, PIT, Measurements, StrategyChoiceClosedTian Song

Actions
Blocked by NFD - Task #1187: NameTreeClosedHaowei Yuan

Actions
Actions #1

Updated by Junxiao Shi about 10 years ago

  • Start date deleted (01/31/2014)
Actions #2

Updated by Junxiao Shi about 10 years ago

  • Assignee set to Haowei Yuan
Actions #3

Updated by Haowei Yuan about 10 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.

Actions #4

Updated by Junxiao Shi about 10 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.

Actions #5

Updated by Haowei Yuan about 10 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.

Actions #6

Updated by Junxiao Shi about 10 years ago

It's fine to have all necessary steps inside Pit::remove method.
The caller (forwarding) only needs to call Pit::remove.

Actions #7

Updated by Haowei Yuan about 10 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.

Actions #8

Updated by Junxiao Shi about 10 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.

Actions #9

Updated by Haowei Yuan about 10 years ago

Sure, I think we could leave this issue open for now, and consider it as an optimization option.

Actions #10

Updated by Haowei Yuan about 10 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?

Actions #11

Updated by Junxiao Shi about 10 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.

Actions #12

Updated by Junxiao Shi about 10 years ago

  • Description updated (diff)
Actions #13

Updated by Haowei Yuan about 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.

Actions #14

Updated by Junxiao Shi about 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.

Actions #15

Updated by Haowei Yuan about 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.

Actions #16

Updated by Junxiao Shi about 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.

Actions #17

Updated by Haowei Yuan about 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?

Actions #18

Updated by Haowei Yuan about 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;
Actions #19

Updated by Haowei Yuan about 10 years ago

  • % Done changed from 0 to 80

I found it out, matchesName() actually handles selectors. : )

Actions #20

Updated by Junxiao Shi about 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.

Actions #21

Updated by Haowei Yuan about 10 years ago

  • Status changed from In Progress to Code review
Actions #22

Updated by Junxiao Shi about 10 years ago

  • Status changed from Code review to Closed
  • % Done changed from 80 to 100
Actions

Also available in: Atom PDF