Task #1349
closedndn-tlv-peek: simple consumer
100%
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.
Updated by Junxiao Shi almost 11 years ago
- Priority changed from High to Urgent
Updated by Jerald Paul Abraham almost 11 years ago
- Status changed from New to In Progress
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];
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.
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());
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());
}
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!
Updated by Jerald Paul Abraham almost 11 years ago
- Status changed from Code review to Closed