<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; color: rgb(0, 0, 0); font-size: 14px; font-family: Calibri, sans-serif;">
<div><span style="font-family: Calibri; font-size: medium;">Hello,</span></div>
<div><span style="font-family: Calibri; font-size: medium;"><br>
</span></div>
<span style="font-family: Calibri; font-size: medium;">           ByteBuffer contentBuffer = contentArr[i];</span><br style="font-family: Calibri; font-size: medium;">
<span style="font-family: Calibri; font-size: medium;">            contentBuffer.flip();</span><br style="font-family: Calibri; font-size: medium;">
<span style="font-family: Calibri; font-size: medium;">            Blob contentBlob = new Blob(contentBuffer.array());</span><br style="font-family: Calibri; font-size: medium;">
<span style="font-family: Calibri; font-size: medium;">            Name.Component nComp = new Name.Component(contentBlob);</span><br style="font-family: Calibri; font-size: medium;">
<div><span style="font-family: Calibri; font-size: medium;"><br>
</span></div>
<div><span style="font-family: Calibri; font-size: medium;">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 </span></div>
<div><a href="http://named-data.net/publications/techreports/ndn-tr-22-ndn-memo-naming-conventions" target="_blank">http://named-data.net/publications/techreports/ndn-tr-22-ndn-memo-naming-conventions</a>/</div>
<div><br>
</div>
<div>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.</div>
<div><br>
</div>
<div>Thanks,</div>
<div>- Jeff T</div>
<div><br>
</div>
<span id="OLK_SRC_BODY_SECTION">
<div style="font-family:Calibri; font-size:11pt; text-align:left; color:black; BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; PADDING-BOTTOM: 0in; PADDING-LEFT: 0in; PADDING-RIGHT: 0in; BORDER-TOP: #b5c4df 1pt solid; BORDER-RIGHT: medium none; PADDING-TOP: 3pt">
<span style="font-weight:bold">From: </span>Bassem Labib <<a href="mailto:bassem.labib@gmail.com">bassem.labib@gmail.com</a>><br>
<span style="font-weight:bold">Date: </span>Saturday, October 25, 2014 at 7:00 AM<br>
<span style="font-weight:bold">To: </span>"<a href="mailto:ndn-interest@lists.cs.ucla.edu">ndn-interest@lists.cs.ucla.edu</a>" <<a href="mailto:ndn-interest@lists.cs.ucla.edu">ndn-interest@lists.cs.ucla.edu</a>>, Jeff Thompson <<a href="mailto:jefft0@remap.ucla.edu">jefft0@remap.ucla.edu</a>><br>
<span style="font-weight:bold">Cc: </span>Steve DiBenedetto <<a href="mailto:dibenede@cs.colostate.edu">dibenede@cs.colostate.edu</a>><br>
<span style="font-weight:bold">Subject: </span>Re: [Ndn-interest] Send and Receive Video using jNDN Client<br>
</div>
<div><br>
</div>
<div>
<div>
<div dir="ltr">
<div>
<div>Hi Jeff,<br>
<br>
</div>
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.
<br>
<br>
how can I use a Data.setContent(Blob)?<br>
As the below code:</div>
<div><br>
public void onInterest(Name prefix, Interest interest, Transport transport,long registeredPrefixId)
<br>
    {<br>
        Name intrstName = interest.getName();<br>
</div>
        // Read the Video file and conver it to ByteBuffer.<br>
<div>        ByteBuffer[] contentArr = (new FileHandler()).readArray();<br>
        <br>
        for (int i = 0; i < contentArr.length; i++) <br>
        {<br>
            ByteBuffer contentBuffer = contentArr[i];<br>
            contentBuffer.flip();<br>
<br>
            Blob contentBlob = new Blob(contentBuffer.array());<br>
            Name.Component nComp = new Name.Component(contentBlob);<br>
            <br>
            long segment = -1;<br>
            try {<br>
                segment = nComp.toSegment();<br>
            } catch (EncodingException e) {<br>
                e.printStackTrace();<br>
            }<br>
            intrstName = intrstName.appendSegment(segment);<br>
        }    <br>
        <br>
        Data data =  new Data(intrstName);<br>
        //data = data.setContent(contentBlob);   <==== How To Use This<br>
        data.getMetaInfo().setTimestampMilliseconds(System.currentTimeMillis());<br>
       <br>
        try {<br>
            keyChain_.sign(data, certificateName_);<br>
            Blob encodedData = data.wireEncode();<br>
            transport.send(encodedData.buf());<br>
        } <br>
        catch (IOException | SecurityException ex) {<br>
            System.out.println("Echo: Exception: "+ ex.getMessage());<br>
        }<br>
    }<br>
<br>
<br>
<br>
public void onData(Interest interest, Data data)<br>
    {<br>
        ++callbackCount_;<br>
                <br>
        //ByteBuffer contentBuffer = data.getContent().buf();<br>
        <br>
        Name intrstName = interest.getName();<br>
        ByteBuffer[] contentBufferArr = new ByteBuffer[intrstName.size()];<br>
        for(int i=0; i < intrstName.size(); i++)<br>
        {<br>
            contentBufferArr[i] = intrstName.get(i).getValue().buf();<br>
        }<br>
        <br>
</div>
<div>        // Write the recieved data into a file.<br>
</div>
<div>        (new FileHandler()).writeArray(contentBufferArr);<br>
<br>
    }<br>
<br>
<br>
This code is not work properly, Please advise if there is other implementation for that issue.<br>
<div><br>
</div>
Thanks<br>
</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Fri, Oct 24, 2014 at 9:15 AM, Bassem Labib <span dir="ltr">
<<a href="mailto:bassem.labib@gmail.com" target="_blank">bassem.labib@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">
<div>Hi,<br>
<br>
</div>
Thanks, for your quick response, I will go through this document and try to implement segments solution.<br>
<br>
</div>
<div class="HOEnZb">
<div class="h5">
<div class="gmail_extra"><br>
<div class="gmail_quote">On Thu, Oct 23, 2014 at 7:27 PM, Thompson, Jeff <span dir="ltr">
<<a href="mailto:jefft0@remap.ucla.edu" target="_blank">jefft0@remap.ucla.edu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word;color:rgb(0,0,0);font-size:14px;font-family:Calibri,sans-serif">
<div>Hello,</div>
<div><br>
</div>
<div>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.</div>
<div><br>
</div>
<div>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":</div>
<div><a href="http://named-data.net/publications/techreports/ndn-tr-22-ndn-memo-naming-conventions" target="_blank">http://named-data.net/publications/techreports/ndn-tr-22-ndn-memo-naming-conventions</a>/</div>
<div><br>
</div>
<div>Adding and parsing segment markers in names is supported in jNDN with Name.appendSegment and Name.Component.toSegment.</div>
<div><a href="http://named-data.net/doc/ndn-ccl-api/name.html#name-appendsegment-method" target="_blank">http://named-data.net/doc/ndn-ccl-api/name.html#name-appendsegment-method</a></div>
<div><a href="http://named-data.net/doc/ndn-ccl-api/name-component.html#name-component-tosegment-method" target="_blank">http://named-data.net/doc/ndn-ccl-api/name-component.html#name-component-tosegment-method</a></div>
<div><br>
</div>
<div>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.</div>
<div><br>
</div>
<div>Thank you,</div>
<div>- Jeff T</div>
<div><br>
</div>
<span>
<div style="font-family:Calibri;font-size:11pt;text-align:left;color:black;BORDER-BOTTOM:medium none;BORDER-LEFT:medium none;PADDING-BOTTOM:0in;PADDING-LEFT:0in;PADDING-RIGHT:0in;BORDER-TOP:#b5c4df 1pt solid;BORDER-RIGHT:medium none;PADDING-TOP:3pt">
<span style="font-weight:bold">From: </span>Bassem Labib <<a href="mailto:bassem.labib@gmail.com" target="_blank">bassem.labib@gmail.com</a>><br>
<span style="font-weight:bold">Date: </span>Thursday, October 23, 2014 at 9:15 AM<br>
<span style="font-weight:bold">To: </span>"<a href="mailto:ndn-interest@lists.cs.ucla.edu" target="_blank">ndn-interest@lists.cs.ucla.edu</a>" <<a href="mailto:ndn-interest@lists.cs.ucla.edu" target="_blank">ndn-interest@lists.cs.ucla.edu</a>><br>
<span style="font-weight:bold">Subject: </span>[Ndn-interest] Send and Receive Video using jNDN Client<br>
</div>
<div>
<div>
<div><br>
</div>
<div>
<div>
<div dir="ltr">
<div>
<div>
<div>
<div>Hi,<br>
<br>
</div>
I am trying to send and receive a video file using jNDN Client.<br>
</div>
There is a limitation of the ByteBuffer with max 8K bytes only!!<br>
How can I extend it without receiving it in the onTimeout state.<br>
<br>
</div>
 Best Regards,<br>
</div>
Bassem Labib<br>
</div>
</div>
</div>
</div>
</div>
</span></div>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</span>
</body>
</html>