Project

General

Profile

Actions

Task #4982

closed

Error in sending/receiving parameters in Interest using setApplicationParameters

Added by Ritik kumar over 5 years ago. Updated over 5 years ago.

Status:
Closed
Priority:
Urgent
Assignee:
-
Start date:
08/14/2019
Due date:
% Done:

0%

Estimated time:

Description

Trying to send an interest using the Java client, to a Cpp Server listening to the same prefix, I got the error,

ERROR: ParametersSha256DigestComponent does not match the SHA-256 of Interest parameters

This behaviour is observed when using the method interest.setApplicationParameters with non-empty Blob.

Meanwhile listening as a Java Server worked fine.


Files

Actions #1

Updated by Anonymous over 5 years ago

It looks like Cpp Server is written with ndn-cxx which is enforcing a check of the parameters.
Instead of setApplicationParameters, please try appendParametersDigestToName().
https://github.com/named-data/jndn/blob/master/src/net/named_data/jndn/Interest.java#L680

appendParametersDigestToName() was written according to the first spec of computing the Parameters digest. (From what I undersatand the spec is not finalized. I don't know which spec is used by your version of ndn-cxx.)

Actions #2

Updated by Ritik kumar over 5 years ago

I have used that here (uncomment!). But even after that, the error continues.
I have built the latest commit of ndn-cxx.

Actions #3

Updated by Anonymous over 5 years ago

There have been many changes to ndn-cxx for ApplicationParameters since the last release. I'm still waiting for the new digest calculation spec to be finalized.

In the mean time, can you call Interest::setAutoCheckParametersDigest(false) ?

https://github.com/named-data/ndn-cxx/blob/2b0cc7bf019ed60ef8094aba11db0ef1d7d2015b/ndn-cxx/interest.hpp#L369

Actions #4

Updated by Anonymous over 5 years ago

(Call it in the Cpp Server app which is throwing the error.)

Actions #5

Updated by Ritik kumar over 5 years ago

Thanks for the help, the Cpp server doesn't crash now but there's a new problem!
The received Block on the Cpp Server gets a size 2 more than that of the Blob sent from the Java Client. Consequently, this results in parsing errors. (I have updated the files on the link to print this difference)

Actions #6

Updated by Anonymous over 5 years ago

Can you please post the two different printouts so that I don't have to compile and run your code?

Actions #8

Updated by Anonymous over 5 years ago

Can you print the hex of the Received Block? I suspect that it is the entire TLV of the ApplicationParameters, including the type and length bytes 0x24 0x12. You need to use the correct ndn-cxx code to just get the value from the Received Block TLV.

Also, why do you use paramFromJson? The parameters are already encoded in a JSON string (of 16 bytes). You don't need to encode them again into a TLV. You can just put the JSON string as the value of the ApplicationParameters.

https://gist.github.com/dev-ritik/d5ba9ea2bbebad0a2bfd9cb0fe03bb0f#file-client-java-L27

Instead of

Blob blob = paramFromJson(jo.toString());

just use

Blob blob = new Blob(jo.toString().getBytes());
Actions #9

Updated by Ritik kumar over 5 years ago

Thanks for the prompt help, the error was fixed following what you suggested above.

Actions #10

Updated by Anonymous over 5 years ago

  • Status changed from New to Closed

You're welcome. Closing.

Actions

Also available in: Atom PDF