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

Thompson, Jeff jefft0 at remap.ucla.edu
Mon Oct 27 11:54:58 PDT 2014


Hello,

           ByteBuffer contentBuffer = contentArr[i];
            contentBuffer.flip();
            Blob contentBlob = new Blob(contentBuffer.array());
            Name.Component nComp = new Name.Component(contentBlob);

What is in contentArr?  The "segment" that goes in a Name component is just an integer for the number of the segment, starting from 0. (It is not the segment data itself.) In the name component, these are encoded as a short byte array. As described in
http://named-data.net/publications/techreports/ndn-tr-22-ndn-memo-naming-conventions/

The name has the segment number. This is the name of a data packet, where the content is the actual bytes for the segment of the file.

Thanks,
- Jeff T

From: Bassem Labib <bassem.labib at gmail.com<mailto:bassem.labib at gmail.com>>
Date: Saturday, October 25, 2014 at 7:00 AM
To: "ndn-interest at lists.cs.ucla.edu<mailto:ndn-interest at lists.cs.ucla.edu>" <ndn-interest at lists.cs.ucla.edu<mailto:ndn-interest at lists.cs.ucla.edu>>, Jeff Thompson <jefft0 at remap.ucla.edu<mailto:jefft0 at remap.ucla.edu>>
Cc: Steve DiBenedetto <dibenede at cs.colostate.edu<mailto:dibenede at cs.colostate.edu>>
Subject: Re: [Ndn-interest] Send and Receive Video using jNDN Client

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];
            contentBuffer.flip();

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

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

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

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



public void onData(Interest interest, Data data)
    {
        ++callbackCount_;

        //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.

Thanks

On Fri, Oct 24, 2014 at 9:15 AM, Bassem Labib <bassem.labib at gmail.com<mailto:bassem.labib at gmail.com>> wrote:
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<mailto: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<mailto:bassem.labib at gmail.com>>
Date: Thursday, October 23, 2014 at 9:15 AM
To: "ndn-interest at lists.cs.ucla.edu<mailto:ndn-interest at lists.cs.ucla.edu>" <ndn-interest at lists.cs.ucla.edu<mailto: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/20141027/4f5b76ec/attachment.html>


More information about the Ndn-interest mailing list