Task #1349
closed
ndn-tlv-peek: simple consumer
Added by Junxiao Shi over 10 years ago.
Updated over 10 years ago.
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.
- 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.
- Status changed from New to In Progress
Development is 90% complete.
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];
- % Done changed from 0 to 90
Ignore Above Query. It works. Tried piping output to tlvdump and it shows expected output.
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());
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());
}
- 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!
- Status changed from Code review to Closed
Also available in: Atom
PDF