Project

General

Profile

Actions

Task #1349

closed

ndn-tlv-peek: simple consumer

Added by Junxiao Shi almost 11 years ago. Updated almost 11 years ago.

Status:
Closed
Priority:
Urgent
Category:
Tools
Target version:
Start date:
Due date:
% Done:

100%

Estimated time:
2.00 h

Description

Develop a simple consumer program that sends one Interest and expects one response.

ndn-tlv-peek [-f] [-r] [-m min] [-M max] [-l lifetime] [-p] [-w timeout] ndn:/name
  Get one Data item matching the name prefix and write it to stdout
  -f set MustBeFresh
  -r set ChildSelector=rightmost
  -m set MinSuffixComponents
  -M set MaxSuffixComponents
  -l set InterestLifetime in milliseconds
  -p payload only, not full packet
  -w timeout in milliseconds

The full Data packet (in TLV format) is written to stdout (it's intended to be processed by tlvdump).

If -p is specified, write just the payload (value of Content element).

The program terminates with return code 0 if Data arrives, or terminates with return code 1 on timeout.

Timeout is specified with -w. If -w is missing, use InterestLifetime as timeout.

Actions #1

Updated by Junxiao Shi almost 11 years ago

  • Priority changed from High to Urgent

This tool is needed for testing #1245 #1192 #1199.

I have sent an email to @Jerald asking him to start working on this task.

Actions #2

Updated by Jerald Paul Abraham almost 11 years ago

  • Status changed from New to In Progress
Actions #3

Updated by Jerald Paul Abraham almost 11 years ago

Development is 90% complete.

Actions #4

Updated by Jerald Paul Abraham almost 11 years ago

Is this the correct way print the data packet content to standard output in TLV format:

  ndn::Block block;
  size_t bufferSize;
  const uint8_t* buffer;

  //Here data is of type ndn::data
  block = data.getContent();
  buffer = block.wire();
  bufferSize = block.size();

  for (int i=0; i<bufferSize; i++)
    std::cout << (char)buffer[i];
Actions #5

Updated by Jerald Paul Abraham almost 11 years ago

  • % Done changed from 0 to 90

Ignore Above Query. It works. Tried piping output to tlvdump and it shows expected output.

Actions #6

Updated by Alex Afanasyev almost 11 years ago

To dump the whole data packet

std::cout.write((const char*)block.wire(), block.size())

When dumping content of the Data packet, there will be a small difference

Data data;
const Block& block = data.getContent();
std::cout.write((const char*)block.value(), block.value_size());
Actions #7

Updated by Junxiao Shi almost 11 years ago

Code in note-4 is incorrect and inefficient.

Code in note-6 violates CodeStyle amended rule 44.

if (isPayloadOnly) {
  Block payload = data.getContent();
  write(1, payload.value(), payload.value_size());
}
else {
  Block wire = data.wireEncode();
  write(1, wire.wire(), wire.size());
}
Actions #8

Updated by Jerald Paul Abraham almost 11 years ago

  • Status changed from In Progress to Code review
  • % Done changed from 90 to 100

Thanks guys. I have changed code as per Alex's suggestion and tested it. Works great!

Actions #9

Updated by Jerald Paul Abraham almost 11 years ago

  • Status changed from Code review to Closed
Actions

Also available in: Atom PDF