[Ndn-interest] Send and Receive Video using jNDN Client

Bassem Labib bassem.labib at gmail.com
Sat Oct 25 07:00:26 PDT 2014

Hi Jeff,

I got confused regarding segmenting the chunk file into the Name, and how
to use the Data object to send its content, and receive it from the other
side to be display.

how can I use a Data.setContent(Blob)?
As the below code:

public void onInterest(Name prefix, Interest interest, Transport
transport,long registeredPrefixId)
        Name intrstName = interest.getName();
        // Read the Video file and conver it to ByteBuffer.
        ByteBuffer[] contentArr = (new FileHandler()).readArray();

        for (int i = 0; i < contentArr.length; i++)
            ByteBuffer contentBuffer = contentArr[i];

            Blob contentBlob = new Blob(contentBuffer.array());
            Name.Component nComp = new Name.Component(contentBlob);

            long segment = -1;
            try {
                segment = nComp.toSegment();
            } catch (EncodingException e) {
            intrstName = intrstName.appendSegment(segment);

        Data data =  new Data(intrstName);
        //data = data.setContent(contentBlob);   <==== How To Use This


        try {
            keyChain_.sign(data, certificateName_);
            Blob encodedData = data.wireEncode();
        catch (IOException | SecurityException ex) {
            System.out.println("Echo: Exception: "+ ex.getMessage());

public void onData(Interest interest, Data data)

        //ByteBuffer contentBuffer = data.getContent().buf();

        Name intrstName = interest.getName();
        ByteBuffer[] contentBufferArr = new ByteBuffer[intrstName.size()];
        for(int i=0; i < intrstName.size(); i++)
            contentBufferArr[i] = intrstName.get(i).getValue().buf();

        // Write the recieved data into a file.
        (new FileHandler()).writeArray(contentBufferArr);


This code is not work properly, Please advise if there is other
implementation for that issue.


On Fri, Oct 24, 2014 at 9:15 AM, Bassem Labib <bassem.labib at gmail.com>

> Hi,
> Thanks, for your quick response, I will go through this document and try
> to implement segments solution.
> On Thu, Oct 23, 2014 at 7:27 PM, Thompson, Jeff <jefft0 at remap.ucla.edu>
> wrote:
>>  Hello,
>>  I'm a little confused. The Java ByteBuffer doesn't have a limit of 8K
>> bytes.  Do you mean a limit on the size of an NDN data packet?  The NDN
>> data packet has a max size of 8800 (including content, signature, etc.)
>>  This is due to network MTU size.  NDN handles this by dividing a file into
>> segments.
>>  Before I explain more, are you familiar with NDN segments and how NDN
>> names segments?  These are described in section 3.2 of "NDN Technical Memo:
>> Naming Conventions":
>> http://named-data.net/publications/techreports/ndn-tr-22-ndn-memo-naming-conventions
>> /
>>  Adding and parsing segment markers in names is supported in jNDN
>> with Name.appendSegment and Name.Component.toSegment.
>> http://named-data.net/doc/ndn-ccl-api/name.html#name-appendsegment-method
>> http://named-data.net/doc/ndn-ccl-api/name-component.html#name-component-tosegment-method
>>  Other than supporing segments in names, jNDN does not yet have a
>> utility to automatically send a file in segments or fetch a file with
>> segments. This is a planned future higher-level API.  For now, the
>> application must divide the file into segments and create names that have a
>> segment marker.  In practice, each application may want to handle this
>> differently. For example a real-time streaming video application may want
>> to drop segments if the network does not deliver them.  But with a file
>> transfer application, the appilcation may want to repeatedly try to fetch a
>> segment if the fetch times out.
>>  Thank you,
>> - Jeff T
>>   From: Bassem Labib <bassem.labib at gmail.com>
>> Date: Thursday, October 23, 2014 at 9:15 AM
>> To: "ndn-interest at lists.cs.ucla.edu" <ndn-interest at lists.cs.ucla.edu>
>> Subject: [Ndn-interest] Send and Receive Video using jNDN Client
>>     Hi,
>>  I am trying to send and receive a video file using jNDN Client.
>>  There is a limitation of the ByteBuffer with max 8K bytes only!!
>> How can I extend it without receiving it in the onTimeout state.
>>   Best Regards,
>>  Bassem Labib
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.lists.cs.ucla.edu/pipermail/ndn-interest/attachments/20141025/66516e04/attachment.html>

More information about the Ndn-interest mailing list