<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> <title>DTN Reference Implementation: FragmentManager.h Source File</title> <link href="doxygen.css" rel="stylesheet" type="text/css"> <link href="tabs.css" rel="stylesheet" type="text/css"> </head><body> <!-- Generated by Doxygen 1.5.6 --> <div class="navigation" id="top"> <div class="tabs"> <ul> <li><a href="main.html"><span>Main Page</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li><a href="annotated.html"><span>Classes</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> </ul> </div> <h1>FragmentManager.h</h1><a href="FragmentManager_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span> <a name="l00002"></a>00002 <span class="comment"> * Copyright 2004-2006 Intel Corporation</span> <a name="l00003"></a>00003 <span class="comment"> * </span> <a name="l00004"></a>00004 <span class="comment"> * Licensed under the Apache License, Version 2.0 (the "License");</span> <a name="l00005"></a>00005 <span class="comment"> * you may not use this file except in compliance with the License.</span> <a name="l00006"></a>00006 <span class="comment"> * You may obtain a copy of the License at</span> <a name="l00007"></a>00007 <span class="comment"> * </span> <a name="l00008"></a>00008 <span class="comment"> * http://www.apache.org/licenses/LICENSE-2.0</span> <a name="l00009"></a>00009 <span class="comment"> * </span> <a name="l00010"></a>00010 <span class="comment"> * Unless required by applicable law or agreed to in writing, software</span> <a name="l00011"></a>00011 <span class="comment"> * distributed under the License is distributed on an "AS IS" BASIS,</span> <a name="l00012"></a>00012 <span class="comment"> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</span> <a name="l00013"></a>00013 <span class="comment"> * See the License for the specific language governing permissions and</span> <a name="l00014"></a>00014 <span class="comment"> * limitations under the License.</span> <a name="l00015"></a>00015 <span class="comment"> */</span> <a name="l00016"></a>00016 <a name="l00017"></a>00017 <span class="preprocessor">#ifndef __FRAGMENT_MANAGER_H__</span> <a name="l00018"></a>00018 <span class="preprocessor"></span><span class="preprocessor">#define __FRAGMENT_MANAGER_H__</span> <a name="l00019"></a>00019 <span class="preprocessor"></span> <a name="l00020"></a>00020 <span class="preprocessor">#include <string></span> <a name="l00021"></a>00021 <span class="preprocessor">#include <oasys/debug/Log.h></span> <a name="l00022"></a>00022 <span class="preprocessor">#include <oasys/util/StringUtils.h></span> <a name="l00023"></a>00023 <a name="l00024"></a>00024 <span class="keyword">namespace </span>oasys { <a name="l00025"></a>00025 <span class="keyword">class </span>SpinLock; <a name="l00026"></a>00026 } <a name="l00027"></a>00027 <a name="l00028"></a>00028 <span class="keyword">namespace </span>dtn { <a name="l00029"></a>00029 <a name="l00030"></a>00030 <span class="keyword">class </span>Link; <a name="l00031"></a>00031 <span class="keyword">class </span>Bundle; <a name="l00032"></a>00032 <span class="keyword">class </span>BundleList; <a name="l00033"></a>00033 <span class="keyword">class </span>BlockInfoVec; <a name="l00034"></a>00034 <span class="keyword">class </span>FragmentState; <a name="l00035"></a>00035 <span class="keyword">class </span>BlockInfoPointerList; <a name="l00036"></a>00036 <a name="l00037"></a>00037 <span class="comment">// XXX/demmer should change the overall flow of the reassembly so all</span> <a name="l00038"></a>00038 <span class="comment">// arriving bundle fragments are enqueued onto the appropriate</span> <a name="l00039"></a>00039 <span class="comment">// reassembly state list immediately -- in fact all the fragmentation</span> <a name="l00040"></a>00040 <span class="comment">// and reassembly stuff needs rework</span> <a name="l00041"></a>00041 <a name="l00049"></a><a class="code" href="classdtn_1_1FragmentManager.html">00049</a> <span class="keyword">class </span><a class="code" href="classdtn_1_1FragmentManager.html" title="The Fragment Manager maintains state for all of the fragmentary bundles, reconstructing...">FragmentManager</a> : <span class="keyword">public</span> oasys::<a class="code" href="classoasys_1_1Logger.html">Logger</a> { <a name="l00050"></a>00050 <span class="keyword">public</span>: <a name="l00054"></a>00054 <a class="code" href="classdtn_1_1FragmentManager.html#694dece64b76aaddff128b23e3c5a06f" title="Constructor.">FragmentManager</a>(); <a name="l00055"></a>00055 <a name="l00075"></a>00075 <a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>* <a class="code" href="classdtn_1_1FragmentManager.html#f6f29fb926b821b27d8d6cda64ffa96a" title="Create a bundle fragment from another bundle.">create_fragment</a>(<a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>* bundle, <a name="l00076"></a>00076 <a class="code" href="classdtn_1_1BlockInfoVec.html" title="Class for a vector of BlockInfo structures.">BlockInfoVec</a>* blocks, <a name="l00077"></a>00077 <span class="keywordtype">size_t</span> offset, <a name="l00078"></a>00078 <span class="keywordtype">size_t</span> length); <a name="l00079"></a>00079 <a name="l00083"></a>00083 <a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>* <a class="code" href="classdtn_1_1FragmentManager.html#f6f29fb926b821b27d8d6cda64ffa96a" title="Create a bundle fragment from another bundle.">create_fragment</a>(<a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>* bundle, <a name="l00084"></a>00084 <span class="keyword">const</span> <a class="code" href="namespacedtn.html#6efb37e503f8062c537b022eb755b94e" title="Typedef for a reference on a link.">LinkRef</a>& link, <a name="l00085"></a>00085 <span class="keyword">const</span> <a class="code" href="classdtn_1_1BlockInfoPointerList.html">BlockInfoPointerList</a>& blocks_to_copy, <a name="l00086"></a>00086 <span class="keywordtype">size_t</span> offset, <a name="l00087"></a>00087 <span class="keywordtype">size_t</span> length); <a name="l00088"></a>00088 <a name="l00095"></a>00095 <span class="keywordtype">void</span> <a class="code" href="classdtn_1_1FragmentManager.html#78e055f146c81f00cb1a0a82324cd585" title="Turn a bundle into a fragment.">convert_to_fragment</a>(<a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>* bundle, <span class="keywordtype">size_t</span> length); <a name="l00096"></a>00096 <a name="l00106"></a>00106 <a class="code" href="classdtn_1_1FragmentState.html">FragmentState</a>* <a class="code" href="classdtn_1_1FragmentManager.html#fbc6aa92f31a9e8a72cadb302e9c8a54" title="Given the given fragmentation threshold, determine whether the given bundle should...">proactively_fragment</a>(<a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>* bundle, <a name="l00107"></a>00107 <span class="keyword">const</span> <a class="code" href="namespacedtn.html#6efb37e503f8062c537b022eb755b94e" title="Typedef for a reference on a link.">LinkRef</a>& link, <a name="l00108"></a>00108 <span class="keywordtype">size_t</span> max_length); <a name="l00109"></a>00109 <a name="l00110"></a>00110 <a class="code" href="classdtn_1_1FragmentState.html">FragmentState</a>* <a class="code" href="classdtn_1_1FragmentManager.html#6d648fcee877721cf9e6448b24641246">get_fragment_state</a>(<a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>* bundle); <a name="l00111"></a>00111 <a name="l00112"></a>00112 <span class="keywordtype">void</span> <a class="code" href="classdtn_1_1FragmentManager.html#1e7b45257f6281030c8fe71fa2f809db">erase_fragment_state</a>(<a class="code" href="classdtn_1_1FragmentState.html">FragmentState</a>* fragment); <a name="l00113"></a>00113 <a name="l00120"></a>00120 <span class="keywordtype">bool</span> <a class="code" href="classdtn_1_1FragmentManager.html#2f9394ef9f40337b95fed1f6cca381ac" title="If only part of the given bundle was sent successfully, split it into two.">try_to_reactively_fragment</a>(<a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>* bundle, <a class="code" href="classdtn_1_1BlockInfoVec.html" title="Class for a vector of BlockInfo structures.">BlockInfoVec</a> *blocks, <a name="l00121"></a>00121 <span class="keywordtype">size_t</span> bytes_sent); <a name="l00122"></a>00122 <a name="l00128"></a>00128 <span class="keywordtype">bool</span> <a class="code" href="classdtn_1_1FragmentManager.html#d3a2b8e4ecd2838da9caee845f47dccb" title="Convert a partially received bundle into a fragment.">try_to_convert_to_fragment</a>(<a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>* bundle); <a name="l00129"></a>00129 <a name="l00136"></a>00136 <span class="keywordtype">void</span> <a class="code" href="classdtn_1_1FragmentManager.html#06ba9686e9d9a7fca8cdc31c3ffca187" title="Given a newly arrived bundle fragment, append it to the table of fragments and see...">process_for_reassembly</a>(<a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>* fragment); <a name="l00137"></a>00137 <a name="l00141"></a>00141 <span class="keywordtype">void</span> <a class="code" href="classdtn_1_1FragmentManager.html#900e9f477dc6ff5aac6cd6621daf04d9" title="Delete any fragments that are no longer needed given the incoming (non-fragment)...">delete_obsoleted_fragments</a>(<a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>* fragment); <a name="l00142"></a>00142 <a name="l00146"></a>00146 <span class="keywordtype">void</span> <a class="code" href="classdtn_1_1FragmentManager.html#3cf63b648553dda12d36e0f05d17380e" title="Delete reassembly state for a bundle.">delete_fragment</a>(<a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>* fragment); <a name="l00147"></a>00147 <a name="l00148"></a>00148 <span class="keyword">protected</span>: <a name="l00152"></a>00152 <span class="keywordtype">void</span> <a class="code" href="classdtn_1_1FragmentManager.html#14e6759dca799277da24a3425274d9f9" title="Calculate a hash table key from a bundle.">get_hash_key</a>(<span class="keyword">const</span> <a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>*, std::string* key); <a name="l00153"></a>00153 <a name="l00157"></a>00157 <span class="comment">//bool check_completed(FragmentState* state);</span> <a name="l00158"></a>00158 <a name="l00160"></a><a class="code" href="classdtn_1_1FragmentManager.html#a89f7eb445d19fa240f69b36b4ee89e4">00160</a> <span class="keyword">typedef</span> oasys::StringHashMap<FragmentState*> <a class="code" href="classdtn_1_1FragmentManager.html#a89f7eb445d19fa240f69b36b4ee89e4" title="Check if the bundle has been completely reassembled.">FragmentTable</a>; <a name="l00161"></a><a class="code" href="classdtn_1_1FragmentManager.html#c16a79e94b6eb8ac6aeed3f52752022b">00161</a> <a class="code" href="classdtn_1_1FragmentManager.html#a89f7eb445d19fa240f69b36b4ee89e4" title="Check if the bundle has been completely reassembled.">FragmentTable</a> <a class="code" href="classdtn_1_1FragmentManager.html#c16a79e94b6eb8ac6aeed3f52752022b">fragment_table_</a>; <a name="l00162"></a>00162 }; <a name="l00163"></a>00163 <a name="l00164"></a>00164 } <span class="comment">// namespace dtn</span> <a name="l00165"></a>00165 <a name="l00166"></a>00166 <span class="preprocessor">#endif </span><span class="comment">/* __FRAGMENT_MANAGER_H__ */</span> </pre></div></div> <hr size="1"><address style="text-align: right;"><small>Generated on Mon Jul 21 14:09:45 2008 for DTN Reference Implementation by <a href="http://www.doxygen.org/index.html"> <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.6 </small></address> </body> </html>