PageRenderTime 55ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 1ms

/OverSim-20101103/doc/doxy/BaseOverlay_8cc_source.html

https://bitbucket.org/indigopony/omnetproject
HTML | 2094 lines | 2093 code | 0 blank | 1 comment | 0 complexity | f753b4e198ec6916bd8c6dc7bce47050 MD5 | raw file
Possible License(s): BSD-3-Clause, AGPL-1.0, GPL-2.0, Apache-2.0, JSON
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
  5. <title>OverSim: BaseOverlay.cc Source File</title>
  6. <link href="tabs.css" rel="stylesheet" type="text/css"/>
  7. <link href="doxygen.css" rel="stylesheet" type="text/css"/>
  8. </head>
  9. <body>
  10. <!-- Generated by Doxygen 1.7.1 -->
  11. <div class="navigation" id="top">
  12. <div class="tabs">
  13. <ul class="tablist">
  14. <li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
  15. <li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
  16. <li><a href="namespaces.html"><span>Namespaces</span></a></li>
  17. <li><a href="annotated.html"><span>Classes</span></a></li>
  18. <li class="current"><a href="files.html"><span>Files</span></a></li>
  19. <li><a href="dirs.html"><span>Directories</span></a></li>
  20. </ul>
  21. </div>
  22. <div class="tabs2">
  23. <ul class="tablist">
  24. <li><a href="files.html"><span>File&nbsp;List</span></a></li>
  25. <li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
  26. </ul>
  27. </div>
  28. <div class="navpath">
  29. <ul>
  30. <li><a class="el" href="dir_668dee661430860db5868c2621a9c372.html">src</a> </li>
  31. <li><a class="el" href="dir_c6e45067cd9ed30d67160903d22a8d0a.html">common</a> </li>
  32. </ul>
  33. </div>
  34. </div>
  35. <div class="header">
  36. <div class="headertitle">
  37. <h1>BaseOverlay.cc</h1> </div>
  38. </div>
  39. <div class="contents">
  40. <a href="BaseOverlay_8cc.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">//</span>
  41. <a name="l00002"></a>00002 <span class="comment">// Copyright (C) 2006 Institut fuer Telematik, Universitaet Karlsruhe (TH)</span>
  42. <a name="l00003"></a>00003 <span class="comment">//</span>
  43. <a name="l00004"></a>00004 <span class="comment">// This program is free software; you can redistribute it and/or</span>
  44. <a name="l00005"></a>00005 <span class="comment">// modify it under the terms of the GNU General Public License</span>
  45. <a name="l00006"></a>00006 <span class="comment">// as published by the Free Software Foundation; either version 2</span>
  46. <a name="l00007"></a>00007 <span class="comment">// of the License, or (at your option) any later version.</span>
  47. <a name="l00008"></a>00008 <span class="comment">//</span>
  48. <a name="l00009"></a>00009 <span class="comment">// This program is distributed in the hope that it will be useful,</span>
  49. <a name="l00010"></a>00010 <span class="comment">// but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
  50. <a name="l00011"></a>00011 <span class="comment">// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
  51. <a name="l00012"></a>00012 <span class="comment">// GNU General Public License for more details.</span>
  52. <a name="l00013"></a>00013 <span class="comment">//</span>
  53. <a name="l00014"></a>00014 <span class="comment">// You should have received a copy of the GNU General Public License</span>
  54. <a name="l00015"></a>00015 <span class="comment">// along with this program; if not, write to the Free Software</span>
  55. <a name="l00016"></a>00016 <span class="comment">// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.</span>
  56. <a name="l00017"></a>00017 <span class="comment">//</span>
  57. <a name="l00018"></a>00018
  58. <a name="l00028"></a>00028 <span class="preprocessor">#include &lt;cassert&gt;</span>
  59. <a name="l00029"></a>00029
  60. <a name="l00030"></a>00030 <span class="preprocessor">#include &lt;<a class="code" href="RpcMacros_8h.html" title="This file declares some macros for RPC implementation.">RpcMacros.h</a>&gt;</span>
  61. <a name="l00031"></a>00031
  62. <a name="l00032"></a>00032 <span class="preprocessor">#include &lt;UDPAppBase.h&gt;</span>
  63. <a name="l00033"></a>00033 <span class="preprocessor">#include &lt;UDPSocket.h&gt;</span>
  64. <a name="l00034"></a>00034 <span class="preprocessor">#include &lt;IPAddressResolver.h&gt;</span>
  65. <a name="l00035"></a>00035 <span class="preprocessor">#include &lt;NotificationBoard.h&gt;</span>
  66. <a name="l00036"></a>00036
  67. <a name="l00037"></a>00037 <span class="preprocessor">#include &lt;<a class="code" href="GlobalNodeListAccess_8h.html">GlobalNodeListAccess.h</a>&gt;</span>
  68. <a name="l00038"></a>00038 <span class="preprocessor">#include &lt;<a class="code" href="UnderlayConfiguratorAccess_8h.html">UnderlayConfiguratorAccess.h</a>&gt;</span>
  69. <a name="l00039"></a>00039 <span class="preprocessor">#include &lt;<a class="code" href="GlobalStatisticsAccess_8h.html">GlobalStatisticsAccess.h</a>&gt;</span>
  70. <a name="l00040"></a>00040 <span class="preprocessor">#include &lt;<a class="code" href="GlobalParametersAccess_8h.html">GlobalParametersAccess.h</a>&gt;</span>
  71. <a name="l00041"></a>00041
  72. <a name="l00042"></a>00042 <span class="preprocessor">#include &lt;<a class="code" href="LookupListener_8h.html">LookupListener.h</a>&gt;</span>
  73. <a name="l00043"></a>00043 <span class="preprocessor">#include &lt;<a class="code" href="RecursiveLookup_8h.html">RecursiveLookup.h</a>&gt;</span>
  74. <a name="l00044"></a>00044 <span class="preprocessor">#include &lt;<a class="code" href="IterativeLookup_8h.html">IterativeLookup.h</a>&gt;</span>
  75. <a name="l00045"></a>00045
  76. <a name="l00046"></a>00046 <span class="preprocessor">#include &lt;<a class="code" href="BootstrapList_8h.html">BootstrapList.h</a>&gt;</span>
  77. <a name="l00047"></a>00047
  78. <a name="l00048"></a>00048 <span class="preprocessor">#include &quot;<a class="code" href="BaseOverlay_8h.html">BaseOverlay.h</a>&quot;</span>
  79. <a name="l00049"></a>00049
  80. <a name="l00050"></a>00050 <span class="keyword">using namespace </span>std;
  81. <a name="l00051"></a>00051
  82. <a name="l00052"></a>00052
  83. <a name="l00053"></a>00053 <span class="comment">//------------------------------------------------------------------------</span>
  84. <a name="l00054"></a>00054 <span class="comment">//--- Initialization &amp; finishing -----------------------------------------</span>
  85. <a name="l00055"></a>00055 <span class="comment">//------------------------------------------------------------------------</span>
  86. <a name="l00056"></a>00056
  87. <a name="l00057"></a><a class="code" href="classBaseOverlay.html#a9d3fd0a833ef00d1a739ced007469505">00057</a> <a class="code" href="classBaseOverlay.html#a9d3fd0a833ef00d1a739ced007469505">BaseOverlay::BaseOverlay</a>()
  88. <a name="l00058"></a>00058 {
  89. <a name="l00059"></a>00059 <a class="code" href="classBaseOverlay.html#a933e505ea77cae4ab0c8edcb77ade2c7" title="pointer to GlobalNodeList in this node">globalNodeList</a> = NULL;
  90. <a name="l00060"></a>00060 <a class="code" href="classBaseOverlay.html#af2f7102d7cc6f5ecb1c3ecb3d9c93df3" title="pointer to UnderlayConfigurator in this node">underlayConfigurator</a> = NULL;
  91. <a name="l00061"></a>00061 <a class="code" href="classBaseOverlay.html#af0704186e295039c92666176b0b91dae" title="pointer to NotificationBoard in this node">notificationBoard</a> = NULL;
  92. <a name="l00062"></a>00062 <a class="code" href="classBaseOverlay.html#a59bde2858b8537864fbad3eb487dbc55" title="pointer to the GlobalParameters module">globalParameters</a> = NULL;
  93. <a name="l00063"></a>00063 <a class="code" href="classBaseOverlay.html#abe4dea93564123116c97d5c4721f0504" title="pointer to the BootstrapList module">bootstrapList</a> = NULL;
  94. <a name="l00064"></a>00064 }
  95. <a name="l00065"></a>00065
  96. <a name="l00066"></a><a class="code" href="classBaseOverlay.html#a4fd9da1c26016b59e19ac0ca938ba312">00066</a> <a class="code" href="classBaseOverlay.html#a4fd9da1c26016b59e19ac0ca938ba312" title="Virtual destructor.">BaseOverlay::~BaseOverlay</a>()
  97. <a name="l00067"></a>00067 {
  98. <a name="l00068"></a>00068 <a class="code" href="classBaseOverlay.html#abaaca6fe44d8e317d56c90a14e0fcada" title="deletes entries in lookups">finishLookups</a>();
  99. <a name="l00069"></a>00069 <a class="code" href="classBaseRpc.html#a02b90067d0a0b630baca5808d7f82b5a" title="Deinitializes Remote-Procedure state.">finishRpcs</a>();
  100. <a name="l00070"></a>00070 }
  101. <a name="l00071"></a>00071
  102. <a name="l00072"></a><a class="code" href="classBaseOverlay.html#a3234dfcf81463984e88a42432734a615">00072</a> <span class="keywordtype">int</span> <a class="code" href="classBaseOverlay.html#a3234dfcf81463984e88a42432734a615" title="Sets init stage.">BaseOverlay::numInitStages</a>()<span class="keyword"> const</span>
  103. <a name="l00073"></a>00073 <span class="keyword"></span>{
  104. <a name="l00074"></a>00074 <span class="keywordflow">return</span> NUM_STAGES_ALL;
  105. <a name="l00075"></a>00075 }
  106. <a name="l00076"></a>00076
  107. <a name="l00077"></a><a class="code" href="classBaseOverlay.html#a9738ba6065b0f699f1921bbe82ab97be">00077</a> <span class="keywordtype">void</span> <a class="code" href="classBaseOverlay.html#a9738ba6065b0f699f1921bbe82ab97be" title="initializes base-class-attributes">BaseOverlay::initialize</a>(<span class="keywordtype">int</span> stage)
  108. <a name="l00078"></a>00078 {
  109. <a name="l00079"></a>00079 <span class="keywordflow">if</span> (stage == 0) {
  110. <a name="l00080"></a>00080 <a class="code" href="classOverlayKey.html#a4d1b67c81853679686ed8f9d52bade16" title="Set the length of an OverlayKey.">OverlayKey::setKeyLength</a>(par(<span class="stringliteral">&quot;keyLength&quot;</span>));
  111. <a name="l00081"></a>00081 }
  112. <a name="l00082"></a>00082
  113. <a name="l00083"></a>00083 <span class="keywordflow">if</span> (stage == <a class="code" href="InitStages_8h.html#a42fde1aa1e14a1c45d29061d6e87e532af7318a654ca995f5f66f3396e4ebf61a">REGISTER_STAGE</a>) {
  114. <a name="l00084"></a>00084 <a class="code" href="classBaseOverlay.html#a2096f89814b5740257cee106b60dda15">registerComp</a>(<a class="code" href="classBaseOverlay.html#a92e0d3f96a5716245465e05da60ef487">getThisCompType</a>(), <span class="keyword">this</span>);
  115. <a name="l00085"></a>00085 <span class="keywordflow">return</span>;
  116. <a name="l00086"></a>00086 }
  117. <a name="l00087"></a>00087
  118. <a name="l00088"></a>00088 <span class="keywordflow">if</span> (stage == <a class="code" href="InitStages_8h.html#a42fde1aa1e14a1c45d29061d6e87e532a58e83c497c7c8495e9c592ff3148b6b9" title="first stage for overlay modules (Tier 0 / KBR)">MIN_STAGE_OVERLAY</a>) {
  119. <a name="l00089"></a>00089 <span class="comment">// find friend modules</span>
  120. <a name="l00090"></a>00090 <a class="code" href="classBaseOverlay.html#a933e505ea77cae4ab0c8edcb77ade2c7" title="pointer to GlobalNodeList in this node">globalNodeList</a> = <a class="code" href="classGlobalNodeListAccess.html" title="Gives access to the GlobalNodeList.">GlobalNodeListAccess</a>().get();
  121. <a name="l00091"></a>00091 <a class="code" href="classBaseOverlay.html#af2f7102d7cc6f5ecb1c3ecb3d9c93df3" title="pointer to UnderlayConfigurator in this node">underlayConfigurator</a> = <a class="code" href="classUnderlayConfiguratorAccess.html" title="Gives access to the UnderlayConfigurator.">UnderlayConfiguratorAccess</a>().get();
  122. <a name="l00092"></a>00092 <a class="code" href="classBaseOverlay.html#af0704186e295039c92666176b0b91dae" title="pointer to NotificationBoard in this node">notificationBoard</a> = NotificationBoardAccess().get();
  123. <a name="l00093"></a>00093 <a class="code" href="classBaseOverlay.html#a59bde2858b8537864fbad3eb487dbc55" title="pointer to the GlobalParameters module">globalParameters</a> = <a class="code" href="classGlobalParametersAccess.html" title="Gives access to the GlobalParameters module.">GlobalParametersAccess</a>().get();
  124. <a name="l00094"></a>00094 <a class="code" href="classBaseOverlay.html#abe4dea93564123116c97d5c4721f0504" title="pointer to the BootstrapList module">bootstrapList</a> = check_and_cast&lt;<a class="code" href="classBootstrapList.html" title="The BootstrapList module maintains a list of bootstrap node candidates.">BootstrapList</a>*&gt;(getParentModule()-&gt;
  125. <a name="l00095"></a>00095 getParentModule()-&gt;getSubmodule(<span class="stringliteral">&quot;bootstrapList&quot;</span>, 0));
  126. <a name="l00096"></a>00096
  127. <a name="l00097"></a>00097 <a class="code" href="classBaseOverlay.html#a2e2f70aa82a9b4920877b3a13dd1e0ea">udpGate</a> = gate(<span class="stringliteral">&quot;udpIn&quot;</span>);
  128. <a name="l00098"></a>00098 <a class="code" href="classBaseOverlay.html#a6523faf8f52af34c73643dc7f3e083eb">appGate</a> = gate(<span class="stringliteral">&quot;appIn&quot;</span>);
  129. <a name="l00099"></a>00099
  130. <a name="l00100"></a>00100 <span class="comment">// fetch some parameters</span>
  131. <a name="l00101"></a>00101 <a class="code" href="classBaseOverlay.html#a49ff0fb8c25792a1339d54a60c36f2cd" title="debug output ?">debugOutput</a> = par(<span class="stringliteral">&quot;debugOutput&quot;</span>);
  132. <a name="l00102"></a>00102 <a class="code" href="classBaseOverlay.html#a2694627a0082c456367bfa472fff56b9" title="collect delay for single hops">collectPerHopDelay</a> = par(<span class="stringliteral">&quot;collectPerHopDelay&quot;</span>);
  133. <a name="l00103"></a>00103 <a class="code" href="classBaseOverlay.html#aef12c08638b508af44f257824f9391ef" title="used UDP-port">localPort</a> = par(<span class="stringliteral">&quot;localPort&quot;</span>);
  134. <a name="l00104"></a>00104 <a class="code" href="classBaseOverlay.html#abffe6fbd25963bc2b7542f22ba6455b9" title="maximum hop count">hopCountMax</a> = par(<span class="stringliteral">&quot;hopCountMax&quot;</span>);
  135. <a name="l00105"></a>00105 <a class="code" href="classBaseOverlay.html#a79031cb868377512713e343a326dbbd9">drawOverlayTopology</a> = par(<span class="stringliteral">&quot;drawOverlayTopology&quot;</span>);
  136. <a name="l00106"></a>00106 <a class="code" href="classBaseOverlay.html#aecfcf5743d274d9c17730f2aeccf1635">rejoinOnFailure</a> = par(<span class="stringliteral">&quot;rejoinOnFailure&quot;</span>);
  137. <a name="l00107"></a>00107 <a class="code" href="classBaseOverlay.html#a84fe39074cd9dc69acf188abf3e2ea12" title="needed by KBR protocols for NAT support">sendRpcResponseToLastHop</a> = par(<span class="stringliteral">&quot;sendRpcResponseToLastHop&quot;</span>);
  138. <a name="l00108"></a>00108 <a class="code" href="classBaseOverlay.html#ab53aaadb5dfe6fea1ac6b90db356cc52" title="if node is malicious, it tries a findNode attack">dropFindNodeAttack</a> = par(<span class="stringliteral">&quot;dropFindNodeAttack&quot;</span>);
  139. <a name="l00109"></a>00109 <a class="code" href="classBaseOverlay.html#ae70528858c70e2404e0d83824d6f5bbc" title="if node is malicious, it tries a isSibling attack">isSiblingAttack</a> = par(<span class="stringliteral">&quot;isSiblingAttack&quot;</span>);
  140. <a name="l00110"></a>00110 <a class="code" href="classBaseOverlay.html#a319a6b16e55af5e67fbbf65f6d07d5d9" title="if node is malicious, it tries a invalidNode attack">invalidNodesAttack</a> = par(<span class="stringliteral">&quot;invalidNodesAttack&quot;</span>);
  141. <a name="l00111"></a>00111 <a class="code" href="classBaseOverlay.html#a3bcd2bdd704803d7ec8ae77633cf03fa" title="if node is malicious, it drops all received BaseRouteMessages">dropRouteMessageAttack</a> = par(<span class="stringliteral">&quot;dropRouteMessageAttack&quot;</span>);
  142. <a name="l00112"></a>00112 <a class="code" href="classBaseOverlay.html#ab0b0274a06e70c91e8bd8df0c23d435f" title="if true, measure the overhead of signatures in rpc messages">measureAuthBlock</a> = par(<span class="stringliteral">&quot;measureAuthBlock&quot;</span>);
  143. <a name="l00113"></a>00113 <a class="code" href="classBaseOverlay.html#a7d0beff122a0b5c573dd8ae90c9372d5" title="if true, a node rejoins with its old nodeId and malicious state">restoreContext</a> = par(<span class="stringliteral">&quot;restoreContext&quot;</span>);
  144. <a name="l00114"></a>00114
  145. <a name="l00115"></a>00115 <span class="comment">// we assume most overlays don&#39;t provide KBR services</span>
  146. <a name="l00116"></a>00116 <a class="code" href="classBaseOverlay.html#a53389ea3326d2e8ad53f02b388487d0b" title="set this to true, if the overlay provides KBR services">kbr</a> = <span class="keyword">false</span>;
  147. <a name="l00117"></a>00117
  148. <a name="l00118"></a>00118 <span class="comment">// set routing type</span>
  149. <a name="l00119"></a>00119 std::string temp = par(<span class="stringliteral">&quot;routingType&quot;</span>).stdstringValue();
  150. <a name="l00120"></a>00120 <span class="keywordflow">if</span> (temp == <span class="stringliteral">&quot;iterative&quot;</span>)
  151. <a name="l00121"></a>00121 <a class="code" href="classBaseOverlay.html#a9e13844ea8090b84a90286f048cdcbf9">defaultRoutingType</a> = ITERATIVE_ROUTING;
  152. <a name="l00122"></a>00122 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (temp == <span class="stringliteral">&quot;exhaustive-iterative&quot;</span>)
  153. <a name="l00123"></a>00123 <a class="code" href="classBaseOverlay.html#a9e13844ea8090b84a90286f048cdcbf9">defaultRoutingType</a> = EXHAUSTIVE_ITERATIVE_ROUTING;
  154. <a name="l00124"></a>00124 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (temp == <span class="stringliteral">&quot;semi-recursive&quot;</span>)
  155. <a name="l00125"></a>00125 <a class="code" href="classBaseOverlay.html#a9e13844ea8090b84a90286f048cdcbf9">defaultRoutingType</a> = SEMI_RECURSIVE_ROUTING;
  156. <a name="l00126"></a>00126 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (temp == <span class="stringliteral">&quot;full-recursive&quot;</span>)
  157. <a name="l00127"></a>00127 <a class="code" href="classBaseOverlay.html#a9e13844ea8090b84a90286f048cdcbf9">defaultRoutingType</a> = FULL_RECURSIVE_ROUTING;
  158. <a name="l00128"></a>00128 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (temp == <span class="stringliteral">&quot;source-routing-recursive&quot;</span>)
  159. <a name="l00129"></a>00129 <a class="code" href="classBaseOverlay.html#a9e13844ea8090b84a90286f048cdcbf9">defaultRoutingType</a> = RECURSIVE_SOURCE_ROUTING;
  160. <a name="l00130"></a>00130 <span class="keywordflow">else</span> <span class="keywordflow">throw</span> cRuntimeError((std::string(<span class="stringliteral">&quot;Wrong routing type: &quot;</span>)
  161. <a name="l00131"></a>00131 + temp).c_str());
  162. <a name="l00132"></a>00132
  163. <a name="l00133"></a>00133 <a class="code" href="classBaseOverlay.html#ac9acbeb30646d54f620d87641d91b113" title="forward messages to applications?">useCommonAPIforward</a> = par(<span class="stringliteral">&quot;useCommonAPIforward&quot;</span>);
  164. <a name="l00134"></a>00134 <a class="code" href="classBaseOverlay.html#a6e9090bf68f45a31d727a6c7f0501d43" title="send ACK when receiving route message">routeMsgAcks</a> = par(<span class="stringliteral">&quot;routeMsgAcks&quot;</span>);
  165. <a name="l00135"></a>00135 <a class="code" href="classBaseOverlay.html#ad0094285f9af244aec5e5fe600126243" title="numRedundantNodes for recursive routing">recNumRedundantNodes</a> = par(<span class="stringliteral">&quot;recNumRedundantNodes&quot;</span>);
  166. <a name="l00136"></a>00136 <a class="code" href="classBaseOverlay.html#a61186fd8bd7368c8a91a63ecc9c62a89" title="record visited hops on route">recordRoute</a> = par(<span class="stringliteral">&quot;recordRoute&quot;</span>);
  167. <a name="l00137"></a>00137
  168. <a name="l00138"></a>00138 <span class="comment">// set base lookup parameters</span>
  169. <a name="l00139"></a>00139 <a class="code" href="classBaseOverlay.html#a32b8cfb47f3ef824dcf6ad882e6a6a9f">iterativeLookupConfig</a>.<a class="code" href="classIterativeLookupConfiguration.html#a5ffefd1d559420cc498307521ae1fac7" title="number of next hops in each step">redundantNodes</a> = par(<span class="stringliteral">&quot;lookupRedundantNodes&quot;</span>);
  170. <a name="l00140"></a>00140 <a class="code" href="classBaseOverlay.html#a32b8cfb47f3ef824dcf6ad882e6a6a9f">iterativeLookupConfig</a>.<a class="code" href="classIterativeLookupConfiguration.html#ad847495e9bdd53b83437150b0b26381e" title="number of parallel paths">parallelPaths</a> = par(<span class="stringliteral">&quot;lookupParallelPaths&quot;</span>);
  171. <a name="l00141"></a>00141 <a class="code" href="classBaseOverlay.html#a32b8cfb47f3ef824dcf6ad882e6a6a9f">iterativeLookupConfig</a>.<a class="code" href="classIterativeLookupConfiguration.html#ad0cc5694665de82ca47d2763d829238a" title="number of nodes to ask in parallel">parallelRpcs</a> = par(<span class="stringliteral">&quot;lookupParallelRpcs&quot;</span>);
  172. <a name="l00142"></a>00142 <a class="code" href="classBaseOverlay.html#a32b8cfb47f3ef824dcf6ad882e6a6a9f">iterativeLookupConfig</a>.<a class="code" href="classIterativeLookupConfiguration.html#ac4f7617d2cf8e6a7a9d178b9092fec7f" title="true, if siblings need to be authenticated with a ping">verifySiblings</a> = par(<span class="stringliteral">&quot;lookupVerifySiblings&quot;</span>);
  173. <a name="l00143"></a>00143 <a class="code" href="classBaseOverlay.html#a32b8cfb47f3ef824dcf6ad882e6a6a9f">iterativeLookupConfig</a>.<a class="code" href="classIterativeLookupConfiguration.html#a948fd1a937d5d2fb516e0e9181183078" title="true, if sibling candidates are selected by a majority decision if using parallel paths...">majoritySiblings</a> = par(<span class="stringliteral">&quot;lookupMajoritySiblings&quot;</span>);
  174. <a name="l00144"></a>00144 <a class="code" href="classBaseOverlay.html#a32b8cfb47f3ef824dcf6ad882e6a6a9f">iterativeLookupConfig</a>.<a class="code" href="classIterativeLookupConfiguration.html#a1bb036f4f3d11da022eacb20c9175132" title="true, if parallel RPCs results should be merged">merge</a> = par(<span class="stringliteral">&quot;lookupMerge&quot;</span>);
  175. <a name="l00145"></a>00145 <a class="code" href="classBaseOverlay.html#a32b8cfb47f3ef824dcf6ad882e6a6a9f">iterativeLookupConfig</a>.<a class="code" href="classIterativeLookupConfiguration.html#a7e4a47e8ecba9deba2509cb674c53e8c" title="communicate failed nodes">failedNodeRpcs</a> = par(<span class="stringliteral">&quot;lookupFailedNodeRpcs&quot;</span>);
  176. <a name="l00146"></a>00146 <a class="code" href="classBaseOverlay.html#a32b8cfb47f3ef824dcf6ad882e6a6a9f">iterativeLookupConfig</a>.<a class="code" href="classIterativeLookupConfiguration.html#a4b0e4def1dc1071314091dc9e5ec854a" title="limited the number of concurrent RPCS to parameter parallelRpcs">strictParallelRpcs</a> =
  177. <a name="l00147"></a>00147 par(<span class="stringliteral">&quot;lookupStrictParallelRpcs&quot;</span>);
  178. <a name="l00148"></a>00148 <a class="code" href="classBaseOverlay.html#a32b8cfb47f3ef824dcf6ad882e6a6a9f">iterativeLookupConfig</a>.<a class="code" href="classIterativeLookupConfiguration.html#a0285a36b3308b2d9d9531658fe08cb29" title="merge all parallel responses from earlier steps">useAllParallelResponses</a> =
  179. <a name="l00149"></a>00149 par(<span class="stringliteral">&quot;lookupUseAllParallelResponses&quot;</span>);
  180. <a name="l00150"></a>00150 <a class="code" href="classBaseOverlay.html#a32b8cfb47f3ef824dcf6ad882e6a6a9f">iterativeLookupConfig</a>.<a class="code" href="classIterativeLookupConfiguration.html#a691b1a92109829e5a7e84bfbddd868ea" title="send a new RPC immediately after an RPC timeouts">newRpcOnEveryTimeout</a> =
  181. <a name="l00151"></a>00151 par(<span class="stringliteral">&quot;lookupNewRpcOnEveryTimeout&quot;</span>);
  182. <a name="l00152"></a>00152 <a class="code" href="classBaseOverlay.html#a32b8cfb47f3ef824dcf6ad882e6a6a9f">iterativeLookupConfig</a>.<a class="code" href="classIterativeLookupConfiguration.html#a9b8b8df5836e6d138869c54a0e59ca26" title="send a new RPC after every response, even if there was no progress">newRpcOnEveryResponse</a> =
  183. <a name="l00153"></a>00153 par(<span class="stringliteral">&quot;lookupNewRpcOnEveryResponse&quot;</span>);
  184. <a name="l00154"></a>00154 <a class="code" href="classBaseOverlay.html#a32b8cfb47f3ef824dcf6ad882e6a6a9f">iterativeLookupConfig</a>.<a class="code" href="classIterativeLookupConfiguration.html#a156800b5539367619349b4b55542931c" title="finish lookup, if the last pending RPC returned without progress">finishOnFirstUnchanged</a> =
  185. <a name="l00155"></a>00155 par(<span class="stringliteral">&quot;lookupFinishOnFirstUnchanged&quot;</span>);
  186. <a name="l00156"></a>00156 <a class="code" href="classBaseOverlay.html#a32b8cfb47f3ef824dcf6ad882e6a6a9f">iterativeLookupConfig</a>.<a class="code" href="classIterativeLookupConfiguration.html#a7c59dacd3b232a23104bf8d6e9986f61" title="if true, the same node is never asked twice during a single lookup">visitOnlyOnce</a> =
  187. <a name="l00157"></a>00157 par(<span class="stringliteral">&quot;lookupVisitOnlyOnce&quot;</span>);
  188. <a name="l00158"></a>00158 <a class="code" href="classBaseOverlay.html#a32b8cfb47f3ef824dcf6ad882e6a6a9f">iterativeLookupConfig</a>.<a class="code" href="classIterativeLookupConfiguration.html#addae3ccd0ed97c72baea50ad03711f5a" title="if true, a FindNodeResponse with sibling flag set is always accepted, even if it is from a previous l...">acceptLateSiblings</a> =
  189. <a name="l00159"></a>00159 par(<span class="stringliteral">&quot;lookupAcceptLateSiblings&quot;</span>);
  190. <a name="l00160"></a>00160
  191. <a name="l00161"></a>00161 <a class="code" href="classBaseOverlay.html#af6573aac3c99626958737209309d7e99">recursiveLookupConfig</a>.<a class="code" href="classRecursiveLookupConfiguration.html#a344319f090e4d972a5514ef0e800836f" title="number of next hops in each step">redundantNodes</a> = par(<span class="stringliteral">&quot;lookupRedundantNodes&quot;</span>);
  192. <a name="l00162"></a>00162 <a class="code" href="classBaseOverlay.html#af6573aac3c99626958737209309d7e99">recursiveLookupConfig</a>.<a class="code" href="classRecursiveLookupConfiguration.html#acfc1d3d17ad0db3aa9654f399a1a93c9">numRetries</a> = 0; <span class="comment">//TODO</span>
  193. <a name="l00163"></a>00163
  194. <a name="l00164"></a>00164 <span class="comment">// statistics</span>
  195. <a name="l00165"></a>00165 <a class="code" href="classBaseOverlay.html#aa8c1469e21c59a08a84dec36218582b4" title="number of sent app data packets (incl. forwarded packets)">numAppDataSent</a> = 0;
  196. <a name="l00166"></a>00166 <a class="code" href="classBaseOverlay.html#ae6453766e7a58060722a6323ee3923e4" title="number of sent app data bytes (incl. forwarded bytes)">bytesAppDataSent</a> = 0;
  197. <a name="l00167"></a>00167 <a class="code" href="classBaseOverlay.html#a5b42fe053fd79b9b62680cbfc740ec4f" title="number of sent app loookup packets (incl. forwarded packets)">numAppLookupSent</a> = 0;
  198. <a name="l00168"></a>00168 <a class="code" href="classBaseOverlay.html#a118e46bc3e194c63a70e28846480ffe4" title="number of sent app lookup bytes (incl. forwarded bytes)">bytesAppLookupSent</a> = 0;
  199. <a name="l00169"></a>00169 <a class="code" href="classBaseOverlay.html#af1077d5c646390fb11d4f646fc22eaaa" title="number of sent maintenance packets (incl. forwarded packets)">numMaintenanceSent</a> = 0;
  200. <a name="l00170"></a>00170 <a class="code" href="classBaseOverlay.html#a27259327737ad8092c612756c0fe6fb4" title="number of sent maintenance bytes (incl. forwarded bytes)">bytesMaintenanceSent</a> = 0;
  201. <a name="l00171"></a>00171 <a class="code" href="classBaseOverlay.html#aa83e680792f987f9f5f779e12c055898" title="number of received app data packets (incl. packets to be forwarded )">numAppDataReceived</a> = 0;
  202. <a name="l00172"></a>00172 <a class="code" href="classBaseOverlay.html#a82cd1df80e31e2a9148a9efaacc4bc76" title="number of received app data bytes (incl. bytes to be forwarded)">bytesAppDataReceived</a> = 0;
  203. <a name="l00173"></a>00173 <a class="code" href="classBaseOverlay.html#a9298db97a2d651e02729ad197964bdca" title="number of received app lookup packets (incl. packets to be forwarded)">numAppLookupReceived</a> = 0;
  204. <a name="l00174"></a>00174 <a class="code" href="classBaseOverlay.html#a8527c9038c62bf66e58c07d41b308527" title="number of received app lookup bytes (incl. bytes to be forwarded)">bytesAppLookupReceived</a> = 0;
  205. <a name="l00175"></a>00175 <a class="code" href="classBaseOverlay.html#a4e7abb41a2c8698bf530015378a13e46" title="number of received maintenance packets (incl. packets to be forwarded)">numMaintenanceReceived</a> = 0;
  206. <a name="l00176"></a>00176 <a class="code" href="classBaseOverlay.html#ad7bd70b69842cc4db485eafa942332fb" title="number of received maintenance bytes (incl. bytes to be forwarded)">bytesMaintenanceReceived</a> = 0;
  207. <a name="l00177"></a>00177 <a class="code" href="classBaseOverlay.html#a341a65ab7c50dfbc8222c1adf4f08a99" title="number of forwarded app data packets">numAppDataForwarded</a> = 0;
  208. <a name="l00178"></a>00178 <a class="code" href="classBaseOverlay.html#a1c90204205e7e5b8f0f12fe4056914e6" title="number of forwarded app data bytes at out-gate">bytesAppDataForwarded</a> = 0;
  209. <a name="l00179"></a>00179 <a class="code" href="classBaseOverlay.html#a8f5ff290e99ab78f3e0bd4a489bfcadd" title="number of forwarded app lookup packets">numAppLookupForwarded</a> = 0;
  210. <a name="l00180"></a>00180 <a class="code" href="classBaseOverlay.html#adeff8c454760c6eb4ca847e8dda252a7" title="number of forwarded app lookup bytes at out-gate">bytesAppLookupForwarded</a> = 0;
  211. <a name="l00181"></a>00181 <a class="code" href="classBaseOverlay.html#a05fa895acb368180bbca74d92152d2f7" title="number of forwarded maintenance packets">numMaintenanceForwarded</a> = 0;
  212. <a name="l00182"></a>00182 <a class="code" href="classBaseOverlay.html#a8dbb1ce4eee057f23bea55e5e4a7d13b" title="number of forwarded maintenance bytes at out-gate">bytesMaintenanceForwarded</a> = 0;
  213. <a name="l00183"></a>00183 <a class="code" href="classBaseOverlay.html#a30e11530c77c2164f0a5c98a489a9fab" title="number of bytes sent for rpc message signatures">bytesAuthBlockSent</a> = 0;
  214. <a name="l00184"></a>00184
  215. <a name="l00185"></a>00185 <a class="code" href="classBaseOverlay.html#a4a82bd4b76a8d06a1d63bba98f1a34d7" title="number of dropped packets">numDropped</a> = 0;
  216. <a name="l00186"></a>00186 <a class="code" href="classBaseOverlay.html#a9e09857b97f52d340e4710580f25f7a6" title="number of dropped bytes">bytesDropped</a> = 0;
  217. <a name="l00187"></a>00187 <a class="code" href="classBaseOverlay.html#a210e4277548e47f2ec8e772ae5b6eb7f">numFindNodeSent</a> = 0;
  218. <a name="l00188"></a>00188 <a class="code" href="classBaseOverlay.html#a99971f360cdde2d41d239418dfad7281">bytesFindNodeSent</a> = 0;
  219. <a name="l00189"></a>00189 <a class="code" href="classBaseOverlay.html#a248581eed6fedf10b2c350cbedd69773">numFindNodeResponseSent</a> = 0;
  220. <a name="l00190"></a>00190 <a class="code" href="classBaseOverlay.html#a4b2293e58a3bf5a7ddc0d28cb0669f2f">bytesFindNodeResponseSent</a> = 0;
  221. <a name="l00191"></a>00191 <a class="code" href="classBaseOverlay.html#a2fef63e0e6d6d7c991c9cb2c95db5733">numFailedNodeSent</a> = 0;
  222. <a name="l00192"></a>00192 <a class="code" href="classBaseOverlay.html#aca6ed5880fa17a3bfe432deff8d10e7c">bytesFailedNodeSent</a> = 0;
  223. <a name="l00193"></a>00193 <a class="code" href="classBaseOverlay.html#acf40707599a177a1dd5cd9ec4e854dc8">numFailedNodeResponseSent</a> = 0;
  224. <a name="l00194"></a>00194 <a class="code" href="classBaseOverlay.html#aa62ca9476d42c748e40dd0f287823445">bytesFailedNodeResponseSent</a> = 0;
  225. <a name="l00195"></a>00195
  226. <a name="l00196"></a>00196 <a class="code" href="classBaseOverlay.html#aee8e642813784a1f27a81756a4b93b9b" title="number of join retries">joinRetries</a> = 0;
  227. <a name="l00197"></a>00197
  228. <a name="l00198"></a>00198 <a class="code" href="classBaseOverlay.html#ae34cc8a058a4dae47a3815cba64ceba2" title="number of packets sent to same host but different port (SimpleMultiOverlayHost)">numInternalSent</a> = 0;
  229. <a name="l00199"></a>00199 <a class="code" href="classBaseOverlay.html#ad0af3d066a89ced910b082a980f68f25" title="number of bytes sent to same host but different port (SimpleMultiOverlayHost)">bytesInternalSent</a> = 0;
  230. <a name="l00200"></a>00200 <a class="code" href="classBaseOverlay.html#a7f185cb11a818d01dcc1a31553de16ef" title="number of packets received from same host but different port (SimpleMultiOverlayHost)">numInternalReceived</a> = 0;
  231. <a name="l00201"></a>00201 <a class="code" href="classBaseOverlay.html#a55ba3d595b6b23db700cb9f36f34f0ae" title="number of bytes received from same host but different port (SimpleMultiOverlayHost)">bytesInternalReceived</a> = 0;
  232. <a name="l00202"></a>00202
  233. <a name="l00203"></a>00203 WATCH(<a class="code" href="classBaseOverlay.html#aa8c1469e21c59a08a84dec36218582b4" title="number of sent app data packets (incl. forwarded packets)">numAppDataSent</a>);
  234. <a name="l00204"></a>00204 WATCH(<a class="code" href="classBaseOverlay.html#ae6453766e7a58060722a6323ee3923e4" title="number of sent app data bytes (incl. forwarded bytes)">bytesAppDataSent</a>);
  235. <a name="l00205"></a>00205 WATCH(<a class="code" href="classBaseOverlay.html#a5b42fe053fd79b9b62680cbfc740ec4f" title="number of sent app loookup packets (incl. forwarded packets)">numAppLookupSent</a>);
  236. <a name="l00206"></a>00206 WATCH(<a class="code" href="classBaseOverlay.html#a118e46bc3e194c63a70e28846480ffe4" title="number of sent app lookup bytes (incl. forwarded bytes)">bytesAppLookupSent</a>);
  237. <a name="l00207"></a>00207 WATCH(<a class="code" href="classBaseOverlay.html#af1077d5c646390fb11d4f646fc22eaaa" title="number of sent maintenance packets (incl. forwarded packets)">numMaintenanceSent</a>);
  238. <a name="l00208"></a>00208 WATCH(<a class="code" href="classBaseOverlay.html#a27259327737ad8092c612756c0fe6fb4" title="number of sent maintenance bytes (incl. forwarded bytes)">bytesMaintenanceSent</a>);
  239. <a name="l00209"></a>00209 WATCH(<a class="code" href="classBaseOverlay.html#aa83e680792f987f9f5f779e12c055898" title="number of received app data packets (incl. packets to be forwarded )">numAppDataReceived</a>);
  240. <a name="l00210"></a>00210 WATCH(<a class="code" href="classBaseOverlay.html#a82cd1df80e31e2a9148a9efaacc4bc76" title="number of received app data bytes (incl. bytes to be forwarded)">bytesAppDataReceived</a>);
  241. <a name="l00211"></a>00211 WATCH(<a class="code" href="classBaseOverlay.html#a9298db97a2d651e02729ad197964bdca" title="number of received app lookup packets (incl. packets to be forwarded)">numAppLookupReceived</a>);
  242. <a name="l00212"></a>00212 WATCH(<a class="code" href="classBaseOverlay.html#a8527c9038c62bf66e58c07d41b308527" title="number of received app lookup bytes (incl. bytes to be forwarded)">bytesAppLookupReceived</a>);
  243. <a name="l00213"></a>00213 WATCH(<a class="code" href="classBaseOverlay.html#a4e7abb41a2c8698bf530015378a13e46" title="number of received maintenance packets (incl. packets to be forwarded)">numMaintenanceReceived</a>);
  244. <a name="l00214"></a>00214 WATCH(<a class="code" href="classBaseOverlay.html#ad7bd70b69842cc4db485eafa942332fb" title="number of received maintenance bytes (incl. bytes to be forwarded)">bytesMaintenanceReceived</a>);
  245. <a name="l00215"></a>00215 WATCH(<a class="code" href="classBaseOverlay.html#a341a65ab7c50dfbc8222c1adf4f08a99" title="number of forwarded app data packets">numAppDataForwarded</a>);
  246. <a name="l00216"></a>00216 WATCH(<a class="code" href="classBaseOverlay.html#a1c90204205e7e5b8f0f12fe4056914e6" title="number of forwarded app data bytes at out-gate">bytesAppDataForwarded</a>);
  247. <a name="l00217"></a>00217 WATCH(<a class="code" href="classBaseOverlay.html#a8f5ff290e99ab78f3e0bd4a489bfcadd" title="number of forwarded app lookup packets">numAppLookupForwarded</a>);
  248. <a name="l00218"></a>00218 WATCH(<a class="code" href="classBaseOverlay.html#adeff8c454760c6eb4ca847e8dda252a7" title="number of forwarded app lookup bytes at out-gate">bytesAppLookupForwarded</a>);
  249. <a name="l00219"></a>00219 WATCH(<a class="code" href="classBaseOverlay.html#a05fa895acb368180bbca74d92152d2f7" title="number of forwarded maintenance packets">numMaintenanceForwarded</a>);
  250. <a name="l00220"></a>00220 WATCH(<a class="code" href="classBaseOverlay.html#a8dbb1ce4eee057f23bea55e5e4a7d13b" title="number of forwarded maintenance bytes at out-gate">bytesMaintenanceForwarded</a>);
  251. <a name="l00221"></a>00221
  252. <a name="l00222"></a>00222 WATCH(<a class="code" href="classBaseOverlay.html#a4a82bd4b76a8d06a1d63bba98f1a34d7" title="number of dropped packets">numDropped</a>);
  253. <a name="l00223"></a>00223 WATCH(<a class="code" href="classBaseOverlay.html#a9e09857b97f52d340e4710580f25f7a6" title="number of dropped bytes">bytesDropped</a>);
  254. <a name="l00224"></a>00224 WATCH(<a class="code" href="classBaseOverlay.html#a210e4277548e47f2ec8e772ae5b6eb7f">numFindNodeSent</a>);
  255. <a name="l00225"></a>00225 WATCH(<a class="code" href="classBaseOverlay.html#a99971f360cdde2d41d239418dfad7281">bytesFindNodeSent</a>);
  256. <a name="l00226"></a>00226 WATCH(<a class="code" href="classBaseOverlay.html#a248581eed6fedf10b2c350cbedd69773">numFindNodeResponseSent</a>);
  257. <a name="l00227"></a>00227 WATCH(<a class="code" href="classBaseOverlay.html#a4b2293e58a3bf5a7ddc0d28cb0669f2f">bytesFindNodeResponseSent</a>);
  258. <a name="l00228"></a>00228 WATCH(<a class="code" href="classBaseOverlay.html#a2fef63e0e6d6d7c991c9cb2c95db5733">numFailedNodeSent</a>);
  259. <a name="l00229"></a>00229 WATCH(<a class="code" href="classBaseOverlay.html#aca6ed5880fa17a3bfe432deff8d10e7c">bytesFailedNodeSent</a>);
  260. <a name="l00230"></a>00230 WATCH(<a class="code" href="classBaseOverlay.html#acf40707599a177a1dd5cd9ec4e854dc8">numFailedNodeResponseSent</a>);
  261. <a name="l00231"></a>00231 WATCH(<a class="code" href="classBaseOverlay.html#aa62ca9476d42c748e40dd0f287823445">bytesFailedNodeResponseSent</a>);
  262. <a name="l00232"></a>00232
  263. <a name="l00233"></a>00233 WATCH(<a class="code" href="classBaseOverlay.html#aee8e642813784a1f27a81756a4b93b9b" title="number of join retries">joinRetries</a>);
  264. <a name="l00234"></a>00234
  265. <a name="l00235"></a>00235 <span class="keywordflow">if</span> (<a class="code" href="classBaseOverlay.html#abef37828b7f070044154f53bcd2a765b" title="Returns true if overlay is one in an array, inside a SimpleMultiOverlayHost.">isInSimpleMultiOverlayHost</a>()) {
  266. <a name="l00236"></a>00236 WATCH(<a class="code" href="classBaseOverlay.html#ae34cc8a058a4dae47a3815cba64ceba2" title="number of packets sent to same host but different port (SimpleMultiOverlayHost)">numInternalSent</a>);
  267. <a name="l00237"></a>00237 WATCH(<a class="code" href="classBaseOverlay.html#ad0af3d066a89ced910b082a980f68f25" title="number of bytes sent to same host but different port (SimpleMultiOverlayHost)">bytesInternalSent</a>);
  268. <a name="l00238"></a>00238 WATCH(<a class="code" href="classBaseOverlay.html#a7f185cb11a818d01dcc1a31553de16ef" title="number of packets received from same host but different port (SimpleMultiOverlayHost)">numInternalReceived</a>);
  269. <a name="l00239"></a>00239 WATCH(<a class="code" href="classBaseOverlay.html#a55ba3d595b6b23db700cb9f36f34f0ae" title="number of bytes received from same host but different port (SimpleMultiOverlayHost)">bytesInternalReceived</a>);
  270. <a name="l00240"></a>00240 }
  271. <a name="l00241"></a>00241
  272. <a name="l00242"></a>00242 <span class="comment">// set up local nodehandle</span>
  273. <a name="l00243"></a>00243 <a class="code" href="classBaseRpc.html#a88eb68c06450fd12ea072f471bf1c1b8" title="NodeHandle to this node.">thisNode</a>.<a class="code" href="classTransportAddress.html#a1c7b834dc2e6e738f1f4db8711a12814" title="Sets the ip address, port and NAT type.">setIp</a>(IPAddressResolver().
  274. <a name="l00244"></a>00244 addressOf(getParentModule()-&gt;getParentModule()));
  275. <a name="l00245"></a>00245 <a class="code" href="classBaseRpc.html#a88eb68c06450fd12ea072f471bf1c1b8" title="NodeHandle to this node.">thisNode</a>.<a class="code" href="classNodeHandle.html#af3992f1fda9ea42dc10bf4739e47700a" title="saves given key to NodeHandle::key">setKey</a>(<a class="code" href="classOverlayKey.html#ac0d4135dff2985e3582fdbed2a37eb75" title="OverlayKey without defined key.">OverlayKey::UNSPECIFIED_KEY</a>);
  276. <a name="l00246"></a>00246
  277. <a name="l00247"></a>00247 <a class="code" href="classBaseOverlay.html#ab4be6d88417117fbf33a445d56af2655">state</a> = INIT;
  278. <a name="l00248"></a>00248 <a class="code" href="classBaseOverlay.html#aa484556ed4ff9e4e97394106d0c1d323" title="internal overlay state used for setOverlayReady()">internalReadyState</a> = <span class="keyword">false</span>;
  279. <a name="l00249"></a>00249
  280. <a name="l00250"></a>00250 getDisplayString().setTagArg(<span class="stringliteral">&quot;i&quot;</span>, 1, <span class="stringliteral">&quot;red&quot;</span>);
  281. <a name="l00251"></a>00251 <a class="code" href="classBaseOverlay.html#a933e505ea77cae4ab0c8edcb77ade2c7" title="pointer to GlobalNodeList in this node">globalNodeList</a>-&gt;<a class="code" href="classGlobalNodeList.html#a94604495a81e687f7492564d788c7c36" title="Colors module-icon blue (ready), green (ready, malicious) or red (not ready).">setOverlayReadyIcon</a>(<a class="code" href="classBaseRpc.html#ac3f420630d5618e81709c078b06fd9da" title="Returns the NodeHandle of this node.">getThisNode</a>(), <span class="keyword">false</span>);
  282. <a name="l00252"></a>00252
  283. <a name="l00253"></a>00253 <span class="comment">// set up UDP</span>
  284. <a name="l00254"></a>00254 <a class="code" href="classBaseOverlay.html#a512084e3a224f0a3f284e5e240652a26" title="Tells UDP we want to get all packets arriving on the given port.">bindToPort</a>(<a class="code" href="classBaseOverlay.html#aef12c08638b508af44f257824f9391ef" title="used UDP-port">localPort</a>);
  285. <a name="l00255"></a>00255
  286. <a name="l00256"></a>00256 <span class="comment">// subscribe to the notification board</span>
  287. <a name="l00257"></a>00257 <a class="code" href="classBaseOverlay.html#af0704186e295039c92666176b0b91dae" title="pointer to NotificationBoard in this node">notificationBoard</a>-&gt;subscribe(<span class="keyword">this</span>, NF_OVERLAY_TRANSPORTADDRESS_CHANGED);
  288. <a name="l00258"></a>00258 <a class="code" href="classBaseOverlay.html#af0704186e295039c92666176b0b91dae" title="pointer to NotificationBoard in this node">notificationBoard</a>-&gt;subscribe(<span class="keyword">this</span>, NF_OVERLAY_NODE_LEAVE);
  289. <a name="l00259"></a>00259 <a class="code" href="classBaseOverlay.html#af0704186e295039c92666176b0b91dae" title="pointer to NotificationBoard in this node">notificationBoard</a>-&gt;subscribe(<span class="keyword">this</span>, NF_OVERLAY_NODE_GRACEFUL_LEAVE);
  290. <a name="l00260"></a>00260
  291. <a name="l00261"></a>00261 <span class="comment">// init visualization with terminal ptr</span>
  292. <a name="l00262"></a>00262 <span class="keywordflow">if</span> (<a class="code" href="classBaseOverlay.html#a79031cb868377512713e343a326dbbd9">drawOverlayTopology</a>)
  293. <a name="l00263"></a>00263 <a class="code" href="classTopologyVis.html#ab551ff162d16d625b967f228f479bf72">initVis</a>(getParentModule()-&gt;getParentModule());
  294. <a name="l00264"></a>00264
  295. <a name="l00265"></a>00265 <span class="comment">// init rpcs</span>
  296. <a name="l00266"></a>00266 <a class="code" href="classBaseRpc.html#a270e68f0d93dfcf9c5f26dbafd0fba54" title="Initializes Remote-Procedure state.">initRpcs</a>();
  297. <a name="l00267"></a>00267 <a class="code" href="classBaseOverlay.html#af2c8b2108703c4df49217a719f280bb8" title="creates a LookupSet">initLookups</a>();
  298. <a name="l00268"></a>00268
  299. <a name="l00269"></a>00269 <span class="comment">// set TCP output gate</span>
  300. <a name="l00270"></a>00270 <a class="code" href="classBaseTcpSupport.html#a3de2e8b022586f387fdba1ca42dbdfd1" title="Member function to set local gate towards the TCP module during init phase.">setTcpOut</a>(gate(<span class="stringliteral">&quot;tcpOut&quot;</span>));
  301. <a name="l00271"></a>00271
  302. <a name="l00272"></a>00272 <span class="comment">// statistics</span>
  303. <a name="l00273"></a>00273 <a class="code" href="classBaseOverlay.html#af0eebaddea732ee4ab4d247c388e62bd" title="simtime when the node has been created">creationTime</a> = simTime();
  304. <a name="l00274"></a>00274 WATCH(<a class="code" href="classBaseOverlay.html#af0eebaddea732ee4ab4d247c388e62bd" title="simtime when the node has been created">creationTime</a>);
  305. <a name="l00275"></a>00275 }
  306. <a name="l00276"></a>00276
  307. <a name="l00277"></a>00277 <span class="keywordflow">if</span> (stage &gt;= <a class="code" href="InitStages_8h.html#a42fde1aa1e14a1c45d29061d6e87e532a58e83c497c7c8495e9c592ff3148b6b9" title="first stage for overlay modules (Tier 0 / KBR)">MIN_STAGE_OVERLAY</a> &amp;&amp; stage &lt;= <a class="code" href="InitStages_8h.html#a42fde1aa1e14a1c45d29061d6e87e532af261a91f9b71ec40c7c7c7e18b3455ac" title="last stage for overlay modules (Tier 0 / KBR)">MAX_STAGE_OVERLAY</a>)
  308. <a name="l00278"></a>00278 <a class="code" href="classBaseOverlay.html#a41f88dfbea856a2b38319ff52c758c96" title="Initializes derived-class-attributes.">initializeOverlay</a>(stage);
  309. <a name="l00279"></a>00279
  310. <a name="l00280"></a>00280 <span class="keywordflow">if</span> (stage == <a class="code" href="InitStages_8h.html#a42fde1aa1e14a1c45d29061d6e87e532adde3c0e76fb4c24e253ada0ac73e6d08" title="last stage for overlay application modules (Tier 1)">MAX_STAGE_TIER_1</a>) {
  311. <a name="l00281"></a>00281 <span class="comment">// bootstrapList registered its gate to the overlay 0</span>
  312. <a name="l00282"></a>00282 <span class="comment">// if this is not overlay 0, we may not have the gate, so retrieve it</span>
  313. <a name="l00283"></a>00283 <span class="comment">// this assumes that the overlay is in a container module!</span>
  314. <a name="l00284"></a>00284 <span class="keywordflow">if</span> (!<a class="code" href="classBaseOverlay.html#a572cbbdedbbc386f1d9c3851e9250be7">compModuleList</a>.count(<a class="code" href="CommonMessages__m_8h.html#aad57ef0110fe8675eb299d467148bc5ea6b7871eeda317b7934cc8fb0b84899c5">BOOTSTRAPLIST_COMP</a>)) {
  315. <a name="l00285"></a>00285 <a class="code" href="classBaseOverlay.html" title="Base class for overlays.">BaseOverlay</a> *firstOverlay = <span class="keyword">dynamic_cast&lt;</span><a class="code" href="classBaseOverlay.html" title="Base class for overlays.">BaseOverlay</a>*<span class="keyword">&gt;</span>
  316. <a name="l00286"></a>00286 (getParentModule()-&gt;getParentModule()
  317. <a name="l00287"></a>00287 -&gt;getSubmodule(<span class="stringliteral">&quot;overlay&quot;</span>, 0)-&gt;gate(<span class="stringliteral">&quot;appIn&quot;</span>)
  318. <a name="l00288"></a>00288 -&gt;getNextGate()-&gt;getOwnerModule());
  319. <a name="l00289"></a>00289 <span class="keywordflow">if</span> (!firstOverlay) {
  320. <a name="l00290"></a>00290 <span class="keywordflow">throw</span> cRuntimeError(<span class="stringliteral">&quot;BaseOverlay.cc: &quot;</span>
  321. <a name="l00291"></a>00291 <span class="stringliteral">&quot;Couldn&#39;t obtain bootstrap gate&quot;</span>);
  322. <a name="l00292"></a>00292 }
  323. <a name="l00293"></a>00293 <a class="code" href="classBaseOverlay.html#a2096f89814b5740257cee106b60dda15">registerComp</a>(<a class="code" href="CommonMessages__m_8h.html#aad57ef0110fe8675eb299d467148bc5ea6b7871eeda317b7934cc8fb0b84899c5">BOOTSTRAPLIST_COMP</a>,
  324. <a name="l00294"></a>00294 firstOverlay-&gt;<a class="code" href="classBaseOverlay.html#a3aba2b6e93094d3cc8107d33db4b5244">getCompModule</a>(<a class="code" href="CommonMessages__m_8h.html#aad57ef0110fe8675eb299d467148bc5ea6b7871eeda317b7934cc8fb0b84899c5">BOOTSTRAPLIST_COMP</a>));
  325. <a name="l00295"></a>00295 }
  326. <a name="l00296"></a>00296 }
  327. <a name="l00297"></a>00297 }
  328. <a name="l00298"></a>00298
  329. <a name="l00299"></a>00299
  330. <a name="l00300"></a><a class="code" href="classBaseOverlay.html#a41f88dfbea856a2b38319ff52c758c96">00300</a> <span class="keywordtype">void</span> <a class="code" href="classBaseOverlay.html#a41f88dfbea856a2b38319ff52c758c96" title="Initializes derived-class-attributes.">BaseOverlay::initializeOverlay</a>(<span class="keywordtype">int</span> stage)
  331. <a name="l00301"></a>00301 {
  332. <a name="l00302"></a>00302 }
  333. <a name="l00303"></a>00303
  334. <a name="l00304"></a><a class="code" href="classBaseOverlay.html#aed7e3f36b2c70cbdb0e6daa32925917c">00304</a> <span class="keywordtype">void</span> <a class="code" href="classBaseOverlay.html#aed7e3f36b2c70cbdb0e6daa32925917c" title="collects statistical data">BaseOverlay::finish</a>()
  335. <a name="l00305"></a>00305 {
  336. <a name="l00306"></a>00306 <a class="code" href="classBaseOverlay.html#a8db85b9c706d04007154761d5a0cec16" title="collects statistical data in derived class">finishOverlay</a>();
  337. <a name="l00307"></a>00307
  338. <a name="l00308"></a>00308 simtime_t time = <a class="code" href="classBaseRpc.html#a9552ba3a2b09c83b3c561e65dab9f23d" title="pointer to GlobalStatistics module in this node">globalStatistics</a>-&gt;<a class="code" href="classGlobalStatistics.html#a610799ebfbf64696c59b811870cc8300">calcMeasuredLifetime</a>(<a class="code" href="classBaseOverlay.html#af0eebaddea732ee4ab4d247c388e62bd" title="simtime when the node has been created">creationTime</a>);
  339. <a name="l00309"></a>00309
  340. <a name="l00310"></a>00310 <span class="keywordflow">if</span> (time &gt;= <a class="code" href="classGlobalStatistics.html#a169810c78519b271f7e32fdc7c9fc641" title="minimum useful measured lifetime in seconds">GlobalStatistics::MIN_MEASURED</a>) {
  341. <a name="l00311"></a>00311
  342. <a name="l00312"></a>00312 <span class="keywordflow">if</span> (<a class="code" href="classBaseOverlay.html#a2694627a0082c456367bfa472fff56b9" title="collect delay for single hops">collectPerHopDelay</a>) {
  343. <a name="l00313"></a>00313 std::ostringstream singleHopName;
  344. <a name="l00314"></a>00314 <a class="code" href="structBaseOverlay_1_1HopDelayRecord.html" title="Structure for computing the average delay in one specific hop.">HopDelayRecord</a>* hdrl = NULL;
  345. <a name="l00315"></a>00315 <a class="code" href="structBaseOverlay_1_1HopDelayRecord.html" title="Structure for computing the average delay in one specific hop.">HopDelayRecord</a>* hdr = NULL;
  346. <a name="l00316"></a>00316 <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i = 0; i &lt; <a class="code" href="classBaseOverlay.html#a93d899c36b4b7b7b012413924c9fb4b5">singleHopDelays</a>.size();) {
  347. <a name="l00317"></a>00317 hdrl = <a class="code" href="classBaseOverlay.html#a93d899c36b4b7b7b012413924c9fb4b5">singleHopDelays</a>[i++];
  348. <a name="l00318"></a>00318 hdr = hdrl;
  349. <a name="l00319"></a>00319 <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> j = 1; j &lt;= i; ++j) {
  350. <a name="l00320"></a>00320 <span class="keywordflow">if</span> (hdr-&gt;<a class="code" href="structBaseOverlay_1_1HopDelayRecord.html#a83f056780cd6b9b68f8eb999d5b45482">count</a> == 0) <span class="keywordflow">continue</span>;
  351. <a name="l00321"></a>00321 singleHopName.str(<span class="stringliteral">&quot;&quot;</span>);
  352. <a name="l00322"></a>00322 singleHopName &lt;&lt; <span class="stringliteral">&quot;BaseOverlay: Average Delay in Hop &quot;</span>
  353. <a name="l00323"></a>00323 &lt;&lt; j &lt;&lt; <span class="stringliteral">&quot; of &quot;</span> &lt;&lt; i;
  354. <a name="l00324"></a>00324 <a class="code" href="classBaseRpc.html#a9552ba3a2b09c83b3c561e65dab9f23d" title="pointer to GlobalStatistics module in this node">globalStatistics</a>-&gt;<a class="code" href="classGlobalStatistics.html#a6a697a0b67f344e4bc214159761f943a" title="Add a new value to the cStdDev container specified by the name parameter.">addStdDev</a>(singleHopName.str(),
  355. <a name="l00325"></a>00325 SIMTIME_DBL(hdr-&gt;<a class="code" href="structBaseOverlay_1_1HopDelayRecord.html#abcc398fdefba9230fcafb94e701f3071">val</a> / hdr-&gt;<a class="code" href="structBaseOverlay_1_1HopDelayRecord.html#a83f056780cd6b9b68f8eb999d5b45482">count</a>));
  356. <a name="l00326"></a>00326 ++hdr;
  357. <a name="l00327"></a>00327 }
  358. <a name="l00328"></a>00328 <span class="keyword">delete</span>[] hdrl;
  359. <a name="l00329"></a>00329 }
  360. <a name="l00330"></a>00330 <a class="code" href="classBaseOverlay.html#a93d899c36b4b7b7b012413924c9fb4b5">singleHopDelays</a>.clear();
  361. <a name="l00331"></a>00331 }
  362. <a name="l00332"></a>00332
  363. <a name="l00333"></a>00333 <a class="code" href="classBaseRpc.html#a9552ba3a2b09c83b3c561e65dab9f23d" title="pointer to GlobalStatistics module in this node">globalStatistics</a>-&gt;<a class="code" href="classGlobalStatistics.html#a6a697a0b67f344e4bc214159761f943a" title="Add a new value to the cStdDev container specified by the name parameter.">addStdDev</a>(<span class="stringliteral">&quot;BaseOverlay: Join Retries&quot;</span>, <a class="code" href="classBaseOverlay.html#aee8e642813784a1f27a81756a4b93b9b" title="number of join retries">joinRetries</a>);
  364. <a name="l00334"></a>00334
  365. <a name="l00335"></a>00335 <a class="code" href="classBaseRpc.html#a9552ba3a2b09c83b3c561e65dab9f23d" title="pointer to GlobalStatistics module in this node">globalStatistics</a>-&gt;<a class="code" href="classGlobalStatistics.html#a6a697a0b67f344e4bc214159761f943a" title="Add a new value to the cStdDev container specified by the name parameter.">addStdDev</a>(<span class="stringliteral">&quot;BaseOverlay: Sent App Data Messages/s&quot;</span>,
  366. <a name="l00336"></a>00336 <a class="code" href="classBaseOverlay.html#aa8c1469e21c59a08a84dec36218582b4" title="number of sent app data packets (incl. forwarded packets)">numAppDataSent</a> / time);
  367. <a name="l00337"></a>00337 <a class="code" href="classBaseRpc.html#a9552ba3a2b09c83b3c561e65dab9f23d" title="pointer to GlobalStatistics module in this node">globalStatistics</a>-&gt;<a class="code" href="classGlobalStatistics.html#a6a697a0b67f344e4bc214159761f943a" title="Add a new value to the cStdDev container specified by the name parameter.">addStdDev</a>(<span class="stringliteral">&quot;BaseOverlay: Sent App Data Bytes/s&quot;</span>,
  368. <a name="l00338"></a>00338 <a class="code" href="classBaseOverlay.html#ae6453766e7a58060722a6323ee3923e4" title="number of sent app data bytes (incl. forwarded bytes)">bytesAppDataSent</a> / time);
  369. <a name="l00339"></a>00339 <span class="keywordflow">if</span> (<a class="code" href="classBaseOverlay.html#abef37828b7f070044154f53bcd2a765b" title="Returns true if overlay is one in an array, inside a SimpleMultiOverlayHost.">isInSimpleMultiOverlayHost</a>()) {
  370. <a name="l00340"></a>00340 <a class="code" href="classBaseRpc.html#a9552ba3a2b09c83b3c561e65dab9f23d" title="pointer to GlobalStatistics module in this node">globalStatistics</a>-&gt;<a class="code" href="classGlobalStatistics.html#a6a697a0b67f344e4bc214159761f943a" title="Add a new value to the cStdDev container specified by the name parameter.">addStdDev</a>(<span class="stringliteral">&quot;BaseOverlay: Internal Sent Messages/s&quot;</span>,
  371. <a name="l00341"></a>00341 <a class="code" href="classBaseOverlay.html#a7f185cb11a818d01dcc1a31553de16ef" title="number of packets received from same host but different port (SimpleMultiOverlayHost)">numInternalReceived</a> / time);
  372. <a name="l00342"></a>00342 <a class="code" href="classBaseRpc.html#a9552ba3a2b09c83b3c561e65dab9f23d" title="pointer to GlobalStatistics module in this node">globalStatistics</a>-&gt;<a class="code" href="classGlobalStatistics.html#a6a697a0b67f344e4bc214159761f943a" title="Add a new value to the cStdDev container specified by the name parameter.">addStdDev</a>(<span class="stringliteral">&quot;BaseOverlay: Internal Sent Bytes/s&quot;</span>,
  373. <a name="l00343"></a>00343 <a class="code" href="classBaseOverlay.html#a55ba3d595b6b23db700cb9f36f34f0ae" title="number of bytes received from same host but different port (SimpleMultiOverlayHost)">bytesInternalReceived</a> / time);
  374. <a name="l00344"></a>00344 }
  375. <a name="l00345"></a>00345 <a class="code" href="classBaseRpc.html#a9552ba3a2b09c83b3c561e65dab9f23d" title="pointer to GlobalStatistics module in this node">globalStatistics</a>-&gt;<a class="code" href="classGlobalStatistics.html#a6a697a0b67f344e4bc214159761f943a" title="Add a new value to the cStdDev container specified by the name parameter.">addStdDev</a>(<span class="stringliteral">&quot;BaseOverlay: Sent App Lookup Messages/s&quot;</span>,
  376. <a name="l00346"></a>00346 <a class="code" href="classBaseOverlay.html#a5b42fe053fd79b9b62680cbfc740ec4f" title="number of sent app loookup packets (incl. forwarded packets)">numAppLookupSent</a> / time);
  377. <a name="l00347"></a>00347 <a class="code" href="classBaseRpc.html#a9552ba3a2b09c83b3c561e65dab9f23d" title="pointer to GlobalStatistics module in this node">globalStatistics</a>-&gt;<a class="code" href="classGlobalStatistics.html#a6a697a0b67f344e4bc214159761f943a" title="Add a new value to the cStdDev container specified by the name parameter.">addStdDev</a>(<span class="stringliteral">&quot;BaseOverlay: Sent App Lookup Bytes/s&quot;</span>,
  378. <a name="l00348"></a>00348 <a class="code" href="classBaseOverlay.html#a118e46bc3e194c63a70e28846480ffe4" title="number of sent app lookup bytes (incl. forwarded bytes)">bytesAppLookupSent</a> / time);
  379. <a name="l00349"></a>00349 <a class="code" href="classBaseRpc.html#a9552ba3a2b09c83b3c561e65dab9f23d" title="pointer to GlobalStatistics module in this node">globalStatistics</a>-&gt;<a class="code" href="classGlobalStatistics.html#a6a697a0b67f344e4bc214159761f943a" title="Add a new value to the cStdDev container specified by the name parameter.">addStdDev</a>(<span class="stringliteral">&quot;BaseOverlay: Sent Maintenance Messages/s&quot;</span>,
  380. <a name="l00350"></a>00350 <a class="code" href="classBaseOverlay.html#af1077d5c646390fb11d4f646fc22eaaa" title="number of sent maintenance packets (incl. forwarded packets)">numMaintenanceSent</a> / time);
  381. <a name="l00351"></a>00351 <a class="code" href="classBaseRpc.html#a9552ba3a2b09c83b3c561e65dab9f23d" title="pointer to GlobalStatistics module in this node">globalStatistics</a>-&gt;<a class="code" href="classGlobalStatistics.html#a6a697a0b67f344e4bc214159761f943a" title="Add a new value to the cStdDev container specified by the name parameter.">addStdDev</a>(<span class="stringliteral">&quot;BaseOverlay: Sent Maintenance Bytes/s&quot;</span>,
  382. <a name="l00352"></a>00352 <a class="code" href="classBaseOverlay.html#a27259327737ad8092c612756c0fe6fb4" title="number of sent maintenance bytes (incl. forwarded bytes)">bytesMaintenanceSent</a> / time);
  383. <a name="l00353"></a>00353
  384. <a name="l00354"></a>00354 <a class="code" href="classBaseRpc.html#a9552ba3a2b09c83b3c561e65dab9f23d" title="pointer to GlobalStatistics module in this node">globalStatistics</a>-&gt;<a class="code" href="classGlobalStatistics.html#a6a697a0b67f344e4bc214159761f943a" title="Add a new value to the cStdDev container specified by the name parameter.">addStdDev</a>(<span class="stringliteral">&quot;BaseOverlay: Sent Total Messages/s&quot;</span>,
  385. <a name="l00355"></a>00355 (<a class="code" href="classBaseOverlay.html#aa8c1469e21c59a08a84dec36218582b4" title="number of sent app data packets (incl. forwarded packets)">numAppDataSent</a> + <a class="code" href="classBaseOverlay.html#a5b42fe053fd79b9b62680cbfc740ec4f" title="number of sent app loookup packets (incl. forwarded packets)">numAppLookupSent</a> +
  386. <a name="l00356"></a>00356 <a class="code" href="classBaseOverlay.html#af1077d5c646390fb11d4f646fc22eaaa" title="number of sent maintenance packets (incl. forwarded packets)">numMaintenanceSent</a>) / time);
  387. <a name="l00357"></a>00357 <a class="code" href="classBaseRpc.html#a9552ba3a2b09c83b3c561e65dab9f23d" title="pointer to GlobalStatistics module in this node">globalStatistics</a>-&gt;<a class="code" href="classGlobalStatistics.html#a6a697a0b67f344e4bc214159761f943a" title="Add a new value to the cStdDev container specified by the name parameter.">addStdDev</a>(<span class="stringliteral">&quot;BaseOverlay: Sent Total Bytes/s&quot;</span>,
  388. <a name="l00358"></a>00358 (<a class="code" href="classBaseOverlay.html#ae6453766e7a58060722a6323ee3923e4" title="number of sent app data bytes (incl. forwarded bytes)">bytesAppDataSent</a> + <a class="code" href="classBaseOverlay.html#a118e46bc3e194c63a70e28846480ffe4" title="number of sent app lookup bytes (incl. forwarded bytes)">bytesAppLookupSent</a> +
  389. <a name="l00359"></a>00359 <a class="code" href="classBaseOverlay.html#a27259327737ad8092c612756c0fe6fb4" title="number of sent maintenance bytes (incl. forwarded bytes)">bytesMaintenanceSent</a>) / time);
  390. <a name="l00360"></a>00360 <a class="code" href="classBaseRpc.html#a9552ba3a2b09c83b3c561e65dab9f23d" title="pointer to GlobalStatistics module in this node">globalStatistics</a>-&gt;<a class="code" href="classGlobalStatistics.html#a6a697a0b67f344e4bc214159761f943a" title="Add a new value to the cStdDev container specified by the name parameter.">addStdDev</a>(<span class="stringliteral">&quot;BaseOverlay: Sent FindNode Messages/s&quot;</span>,
  391. <a name="l00361"></a>00361 <a class="code" href="classBaseOverlay.html#a210e4277548e47f2ec8e772ae5b6eb7f">numFindNodeSent</a> / time);
  392. <a name="l00362"></a>00362 <a class="code" href="classBaseRpc.html#a9552ba3a2b09c83b3c561e65dab9f23d" title="pointer to GlobalStatistics module in this node">globalStatistics</a>-&gt;<a class="code" href="classGlobalStatistics.html#a6a697a0b67f344e4bc214159761f943a" title="Add a new value to the cStdDev container specified by the name parameter.">addStdDev</a>(<span class="stringliteral">&quot;BaseOverlay: Sent FindNode Bytes/s&quot;</span>,
  393. <a name="l00363"></a>00363 <a class="code" href="classBaseOverlay.html#a99971f360cdde2d41d239418dfad7281">bytesFindNodeSent</a> / time);
  394. <a name="l00364"></a>00364
  395. <a name="l00365"></a>00365 <a class="code" href="classBaseRpc.html#a9552ba3a2b09c83b3c561e65dab9f23d" title="pointer to GlobalStatistics module in this node">globalStatistics</a>-&gt;<a class="code" href="classGlobalStatistics.html#a6a697a0b67f344e4bc214159761f943a" title="Add a new value to the cStdDev container specified by the name parameter.">addStdDev</a>(<span class="stringliteral">&quot;BaseOverlay: Sent FindNodeResponse Messages/s&quot;</span>,
  396. <a name="l00366"></a>00366 <a class="code" href="classBaseOverlay.html#a248581eed6fedf10b2c350cbedd69773">numFindNodeResponseSent</a> / time);
  397. <a name="l00367"></a>00367 <a class="code" href="classBaseRpc.html#a9552ba3a2b09c83b3c561e65dab9f23d" title="pointer to GlobalStatistics module in this node">globalStatistics</a>-&gt;<a class="code" href="classGlobalStatistics.html#a6a697a0b67f344e4bc214159761f943a" title="Add a new value to the cStdDev container specified by the name parameter.">addStdDev</a>(<span class="stringliteral">&quot;BaseOverlay: Sent FindNodeResponse Bytes/s&quot;</span>,
  398. <a name="l00368"></a>00368 <a class="code" href="classBaseOverlay.html#a4b2293e58a3bf5a7ddc0d28cb0669f2f">bytesFindNodeResponseSent</a> / time);
  399. <a name="l00369"></a>00369 <a class="code" href="classBaseRpc.html#a9552ba3a2b09c83b3c561e65dab9f23d" title="pointer to GlobalStatistics module in this node">globalStatistics</a>-&gt;<a class="code" href="classGlobalStatistics.html#a6a697a0b67f344e4bc214159761f943a" title="Add a new value to the cStdDev container specified by the name parameter.">addStdDev</a>(<span class="stringliteral">&quot;BaseOverlay: Sent FailedNode Messages/s&quot;</span>,
  400. <a name="l00370"></a>00370 <a class="code" href="classBaseOverlay.html#a2fef63e0e6d6d7c991c9cb2c95db5733">numFailedNodeSent</a> / time);
  401. <a name="l00371"></a>00371 <a class="code" href="classBaseRpc.html#a9552ba3a2b09c83b3c561e65dab9f23d" title="pointer to GlobalStatistics module in this node">globalStatistics</a>-&gt;<a class="code" href="classGlobalStatistics.html#a6a697a0b67f344e4bc214159761f943a" title="Add a new value to the cStdDev container specified by the name parameter.">addStdDev</a>(<span class="stringliteral">&quot;BaseOverlay: Sent FailedNode Bytes/s&quot;</span>,
  402. <a name="l00372"></a>00372 <a class="code" href="classBaseOverlay.html#aca6ed5880fa17a3bfe432deff8d10e7c">bytesFailedNodeSent</a> / time);
  403. <a name="l00373"></a>00373 <a class="code" href="classBaseRpc.html#a9552ba3a2b09c83b3c561e65dab9f23d" title="pointer to GlobalStatistics module in this node">globalStatistics</a>-&gt;<a class="code" href="classGlobalStatistics.html#a6a697a0b67f344e4bc214159761f943a" title="Add a new value to the cStdDev container specified by the name parameter.">addStdDev</a>(<span class="stringliteral">&quot;BaseOverlay: Sent FailedNodeResponse Messages/s&quot;</span>,
  404. <a name="l00374"></a>00374 <a class="code" href="classBaseOverlay.html#acf40707599a177a1dd5cd9ec4e854dc8">numFailedNodeResponseSent</a> / time);
  405. <a name="l00375"></a>00375 <a class="code" href="classBaseRpc.html#a9552ba3a2b09c83b3c561e65dab9f23d" title="pointer to GlobalStatistics module in this node">globalStatistics</a>-&gt;<a class="code" href="classGlobalStatistics.html#a6a697a0b67f344e4bc214159761f943a" title="Add a new value to the cStdDev container specified by the name parameter.">addStdDev</a>(<span class="stringliteral">&quot;BaseOverlay: Sent FailedNodeResponse Bytes/s&quot;</span>,
  406. <a name="l00376"></a>00376 <a class="code" href="classBaseOverlay.html#aa62ca9476d42c748e40dd0f287823445">bytesFailedNodeResponseSent</a> / time);
  407. <a name="l00377"></a>00377 <a class="code" href="classBaseRpc.html#a9552ba3a2b09c83b3c561e65dab9f23d" title="pointer to GlobalStatistics module in this node">globalStatistics</a>-&gt;<a class="code" href="classGlobalStatistics.html#a6a697a0b67f344e4bc214159761f943a" title="Add a new value to the cStdDev container specified by the name parameter.">addStdDev</a>(<span class="stringliteral">&quot;BaseOverlay: Received App Data Messages/s&quot;</span>,
  408. <a name="l00378"></a>00378 <a class="code" href="classBaseOverlay.html#aa83e680792f987f9f5f779e12c055898" title="number of received app data packets (incl. packets to be forwarded )">numAppDataReceived</a> / time);
  409. <a name="l00379"></a>00379 <a class="code" href="classBaseRpc.html#a9552ba3a2b09c83b3c561e65dab9f23d" title="pointer to GlobalStatistics module in this node">globalStatistics</a>-&gt;<a class="code" href="classGlobalStatistics.html#a6a697a0b67f344e4bc214159761f943a" title="Add a new value to the cStdDev container specified by the name parameter.">addStdDev</a>(<span class="stringliteral">&quot;BaseOverlay: Received App Data Bytes/s&quot;</span>,
  410. <a name="l00380"></a>00380 <a class="code" href="classBaseOverlay.html#a82cd1df80e31e2a9148a9efaacc4bc76" title="number of received app data bytes (incl. bytes to be forwarded)">bytesAppDataReceived</a> / time);
  411. <a name="l00381"></a>00381 <span class="keywordflow">if</span> (<a class="code" href="classBaseOverlay.html#abef37828b7f070044154f53bcd2a765b" title="Returns true if overlay is one in an array, inside a SimpleMultiOverlayHost.">isInSimpleMultiOverlayHost</a>()) {
  412. <a name="l00382"></a>00382 <a class="code" href="classBaseRpc.html#a9552ba3a2b09c83b3c561e65dab9f23d" title="pointer to GlobalStatistics module in this node">globalStatistics</a>-&gt;<a class="code" href="classGlobalStatistics.html#a6a697a0b67f344e4bc214159761f943a" title="Add a new value to the cStdDev container specified by the name parameter.">addStdDev</a>(<span class="stringliteral">&quot;BaseOverlay: Internal Received Messages/s&quot;</span>,
  413. <a name="l00383"></a>00383 <a class="code" href="classBaseOverlay.html#a7f185cb11a818d01dcc1a31553de16ef" title="number of packets received from same host but different port (SimpleMultiOverlayHost)">numInternalReceived</a> / time);
  414. <a name="l00384"></a>00384 <a class="code" href="classBaseRpc.html#a9552ba3a2b09c83b3c561e65dab9f23d" title="pointer to GlobalStatistics module in this node">globalStatistics</a>-&gt;<a class="code" href="classGlobalStatistics.html#a6a697a0b67f344e4bc214159761f943a" title="Add a new value to the cStdDev container specified by the name parameter.">addStdDev</a>(<span class="stringliteral">&quot;BaseOverlay: Internal Received Bytes/s&quot;</span>,
  415. <a name="l00385"></a>00385 <a class="code" href="classBaseOverlay.html#a55ba3d595b6b23db700cb9f36f34f0ae" title="number of bytes received from same host but different port (SimpleMultiOverlayHost)">bytesInternalReceived</a> / time);
  416. <a name="l00386"></a>00386 }
  417. <a name="l00387"></a>00387 <a class="code" href="classBaseRpc.html#a9552ba3a2b09c83b3c561e65dab9f23d" title="pointer to GlobalStatistics module in this node">globalStatistics</a>-&gt;<a class="code" href="classGlobalStatistics.html#a6a697a0b67f344e4bc214159761f943a" title="Add a new value to the cStdDev container specified by the name parameter.">addStdDev</a>(<span class="stringliteral">&quot;BaseOverlay: Received App Lookup Messages/s&quot;</span>,
  418. <a name="l00388"></a>00388 <a class="code" href="classBaseOverlay.html#a9298db97a2d651e02729ad197964bdca" title="number of received app lookup packets (incl. packets to be forwarded)">numAppLookupReceived</a> / time);
  419. <a name="l00389"></a>00389 <a class="code" href="classBaseRpc.html#a9552ba3a2b09c83b3c561e65dab9f23d" title="pointer to GlobalStatistics module in this node">globalStatistics</a>-&gt;<a class="code" href="classGlobalStatistics.html#a6a697a0b67f344e4bc214159761f943a" title="Add a new value to the cStdDev container specified by the name parameter.">addStdDev</a>(<span class="stringliteral">&quot;BaseOverlay: Received App Lookup Bytes/s&quot;</span>,
  420. <a name="l00390"></a>00390 <a class="code" href="classBaseOverlay.html#a8527c9038c62bf66e58c07d41b308527" title="number of received app lookup bytes (incl. bytes to be forwarded)">bytesAppLookupReceived</a> / time);
  421. <a name="l00391"></a>00391 <a class="code" href="classBaseRpc.html#a9552ba3a2b09c83b3c561e65dab9f23d" title="pointer to GlobalStatistics module in this node">globalStatistics</a>-&gt;<a class="code" href="classGlobalStatistics.html#a6a697a0b67f344e4bc214159761f943a" title="Add a new value to the cStdDev container specified by the name parameter.">addStdDev</a>(<span class="stringliteral">&quot;BaseOverlay: Received Maintenance Messages/s&quot;</span>,
  422. <a name="l00392"></a>00392 <a class="code" href="classBaseOverlay.html#a4e7abb41a2c8698bf530015378a13e46" title="number of received maintenance packets (incl. packets to be forwarded)">numMaintenanceReceived</a> / time);
  423. <a name="l00393"></a>00393 <a class="code" href="classBaseRpc.html#a9552ba3a2b09c83b3c561e65dab9f23d" title="pointer to GlobalStatistics module in this node">globalStatistics</a>-&gt;<a class="code" href="classGlobalStatistics.html#a6a697a0b67f344e4bc214159761f943a" title="Add a new value to the cStdDev container specified by the name parameter.">addStdDev</a>(<span class="stringliteral">&quot;BaseOverlay: Received Maintenance Bytes/s&quot;</span>,
  424. <a name="l00394"></a>00394 <a class="code" href="classBaseOverlay.html#ad7bd70b69842cc4db485eafa942332fb" title="number of received maintenance bytes (incl. bytes to be forwarded)">bytesMaintenanceReceived</a> / time);
  425. <a name="l00395"></a>00395
  426. <a name="l00396"></a>00396 <a class="code" href="classBaseRpc.html#a9552ba3a2b09c83b3c561e65dab9f23d" title="pointer to GlobalStatistics module in this node">globalStatistics</a>-&gt;<a class="code" href="classGlobalStatistics.html#a6a697a0b67f344e4bc214159761f943a" title="Add a new value to the cStdDev container specified by the name parameter.">addStdDev</a>(<span class="stringliteral">&quot;BaseOverlay: Received Total Messages/s&quot;</span>,
  427. <a name="l00397"></a>00397 (<a class="code" href="classBaseOverlay.html#aa83e680792f987f9f5f779e12c055898" title="number of received app data packets (incl. packets to be forwarded )">numAppDataReceived</a> + <a class="code" href="classBaseOverlay.html#a9298db97a2d651e02729ad197964bdca" title="number of received app lookup packets (incl. packets to be forwarded)">numAppLookupReceived</a> +
  428. <a name="l00398"></a>00398 <a class="code" href="classBaseOverlay.html#a4e7abb41a2c8698bf530015378a13e46" title="number of received maintenance packets (incl. packets to be forwarded)">numMaintenanceReceived</a>)/time);
  429. <a name="l00399"></a>00399 <a class="code" href="classBaseRpc.html#a9552ba3a2b09c83b3c561e65dab9f23d" title="pointer to GlobalStatistics module in this node">globalStatistics</a>-&gt;<a class="code" href="classGlobalStatistics.html#a6a697a0b67f344e4bc214159761f943a" title="Add a new value to the cStdDev container specified by the name parameter.">addStdDev</a>(<span class="stringliteral">&quot;BaseOverlay: Received Total Bytes/s&quot;</span>,
  430. <a name="l00400"></a>00400 (<a class="code" href="classBaseOverlay.html#a82cd1df80e31e2a9148a9efaacc4bc76" title="number of received app data bytes (incl. bytes to be forwarded)">bytesAppDataReceived</a> + <a class="code" href="classBaseOverlay.html#a8527c9038c62bf66e58c07d41b308527" title="number of received app lookup bytes (incl. bytes to be forwarded)">bytesAppLookupReceived</a> +
  431. <a name="l00401"></a>00401 <a class="code" href="classBaseOverlay.html#ad7bd70b69842cc4db485eafa942332fb" title="number of received maintenance bytes (incl. bytes to be forwarded)">bytesMaintenanceReceived</a>)/time);
  432. <a name="l00402"></a>00402 <a class="code" href="classBaseRpc.html#a9552ba3a2b09c83b3c561e65dab9f23d" title="pointer to GlobalStatistics module in this node">globalStatistics</a>-&gt;<a class="code" href="classGlobalStatistics.html#a6a697a0b67f344e4bc214159761f943a" title="Add a new value to the cStdDev container specified by the name parameter.">addStdDev</a>(<span class="stringliteral">&quot;BaseOverlay: Forwarded App Data Messages/s&quot;</span>,
  433. <a name="l00403"></a>00403 <a class="code" href="classBaseOverlay.html#a341a65ab7c50dfbc8222c1adf4f08a99" title="number of forwarded app data packets">numAppDataForwarded</a> / time);
  434. <a name="l00404"></a>00404 <a class="code" href="classBaseRpc.html#a9552ba3a2b09c83b3c561e65dab9f23d" title="pointer to GlobalStatistics module in this node">globalStatistics</a>-&gt;<a class="code" href="classGlobalStatistics.html#a6a697a0b67f344e4bc214159761f943a" title="Add a new value to the cStdDev container specified by the name parameter.">addStdDev</a>(<span class="stringliteral">&quot;BaseOverlay: Forwarded App Data Bytes/s&quot;</span>,
  435. <a name="l00405"></a>00405 <a class="code" href="classBaseOverlay.html#a1c90204205e7e5b8f0f12fe4056914e6" title="number of forwarded app data bytes at out-gate">bytesAppDataForwarded</a> / time);
  436. <a name="l00406"></a>00406 <a class="code" href="classBaseRpc.html#a9552ba3a2b09c83b3c561e65dab9f23d" title="pointer to GlobalStatistics module in this node">globalStatistics</a>-&gt;<a class="code" href="classGlobalStatistics.html#a6a697a0b67f344e4bc214159761f943a" title="Add a new value to the cStdDev container specified by the name parameter.">addStdDev</a>(<span class="stringliteral">&quot;BaseOverlay: Forwarded App Lookup Messages/s&quot;</span>,
  437. <a name="l00407"></a>00407 <a class="code" href="classBaseOverlay.html#a8f5ff290e99ab78f3e0bd4a489bfcadd" title="number of forwarded app lookup packets">numAppLookupForwarded</a> / time);
  438. <a name="l00408"></a>00408 <a class="code" href="classBaseRpc.html#a9552ba3a2b09c83b3c561e65dab9f23d" title="pointer to GlobalStatistics module in this node">globalStatistics</a>-&gt;<a class="code" href="classGlobalStatistics.html#a6a697a0b67f344e4bc214159761f943a" title="Add a new value to the cStdDev container specified by the name parameter.">addStdDev</a>(<span class="stringliteral">&quot;BaseOverlay: Forwarded App Lookup Bytes/s&quot;</span>,
  439. <a name="l00409"></a>00409 <a class="code" href="classBaseOverlay.html#adeff8c454760c6eb4ca847e8dda252a7" title="number of forwarded app lookup bytes at out-gate">bytesAppLookupForwarded</a> / time);
  440. <a name="l00410"></a>00410 <a class="code" href="classBaseRpc.html#a9552ba3a2b09c83b3c561e65dab9f23d" title="pointer to GlobalStatistics module in this node">globalStatistics</a>-&gt;<a class="code" href="classGlobalStatistics.html#a6a697a0b67f344e4bc214159761f943a" title="Add a new value to the cStdDev container specified by the name parameter.">addStdDev</a>(<span class="stringliteral">&quot;BaseOverlay: Forwarded Maintenance Messages/s&quot;</span>,
  441. <a name="l00411"></a>00411 <a class="code" href="classBaseOverlay.html#a05fa895acb368180bbca74d92152d2f7" title="number of forwarded maintenance packets">numMaintenanceForwarded</a> / time);
  442. <a name="l00412"></a>00412 <a class="code" href="classBaseRpc.html#a9552ba3a2b09c83b3c561e65dab9f23d" title="pointer to GlobalStatistics module in this node">globalStatistics</a>-&gt;<a class="code" href="classGlobalStatistics.html#a6a697a0b67f344e4bc214159761f943a" title="Add a new value to the cStdDev container specified by the name parameter.">addStdDev</a>(<span class="stringliteral">&quot;BaseOverlay: Forwarded Maintenance Bytes/s&quot;</span>,
  443. <a name="l00413"></a>00413 <a class="code" href="classBaseOverlay.html#a8dbb1ce4eee057f23bea55e5e4a7d13b" title="number of forwarded maintenance bytes at out-gate">bytesMaintenanceForwarded</a> / time);
  444. <a name="l00414"></a>00414 <a class="code" href="classBaseRpc.html#a9552ba3a2b09c83b3c561e65dab9f23d" title="pointer to GlobalStatistics module in this node">globalStatistics</a>-&gt;<a class="code" href="classGlobalStatistics.html#a6a697a0b67f344e4bc214159761f943a" title="Add a new value to the cStdDev container specified by the name parameter.">addStdDev</a>(<span class="stringliteral">&quot;BaseOverlay: Forwarded Total Messages/s&quot;</span>,
  445. <a name="l00415"></a>00415 (<a class="code" href="classBaseOverlay.html#a341a65ab7c50dfbc8222c1adf4f08a99" title="number of forwarded app data packets">numAppDataForwarded</a> + <a class="code" href="classBaseOverlay.html#a8f5ff290e99ab78f3e0bd4a489bfcadd" title="number of forwarded app lookup packets">numAppLookupForwarded</a> +
  446. <a name="l00416"></a>00416 <a class="code" href="classBaseOverlay.html#a05fa895acb368180bbca74d92152d2f7" title="number of forwarded maintenance packets">numMaintenanceForwarded</a>) / time);
  447. <a name="l00417"></a>00417 <a class="code" href="classBaseRpc.html#a9552ba3a2b09c83b3c561e65dab9f23d" title="pointer to GlobalStatistics module in this node">globalStatistics</a>-&gt;<a class="code" href="classGlobalStatistics.html#a6a697a0b67f344e4bc214159761f943a" title="Add a new value to the cStdDev container specified by the name parameter.">addStdDev</a>(<span class="stringliteral">&quot;BaseOverlay: Forwarded Total Bytes/s&quot;</span>,
  448. <a name="l00418"></a>00418 (<a class="code" href="classBaseOverlay.html#a1c90204205e7e5b8f0f12fe4056914e6" title="number of forwarded app data bytes at out-gate">bytesAppDataForwarded</a> + <a class="code" href="classBaseOverlay.html#adeff8c454760c6eb4ca847e8dda252a7" title="number of forwarded app lookup bytes at out-gate">bytesAppLookupForwarded</a> +
  449. <a name="l00419"></a>00419 <a class="code" href="classBaseOverlay.html#a8dbb1ce4eee057f23bea55e5e4a7d13b" title="number of forwarded maintenance bytes at out-gate">bytesMaintenanceForwarded</a>) / time);
  450. <a name="l00420"></a>00420
  451. <a name="l00421"></a>00421 <a class="code" href="classBaseRpc.html#a9552ba3a2b09c83b3c561e65dab9f23d" title="pointer to GlobalStatistics module in this node">globalStatistics</a>-&gt;<a class="code" href="classGlobalStatistics.html#a6a697a0b67f344e4bc214159761f943a" title="Add a new value to the cStdDev container specified by the name parameter.">addStdDev</a>(<span class="stringliteral">&quot;BaseOverlay: Dropped Messages/s&quot;</span>,
  452. <a name="l00422"></a>00422 <a class="code" href="classBaseOverlay.html#a4a82bd4b76a8d06a1d63bba98f1a34d7" title="number of dropped packets">numDropped</a> / time);
  453. <a name="l00423"></a>00423 <a class="code" href="classBaseRpc.html#a9552ba3a2b09c83b3c561e65dab9f23d" title="pointer to GlobalStatistics module in this node">globalStatistics</a>-&gt;<a class="code" href="classGlobalStatistics.html#a6a697a0b67f344e4bc214159761f943a" title="Add a new value to the cStdDev container specified by the name parameter.">addStdDev</a>(<span class="stringliteral">&quot;BaseOverlay: Dropped Bytes/s&quot;</span>,
  454. <a name="l00424"></a>00424 <a class="code" href="classBaseOverlay.html#a9e09857b97f52d340e4710580f25f7a6" title="number of dropped bytes">bytesDropped</a> / time);
  455. <a name="l00425"></a>00425
  456. <a name="l00426"></a>00426 <a class="code" href="classBaseRpc.html#a9552ba3a2b09c83b3c561e65dab9f23d" title="pointer to GlobalStatistics module in this node">globalStatistics</a>-&gt;<a class="code" href="classGlobalStatistics.html#a6a697a0b67f344e4bc214159761f943a" title="Add a new value to the cStdDev container specified by the name parameter.">addStdDev</a>(<span class="stringliteral">&quot;BaseOverlay: Measured Session Time&quot;</span>,
  457. <a name="l00427"></a>00427 SIMTIME_DBL(simTime() - <a class="code" href="classBaseOverlay.html#af0eebaddea732ee4ab4d247c388e62bd" title="simtime when the node has been created">creationTime</a>));
  458. <a name="l00428"></a>00428
  459. <a name="l00429"></a>00429 <a class="code" href="classBaseRpc.html#a9552ba3a2b09c83b3c561e65dab9f23d" title="pointer to GlobalStatistics module in this node">globalStatistics</a>-&gt;<a class="code" href="classGlobalStatistics.html#a6a697a0b67f344e4bc214159761f943a" title="Add a new value to the cStdDev container specified by the name parameter.">addStdDev</a>(<span class="stringliteral">&quot;BaseOverlay: Sent Ping Messages/s&quot;</span>,
  460. <a name="l00430"></a>00430 <a class="code" href="classBaseRpc.html#a16d5d34610391c442e9f9cde71b2518a">numPingSent</a> / time);
  461. <a name="l00431"></a>00431 <a class="code" href="classBaseRpc.html#a9552ba3a2b09c83b3c561e65dab9f23d" title="pointer to GlobalStatistics module in this node">globalStatistics</a>-&gt;<a class="code" href="classGlobalStatistics.html#a6a697a0b67f344e4bc214159761f943a" title="Add a new value to the cStdDev container specified by the name parameter.">addStdDev</a>(<span class="stringliteral">&quot;BaseOverlay: Sent Ping Bytes/s&quot;</span>,
  462. <a name="l00432"></a>00432 <a class="code" href="classBaseRpc.html#a5653805d9dcb9a53bc240b388e735389">bytesPingSent</a> / time);
  463. <a name="l00433"></a>00433 <a class="code" href="classBaseRpc.html#a9552ba3a2b09c83b3c561e65dab9f23d" title="pointer to GlobalStatistics module in this node">globalStatistics</a>-&gt;<a class="code" href="classGlobalStatistics.html#a6a697a0b67f344e4bc214159761f943a" title="Add a new value to the cStdDev container specified by the name parameter.">addStdDev</a>(<span class="stringliteral">&quot;BaseOverlay: Sent Ping Response Messages/s&quot;</span>,
  464. <a name="l00434"></a>00434 <a class="code" href="classBaseRpc.html#a5f194baa9787f523bdbf6f8639356a62">numPingResponseSent</a> / time);
  465. <a name="l00435"></a>00435 <a class="code" href="classBaseRpc.html#a9552ba3a2b09c83b3c561e65dab9f23d" title="pointer to GlobalStatistics module in this node">globalStatistics</a>-&gt;<a class="code" href="classGlobalStatistics.html#a6a697a0b67f344e4bc214159761f943a" title="Add a new value to the cStdDev container specified by the name parameter.">addStdDev</a>(<span class="stringliteral">&quot;BaseOverlay: Sent Ping Response Bytes/s&quot;</span>,
  466. <a name="l00436"></a>00436 <a class="code" href="classBaseRpc.html#a8525bc500487a2641a2a947b0d5e1946">bytesPingResponseSent</a> / time);
  467. <a name="l00437"></a>00437
  468. <a name="l00438"></a>00438 <span class="keywordflow">if</span> (<a class="code" href="classBaseOverlay.html#a077a698fb5f760290bc67e4a50dfed9e">getMeasureAuthBlock</a>()) {
  469. <a name="l00439"></a>00439 <a class="code" href="classBaseRpc.html#a9552ba3a2b09c83b3c561e65dab9f23d" title="pointer to GlobalStatistics module in this node">globalStatistics</a>-&gt;<a class="code" href="classGlobalStatistics.html#a6a697a0b67f344e4bc214159761f943a" title="Add a new value to the cStdDev container specified by the name parameter.">addStdDev</a>(<span class="stringliteral">&quot;BaseOverlay: Sent AuthBlock Bytes/s&quot;</span>,
  470. <a name="l00440"></a>00440 <a class="code" href="classBaseOverlay.html#a30e11530c77c2164f0a5c98a489a9fab" title="number of bytes sent for rpc message signatures">bytesAuthBlockSent</a> / time);
  471. <a name="l00441"></a>00441 }
  472. <a name="l00442"></a>00442 }
  473. <a name="l00443"></a>00443 }
  474. <a name="l00444"></a>00444
  475. <a name="l00445"></a><a class="code" href="classBaseOverlay.html#a8db85b9c706d04007154761d5a0cec16">00445</a> <span class="keywordtype">void</span> <a class="code" href="classBaseOverlay.html#a8db85b9c706d04007154761d5a0cec16" title="collects statistical data in derived class">BaseOverlay::finishOverlay</a>()
  476. <a name="l00446"></a>00446 {
  477. <a name="l00447"></a>00447 }
  478. <a name="l00448"></a>00448
  479. <a name="l00449"></a>00449 <span class="comment">//------------------------------------------------------------------------</span>
  480. <a name="l00450"></a>00450 <span class="comment">//--- General Overlay Parameters (getter and setters) --------------------</span>
  481. <a name="l00451"></a>00451 <span class="comment">//------------------------------------------------------------------------</span>
  482. <a name="l00452"></a><a class="code" href="classBaseOverlay.html#a234b046348574d37d811638f0b27a89e">00452</a> <span class="keywordtype">bool</span> <a class="code" href="classBaseOverlay.html#a234b046348574d37d811638f0b27a89e" title="Returns true, if node is malicious.">BaseOverlay::isMalicious</a>()
  483. <a name="l00453"></a>00453 {
  484. <a name="l00454"></a>00454 <span class="keywordflow">return</span> <a class="code" href="classBaseOverlay.html#a933e505ea77cae4ab0c8edcb77ade2c7" title="pointer to GlobalNodeList in this node">globalNodeList</a>-&gt;<a class="code" href="classGlobalNodeList.html#a8312d71c91eac1144c94c41fe121a755" title="Check if a node is malicious.">isMalicious</a>(<a class="code" href="classBaseRpc.html#ac3f420630d5618e81709c078b06fd9da" title="Returns the NodeHandle of this node.">getThisNode</a>());
  485. <a name="l00455"></a>00455 }
  486. <a name="l00456"></a>00456
  487. <a name="l00457"></a><a class="code" href="classBaseOverlay.html#a92e0d3f96a5716245465e05da60ef487">00457</a> <a class="code" href="CommonMessages__m_8h.html#aad57ef0110fe8675eb299d467148bc5e" title="Enum generated from common/CommonMessages.msg by opp_msgc.">CompType</a> <a class="code" href="classBaseOverlay.html#a92e0d3f96a5716245465e05da60ef487">BaseOverlay::getThisCompType</a>()
  488. <a name="l00458"></a>00458 {
  489. <a name="l00459"></a>00459 <span class="keywordflow">return</span> OVERLAY_COMP;
  490. <a name="l00460"></a>00460 }
  491. <a name="l00461"></a>00461
  492. <a name="l00462"></a>00462 <span class="comment">//------------------------------------------------------------------------</span>
  493. <a name="l00463"></a>00463 <span class="comment">//--- UDP functions copied from the INET framework .----------------------</span>
  494. <a name="l00464"></a>00464 <span class="comment">//------------------------------------------------------------------------</span>
  495. <a name="l00465"></a><a class="code" href="classBaseOverlay.html#a512084e3a224f0a3f284e5e240652a26">00465</a> <span class="keywordtype">void</span> <a class="code" href="classBaseOverlay.html#a512084e3a224f0a3f284e5e240652a26" title="Tells UDP we want to get all packets arriving on the given port.">BaseOverlay::bindToPort</a>(<span class="keywordtype">int</span> port)
  496. <a name="l00466"></a>00466 {
  497. <a name="l00467"></a>00467 EV &lt;&lt; <span class="stringliteral">&quot;[BaseOverlay::bindToPort() @ &quot;</span> &lt;&lt; <a class="code" href="classBaseRpc.html#a88eb68c06450fd12ea072f471bf1c1b8" title="NodeHandle to this node.">thisNode</a>.<a class="code" href="classTransportAddress.html#a00e613d98d3412e2b92897c25aa0eb4c" title="returns ip address">getIp</a>()
  498. <a name="l00468"></a>00468 &lt;&lt; <span class="stringliteral">&quot; (&quot;</span> &lt;&lt; <a class="code" href="classBaseRpc.html#a88eb68c06450fd12ea072f471bf1c1b8" title="NodeHandle to this node.">thisNode</a>.<a class="code" href="classNodeHandle.html#aef531103cdf07c8353267f4d30a80112" title="returns key of this NodeHandle">getKey</a>().<a class="code" href="classOverlayKey.html#aabeb4fd284a630a82e982ba34ece4fd9" title="Returns a string representation of this key.">toString</a>(16) &lt;&lt; <span class="stringliteral">&quot;)]\n&quot;</span>
  499. <a name="l00469"></a>00469 &lt;&lt; <span class="stringliteral">&quot; Binding to UDP port &quot;</span> &lt;&lt; port
  500. <a name="l00470"></a>00470 &lt;&lt; endl;
  501. <a name="l00471"></a>00471
  502. <a name="l00472"></a>00472 <a class="code" href="classBaseRpc.html#a88eb68c06450fd12ea072f471bf1c1b8" title="NodeHandle to this node.">thisNode</a>.<a class="code" href="classTransportAddress.html#a46a1b53760e5f2d3f8af8c9591160a48" title="sets this-&amp;gt;port to the given port">setPort</a>(port);
  503. <a name="l00473"></a>00473
  504. <a name="l00474"></a>00474 <span class="comment">// TODO UDPAppBase should be ported to use UDPSocket sometime, but for now</span>
  505. <a name="l00475"></a>00475 <span class="comment">// we just manage the UDP socket by hand...</span>
  506. <a name="l00476"></a>00476 cMessage *msg = <span class="keyword">new</span> cMessage(<span class="stringliteral">&quot;UDP_C_BIND&quot;</span>, UDP_C_BIND);
  507. <a name="l00477"></a>00477 UDPControlInfo *ctrl = <span class="keyword">new</span> UDPControlInfo();
  508. <a name="l00478"></a>00478 ctrl-&gt;setSrcPort(port);
  509. <a name="l00479"></a>00479 ctrl-&gt;setSockId(UDPSocket::generateSocketId());
  510. <a name="l00480"></a>00480 msg-&gt;setControlInfo(ctrl);
  511. <a name="l00481"></a>00481 send(msg, <span class="stringliteral">&quot;udpOut&quot;</span>);
  512. <a name="l00482"></a>00482 }
  513. <a name="l00483"></a>00483
  514. <a name="l00484"></a>00484
  515. <a name="l00485"></a>00485 <span class="comment">//------------------------------------------------------------------------</span>
  516. <a name="l00486"></a>00486 <span class="comment">//--- Overlay Common API: Key-based Routing ------------------------------</span>
  517. <a name="l00487"></a>00487 <span class="comment">//------------------------------------------------------------------------</span>
  518. <a name="l00488"></a>00488
  519. <a name="l00489"></a><a class="code" href="classBaseOverlay.html#a432f79071b87baece93311300cfda0c3">00489</a> <span class="keywordtype">void</span> <a class="code" href="classBaseOverlay.html#a432f79071b87baece93311300cfda0c3" title="Calls deliver function in application.">BaseOverlay::callDeliver</a>(<a class="code" href="classBaseOverlayMessage.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">BaseOverlayMessage</a>* msg,
  520. <a name="l00490"></a>00490 <span class="keyword">const</span> <a class="code" href="classOverlayKey.html" title="A common overlay key class.">OverlayKey</a>&amp; destKey)
  521. <a name="l00491"></a>00491 {
  522. <a name="l00492"></a>00492 <a class="code" href="classKBRdeliver.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">KBRdeliver</a>* deliverMsg = <span class="keyword">new</span> <a class="code" href="classKBRdeliver.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">KBRdeliver</a>();
  523. <a name="l00493"></a>00493
  524. <a name="l00494"></a>00494 <a class="code" href="classOverlayCtrlInfo.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">OverlayCtrlInfo</a>* overlayCtrlInfo =
  525. <a name="l00495"></a>00495 check_and_cast&lt;<a class="code" href="classOverlayCtrlInfo.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">OverlayCtrlInfo</a>*&gt;(msg-&gt;removeControlInfo());
  526. <a name="l00496"></a>00496
  527. <a name="l00497"></a>00497 <a class="code" href="classBaseAppDataMessage.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">BaseAppDataMessage</a>* appDataMsg = <span class="keyword">dynamic_cast&lt;</span><a class="code" href="classBaseAppDataMessage.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">BaseAppDataMessage</a>*<span class="keyword">&gt;</span>(msg);
  528. <a name="l00498"></a>00498
  529. <a name="l00499"></a>00499 <span class="comment">// TODO GIA</span>
  530. <a name="l00500"></a>00500 <span class="keywordflow">if</span> (appDataMsg != NULL) {
  531. <a name="l00501"></a>00501 overlayCtrlInfo-&gt;<a class="code" href="classOverlayCtrlInfo.html#a984d51d889959257fd74b9a35ca4ffb6">setSrcComp</a>(appDataMsg-&gt;getSrcComp());
  532. <a name="l00502"></a>00502 overlayCtrlInfo-&gt;<a class="code" href="classOverlayCtrlInfo.html#a5db196b85bb865f24777badc887f0e66">setDestComp</a>(appDataMsg-&gt;getDestComp());
  533. <a name="l00503"></a>00503 }
  534. <a name="l00504"></a>00504
  535. <a name="l00505"></a>00505 deliverMsg-&gt;setControlInfo(overlayCtrlInfo);
  536. <a name="l00506"></a>00506 deliverMsg-&gt;<a class="code" href="classKBRdeliver.html#a961d293718a9481253585a7b0103e054">setDestKey</a>(destKey);
  537. <a name="l00507"></a>00507 deliverMsg-&gt;encapsulate(msg-&gt;decapsulate());
  538. <a name="l00508"></a>00508 deliverMsg-&gt;<a class="code" href="classCommonAPIMessage.html#a161ae8c663ecca1ada7f68f2b010d774">setType</a>(<a class="code" href="CommonMessages__m_8h.html#a61951439f8b8b0a1c54516d2e4c72297a9379c2a8f1bf319d3839652a3f3270ca">KBR_DELIVER</a>);
  539. <a name="l00509"></a>00509
  540. <a name="l00510"></a>00510 cGate* destGate = <a class="code" href="classBaseOverlay.html#a5fc03fda227c0cca828109842af1b320">getCompRpcGate</a>(static_cast&lt;CompType&gt;(
  541. <a name="l00511"></a>00511 overlayCtrlInfo-&gt;<a class="code" href="classOverlayCtrlInfo.html#a082f26c9d0cac0aec9ca23da4d338134">getDestComp</a>()));
  542. <a name="l00512"></a>00512
  543. <a name="l00513"></a>00513 <span class="keywordflow">if</span> (destGate == NULL) {
  544. <a name="l00514"></a>00514 <span class="keywordflow">throw</span> cRuntimeError(<span class="stringliteral">&quot;BaseOverlay::callDeliver(): Unknown destComp!&quot;</span>);
  545. <a name="l00515"></a>00515 }
  546. <a name="l00516"></a>00516
  547. <a name="l00517"></a>00517 sendDirect(deliverMsg, destGate);
  548. <a name="l00518"></a>00518
  549. <a name="l00519"></a>00519 <span class="keyword">delete</span> msg;
  550. <a name="l00520"></a>00520 }
  551. <a name="l00521"></a>00521
  552. <a name="l00522"></a><a class="code" href="classBaseOverlay.html#a71bcb54aa4fc66bdf97cc9c87fffc318">00522</a> <span class="keywordtype">void</span> <a class="code" href="classBaseOverlay.html#a71bcb54aa4fc66bdf97cc9c87fffc318" title="Calls forward function in application.">BaseOverlay::callForward</a>(<span class="keyword">const</span> <a class="code" href="classOverlayKey.html" title="A common overlay key class.">OverlayKey</a>&amp; key, <a class="code" href="classBaseRouteMessage.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">BaseRouteMessage</a>* msg,
  553. <a name="l00523"></a>00523 <span class="keyword">const</span> <a class="code" href="classNodeHandle.html" title="This class implements a node handle.">NodeHandle</a>&amp; nextHopNode)
  554. <a name="l00524"></a>00524 {
  555. <a name="l00525"></a>00525 <a class="code" href="classKBRforward.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">KBRforward</a>* forwardMsg = <span class="keyword">new</span> <a class="code" href="classKBRforward.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">KBRforward</a>();
  556. <a name="l00526"></a>00526
  557. <a name="l00527"></a>00527 forwardMsg-&gt;<a class="code" href="classKBRforward.html#abd3f6be7b4fcfa4549386076963cd352">setDestKey</a>(msg-&gt;<a class="code" href="classBaseRouteMessage.html#ad983641a05758bc9d25070f1659b2f34">getDestKey</a>());
  558. <a name="l00528"></a>00528 forwardMsg-&gt;<a class="code" href="classKBRforward.html#aa6ef158528be8b36ba7cec392da0b1ba">setNextHopNode</a>(nextHopNode);
  559. <a name="l00529"></a>00529 forwardMsg-&gt;encapsulate(msg-&gt;getEncapsulatedPacket()-&gt;decapsulate());
  560. <a name="l00530"></a>00530
  561. <a name="l00531"></a>00531 <a class="code" href="classOverlayCtrlInfo.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">OverlayCtrlInfo</a>* overlayCtrlInfo =
  562. <a name="l00532"></a>00532 <span class="keyword">new</span> <a class="code" href="classOverlayCtrlInfo.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">OverlayCtrlInfo</a>();
  563. <a name="l00533"></a>00533 overlayCtrlInfo-&gt;<a class="code" href="classOverlayCtrlInfo.html#a129cf7292587fa2ee6e4e6238c5e4d33">setTransportType</a>(<a class="code" href="CommonMessages__m_8h.html#aca1e72535e7f260e54ed8bbf984dade9a03dcc78e081682d383ff0baec54dcf8c">ROUTE_TRANSPORT</a>);
  564. <a name="l00534"></a>00534 overlayCtrlInfo-&gt;<a class="code" href="classOverlayCtrlInfo.html#a2e3bd66c1e71acd70a6d87817efe15db">setRoutingType</a>(msg-&gt;<a class="code" href="classBaseRouteMessage.html#a834dd9c8f0b2b776ed5f5b1fa285149a">getRoutingType</a>());
  565. <a name="l00535"></a>00535 overlayCtrlInfo-&gt;<a class="code" href="classOverlayCtrlInfo.html#a790ec1f663fccc40033e6a8e714adbff">setHopCount</a>(msg-&gt;<a class="code" href="classBaseRouteMessage.html#ab59d2969c812aa35d132a68fc2baf819">getHopCount</a>());
  566. <a name="l00536"></a>00536 overlayCtrlInfo-&gt;<a class="code" href="classOverlayCtrlInfo.html#a57150c423c6413ed906a81402e8df0f5">setSrcNode</a>(msg-&gt;<a class="code" href="classBaseRouteMessage.html#af9787d89915f01a2055e920148015e17">getSrcNode</a>());
  567. <a name="l00537"></a>00537 overlayCtrlInfo-&gt;<a class="code" href="classOverlayCtrlInfo.html#a984d51d889959257fd74b9a35ca4ffb6">setSrcComp</a>(check_and_cast&lt;BaseAppDataMessage*&gt;
  568. <a name="l00538"></a>00538 (msg-&gt;getEncapsulatedPacket())-&gt;getSrcComp());
  569. <a name="l00539"></a>00539 overlayCtrlInfo-&gt;<a class="code" href="classOverlayCtrlInfo.html#a5db196b85bb865f24777badc887f0e66">setDestComp</a>(check_and_cast&lt;BaseAppDataMessage*&gt;
  570. <a name="l00540"></a>00540 (msg-&gt;getEncapsulatedPacket())-&gt;getDestComp());
  571. <a name="l00541"></a>00541
  572. <a name="l00542"></a>00542 <span class="keywordflow">if</span> (msg-&gt;getControlInfo() != NULL) {
  573. <a name="l00543"></a>00543 <a class="code" href="classOverlayCtrlInfo.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">OverlayCtrlInfo</a>* ctrlInfo =
  574. <a name="l00544"></a>00544 check_and_cast&lt;<a class="code" href="classOverlayCtrlInfo.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">OverlayCtrlInfo</a>*&gt;(msg-&gt;removeControlInfo());
  575. <a name="l00545"></a>00545
  576. <a name="l00546"></a>00546 overlayCtrlInfo-&gt;<a class="code" href="classOverlayCtrlInfo.html#a6c2c1955d30ba60f696247685dc3d6ae">setLastHop</a>(ctrlInfo-&gt;<a class="code" href="classOverlayCtrlInfo.html#ad12b7ac74244fb7ab79ebf41e05fe79c">getLastHop</a>());
  577. <a name="l00547"></a>00547
  578. <a name="l00548"></a>00548 <span class="keyword">delete</span> ctrlInfo;
  579. <a name="l00549"></a>00549 }
  580. <a name="l00550"></a>00550
  581. <a name="l00551"></a>00551 forwardMsg-&gt;setControlInfo(overlayCtrlInfo);
  582. <a name="l00552"></a>00552
  583. <a name="l00553"></a>00553 forwardMsg-&gt;<a class="code" href="classCommonAPIMessage.html#a161ae8c663ecca1ada7f68f2b010d774">setType</a>(<a class="code" href="CommonMessages__m_8h.html#a61951439f8b8b0a1c54516d2e4c72297a0afbe139422edee97cf4f5998edbfc9e">KBR_FORWARD</a>);
  584. <a name="l00554"></a>00554
  585. <a name="l00555"></a>00555 send(forwardMsg, <span class="stringliteral">&quot;appOut&quot;</span>);
  586. <a name="l00556"></a>00556
  587. <a name="l00557"></a>00557 <span class="keyword">delete</span> msg;
  588. <a name="l00558"></a>00558 }
  589. <a name="l00559"></a>00559
  590. <a name="l00560"></a><a class="code" href="classBaseOverlay.html#a95851770a6ab3a176e1d7b5a7afba3f0">00560</a> <a class="code" href="classBaseKeySortedVector.html">NodeVector</a>* <a class="code" href="classBaseOverlay.html#a95851770a6ab3a176e1d7b5a7afba3f0" title="finds nodes closest to the given OverlayKey">BaseOverlay::local_lookup</a>(<span class="keyword">const</span> <a class="code" href="classOverlayKey.html" title="A common overlay key class.">OverlayKey</a>&amp; key,
  591. <a name="l00561"></a>00561 <span class="keywordtype">int</span> num, <span class="keywordtype">bool</span> safe)
  592. <a name="l00562"></a>00562 {
  593. <a name="l00563"></a>00563 Enter_Method(<span class="stringliteral">&quot;local_lookup()&quot;</span>);
  594. <a name="l00564"></a>00564
  595. <a name="l00565"></a>00565 <span class="keywordflow">if</span> (safe == <span class="keyword">true</span>) {
  596. <a name="l00566"></a>00566 <span class="keywordflow">throw</span> cRuntimeError(<span class="stringliteral">&quot;BaseOverlay::local_lookup(): &quot;</span>
  597. <a name="l00567"></a>00567 <span class="stringliteral">&quot;safe flag is not implemented!&quot;</span>);
  598. <a name="l00568"></a>00568 }
  599. <a name="l00569"></a>00569
  600. <a name="l00570"></a>00570 <span class="keywordflow">if</span> (num &lt; 0) num = INT_MAX;
  601. <a name="l00571"></a>00571 <a class="code" href="classBaseKeySortedVector.html">NodeVector</a>* nodeVector = <a class="code" href="classBaseOverlay.html#a7cbdce336237331b67a3c69c4e43d489" title="Implements the find node call.">findNode</a>(key, min(num, <a class="code" href="classBaseOverlay.html#ab4dadd02486560de3a58773b3a90fb41" title="Query the maximum number of redundant next hop nodes that are returned by findNode().">getMaxNumRedundantNodes</a>()),
  602. <a name="l00572"></a>00572 min(num,<a class="code" href="classBaseOverlay.html#acd3058ad15b470e024500dd4872e2f09" title="Query the maximum number of siblings (nodes close to a key) that are maintained by this overlay proto...">getMaxNumSiblings</a>()));
  603. <a name="l00573"></a>00573
  604. <a name="l00574"></a>00574 <span class="keywordflow">if</span> (((<span class="keywordtype">int</span>)nodeVector-&gt;size()) &gt; num)
  605. <a name="l00575"></a>00575 nodeVector-&gt;resize(num);
  606. <a name="l00576"></a>00576
  607. <a name="l00577"></a>00577 <span class="keywordflow">return</span> nodeVector;
  608. <a name="l00578"></a>00578 }
  609. <a name="l00579"></a>00579
  610. <a name="l00580"></a><a class="code" href="classBaseOverlay.html#acb8855faa86247ae37ab894891d9f4dd">00580</a> <span class="keywordtype">void</span> <a class="code" href="classBaseOverlay.html#acb8855faa86247ae37ab894891d9f4dd" title="Join the overlay with a given nodeID.">BaseOverlay::join</a>(<span class="keyword">const</span> <a class="code" href="classOverlayKey.html" title="A common overlay key class.">OverlayKey</a>&amp; nodeID)
  611. <a name="l00581"></a>00581 {
  612. <a name="l00582"></a>00582 Enter_Method(<span class="stringliteral">&quot;join()&quot;</span>);
  613. <a name="l00583"></a>00583
  614. <a name="l00584"></a>00584 <a class="code" href="classBaseOverlay.html#aee8e642813784a1f27a81756a4b93b9b" title="number of join retries">joinRetries</a>++;
  615. <a name="l00585"></a>00585
  616. <a name="l00586"></a>00586 <span class="keywordflow">if</span> (((<a class="code" href="classBaseOverlay.html#ab4be6d88417117fbf33a445d56af2655">state</a> == <a class="code" href="classBaseOverlay.html#a0ad4b12b0c9949661f66db7fbbf7d40fab3a263fb274a58d63b15cd61ba910335">READY</a>) || (<a class="code" href="classBaseOverlay.html#ab4be6d88417117fbf33a445d56af2655">state</a> == <a class="code" href="classBaseOverlay.html#a0ad4b12b0c9949661f66db7fbbf7d40fa99c9df0220f7a63e3b548d19181dc2b1">FAILED</a>)) &amp;&amp; !<a class="code" href="classBaseOverlay.html#aecfcf5743d274d9c17730f2aeccf1635">rejoinOnFailure</a>) {
  617. <a name="l00587"></a>00587 <a class="code" href="classBaseOverlay.html#ab4be6d88417117fbf33a445d56af2655">state</a> = FAILED;
  618. <a name="l00588"></a>00588 <span class="keywordflow">return</span>;
  619. <a name="l00589"></a>00589 }
  620. <a name="l00590"></a>00590
  621. <a name="l00591"></a>00591 <span class="keywordflow">if</span> (<a class="code" href="classBaseOverlay.html#ab4be6d88417117fbf33a445d56af2655">state</a> != <a class="code" href="classBaseOverlay.html#a0ad4b12b0c9949661f66db7fbbf7d40fab3a263fb274a58d63b15cd61ba910335">READY</a>) {
  622. <a name="l00592"></a>00592 <span class="comment">// set nodeID and IP</span>
  623. <a name="l00593"></a>00593 <a class="code" href="classBaseRpc.html#a88eb68c06450fd12ea072f471bf1c1b8" title="NodeHandle to this node.">thisNode</a>.<a class="code" href="classTransportAddress.html#a1c7b834dc2e6e738f1f4db8711a12814" title="Sets the ip address, port and NAT type.">setIp</a>(
  624. <a name="l00594"></a>00594 IPAddressResolver().addressOf(getParentModule()-&gt;getParentModule()));
  625. <a name="l00595"></a>00595
  626. <a name="l00596"></a>00596 <span class="keywordflow">if</span> (!nodeID.<a class="code" href="classOverlayKey.html#abe357a4d1babcf7d30598a61cbc0f5c2" title="Returns true, if the key is unspecified.">isUnspecified</a>()) {
  627. <a name="l00597"></a>00597 <a class="code" href="classBaseRpc.html#a88eb68c06450fd12ea072f471bf1c1b8" title="NodeHandle to this node.">thisNode</a>.<a class="code" href="classNodeHandle.html#af3992f1fda9ea42dc10bf4739e47700a" title="saves given key to NodeHandle::key">setKey</a>(nodeID);
  628. <a name="l00598"></a>00598 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="classBaseRpc.html#a88eb68c06450fd12ea072f471bf1c1b8" title="NodeHandle to this node.">thisNode</a>.<a class="code" href="classNodeHandle.html#aef531103cdf07c8353267f4d30a80112" title="returns key of this NodeHandle">getKey</a>().<a class="code" href="classOverlayKey.html#abe357a4d1babcf7d30598a61cbc0f5c2" title="Returns true, if the key is unspecified.">isUnspecified</a>()) {
  629. <a name="l00599"></a>00599 std::string nodeIdStr = par(<span class="stringliteral">&quot;nodeId&quot;</span>).stdstringValue();
  630. <a name="l00600"></a>00600
  631. <a name="l00601"></a>00601 <span class="keywordflow">if</span> (nodeIdStr.size()) {
  632. <a name="l00602"></a>00602 <span class="comment">// manual configuration of nodeId in ini file</span>
  633. <a name="l00603"></a>00603 <a class="code" href="classBaseRpc.html#a88eb68c06450fd12ea072f471bf1c1b8" title="NodeHandle to this node.">thisNode</a>.<a class="code" href="classNodeHandle.html#af3992f1fda9ea42dc10bf4739e47700a" title="saves given key to NodeHandle::key">setKey</a>(<a class="code" href="classOverlayKey.html" title="A common overlay key class.">OverlayKey</a>(nodeIdStr));
  634. <a name="l00604"></a>00604 } <span class="keywordflow">else</span> {
  635. <a name="l00605"></a>00605 <a class="code" href="classBaseOverlay.html#a31e60de81d77afdeb0e68f781ded0f9e" title="Overlay implementations can overwrite this virtual method to set a specific nodeID.">setOwnNodeID</a>();
  636. <a name="l00606"></a>00606 }
  637. <a name="l00607"></a>00607 }
  638. <a name="l00608"></a>00608 }
  639. <a name="l00609"></a>00609
  640. <a name="l00610"></a>00610 cObject** context = <a class="code" href="classBaseOverlay.html#a933e505ea77cae4ab0c8edcb77ade2c7" title="pointer to GlobalNodeList in this node">globalNodeList</a>-&gt;<a class="code" href="classGlobalNodeList.html#a9c0e986f725906c17373fac655710e5c">getContext</a>(<a class="code" href="classBaseRpc.html#ac3f420630d5618e81709c078b06fd9da" title="Returns the NodeHandle of this node.">getThisNode</a>());
  641. <a name="l00611"></a>00611 <span class="keywordflow">if</span> (<a class="code" href="classBaseOverlay.html#a7d0beff122a0b5c573dd8ae90c9372d5" title="if true, a node rejoins with its old nodeId and malicious state">restoreContext</a> &amp;&amp; context) {
  642. <a name="l00612"></a>00612 <span class="keywordflow">if</span> (*context == NULL) {
  643. <a name="l00613"></a>00613 *context = <span class="keyword">new</span> <a class="code" href="classBaseOverlay_1_1BaseOverlayContext.html">BaseOverlayContext</a>(<a class="code" href="classBaseRpc.html#ac3f420630d5618e81709c078b06fd9da" title="Returns the NodeHandle of this node.">getThisNode</a>().getKey(),
  644. <a name="l00614"></a>00614 <a class="code" href="classBaseOverlay.html#a234b046348574d37d811638f0b27a89e" title="Returns true, if node is malicious.">isMalicious</a>());
  645. <a name="l00615"></a>00615 }
  646. <a name="l00616"></a>00616 }
  647. <a name="l00617"></a>00617
  648. <a name="l00618"></a>00618 <a class="code" href="classBaseOverlay.html#a3eefb56c2396601373c89d21b5b58110" title="Join the overlay with a given nodeID in thisNode.key.">joinOverlay</a>();
  649. <a name="l00619"></a>00619 }
  650. <a name="l00620"></a>00620
  651. <a name="l00621"></a><a class="code" href="classBaseOverlay.html#ad032eda7f8a65884cf8c6d141224331e">00621</a> <span class="keywordtype">void</span> <a class="code" href="classBaseOverlay.html#ad032eda7f8a65884cf8c6d141224331e" title="Join another overlay partition with the given node as bootstrap node.">BaseOverlay::joinForeignPartition</a>(<span class="keyword">const</span> <a class="code" href="classNodeHandle.html" title="This class implements a node handle.">NodeHandle</a>&amp; node)
  652. <a name="l00622"></a>00622 {
  653. <a name="l00623"></a>00623 <span class="keywordflow">throw</span> cRuntimeError(<span class="stringliteral">&quot;BaseOverlay::joinForeignPartition(): &quot;</span>
  654. <a name="l00624"></a>00624 <span class="stringliteral">&quot;This overlay doesn&#39;t support merging!&quot;</span>);
  655. <a name="l00625"></a>00625 }
  656. <a name="l00626"></a>00626
  657. <a name="l00627"></a><a class="code" href="classBaseOverlay.html#a31e60de81d77afdeb0e68f781ded0f9e">00627</a> <span class="keywordtype">void</span> <a class="code" href="classBaseOverlay.html#a31e60de81d77afdeb0e68f781ded0f9e" title="Overlay implementations can overwrite this virtual method to set a specific nodeID.">BaseOverlay::setOwnNodeID</a>()
  658. <a name="l00628"></a>00628 {
  659. <a name="l00629"></a>00629 <a class="code" href="classBaseRpc.html#a88eb68c06450fd12ea072f471bf1c1b8" title="NodeHandle to this node.">thisNode</a>.<a class="code" href="classNodeHandle.html#af3992f1fda9ea42dc10bf4739e47700a" title="saves given key to NodeHandle::key">setKey</a>(<a class="code" href="classOverlayKey.html#a1983e1b47e32783f8ccd5e59fe725290" title="Returns a random key.">OverlayKey::random</a>());
  660. <a name="l00630"></a>00630 }
  661. <a name="l00631"></a>00631
  662. <a name="l00632"></a><a class="code" href="classBaseOverlay.html#a08f453e70d8d295bdbabec4accbb9dad">00632</a> <a class="code" href="classBaseKeySortedVector.html">NodeVector</a>* <a class="code" href="classBaseOverlay.html#a08f453e70d8d295bdbabec4accbb9dad">BaseOverlay::neighborSet</a>(<span class="keywordtype">int</span> num)
  663. <a name="l00633"></a>00633 {
  664. <a name="l00634"></a>00634 Enter_Method(<span class="stringliteral">&quot;neighborSet()&quot;</span>);
  665. <a name="l00635"></a>00635
  666. <a name="l00636"></a>00636 <span class="keywordflow">return</span> <a class="code" href="classBaseOverlay.html#a95851770a6ab3a176e1d7b5a7afba3f0" title="finds nodes closest to the given OverlayKey">local_lookup</a>(<a class="code" href="classBaseRpc.html#a88eb68c06450fd12ea072f471bf1c1b8" title="NodeHandle to this node.">thisNode</a>.<a class="code" href="classNodeHandle.html#aef531103cdf07c8353267f4d30a80112" title="returns key of this NodeHandle">getKey</a>(), num, <span class="keyword">false</span>);
  667. <a name="l00637"></a>00637 }
  668. <a name="l00638"></a>00638
  669. <a name="l00639"></a><a class="code" href="classBaseOverlay.html#a1422696a8eb138dde850390152ff88c7">00639</a> <span class="keywordtype">void</span> <a class="code" href="classBaseOverlay.html#a1422696a8eb138dde850390152ff88c7" title="Informs application about state changes of nodes or newly joined nodes.">BaseOverlay::callUpdate</a>(<span class="keyword">const</span> <a class="code" href="classNodeHandle.html" title="This class implements a node handle.">NodeHandle</a>&amp; node, <span class="keywordtype">bool</span> joined)
  670. <a name="l00640"></a>00640 {
  671. <a name="l00641"></a>00641 <span class="keywordflow">if</span> ((!node.<a class="code" href="classNodeHandle.html#ab5136375a4548ced7c2014a73c8743c9" title="indicates if this NodeHandle is specified">isUnspecified</a>()) &amp;&amp; (node != <a class="code" href="classBaseRpc.html#a88eb68c06450fd12ea072f471bf1c1b8" title="NodeHandle to this node.">thisNode</a>)) {
  672. <a name="l00642"></a>00642 <span class="keywordflow">if</span> (joined) {
  673. <a name="l00643"></a>00643 EV &lt;&lt; <span class="stringliteral">&quot;[BaseOverlay::callUpdate() @ &quot;</span> &lt;&lt; <a class="code" href="classBaseRpc.html#a88eb68c06450fd12ea072f471bf1c1b8" title="NodeHandle to this node.">thisNode</a>.<a class="code" href="classTransportAddress.html#a00e613d98d3412e2b92897c25aa0eb4c" title="returns ip address">getIp</a>()
  674. <a name="l00644"></a>00644 &lt;&lt; <span class="stringliteral">&quot; (&quot;</span> &lt;&lt; <a class="code" href="classBaseRpc.html#a88eb68c06450fd12ea072f471bf1c1b8" title="NodeHandle to this node.">thisNode</a>.<a class="code" href="classNodeHandle.html#aef531103cdf07c8353267f4d30a80112" title="returns key of this NodeHandle">getKey</a>().<a class="code" href="classOverlayKey.html#aabeb4fd284a630a82e982ba34ece4fd9" title="Returns a string representation of this key.">toString</a>(16) &lt;&lt; <span class="stringliteral">&quot;)]\n&quot;</span>
  675. <a name="l00645"></a>00645 &lt;&lt; <span class="stringliteral">&quot; (&quot;</span> &lt;&lt; node &lt;&lt; <span class="stringliteral">&quot;, &quot;</span> &lt;&lt; joined &lt;&lt; <span class="stringliteral">&quot;) joined&quot;</span>
  676. <a name="l00646"></a>00646 &lt;&lt; endl;
  677. <a name="l00647"></a>00647 } <span class="keywordflow">else</span> {
  678. <a name="l00648"></a>00648 EV &lt;&lt; <span class="stringliteral">&quot;[BaseOverlay::callUpdate() @ &quot;</span> &lt;&lt; <a class="code" href="classBaseRpc.html#a88eb68c06450fd12ea072f471bf1c1b8" title="NodeHandle to this node.">thisNode</a>.<a class="code" href="classTransportAddress.html#a00e613d98d3412e2b92897c25aa0eb4c" title="returns ip address">getIp</a>()
  679. <a name="l00649"></a>00649 &lt;&lt; <span class="stringliteral">&quot; (&quot;</span> &lt;&lt; <a class="code" href="classBaseRpc.html#a88eb68c06450fd12ea072f471bf1c1b8" title="NodeHandle to this node.">thisNode</a>.<a class="code" href="classNodeHandle.html#aef531103cdf07c8353267f4d30a80112" title="returns key of this NodeHandle">getKey</a>().<a class="code" href="classOverlayKey.html#aabeb4fd284a630a82e982ba34ece4fd9" title="Returns a string representation of this key.">toString</a>(16) &lt;&lt; <span class="stringliteral">&quot;)]\n&quot;</span>
  680. <a name="l00650"></a>00650 &lt;&lt; <span class="stringliteral">&quot; (&quot;</span> &lt;&lt; node &lt;&lt; <span class="stringliteral">&quot;, &quot;</span> &lt;&lt; joined &lt;&lt; <span class="stringliteral">&quot;) left&quot;</span>
  681. <a name="l00651"></a>00651 &lt;&lt; endl;
  682. <a name="l00652"></a>00652 }
  683. <a name="l00653"></a>00653 }
  684. <a name="l00654"></a>00654
  685. <a name="l00655"></a>00655 <a class="code" href="classKBRupdate.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">KBRupdate</a>* updateMsg = <span class="keyword">new</span> <a class="code" href="classKBRupdate.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">KBRupdate</a>(<span class="stringliteral">&quot;UPDATE&quot;</span>);
  686. <a name="l00656"></a>00656
  687. <a name="l00657"></a>00657 updateMsg-&gt;<a class="code" href="classKBRupdate.html#aa20a7893984b166f2d19abc501741a1e">setNode</a>(node);
  688. <a name="l00658"></a>00658 updateMsg-&gt;<a class="code" href="classKBRupdate.html#aa87ea437b7f9edbdb530c6ef50d65587">setJoined</a>(joined);
  689. <a name="l00659"></a>00659
  690. <a name="l00660"></a>00660 updateMsg-&gt;<a class="code" href="classCommonAPIMessage.html#a161ae8c663ecca1ada7f68f2b010d774">setType</a>(<a class="code" href="CommonMessages__m_8h.html#a61951439f8b8b0a1c54516d2e4c72297ac502d048ee6f6b1287c7b7843d2706b8">KBR_UPDATE</a>);
  691. <a name="l00661"></a>00661
  692. <a name="l00662"></a>00662 send(updateMsg, <span class="stringliteral">&quot;appOut&quot;</span>);
  693. <a name="l00663"></a>00663 }
  694. <a name="l00664"></a>00664
  695. <a name="l00665"></a><a class="code" href="classBaseOverlay.html#ab5887b89ba9da5973068e834feb69ce7">00665</a> <span class="keywordtype">bool</span> <a class="code" href="classBaseOverlay.html#ab5887b89ba9da5973068e834feb69ce7" title="Query if a node is among the siblings for a given key.">BaseOverlay::isSiblingFor</a>(<span class="keyword">const</span> <a class="code" href="classNodeHandle.html" title="This class implements a node handle.">NodeHandle</a>&amp; node, <span class="keyword">const</span> <a class="code" href="classOverlayKey.html" title="A common overlay key class.">OverlayKey</a>&amp; key,
  696. <a name="l00666"></a>00666 <span class="keywordtype">int</span> numSiblings, <span class="keywordtype">bool</span>* err)
  697. <a name="l00667"></a>00667 {
  698. <a name="l00668"></a>00668 Enter_Method(<span class="stringliteral">&quot;isSiblingFor()&quot;</span>);
  699. <a name="l00669"></a>00669
  700. <a name="l00670"></a>00670 <span class="keywordflow">throw</span> cRuntimeError(<span class="stringliteral">&quot;isSiblingFor: Not implemented!&quot;</span>);
  701. <a name="l00671"></a>00671
  702. <a name="l00672"></a>00672 <span class="keywordflow">return</span> <span class="keyword">false</span>;
  703. <a name="l00673"></a>00673 }
  704. <a name="l00674"></a>00674
  705. <a name="l00675"></a><a class="code" href="classBaseOverlay.html#acd3058ad15b470e024500dd4872e2f09">00675</a> <span class="keywordtype">int</span> <a class="code" href="classBaseOverlay.html#acd3058ad15b470e024500dd4872e2f09" title="Query the maximum number of siblings (nodes close to a key) that are maintained by this overlay proto...">BaseOverlay::getMaxNumSiblings</a>()
  706. <a name="l00676"></a>00676 {
  707. <a name="l00677"></a>00677 Enter_Method(<span class="stringliteral">&quot;getMaxNumSiblings()&quot;</span>);
  708. <a name="l00678"></a>00678
  709. <a name="l00679"></a>00679 <span class="keywordflow">throw</span> cRuntimeError(<span class="stringliteral">&quot;getMaxNumSiblings: Not implemented!&quot;</span>);
  710. <a name="l00680"></a>00680
  711. <a name="l00681"></a>00681 <span class="keywordflow">return</span> <span class="keyword">false</span>;
  712. <a name="l00682"></a>00682 }
  713. <a name="l00683"></a>00683
  714. <a name="l00684"></a><a class="code" href="classBaseOverlay.html#ab4dadd02486560de3a58773b3a90fb41">00684</a> <span class="keywordtype">int</span> <a class="code" href="classBaseOverlay.html#ab4dadd02486560de3a58773b3a90fb41" title="Query the maximum number of redundant next hop nodes that are returned by findNode().">BaseOverlay::getMaxNumRedundantNodes</a>()
  715. <a name="l00685"></a>00685 {
  716. <a name="l00686"></a>00686 Enter_Method(<span class="stringliteral">&quot;getMaxNumRedundantNodes()&quot;</span>);
  717. <a name="l00687"></a>00687
  718. <a name="l00688"></a>00688 <span class="keywordflow">throw</span> cRuntimeError(<span class="stringliteral">&quot;getMaxNumRedundantNodes: Not implemented!&quot;</span>);
  719. <a name="l00689"></a>00689
  720. <a name="l00690"></a>00690 <span class="keywordflow">return</span> <span class="keyword">false</span>;
  721. <a name="l00691"></a>00691 }
  722. <a name="l00692"></a>00692
  723. <a name="l00693"></a>00693
  724. <a name="l00694"></a>00694 <span class="comment">//------------------------------------------------------------------------</span>
  725. <a name="l00695"></a>00695 <span class="comment">//--- Message Handlers ---------------------------------------------------</span>
  726. <a name="l00696"></a>00696 <span class="comment">//------------------------------------------------------------------------</span>
  727. <a name="l00697"></a>00697
  728. <a name="l00698"></a>00698 <span class="comment">//private</span>
  729. <a name="l00699"></a><a class="code" href="classBaseOverlay.html#a870d24a243e4b0d1aeb31ea0861e53a7">00699</a> <span class="keywordtype">void</span> <a class="code" href="classBaseOverlay.html#a870d24a243e4b0d1aeb31ea0861e53a7" title="Checks for message type and calls corresponding method.">BaseOverlay::handleMessage</a>(cMessage* msg)
  730. <a name="l00700"></a>00700 {
  731. <a name="l00701"></a>00701 <span class="keywordflow">if</span> (msg-&gt;getArrivalGate() == <a class="code" href="classBaseOverlay.html#a2e2f70aa82a9b4920877b3a13dd1e0ea">udpGate</a>) {
  732. <a name="l00702"></a>00702 UDPControlInfo* udpControlInfo =
  733. <a name="l00703"></a>00703 check_and_cast&lt;UDPControlInfo*&gt;(msg-&gt;removeControlInfo());
  734. <a name="l00704"></a>00704 <a class="code" href="classOverlayCtrlInfo.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">OverlayCtrlInfo</a>* overlayCtrlInfo = <span class="keyword">new</span> <a class="code" href="classOverlayCtrlInfo.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">OverlayCtrlInfo</a>;
  735. <a name="l00705"></a>00705 overlayCtrlInfo-&gt;setLastHop(<a class="code" href="classTransportAddress.html" title="This class implements a common transport address.">TransportAddress</a>(
  736. <a name="l00706"></a>00706 udpControlInfo-&gt;getSrcAddr(),
  737. <a name="l00707"></a>00707 udpControlInfo-&gt;getSrcPort()));
  738. <a name="l00708"></a>00708 overlayCtrlInfo-&gt;setSrcRoute(overlayCtrlInfo-&gt;getLastHop());
  739. <a name="l00709"></a>00709 overlayCtrlInfo-&gt;setTransportType(<a class="code" href="CommonMessages__m_8h.html#aca1e72535e7f260e54ed8bbf984dade9a01580b2e886cd821bd7f3f2bcd7c690c">UDP_TRANSPORT</a>);
  740. <a name="l00710"></a>00710
  741. <a name="l00711"></a>00711 msg-&gt;setControlInfo(overlayCtrlInfo);
  742. <a name="l00712"></a>00712 <span class="keyword">delete</span> udpControlInfo;
  743. <a name="l00713"></a>00713
  744. <a name="l00714"></a>00714 <span class="comment">// debug message</span>
  745. <a name="l00715"></a>00715 <span class="keywordflow">if</span> (<a class="code" href="classBaseOverlay.html#a49ff0fb8c25792a1339d54a60c36f2cd" title="debug output ?">debugOutput</a>) {
  746. <a name="l00716"></a>00716 EV &lt;&lt; <span class="stringliteral">&quot;[BaseOverlay:handleMessage() @ &quot;</span> &lt;&lt; <a class="code" href="classBaseRpc.html#a88eb68c06450fd12ea072f471bf1c1b8" title="NodeHandle to this node.">thisNode</a>.<a class="code" href="classTransportAddress.html#a00e613d98d3412e2b92897c25aa0eb4c" title="returns ip address">getIp</a>()
  747. <a name="l00717"></a>00717 &lt;&lt; <span class="stringliteral">&quot; (&quot;</span> &lt;&lt; <a class="code" href="classBaseRpc.html#a88eb68c06450fd12ea072f471bf1c1b8" title="NodeHandle to this node.">thisNode</a>.<a class="code" href="classNodeHandle.html#aef531103cdf07c8353267f4d30a80112" title="returns key of this NodeHandle">getKey</a>().<a class="code" href="classOverlayKey.html#aabeb4fd284a630a82e982ba34ece4fd9" title="Returns a string representation of this key.">toString</a>(16) &lt;&lt; <span class="stringliteral">&quot;)]\n&quot;</span>
  748. <a name="l00718"></a>00718 &lt;&lt; <span class="stringliteral">&quot; Received &quot;</span> &lt;&lt; *msg &lt;&lt; <span class="stringliteral">&quot; from &quot;</span>
  749. <a name="l00719"></a>00719 &lt;&lt; overlayCtrlInfo-&gt;getLastHop().getIp() &lt;&lt; endl;
  750. <a name="l00720"></a>00720 }
  751. <a name="l00721"></a>00721
  752. <a name="l00722"></a>00722 <a class="code" href="classBaseOverlayMessage.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">BaseOverlayMessage</a>* baseOverlayMsg =
  753. <a name="l00723"></a>00723 <span class="keyword">dynamic_cast&lt;</span><a class="code" href="classBaseOverlayMessage.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">BaseOverlayMessage</a>*<span class="keyword">&gt;</span>(msg);
  754. <a name="l00724"></a>00724
  755. <a name="l00725"></a>00725 <span class="keywordflow">if</span> (baseOverlayMsg == NULL) {
  756. <a name="l00726"></a>00726 cPacket* packet = check_and_cast&lt;cPacket*&gt;(msg);
  757. <a name="l00727"></a>00727 <a class="code" href="GlobalStatistics_8h.html#af29140ebe8e0a93406a58441f7c5fec8" title="Macro used for recording statistics considering measureNetwIn parameter.">RECORD_STATS</a>(<a class="code" href="classBaseOverlay.html#a4a82bd4b76a8d06a1d63bba98f1a34d7" title="number of dropped packets">numDropped</a>++; <a class="code" href="classBaseOverlay.html#a9e09857b97f52d340e4710580f25f7a6" title="number of dropped bytes">bytesDropped</a> += packet-&gt;getByteLength());
  758. <a name="l00728"></a>00728 <span class="keyword">delete</span> msg;
  759. <a name="l00729"></a>00729 <span class="keywordflow">return</span>;
  760. <a name="l00730"></a>00730 }
  761. <a name="l00731"></a>00731
  762. <a name="l00732"></a>00732 <span class="comment">// records stats if message is not a UDP &quot;self message&quot;</span>
  763. <a name="l00733"></a>00733 <span class="keywordflow">if</span> (overlayCtrlInfo-&gt;getLastHop() != <a class="code" href="classBaseRpc.html#a88eb68c06450fd12ea072f471bf1c1b8" title="NodeHandle to this node.">thisNode</a>) {
  764. <a name="l00734"></a>00734 <span class="comment">// is this from anywhere else?</span>
  765. <a name="l00735"></a>00735 <span class="keywordflow">if</span> (baseOverlayMsg-&gt;<a class="code" href="classBaseOverlayMessage.html#af0a4bf31778e05a809f8d55dff5bfcc1">getStatType</a>() == APP_DATA_STAT)
  766. <a name="l00736"></a>00736 <a class="code" href="GlobalStatistics_8h.html#af29140ebe8e0a93406a58441f7c5fec8" title="Macro used for recording statistics considering measureNetwIn parameter.">RECORD_STATS</a>(<a class="code" href="classBaseOverlay.html#aa83e680792f987f9f5f779e12c055898" title="number of received app data packets (incl. packets to be forwarded )">numAppDataReceived</a>++; <a class="code" href="classBaseOverlay.html#a82cd1df80e31e2a9148a9efaacc4bc76" title="number of received app data bytes (incl. bytes to be forwarded)">bytesAppDataReceived</a> +=
  767. <a name="l00737"></a>00737 baseOverlayMsg-&gt;getByteLength());
  768. <a name="l00738"></a>00738 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (baseOverlayMsg-&gt;<a class="code" href="classBaseOverlayMessage.html#af0a4bf31778e05a809f8d55dff5bfcc1">getStatType</a>() == APP_LOOKUP_STAT)
  769. <a name="l00739"></a>00739 <a class="code" href="GlobalStatistics_8h.html#af29140ebe8e0a93406a58441f7c5fec8" title="Macro used for recording statistics considering measureNetwIn parameter.">RECORD_STATS</a>(<a class="code" href="classBaseOverlay.html#a9298db97a2d651e02729ad197964bdca" title="number of received app lookup packets (incl. packets to be forwarded)">numAppLookupReceived</a>++;<a class="code" href="classBaseOverlay.html#a8527c9038c62bf66e58c07d41b308527" title="number of received app lookup bytes (incl. bytes to be forwarded)">bytesAppLookupReceived</a> +=
  770. <a name="l00740"></a>00740 baseOverlayMsg-&gt;getByteLength());
  771. <a name="l00741"></a>00741 <span class="keywordflow">else</span> <span class="comment">// MAINTENANCE_STAT</span>
  772. <a name="l00742"></a>00742 <a class="code" href="GlobalStatistics_8h.html#af29140ebe8e0a93406a58441f7c5fec8" title="Macro used for recording statistics considering measureNetwIn parameter.">RECORD_STATS</a>(<a class="code" href="classBaseOverlay.html#a4e7abb41a2c8698bf530015378a13e46" title="number of received maintenance packets (incl. packets to be forwarded)">numMaintenanceReceived</a>++;
  773. <a name="l00743"></a>00743 <a class="code" href="classBaseOverlay.html#ad7bd70b69842cc4db485eafa942332fb" title="number of received maintenance bytes (incl. bytes to be forwarded)">bytesMaintenanceReceived</a> +=
  774. <a name="l00744"></a>00744 baseOverlayMsg-&gt;getByteLength());
  775. <a name="l00745"></a>00745 }
  776. <a name="l00746"></a>00746 <span class="keywordflow">if</span> (overlayCtrlInfo-&gt;getLastHop().getIp() == <a class="code" href="classBaseRpc.html#a88eb68c06450fd12ea072f471bf1c1b8" title="NodeHandle to this node.">thisNode</a>.<a class="code" href="classTransportAddress.html#a00e613d98d3412e2b92897c25aa0eb4c" title="returns ip address">getIp</a>()) {
  777. <a name="l00747"></a>00747 <span class="comment">// is this from the same node?</span>
  778. <a name="l00748"></a>00748 <a class="code" href="GlobalStatistics_8h.html#af29140ebe8e0a93406a58441f7c5fec8" title="Macro used for recording statistics considering measureNetwIn parameter.">RECORD_STATS</a>(<a class="code" href="classBaseOverlay.html#a7f185cb11a818d01dcc1a31553de16ef" title="number of packets received from same host but different port (SimpleMultiOverlayHost)">numInternalReceived</a>++; <a class="code" href="classBaseOverlay.html#a55ba3d595b6b23db700cb9f36f34f0ae" title="number of bytes received from same host but different port (SimpleMultiOverlayHost)">bytesInternalReceived</a> +=
  779. <a name="l00749"></a>00749 baseOverlayMsg-&gt;getByteLength());
  780. <a name="l00750"></a>00750 } <span class="keywordflow">else</span> overlayCtrlInfo-&gt;setHopCount(1);
  781. <a name="l00751"></a>00751
  782. <a name="l00752"></a>00752 <span class="comment">// process rpc calls/responses or BaseOverlayMessages</span>
  783. <a name="l00753"></a>00753 <span class="keywordflow">if</span> (!<a class="code" href="classBaseRpc.html#ad68b7208473ba1301deb59d51f0bba6c">internalHandleMessage</a>(msg)) {
  784. <a name="l00754"></a>00754 <a class="code" href="classBaseOverlay.html#ac647b32e360b4db1f0eb53b096437fd8" title="Handles a BaseOverlayMessage ">handleBaseOverlayMessage</a>(baseOverlayMsg);
  785. <a name="l00755"></a>00755 }
  786. <a name="l00756"></a>00756 }
  787. <a name="l00757"></a>00757
  788. <a name="l00758"></a>00758 <span class="comment">// process timer events and rpc timeouts</span>
  789. <a name="l00759"></a>00759 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="classBaseRpc.html#ad68b7208473ba1301deb59d51f0bba6c">internalHandleMessage</a>(msg)) <span class="keywordflow">return</span>;
  790. <a name="l00760"></a>00760
  791. <a name="l00761"></a>00761 <span class="comment">// process CommonAPIMessages from App</span>
  792. <a name="l00762"></a>00762 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (dynamic_cast&lt;CommonAPIMessage*&gt;(msg) != NULL) {
  793. <a name="l00763"></a>00763 <span class="keywordflow">if</span> (dynamic_cast&lt;KBRroute*&gt;(msg) != NULL) {
  794. <a name="l00764"></a>00764 <a class="code" href="classKBRroute.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">KBRroute</a>* apiMsg = <span class="keyword">static_cast&lt;</span><a class="code" href="classKBRroute.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">KBRroute</a>*<span class="keyword">&gt;</span>(msg);
  795. <a name="l00765"></a>00765
  796. <a name="l00766"></a>00766 std::vector&lt;TransportAddress&gt; sourceRoute;
  797. <a name="l00767"></a>00767 <span class="keywordflow">for</span> (uint32_t i = 0; i &lt; apiMsg-&gt;<a class="code" href="classKBRroute.html#ad2ffb68e9163898b3a4846943c687a53">getSourceRouteArraySize</a>(); ++i)
  798. <a name="l00768"></a>00768 sourceRoute.push_back(apiMsg-&gt;<a class="code" href="classKBRroute.html#a40bab7a8989b1eb12246c9e014ba384c">getSourceRoute</a>(i));
  799. <a name="l00769"></a>00769
  800. <a name="l00770"></a>00770 <a class="code" href="classBaseOverlay.html#ad62efdef2b674f46e5368354efb6104f" title="Routes message through overlay.">route</a>(apiMsg-&gt;<a class="code" href="classKBRroute.html#acfbdd202d6783de8d6731d46ab382e00">getDestKey</a>(), <span class="keyword">static_cast&lt;</span><a class="code" href="CommonMessages__m_8h.html#aad57ef0110fe8675eb299d467148bc5e" title="Enum generated from common/CommonMessages.msg by opp_msgc.">CompType</a><span class="keyword">&gt;</span>(apiMsg-&gt;<a class="code" href="classKBRroute.html#a32e7dbb5aaeee13f316f1f6c8e55d2b3">getDestComp</a>()),
  801. <a name="l00771"></a>00771 static_cast&lt;CompType&gt;(apiMsg-&gt;<a class="code" href="classKBRroute.html#a1667fc25f4d80791d79e11c399196353">getSrcComp</a>()), apiMsg-&gt;decapsulate(),
  802. <a name="l00772"></a>00772 sourceRoute);
  803. <a name="l00773"></a>00773 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (dynamic_cast&lt;KBRforward*&gt;(msg) != NULL) {
  804. <a name="l00774"></a>00774 <a class="code" href="classKBRforward.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">KBRforward</a>* apiMsg = <span class="keyword">static_cast&lt;</span><a class="code" href="classKBRforward.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">KBRforward</a>*<span class="keyword">&gt;</span>(msg);
  805. <a name="l00775"></a>00775 <a class="code" href="classOverlayCtrlInfo.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">OverlayCtrlInfo</a>* overlayCtrlInfo =
  806. <a name="l00776"></a>00776 check_and_cast&lt;<a class="code" href="classOverlayCtrlInfo.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">OverlayCtrlInfo</a>*&gt;
  807. <a name="l00777"></a>00777 (msg-&gt;removeControlInfo());
  808. <a name="l00778"></a>00778
  809. <a name="l00779"></a>00779 <a class="code" href="classBaseAppDataMessage.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">BaseAppDataMessage</a>* dataMsg =
  810. <a name="l00780"></a>00780 <span class="keyword">new</span> <a class="code" href="classBaseAppDataMessage.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">BaseAppDataMessage</a>();
  811. <a name="l00781"></a>00781 dataMsg-&gt;setType(<a class="code" href="CommonMessages__m_8h.html#a6af1a552a7a6bce33c291758c369b17eab0641a3f5bcb1e08ee72afe9583ff5e6">APPDATA</a>);
  812. <a name="l00782"></a>00782 dataMsg-&gt;setBitLength(<a class="code" href="CommonMessages__m_8h.html#aebae47ba62d6bd9fe00ca6d779bf0e81">BASEAPPDATA_L</a>(dataMsg));
  813. <a name="l00783"></a>00783 dataMsg-&gt;setName(apiMsg-&gt;getEncapsulatedPacket()-&gt;getName());
  814. <a name="l00784"></a>00784 dataMsg-&gt;encapsulate(apiMsg-&gt;decapsulate());
  815. <a name="l00785"></a>00785 dataMsg-&gt;setSrcComp(overlayCtrlInfo-&gt;<a class="code" href="classOverlayCtrlInfo.html#a79a35b8f98c2fecef8d6bc566c4a7437">getSrcComp</a>());
  816. <a name="l00786"></a>00786 dataMsg-&gt;setDestComp(overlayCtrlInfo-&gt;<a class="code" href="classOverlayCtrlInfo.html#a082f26c9d0cac0aec9ca23da4d338134">getDestComp</a>());
  817. <a name="l00787"></a>00787 dataMsg-&gt;setStatType(<a class="code" href="CommonMessages__m_8h.html#a25418fa818fbb01cd8c0b2c4b0732cdfad8d082af8526e80f7de088c52ad1b7c0">APP_DATA_STAT</a>);
  818. <a name="l00788"></a>00788
  819. <a name="l00789"></a>00789 <a class="code" href="classBaseRouteMessage.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">BaseRouteMessage</a>* routeMsg = <span class="keyword">new</span> <a class="code" href="classBaseRouteMessage.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">BaseRouteMessage</a>(dataMsg-&gt;getName());
  820. <a name="l00790"></a>00790 routeMsg-&gt;<a class="code" href="classBaseOverlayMessage.html#a1441ce272062923bae9d821ac35ed7cf">setType</a>(<a class="code" href="CommonMessages__m_8h.html#a6af1a552a7a6bce33c291758c369b17ea9fb39f8e1c5f2ff00e45bb7294e5524f">OVERLAYROUTE</a>);
  821. <a name="l00791"></a>00791 routeMsg-&gt;setBitLength(<a class="code" href="CommonMessages__m_8h.html#aa51e9b4f9362c33b9a432fd496bc31d0">BASEROUTE_L</a>(routeMsg));
  822. <a name="l00792"></a>00792 routeMsg-&gt;encapsulate(dataMsg);
  823. <a name="l00793"></a>00793
  824. <a name="l00794"></a>00794 routeMsg-&gt;<a class="code" href="classBaseOverlayMessage.html#a46fd21016c6fad4f167d5510f0481f49">setStatType</a>(<a class="code" href="CommonMessages__m_8h.html#a25418fa818fbb01cd8c0b2c4b0732cdfad8d082af8526e80f7de088c52ad1b7c0">APP_DATA_STAT</a>);
  825. <a name="l00795"></a>00795 routeMsg-&gt;<a class="code" href="classBaseRouteMessage.html#a6cf1c098dabdf6382aa647054e2b85e3">setRoutingType</a>(overlayCtrlInfo-&gt;<a class="code" href="classOverlayCtrlInfo.html#a4b81411df66c4c813b664665731ee38c">getRoutingType</a>());
  826. <a name="l00796"></a>00796 routeMsg-&gt;<a class="code" href="classBaseRouteMessage.html#ac3ad2fb57750487addb4611b52e5db71">setDestKey</a>(apiMsg-&gt;<a class="code" href="classKBRforward.html#a5c9aa80a6bd136a034e37af25f9beb42">getDestKey</a>());
  827. <a name="l00797"></a>00797 routeMsg-&gt;<a class="code" href="classBaseRouteMessage.html#a52ea5017b1de1775ee71c203864ba28f">setSrcNode</a>(overlayCtrlInfo-&gt;<a class="code" href="classOverlayCtrlInfo.html#af6e31869ed325ba04288a69346988343">getSrcNode</a>());
  828. <a name="l00798"></a>00798 routeMsg-&gt;<a class="code" href="classBaseRouteMessage.html#a1c843714ac5feca3c13f1e39b77e9b5c">setHopCount</a>(overlayCtrlInfo-&gt;<a class="code" href="classOverlayCtrlInfo.html#a76fd4681ebb00eb023e35a88e4ba9042">getHopCount</a>());
  829. <a name="l00799"></a>00799 routeMsg-&gt;setControlInfo(overlayCtrlInfo);
  830. <a name="l00800"></a>00800
  831. <a name="l00801"></a>00801 <span class="comment">// message marked with this-pointer as already forwarded to tier1</span>
  832. <a name="l00802"></a>00802 routeMsg-&gt;setContextPointer(<span class="keyword">this</span>);
  833. <a name="l00803"></a>00803
  834. <a name="l00804"></a>00804 std::vector&lt;TransportAddress&gt; sourceRoute;
  835. <a name="l00805"></a>00805 sourceRoute.push_back(apiMsg-&gt;<a class="code" href="classKBRforward.html#a7e0e868fc677593aab3e8302e38f7274">getNextHopNode</a>());
  836. <a name="l00806"></a>00806 <a class="code" href="classBaseOverlay.html#a6f2c598f5d3989a63a8cc7220f1aaf76" title="Sends a message to an overlay node, with the generic routing algorithm.">sendToKey</a>(apiMsg-&gt;<a class="code" href="classKBRforward.html#a5c9aa80a6bd136a034e37af25f9beb42">getDestKey</a>(), routeMsg, 1, sourceRoute);
  837. <a name="l00807"></a>00807 }
  838. <a name="l00808"></a>00808
  839. <a name="l00809"></a>00809 <span class="keyword">delete</span> msg;
  840. <a name="l00810"></a>00810 }
  841. <a name="l00811"></a>00811
  842. <a name="l00812"></a>00812 <span class="comment">// process other messages from App</span>
  843. <a name="l00813"></a>00813 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (msg-&gt;getArrivalGate() == <a class="code" href="classBaseOverlay.html#a6523faf8f52af34c73643dc7f3e083eb">appGate</a>) {
  844. <a name="l00814"></a>00814 <a class="code" href="classBaseOverlay.html#aef92d042c22b47c123e59a831acb7033" title="Processes &amp;quot;timer&amp;quot; self-messages.">handleAppMessage</a>(msg);
  845. <a name="l00815"></a>00815 } <span class="keywordflow">else</span> <span class="keywordflow">if</span>(msg-&gt;arrivedOn(<span class="stringliteral">&quot;tcpIn&quot;</span>)) {
  846. <a name="l00816"></a>00816 <a class="code" href="classBaseTcpSupport.html#ac991906514dbe20b4546de49fad67756" title="Member function to handle incoming TCP messages.">handleTCPMessage</a>(msg);
  847. <a name="l00817"></a>00817 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (dynamic_cast&lt;CompReadyMessage*&gt;(msg)) {
  848. <a name="l00818"></a>00818 <a class="code" href="classCompReadyMessage.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">CompReadyMessage</a>* readyMsg = <span class="keyword">static_cast&lt;</span><a class="code" href="classCompReadyMessage.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">CompReadyMessage</a>*<span class="keyword">&gt;</span>(msg);
  849. <a name="l00819"></a>00819 <span class="keywordflow">if</span> (((<span class="keywordtype">bool</span>)par(<span class="stringliteral">&quot;joinOnApplicationRequest&quot;</span>) == <span class="keyword">false</span>) &amp;&amp;
  850. <a name="l00820"></a>00820 readyMsg-&gt;<a class="code" href="classCompReadyMessage.html#adbc73cb3852f357191584e7a9684838f">getReady</a>() &amp;&amp;
  851. <a name="l00821"></a>00821 readyMsg-&gt;<a class="code" href="classCompReadyMessage.html#a3804fb9b24445b1af5484da00634d075">getComp</a>() == NEIGHBORCACHE_COMP) {
  852. <a name="l00822"></a>00822 cObject** context = <a class="code" href="classBaseOverlay.html#a933e505ea77cae4ab0c8edcb77ade2c7" title="pointer to GlobalNodeList in this node">globalNodeList</a>-&gt;<a class="code" href="classGlobalNodeList.html#a9c0e986f725906c17373fac655710e5c">getContext</a>(<a class="code" href="classBaseRpc.html#ac3f420630d5618e81709c078b06fd9da" title="Returns the NodeHandle of this node.">getThisNode</a>());
  853. <a name="l00823"></a>00823 <span class="keywordflow">if</span> (<a class="code" href="classBaseOverlay.html#a7d0beff122a0b5c573dd8ae90c9372d5" title="if true, a node rejoins with its old nodeId and malicious state">restoreContext</a> &amp;&amp; context &amp;&amp; *context) {
  854. <a name="l00824"></a>00824 <a class="code" href="classBaseOverlay_1_1BaseOverlayContext.html">BaseOverlayContext</a>* overlayContext = <span class="keyword">static_cast&lt;</span><a class="code" href="classBaseOverlay_1_1BaseOverlayContext.html">BaseOverlayContext</a>*<span class="keyword">&gt;</span>(*context);
  855. <a name="l00825"></a>00825 <a class="code" href="classBaseOverlay.html#a933e505ea77cae4ab0c8edcb77ade2c7" title="pointer to GlobalNodeList in this node">globalNodeList</a>-&gt;<a class="code" href="classGlobalNodeList.html#ae9b12c25d356b0f02eefc855e338dbd0" title="Set a node to be malicious.">setMalicious</a>(<a class="code" href="classBaseRpc.html#ac3f420630d5618e81709c078b06fd9da" title="Returns the NodeHandle of this node.">getThisNode</a>(),
  856. <a name="l00826"></a>00826 overlayContext-&gt;<a class="code" href="classBaseOverlay_1_1BaseOverlayContext.html#aedc767ab6f5852af04b18666d131da1d">malicious</a>);
  857. <a name="l00827"></a>00827 <a class="code" href="classBaseOverlay.html#acb8855faa86247ae37ab894891d9f4dd" title="Join the overlay with a given nodeID.">join</a>(overlayContext-&gt;<a class="code" href="classBaseOverlay_1_1BaseOverlayContext.html#a7cc31b97afeb437fbb239423c621ad18">key</a>);
  858. <a name="l00828"></a>00828 } <span class="keywordflow">else</span> {
  859. <a name="l00829"></a>00829 <a class="code" href="classBaseOverlay.html#acb8855faa86247ae37ab894891d9f4dd" title="Join the overlay with a given nodeID.">join</a>();
  860. <a name="l00830"></a>00830 }
  861. <a name="l00831"></a>00831 }
  862. <a name="l00832"></a>00832 <span class="keyword">delete</span> msg;
  863. <a name="l00833"></a>00833 } <span class="keywordflow">else</span> {
  864. <a name="l00834"></a>00834 <span class="keywordflow">throw</span> cRuntimeError(<span class="stringliteral">&quot;BaseOverlay::handleMessage(): Received msg with &quot;</span>
  865. <a name="l00835"></a>00835 <span class="stringliteral">&quot;unknown type!&quot;</span>);
  866. <a name="l00836"></a>00836 <span class="keyword">delete</span> msg;
  867. <a name="l00837"></a>00837 }
  868. <a name="l00838"></a>00838 }
  869. <a name="l00839"></a>00839
  870. <a name="l00840"></a><a class="code" href="classBaseOverlay.html#ac647b32e360b4db1f0eb53b096437fd8">00840</a> <span class="keywordtype">void</span> <a class="code" href="classBaseOverlay.html#ac647b32e360b4db1f0eb53b096437fd8" title="Handles a BaseOverlayMessage ">BaseOverlay::handleBaseOverlayMessage</a>(<a class="code" href="classBaseOverlayMessage.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">BaseOverlayMessage</a>* msg,
  871. <a name="l00841"></a>00841 <span class="keyword">const</span> <a class="code" href="classOverlayKey.html" title="A common overlay key class.">OverlayKey</a>&amp; destKey)
  872. <a name="l00842"></a>00842 {
  873. <a name="l00843"></a>00843 <span class="keywordflow">switch</span> (msg-&gt;<a class="code" href="classBaseOverlayMessage.html#a406e342c0841abe2d82b9bb5c1e2aabd">getType</a>()) {
  874. <a name="l00844"></a>00844 <span class="keywordflow">case</span> <a class="code" href="CommonMessages__m_8h.html#a6af1a552a7a6bce33c291758c369b17ea7c7b80e64b0ee54f9c64b4547d82e7fa">OVERLAYSIGNALING</a>:
  875. <a name="l00845"></a>00845 <a class="code" href="classBaseOverlay.html#a31d7dd39ddc9e62ad92f69f6d7210344" title="Processes messages from underlay.">handleUDPMessage</a>(msg);
  876. <a name="l00846"></a>00846 <span class="keywordflow">return</span>;
  877. <a name="l00847"></a>00847
  878. <a name="l00848"></a>00848 <span class="keywordflow">case</span> <a class="code" href="CommonMessages__m_8h.html#a6af1a552a7a6bce33c291758c369b17ea7f7e32ed10aea1dd73b80e96c70e8abf">RPC</a>: {
  879. <a name="l00849"></a>00849 <span class="comment">// process rpc-messages</span>
  880. <a name="l00850"></a>00850 <a class="code" href="classBaseRpcMessage.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">BaseRpcMessage</a>* rpcMsg = check_and_cast&lt;<a class="code" href="classBaseRpcMessage.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">BaseRpcMessage</a>*&gt;(msg);
  881. <a name="l00851"></a>00851
  882. <a name="l00852"></a>00852 <a class="code" href="classBaseRpc.html#a26c06fa9558c497e6dfe1ba6c5153042" title="Handles incoming rpc messages and delegates them to the corresponding listeners or handlers...">internalHandleRpcMessage</a>(rpcMsg);
  883. <a name="l00853"></a>00853 <span class="keywordflow">return</span>;
  884. <a name="l00854"></a>00854 }
  885. <a name="l00855"></a>00855
  886. <a name="l00856"></a>00856 <span class="keywordflow">case</span> <a class="code" href="CommonMessages__m_8h.html#a6af1a552a7a6bce33c291758c369b17eab0641a3f5bcb1e08ee72afe9583ff5e6">APPDATA</a>: {
  887. <a name="l00857"></a>00857 <span class="comment">//TODO use route messages? here: set transport type to ROUTE for &quot;naked&quot;</span>
  888. <a name="l00858"></a>00858 <span class="comment">// app messages</span>
  889. <a name="l00859"></a>00859 <a class="code" href="classOverlayCtrlInfo.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">OverlayCtrlInfo</a>* overlayCtrlInfo = check_and_cast&lt;<a class="code" href="classOverlayCtrlInfo.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">OverlayCtrlInfo</a>*&gt;(msg-&gt;getControlInfo());
  890. <a name="l00860"></a>00860 overlayCtrlInfo-&gt;<a class="code" href="classOverlayCtrlInfo.html#a129cf7292587fa2ee6e4e6238c5e4d33">setTransportType</a>(<a class="code" href="CommonMessages__m_8h.html#aca1e72535e7f260e54ed8bbf984dade9a03dcc78e081682d383ff0baec54dcf8c">ROUTE_TRANSPORT</a>);
  891. <a name="l00861"></a>00861
  892. <a name="l00862"></a>00862 <a class="code" href="classBaseAppDataMessage.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">BaseAppDataMessage</a>* baseAppDataMsg =
  893. <a name="l00863"></a>00863 check_and_cast&lt;<a class="code" href="classBaseAppDataMessage.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">BaseAppDataMessage</a>*&gt;(msg);
  894. <a name="l00864"></a>00864 <a class="code" href="classBaseOverlay.html#a432f79071b87baece93311300cfda0c3" title="Calls deliver function in application.">callDeliver</a>(baseAppDataMsg, destKey);
  895. <a name="l00865"></a>00865 <span class="keywordflow">return</span>;
  896. <a name="l00866"></a>00866 }
  897. <a name="l00867"></a>00867
  898. <a name="l00868"></a>00868 <span class="keywordflow">case</span> <a class="code" href="CommonMessages__m_8h.html#a6af1a552a7a6bce33c291758c369b17ea9fb39f8e1c5f2ff00e45bb7294e5524f">OVERLAYROUTE</a>: {
  899. <a name="l00869"></a>00869 <a class="code" href="classBaseRouteMessage.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">BaseRouteMessage</a>* baseRouteMsg =
  900. <a name="l00870"></a>00870 check_and_cast&lt;<a class="code" href="classBaseRouteMessage.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">BaseRouteMessage</a>*&gt;(msg);
  901. <a name="l00871"></a>00871
  902. <a name="l00872"></a>00872 <span class="comment">// collect delay-value of completed hop</span>
  903. <a name="l00873"></a>00873 <span class="keywordflow">if</span> (<a class="code" href="classBaseOverlay.html#a2694627a0082c456367bfa472fff56b9" title="collect delay for single hops">collectPerHopDelay</a>) {
  904. <a name="l00874"></a>00874 baseRouteMsg-&gt;<a class="code" href="classBaseRouteMessage.html#adae1180a932d161a07885217adcf2213">setHopDelayArraySize</a>(baseRouteMsg-&gt;
  905. <a name="l00875"></a>00875 getHopDelayArraySize() + 1);
  906. <a name="l00876"></a>00876 baseRouteMsg-&gt;<a class="code" href="classBaseRouteMessage.html#a860b477246d3e6ca1b3cf9ab50949f9c">setHopDelay</a>(baseRouteMsg-&gt;<a class="code" href="classBaseRouteMessage.html#ae75d0790b13698bfa9d31e2e2e04983b">getHopDelayArraySize</a>() - 1,
  907. <a name="l00877"></a>00877 simTime() - baseRouteMsg-&gt;<a class="code" href="classBaseRouteMessage.html#a31086f2b50373a749bf986c8ee1bab0f">getHopStamp</a>());
  908. <a name="l00878"></a>00878 }
  909. <a name="l00879"></a>00879
  910. <a name="l00880"></a>00880 <a class="code" href="classOverlayCtrlInfo.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">OverlayCtrlInfo</a>* overlayCtrlInfo
  911. <a name="l00881"></a>00881 = check_and_cast&lt;<a class="code" href="classOverlayCtrlInfo.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">OverlayCtrlInfo</a>*&gt;(baseRouteMsg
  912. <a name="l00882"></a>00882 -&gt;removeControlInfo());
  913. <a name="l00883"></a>00883 <span class="comment">// set transport type</span>
  914. <a name="l00884"></a>00884 overlayCtrlInfo-&gt;<a class="code" href="classOverlayCtrlInfo.html#a129cf7292587fa2ee6e4e6238c5e4d33">setTransportType</a>(<a class="code" href="CommonMessages__m_8h.html#aca1e72535e7f260e54ed8bbf984dade9a03dcc78e081682d383ff0baec54dcf8c">ROUTE_TRANSPORT</a>);
  915. <a name="l00885"></a>00885
  916. <a name="l00886"></a>00886 <span class="comment">// source routing: save visited nodes, copy next hops</span>
  917. <a name="l00887"></a>00887 std::vector&lt;TransportAddress&gt; sourceRoute;
  918. <a name="l00888"></a>00888 <span class="keywordflow">if</span> ((baseRouteMsg-&gt;<a class="code" href="classBaseRouteMessage.html#a4037dda18976c8d98ef3f9ed663f8dc7">getNextHopsArraySize</a>() &gt; 0) ||
  919. <a name="l00889"></a>00889 (baseRouteMsg-&gt;<a class="code" href="classBaseRouteMessage.html#a834dd9c8f0b2b776ed5f5b1fa285149a">getRoutingType</a>() == RECURSIVE_SOURCE_ROUTING) ||
  920. <a name="l00890"></a>00890 <a class="code" href="classBaseOverlay.html#a61186fd8bd7368c8a91a63ecc9c62a89" title="record visited hops on route">recordRoute</a>) {
  921. <a name="l00891"></a>00891 <span class="comment">// store the TransportAddress of the sender in the visited list</span>
  922. <a name="l00892"></a>00892 baseRouteMsg-&gt;<a class="code" href="classBaseRouteMessage.html#a152289adca72ada1c7a8823d08e2164c">setVisitedHopsArraySize</a>(baseRouteMsg
  923. <a name="l00893"></a>00893 -&gt;getVisitedHopsArraySize() + 1);
  924. <a name="l00894"></a>00894 baseRouteMsg-&gt;<a class="code" href="classBaseRouteMessage.html#ade0721c1aa6e69d1f3ea712c8374f249">setVisitedHops</a>(baseRouteMsg
  925. <a name="l00895"></a>00895 -&gt;getVisitedHopsArraySize() - 1,
  926. <a name="l00896"></a>00896 overlayCtrlInfo-&gt;<a class="code" href="classOverlayCtrlInfo.html#ad12b7ac74244fb7ab79ebf41e05fe79c">getLastHop</a>());
  927. <a name="l00897"></a>00897
  928. <a name="l00898"></a>00898 <span class="comment">// remove nodes from next hops and copy them to sourceRoute</span>
  929. <a name="l00899"></a>00899 <span class="keywordflow">if</span> (baseRouteMsg-&gt;<a class="code" href="classBaseRouteMessage.html#a4037dda18976c8d98ef3f9ed663f8dc7">getNextHopsArraySize</a>() &gt; 0) {
  930. <a name="l00900"></a>00900 sourceRoute.resize(baseRouteMsg-&gt;<a class="code" href="classBaseRouteMessage.html#a4037dda18976c8d98ef3f9ed663f8dc7">getNextHopsArraySize</a>()- 1);
  931. <a name="l00901"></a>00901 <span class="keywordflow">for</span> (uint32_t i = 1; i &lt; baseRouteMsg-&gt;<a class="code" href="classBaseRouteMessage.html#a4037dda18976c8d98ef3f9ed663f8dc7">getNextHopsArraySize</a>();
  932. <a name="l00902"></a>00902 ++i) {
  933. <a name="l00903"></a>00903 sourceRoute[i - 1] = baseRouteMsg-&gt;<a class="code" href="classBaseRouteMessage.html#a23f57254381410520aaa67dd52b0bc6c">getNextHops</a>(i);
  934. <a name="l00904"></a>00904 }
  935. <a name="l00905"></a>00905 baseRouteMsg-&gt;<a class="code" href="classBaseRouteMessage.html#a3cb14c09b287d613f26d58ad39fec4d0">setNextHopsArraySize</a>(0);
  936. <a name="l00906"></a>00906 }
  937. <a name="l00907"></a>00907 }
  938. <a name="l00908"></a>00908
  939. <a name="l00909"></a>00909 overlayCtrlInfo-&gt;<a class="code" href="classOverlayCtrlInfo.html#a57150c423c6413ed906a81402e8df0f5">setSrcNode</a>(baseRouteMsg-&gt;<a class="code" href="classBaseRouteMessage.html#af9787d89915f01a2055e920148015e17">getSrcNode</a>());
  940. <a name="l00910"></a>00910
  941. <a name="l00911"></a>00911 <span class="comment">// decapsulate msg if node is sibling for destKey</span>
  942. <a name="l00912"></a>00912 <span class="comment">// or message is at its destination node</span>
  943. <a name="l00913"></a>00913 <span class="keywordtype">bool</span> err;
  944. <a name="l00914"></a>00914 <span class="keywordflow">if</span> ((sourceRoute.size() == 0) &amp;&amp;
  945. <a name="l00915"></a>00915 (baseRouteMsg-&gt;<a class="code" href="classBaseRouteMessage.html#ad983641a05758bc9d25070f1659b2f34">getDestKey</a>().<a class="code" href="classOverlayKey.html#abe357a4d1babcf7d30598a61cbc0f5c2" title="Returns true, if the key is unspecified.">isUnspecified</a>() ||
  946. <a name="l00916"></a>00916 <a class="code" href="classBaseOverlay.html#ab5887b89ba9da5973068e834feb69ce7" title="Query if a node is among the siblings for a given key.">isSiblingFor</a>(<a class="code" href="classBaseRpc.html#a88eb68c06450fd12ea072f471bf1c1b8" title="NodeHandle to this node.">thisNode</a>, baseRouteMsg-&gt;<a class="code" href="classBaseRouteMessage.html#ad983641a05758bc9d25070f1659b2f34">getDestKey</a>(), 1, &amp;err)
  947. <a name="l00917"></a>00917 <span class="comment">/*&amp;&amp; !err*/</span>)) {
  948. <a name="l00918"></a>00918 overlayCtrlInfo-&gt;<a class="code" href="classOverlayCtrlInfo.html#a790ec1f663fccc40033e6a8e714adbff">setHopCount</a>(baseRouteMsg-&gt;<a class="code" href="classBaseRouteMessage.html#ab59d2969c812aa35d132a68fc2baf819">getHopCount</a>());
  949. <a name="l00919"></a>00919 overlayCtrlInfo-&gt;<a class="code" href="classOverlayCtrlInfo.html#a2e3bd66c1e71acd70a6d87817efe15db">setRoutingType</a>(baseRouteMsg-&gt;<a class="code" href="classBaseRouteMessage.html#a834dd9c8f0b2b776ed5f5b1fa285149a">getRoutingType</a>());
  950. <a name="l00920"></a>00920
  951. <a name="l00921"></a>00921 <span class="keywordflow">if</span> (baseRouteMsg-&gt;<a class="code" href="classBaseRouteMessage.html#a4d937e983eb4887400e41749b55ebecb">getVisitedHopsArraySize</a>() &gt; 0) {
  952. <a name="l00922"></a>00922 <span class="comment">// recorded route available =&gt; add to srcNode</span>
  953. <a name="l00923"></a>00923 <a class="code" href="classNodeHandle.html" title="This class implements a node handle.">NodeHandle</a> srcRoute(baseRouteMsg-&gt;<a class="code" href="classBaseRouteMessage.html#af9787d89915f01a2055e920148015e17">getSrcNode</a>().<a class="code" href="classNodeHandle.html#aef531103cdf07c8353267f4d30a80112" title="returns key of this NodeHandle">getKey</a>(),
  954. <a name="l00924"></a>00924 baseRouteMsg-&gt;<a class="code" href="classBaseRouteMessage.html#a5e4624df761b01f0df433ef0ace1c597">getVisitedHops</a>(0));
  955. <a name="l00925"></a>00925
  956. <a name="l00926"></a>00926 <span class="keywordflow">for</span> (uint32_t i = 0; i &lt; baseRouteMsg-&gt;<a class="code" href="classBaseRouteMessage.html#a4d937e983eb4887400e41749b55ebecb">getVisitedHopsArraySize</a>(); ++i) {
  957. <a name="l00927"></a>00927 srcRoute.appendSourceRoute(baseRouteMsg-&gt;<a class="code" href="classBaseRouteMessage.html#a5e4624df761b01f0df433ef0ace1c597">getVisitedHops</a>(i));
  958. <a name="l00928"></a>00928 }
  959. <a name="l00929"></a>00929
  960. <a name="l00930"></a>00930 overlayCtrlInfo-&gt;<a class="code" href="classOverlayCtrlInfo.html#a32d9cea3544768278f7b283b753b018e">setSrcRoute</a>(srcRoute);
  961. <a name="l00931"></a>00931 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (baseRouteMsg-&gt;<a class="code" href="classBaseRouteMessage.html#ad983641a05758bc9d25070f1659b2f34">getDestKey</a>().<a class="code" href="classOverlayKey.html#abe357a4d1babcf7d30598a61cbc0f5c2" title="Returns true, if the key is unspecified.">isUnspecified</a>()) {
  962. <a name="l00932"></a>00932 <span class="comment">// directly received (neither key routed nor source routed)</span>
  963. <a name="l00933"></a>00933 <span class="comment">// TODO: does this happen for a BaseRouteMessage?</span>
  964. <a name="l00934"></a>00934 overlayCtrlInfo-&gt;<a class="code" href="classOverlayCtrlInfo.html#a32d9cea3544768278f7b283b753b018e">setSrcRoute</a>(
  965. <a name="l00935"></a>00935 <a class="code" href="classNodeHandle.html" title="This class implements a node handle.">NodeHandle</a>(baseRouteMsg-&gt;<a class="code" href="classBaseRouteMessage.html#af9787d89915f01a2055e920148015e17">getSrcNode</a>().<a class="code" href="classNodeHandle.html#aef531103cdf07c8353267f4d30a80112" title="returns key of this NodeHandle">getKey</a>(),
  966. <a name="l00936"></a>00936 overlayCtrlInfo-&gt;<a class="code" href="classOverlayCtrlInfo.html#ad12b7ac74244fb7ab79ebf41e05fe79c">getLastHop</a>()));
  967. <a name="l00937"></a>00937 } <span class="keywordflow">else</span> {
  968. <a name="l00938"></a>00938 <span class="comment">// route to key and no recorded route available</span>
  969. <a name="l00939"></a>00939 overlayCtrlInfo-&gt;<a class="code" href="classOverlayCtrlInfo.html#a32d9cea3544768278f7b283b753b018e">setSrcRoute</a>(baseRouteMsg-&gt;<a class="code" href="classBaseRouteMessage.html#af9787d89915f01a2055e920148015e17">getSrcNode</a>());
  970. <a name="l00940"></a>00940 }
  971. <a name="l00941"></a>00941
  972. <a name="l00942"></a>00942 <span class="comment">// copy visited nodes to control info</span>
  973. <a name="l00943"></a>00943 overlayCtrlInfo-&gt;<a class="code" href="classOverlayCtrlInfo.html#abc4f5e4539b4858443cf29523727a995">setVisitedHopsArraySize</a>(
  974. <a name="l00944"></a>00944 baseRouteMsg-&gt;<a class="code" href="classBaseRouteMessage.html#a4d937e983eb4887400e41749b55ebecb">getVisitedHopsArraySize</a>());
  975. <a name="l00945"></a>00945
  976. <a name="l00946"></a>00946 <span class="keywordflow">for</span> (uint32_t i = 0; i &lt; baseRouteMsg-&gt;<a class="code" href="classBaseRouteMessage.html#a4d937e983eb4887400e41749b55ebecb">getVisitedHopsArraySize</a>();
  977. <a name="l00947"></a>00947 ++i) {
  978. <a name="l00948"></a>00948 overlayCtrlInfo-&gt;<a class="code" href="classOverlayCtrlInfo.html#a307f80ca3aeec50add6dee234b9d51f0">setVisitedHops</a>(i,
  979. <a name="l00949"></a>00949 baseRouteMsg-&gt;<a class="code" href="classBaseRouteMessage.html#a5e4624df761b01f0df433ef0ace1c597">getVisitedHops</a>(i));
  980. <a name="l00950"></a>00950 }
  981. <a name="l00951"></a>00951
  982. <a name="l00952"></a>00952 <a class="code" href="classBaseOverlayMessage.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">BaseOverlayMessage</a>* tmpMsg
  983. <a name="l00953"></a>00953 = check_and_cast&lt;<a class="code" href="classBaseOverlayMessage.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">BaseOverlayMessage</a>*&gt;(baseRouteMsg
  984. <a name="l00954"></a>00954 -&gt;decapsulate());
  985. <a name="l00955"></a>00955 tmpMsg-&gt;setControlInfo(overlayCtrlInfo);
  986. <a name="l00956"></a>00956
  987. <a name="l00957"></a>00957 <span class="comment">// delay between hops</span>
  988. <a name="l00958"></a>00958 <span class="keywordflow">if</span> (<a class="code" href="classBaseOverlay.html#a2694627a0082c456367bfa472fff56b9" title="collect delay for single hops">collectPerHopDelay</a>) {
  989. <a name="l00959"></a>00959 <a class="code" href="GlobalStatistics_8h.html#af29140ebe8e0a93406a58441f7c5fec8" title="Macro used for recording statistics considering measureNetwIn parameter.">RECORD_STATS</a>(
  990. <a name="l00960"></a>00960 <span class="keywordtype">size_t</span> i;
  991. <a name="l00961"></a>00961 <span class="keywordflow">for</span> (i = <a class="code" href="classBaseOverlay.html#a93d899c36b4b7b7b012413924c9fb4b5">singleHopDelays</a>.size();
  992. <a name="l00962"></a>00962 i &lt; baseRouteMsg-&gt;<a class="code" href="classBaseRouteMessage.html#ae75d0790b13698bfa9d31e2e2e04983b">getHopDelayArraySize</a>();) {
  993. <a name="l00963"></a>00963 <a class="code" href="classBaseOverlay.html#a93d899c36b4b7b7b012413924c9fb4b5">singleHopDelays</a>.push_back(<span class="keyword">new</span> <a class="code" href="structBaseOverlay_1_1HopDelayRecord.html" title="Structure for computing the average delay in one specific hop.">HopDelayRecord</a>[++i]);
  994. <a name="l00964"></a>00964 }
  995. <a name="l00965"></a>00965
  996. <a name="l00966"></a>00966 i = baseRouteMsg-&gt;<a class="code" href="classBaseRouteMessage.html#ae75d0790b13698bfa9d31e2e2e04983b">getHopDelayArraySize</a>() - 1;
  997. <a name="l00967"></a>00967 <a class="code" href="structBaseOverlay_1_1HopDelayRecord.html" title="Structure for computing the average delay in one specific hop.">HopDelayRecord</a>* hdr = <a class="code" href="classBaseOverlay.html#a93d899c36b4b7b7b012413924c9fb4b5">singleHopDelays</a>[i];
  998. <a name="l00968"></a>00968
  999. <a name="l00969"></a>00969 <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> j = 0; j &lt;= i; ++j) {
  1000. <a name="l00970"></a>00970 hdr[j].<a class="code" href="structBaseOverlay_1_1HopDelayRecord.html#a83f056780cd6b9b68f8eb999d5b45482">count</a>++;
  1001. <a name="l00971"></a>00971 hdr[j].<a class="code" href="structBaseOverlay_1_1HopDelayRecord.html#abcc398fdefba9230fcafb94e701f3071">val</a> += baseRouteMsg-&gt;<a class="code" href="classBaseRouteMessage.html#aadbcf2336edf7d773dfbd6aec4da7b80">getHopDelay</a>(j);
  1002. <a name="l00972"></a>00972 }
  1003. <a name="l00973"></a>00973 );
  1004. <a name="l00974"></a>00974 }
  1005. <a name="l00975"></a>00975
  1006. <a name="l00976"></a>00976 <span class="comment">// handle encapsulated message at destination node</span>
  1007. <a name="l00977"></a>00977 <span class="keywordflow">if</span> (((baseRouteMsg-&gt;<a class="code" href="classBaseRouteMessage.html#a834dd9c8f0b2b776ed5f5b1fa285149a">getRoutingType</a>() == ITERATIVE_ROUTING)
  1008. <a name="l00978"></a>00978 || (baseRouteMsg-&gt;<a class="code" href="classBaseRouteMessage.html#a834dd9c8f0b2b776ed5f5b1fa285149a">getRoutingType</a>() == EXHAUSTIVE_ITERATIVE_ROUTING)
  1009. <a name="l00979"></a>00979 )
  1010. <a name="l00980"></a>00980 || <a class="code" href="classBaseOverlay.html#a42f4c08f6408d155a9907957ecf12d79" title="Hook for forwarded message in recursive lookup mode.">recursiveRoutingHook</a>(<a class="code" href="classBaseRpc.html#a88eb68c06450fd12ea072f471bf1c1b8" title="NodeHandle to this node.">thisNode</a>, baseRouteMsg)) {
  1011. <a name="l00981"></a>00981 <a class="code" href="classBaseOverlay.html#ac647b32e360b4db1f0eb53b096437fd8" title="Handles a BaseOverlayMessage ">handleBaseOverlayMessage</a>(tmpMsg, baseRouteMsg-&gt;<a class="code" href="classBaseRouteMessage.html#ad983641a05758bc9d25070f1659b2f34">getDestKey</a>());
  1012. <a name="l00982"></a>00982 <span class="keyword">delete</span> baseRouteMsg;
  1013. <a name="l00983"></a>00983 }
  1014. <a name="l00984"></a>00984 <span class="keywordflow">return</span>;
  1015. <a name="l00985"></a>00985 } <span class="keywordflow">else</span> {
  1016. <a name="l00986"></a>00986 <span class="comment">// forward msg if this node is not responsible for the key</span>
  1017. <a name="l00987"></a>00987 baseRouteMsg-&gt;setControlInfo(overlayCtrlInfo);
  1018. <a name="l00988"></a>00988
  1019. <a name="l00989"></a>00989 <span class="comment">// if this node is malicious drop the message</span>
  1020. <a name="l00990"></a>00990 <span class="keywordflow">if</span> (<a class="code" href="classBaseOverlay.html#a234b046348574d37d811638f0b27a89e" title="Returns true, if node is malicious.">isMalicious</a>() &amp;&amp; <a class="code" href="classBaseOverlay.html#a3bcd2bdd704803d7ec8ae77633cf03fa" title="if node is malicious, it drops all received BaseRouteMessages">dropRouteMessageAttack</a>) {
  1021. <a name="l00991"></a>00991 EV &lt;&lt; <span class="stringliteral">&quot;[BaseOverlay::handleBaseOverlayMessage() @ &quot;</span> &lt;&lt; <a class="code" href="classBaseRpc.html#a88eb68c06450fd12ea072f471bf1c1b8" title="NodeHandle to this node.">thisNode</a>.<a class="code" href="classTransportAddress.html#a00e613d98d3412e2b92897c25aa0eb4c" title="returns ip address">getIp</a>()
  1022. <a name="l00992"></a>00992 &lt;&lt; <span class="stringliteral">&quot; (&quot;</span> &lt;&lt; <a class="code" href="classBaseRpc.html#a88eb68c06450fd12ea072f471bf1c1b8" title="NodeHandle to this node.">thisNode</a>.<a class="code" href="classNodeHandle.html#aef531103cdf07c8353267f4d30a80112" title="returns key of this NodeHandle">getKey</a>().<a class="code" href="classOverlayKey.html#aabeb4fd284a630a82e982ba34ece4fd9" title="Returns a string representation of this key.">toString</a>(16) &lt;&lt; <span class="stringliteral">&quot;)]\n&quot;</span>
  1023. <a name="l00993"></a>00993 &lt;&lt; <span class="stringliteral">&quot; BaseRouteMessage gets dropped because this node is malicious&quot;</span>
  1024. <a name="l00994"></a>00994 &lt;&lt; endl;
  1025. <a name="l00995"></a>00995 <span class="comment">//std::cout &lt;&lt; &quot;malicious!&quot; &lt;&lt; std::endl;</span>
  1026. <a name="l00996"></a>00996 <a class="code" href="GlobalStatistics_8h.html#af29140ebe8e0a93406a58441f7c5fec8" title="Macro used for recording statistics considering measureNetwIn parameter.">RECORD_STATS</a>(<a class="code" href="classBaseOverlay.html#a4a82bd4b76a8d06a1d63bba98f1a34d7" title="number of dropped packets">numDropped</a>++;
  1027. <a name="l00997"></a>00997 <a class="code" href="classBaseOverlay.html#a9e09857b97f52d340e4710580f25f7a6" title="number of dropped bytes">bytesDropped</a> += baseRouteMsg-&gt;getByteLength());
  1028. <a name="l00998"></a>00998 <span class="keyword">delete</span> baseRouteMsg;
  1029. <a name="l00999"></a>00999 <span class="keywordflow">return</span>;
  1030. <a name="l01000"></a>01000 }
  1031. <a name="l01001"></a>01001
  1032. <a name="l01002"></a>01002 <a class="code" href="classBaseOverlay.html#a6f2c598f5d3989a63a8cc7220f1aaf76" title="Sends a message to an overlay node, with the generic routing algorithm.">sendToKey</a>(baseRouteMsg-&gt;<a class="code" href="classBaseRouteMessage.html#ad983641a05758bc9d25070f1659b2f34">getDestKey</a>(), baseRouteMsg, 1, sourceRoute);
  1033. <a name="l01003"></a>01003 <span class="keywordflow">return</span>;
  1034. <a name="l01004"></a>01004 }
  1035. <a name="l01005"></a>01005 <span class="keywordflow">break</span>;
  1036. <a name="l01006"></a>01006 }
  1037. <a name="l01007"></a>01007
  1038. <a name="l01008"></a>01008 <span class="keywordflow">default</span>:
  1039. <a name="l01009"></a>01009 EV &lt;&lt; <span class="stringliteral">&quot;[BaseOverlay::handleBaseOverlayMessage() @ &quot;</span> &lt;&lt; <a class="code" href="classBaseRpc.html#a88eb68c06450fd12ea072f471bf1c1b8" title="NodeHandle to this node.">thisNode</a>.<a class="code" href="classTransportAddress.html#a00e613d98d3412e2b92897c25aa0eb4c" title="returns ip address">getIp</a>()
  1040. <a name="l01010"></a>01010 &lt;&lt; <span class="stringliteral">&quot; (&quot;</span> &lt;&lt; <a class="code" href="classBaseRpc.html#a88eb68c06450fd12ea072f471bf1c1b8" title="NodeHandle to this node.">thisNode</a>.<a class="code" href="classNodeHandle.html#aef531103cdf07c8353267f4d30a80112" title="returns key of this NodeHandle">getKey</a>().<a class="code" href="classOverlayKey.html#aabeb4fd284a630a82e982ba34ece4fd9" title="Returns a string representation of this key.">toString</a>(16) &lt;&lt; <span class="stringliteral">&quot;)]\n&quot;</span>
  1041. <a name="l01011"></a>01011 &lt;&lt; <span class="stringliteral">&quot; Received unknown message from UDP of type &quot;</span> &lt;&lt; msg-&gt;getName()
  1042. <a name="l01012"></a>01012 &lt;&lt; endl;
  1043. <a name="l01013"></a>01013 <span class="keywordflow">break</span>;
  1044. <a name="l01014"></a>01014 }
  1045. <a name="l01015"></a>01015 }
  1046. <a name="l01016"></a>01016
  1047. <a name="l01017"></a><a class="code" href="classBaseOverlay.html#ac1cf471c2918271ed0244e4a9579c878">01017</a> <span class="keywordtype">void</span> <a class="code" href="classBaseOverlay.html#ac1cf471c2918271ed0244e4a9579c878" title="callback-method for events at the NotificationBoard">BaseOverlay::receiveChangeNotification</a>(<span class="keywordtype">int</span> category, <span class="keyword">const</span> cPolymorphic * details)
  1048. <a name="l01018"></a>01018 {
  1049. <a name="l01019"></a>01019 Enter_Method_Silent();
  1050. <a name="l01020"></a>01020 <span class="keywordflow">if</span> (category == NF_OVERLAY_TRANSPORTADDRESS_CHANGED) {
  1051. <a name="l01021"></a>01021 <a class="code" href="classBaseOverlay.html#a2a53481e2aaf78e6826ab72378bebf48" title="This method gets call if the node has a new TransportAddress (IP address) because he changed his acce...">handleTransportAddressChangedNotification</a>();
  1052. <a name="l01022"></a>01022 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (category == NF_OVERLAY_NODE_LEAVE) {
  1053. <a name="l01023"></a>01023 <a class="code" href="classBaseOverlay.html#af9ea0a59c26b70c50c63c2c1dc4c2ec3" title="This method gets call **.gracefulLeaveDelay seconds before it is killed.">handleNodeLeaveNotification</a>();
  1054. <a name="l01024"></a>01024 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (category == NF_OVERLAY_NODE_GRACEFUL_LEAVE) {
  1055. <a name="l01025"></a>01025 <a class="code" href="classBaseOverlay.html#aa2d70984acd164839ca92694a02e7a91" title="This method gets call **.gracefulLeaveDelay seconds before it is killed if this node is among the gra...">handleNodeGracefulLeaveNotification</a>();
  1056. <a name="l01026"></a>01026 }
  1057. <a name="l01027"></a>01027 }
  1058. <a name="l01028"></a>01028
  1059. <a name="l01029"></a><a class="code" href="classBaseOverlay.html#a2a53481e2aaf78e6826ab72378bebf48">01029</a> <span class="keywordtype">void</span> <a class="code" href="classBaseOverlay.html#a2a53481e2aaf78e6826ab72378bebf48" title="This method gets call if the node has a new TransportAddress (IP address) because he changed his acce...">BaseOverlay::handleTransportAddressChangedNotification</a>()
  1060. <a name="l01030"></a>01030 {
  1061. <a name="l01031"></a>01031 <span class="comment">// get new ip address</span>
  1062. <a name="l01032"></a>01032 <a class="code" href="classBaseRpc.html#a88eb68c06450fd12ea072f471bf1c1b8" title="NodeHandle to this node.">thisNode</a>.<a class="code" href="classTransportAddress.html#a1c7b834dc2e6e738f1f4db8711a12814" title="Sets the ip address, port and NAT type.">setIp</a>(IPAddressResolver().addressOf(
  1063. <a name="l01033"></a>01033 getParentModule()-&gt;getParentModule()));
  1064. <a name="l01034"></a>01034
  1065. <a name="l01035"></a>01035 <a class="code" href="classBaseOverlay.html#a3eefb56c2396601373c89d21b5b58110" title="Join the overlay with a given nodeID in thisNode.key.">joinOverlay</a>();
  1066. <a name="l01036"></a>01036 }
  1067. <a name="l01037"></a>01037
  1068. <a name="l01038"></a><a class="code" href="classBaseOverlay.html#af9ea0a59c26b70c50c63c2c1dc4c2ec3">01038</a> <span class="keywordtype">void</span> <a class="code" href="classBaseOverlay.html#af9ea0a59c26b70c50c63c2c1dc4c2ec3" title="This method gets call **.gracefulLeaveDelay seconds before it is killed.">BaseOverlay::handleNodeLeaveNotification</a>()
  1069. <a name="l01039"></a>01039 {
  1070. <a name="l01040"></a>01040 <span class="comment">// ...</span>
  1071. <a name="l01041"></a>01041 }
  1072. <a name="l01042"></a>01042
  1073. <a name="l01043"></a><a class="code" href="classBaseOverlay.html#aa2d70984acd164839ca92694a02e7a91">01043</a> <span class="keywordtype">void</span> <a class="code" href="classBaseOverlay.html#aa2d70984acd164839ca92694a02e7a91" title="This method gets call **.gracefulLeaveDelay seconds before it is killed if this node is among the gra...">BaseOverlay::handleNodeGracefulLeaveNotification</a>()
  1074. <a name="l01044"></a>01044 {
  1075. <a name="l01045"></a>01045 <span class="comment">// ...</span>
  1076. <a name="l01046"></a>01046 }
  1077. <a name="l01047"></a>01047
  1078. <a name="l01048"></a>01048 <span class="comment">//virtual protected</span>
  1079. <a name="l01049"></a><a class="code" href="classBaseOverlay.html#aef92d042c22b47c123e59a831acb7033">01049</a> <span class="keywordtype">void</span> <a class="code" href="classBaseOverlay.html#aef92d042c22b47c123e59a831acb7033" title="Processes &amp;quot;timer&amp;quot; self-messages.">BaseOverlay::handleAppMessage</a>(cMessage* msg)
  1080. <a name="l01050"></a>01050 {
  1081. <a name="l01051"></a>01051 <span class="keyword">delete</span> msg;
  1082. <a name="l01052"></a>01052 }
  1083. <a name="l01053"></a>01053
  1084. <a name="l01054"></a><a class="code" href="classBaseOverlay.html#a31d7dd39ddc9e62ad92f69f6d7210344">01054</a> <span class="keywordtype">void</span> <a class="code" href="classBaseOverlay.html#a31d7dd39ddc9e62ad92f69f6d7210344" title="Processes messages from underlay.">BaseOverlay::handleUDPMessage</a>(<a class="code" href="classBaseOverlayMessage.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">BaseOverlayMessage</a>* msg)
  1085. <a name="l01055"></a>01055 {
  1086. <a name="l01056"></a>01056 <span class="keyword">delete</span> msg;
  1087. <a name="l01057"></a>01057 }
  1088. <a name="l01058"></a>01058
  1089. <a name="l01059"></a>01059 <span class="comment">//virtual protected</span>
  1090. <a name="l01060"></a><a class="code" href="classBaseOverlay.html#a921ac1fec5765f4099276800a82953ab">01060</a> <span class="keywordtype">void</span> <a class="code" href="classBaseOverlay.html#a921ac1fec5765f4099276800a82953ab" title="Collect overlay specific sent messages statistics.">BaseOverlay::recordOverlaySentStats</a>(<a class="code" href="classBaseOverlayMessage.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">BaseOverlayMessage</a>* msg)
  1091. <a name="l01061"></a>01061 {
  1092. <a name="l01062"></a>01062 <span class="comment">// collect statistics ...</span>
  1093. <a name="l01063"></a>01063 }
  1094. <a name="l01064"></a>01064
  1095. <a name="l01065"></a><a class="code" href="classBaseOverlay.html#a9da615809e832cbc4645cc732d510277">01065</a> <span class="keywordtype">void</span> <a class="code" href="classBaseOverlay.html#a9da615809e832cbc4645cc732d510277" title="Sets the overlay ready icon and register/deregisters the node at the GlobalNodeList.">BaseOverlay::setOverlayReady</a>(<span class="keywordtype">bool</span> ready)
  1096. <a name="l01066"></a>01066 {
  1097. <a name="l01067"></a>01067 <span class="comment">//TODO new setOverlayState(State state) function</span>
  1098. <a name="l01068"></a>01068 <span class="keywordflow">if</span> ((ready &amp;&amp; <a class="code" href="classBaseOverlay.html#aa484556ed4ff9e4e97394106d0c1d323" title="internal overlay state used for setOverlayReady()">internalReadyState</a>) || (!ready &amp;&amp; !<a class="code" href="classBaseOverlay.html#aa484556ed4ff9e4e97394106d0c1d323" title="internal overlay state used for setOverlayReady()">internalReadyState</a>)) {
  1099. <a name="l01069"></a>01069 <span class="keywordflow">return</span>;
  1100. <a name="l01070"></a>01070 }
  1101. <a name="l01071"></a>01071
  1102. <a name="l01072"></a>01072 <a class="code" href="classBaseOverlay.html#aa484556ed4ff9e4e97394106d0c1d323" title="internal overlay state used for setOverlayReady()">internalReadyState</a> = ready;
  1103. <a name="l01073"></a>01073
  1104. <a name="l01074"></a>01074 getDisplayString().setTagArg(<span class="stringliteral">&quot;i&quot;</span>, 1, ready ? <span class="stringliteral">&quot;&quot;</span> : <span class="stringliteral">&quot;red&quot;</span>);
  1105. <a name="l01075"></a>01075 <span class="keywordflow">if</span> (<a class="code" href="classBaseOverlay.html#a234b046348574d37d811638f0b27a89e" title="Returns true, if node is malicious.">isMalicious</a>()) {
  1106. <a name="l01076"></a>01076 getDisplayString().setTagArg(<span class="stringliteral">&quot;i&quot;</span>, 1, ready ? <span class="stringliteral">&quot;green&quot;</span> : <span class="stringliteral">&quot;yellow&quot;</span>);
  1107. <a name="l01077"></a>01077 }
  1108. <a name="l01078"></a>01078
  1109. <a name="l01079"></a>01079 <a class="code" href="classBaseOverlay.html#a933e505ea77cae4ab0c8edcb77ade2c7" title="pointer to GlobalNodeList in this node">globalNodeList</a>-&gt;<a class="code" href="classGlobalNodeList.html#a94604495a81e687f7492564d788c7c36" title="Colors module-icon blue (ready), green (ready, malicious) or red (not ready).">setOverlayReadyIcon</a>(<a class="code" href="classBaseRpc.html#ac3f420630d5618e81709c078b06fd9da" title="Returns the NodeHandle of this node.">getThisNode</a>(), ready);
  1110. <a name="l01080"></a>01080
  1111. <a name="l01081"></a>01081 <span class="keywordflow">if</span> (ready) {
  1112. <a name="l01082"></a>01082 <a class="code" href="classBaseOverlay.html#abe4dea93564123116c97d5c4721f0504" title="pointer to the BootstrapList module">bootstrapList</a>-&gt;<a class="code" href="classBootstrapList.html#a2b29d94b378a75148b777f560adcef13">registerBootstrapNode</a>(<a class="code" href="classBaseRpc.html#a88eb68c06450fd12ea072f471bf1c1b8" title="NodeHandle to this node.">thisNode</a>);
  1113. <a name="l01083"></a>01083 } <span class="keywordflow">else</span> {
  1114. <a name="l01084"></a>01084 <a class="code" href="classBaseOverlay.html#abe4dea93564123116c97d5c4721f0504" title="pointer to the BootstrapList module">bootstrapList</a>-&gt;<a class="code" href="classBootstrapList.html#ae3599c25687b302037e58d3ca68411cd">removeBootstrapNode</a>(<a class="code" href="classBaseRpc.html#a88eb68c06450fd12ea072f471bf1c1b8" title="NodeHandle to this node.">thisNode</a>);
  1115. <a name="l01085"></a>01085 }
  1116. <a name="l01086"></a>01086
  1117. <a name="l01087"></a>01087 <span class="keywordflow">if</span> (<a class="code" href="classBaseOverlay.html#a59bde2858b8537864fbad3eb487dbc55" title="pointer to the GlobalParameters module">globalParameters</a>-&gt;<a class="code" href="classGlobalParameters.html#a8d700111d72e65cdefdf87e8f1b3b9b6">getPrintStateToStdOut</a>()) {
  1118. <a name="l01088"></a>01088 std::cout &lt;&lt; <span class="stringliteral">&quot;OVERLAY STATE: &quot;</span> &lt;&lt; (ready ? <span class="stringliteral">&quot;READY (&quot;</span> : <span class="stringliteral">&quot;OFFLINE (&quot;</span>)
  1119. <a name="l01089"></a>01089 &lt;&lt; <a class="code" href="classBaseRpc.html#a88eb68c06450fd12ea072f471bf1c1b8" title="NodeHandle to this node.">thisNode</a> &lt;&lt; <span class="stringliteral">&quot;)&quot;</span> &lt;&lt; std::endl;
  1120. <a name="l01090"></a>01090 }
  1121. <a name="l01091"></a>01091
  1122. <a name="l01092"></a>01092 <a class="code" href="classCompReadyMessage.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">CompReadyMessage</a>* msg = <span class="keyword">new</span> <a class="code" href="classCompReadyMessage.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">CompReadyMessage</a>;
  1123. <a name="l01093"></a>01093 msg-&gt;<a class="code" href="classCompReadyMessage.html#ac5158504d6b97a32974f14c9b1a7a662">setReady</a>(ready);
  1124. <a name="l01094"></a>01094 msg-&gt;<a class="code" href="classCompReadyMessage.html#ad9a52c5f788e0c11a75bbb5df3855ac0">setComp</a>(<a class="code" href="CommonMessages__m_8h.html#aad57ef0110fe8675eb299d467148bc5ead1b904580b02f8adaa1ab2de239c4c79">OVERLAY_COMP</a>);
  1125. <a name="l01095"></a>01095
  1126. <a name="l01096"></a>01096 <span class="comment">// notify all registered components about new overlay state</span>
  1127. <a name="l01097"></a>01097 <a class="code" href="classBaseOverlay.html#a19c2c01f99a19bb7de0b30cdd866a2e0">sendMessageToAllComp</a>(msg, <a class="code" href="CommonMessages__m_8h.html#aad57ef0110fe8675eb299d467148bc5ead1b904580b02f8adaa1ab2de239c4c79">OVERLAY_COMP</a>);
  1128. <a name="l01098"></a>01098 }
  1129. <a name="l01099"></a>01099
  1130. <a name="l01100"></a>01100
  1131. <a name="l01101"></a>01101
  1132. <a name="l01102"></a>01102 <span class="comment">//------------------------------------------------------------------------</span>
  1133. <a name="l01103"></a>01103 <span class="comment">//--- Messages -----------------------------------------------------------</span>
  1134. <a name="l01104"></a>01104 <span class="comment">//------------------------------------------------------------------------</span>
  1135. <a name="l01105"></a>01105
  1136. <a name="l01106"></a><a class="code" href="classBaseOverlay.html#ac93829bc8095a76e6208cf0ec12188b0">01106</a> <span class="keywordtype">void</span> <a class="code" href="classBaseOverlay.html#ac93829bc8095a76e6208cf0ec12188b0">BaseOverlay::sendRouteMessage</a>(<span class="keyword">const</span> <a class="code" href="classTransportAddress.html" title="This class implements a common transport address.">TransportAddress</a>&amp; dest,
  1137. <a name="l01107"></a>01107 <a class="code" href="classBaseRouteMessage.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">BaseRouteMessage</a>* msg,
  1138. <a name="l01108"></a>01108 <span class="keywordtype">bool</span> ack)
  1139. <a name="l01109"></a>01109 {
  1140. <a name="l01110"></a>01110 <a class="code" href="classOverlayCtrlInfo.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">OverlayCtrlInfo</a>* ctrlInfo =
  1141. <a name="l01111"></a>01111 <span class="keyword">dynamic_cast&lt;</span><a class="code" href="classOverlayCtrlInfo.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">OverlayCtrlInfo</a>*<span class="keyword">&gt;</span>(msg-&gt;removeControlInfo());
  1142. <a name="l01112"></a>01112
  1143. <a name="l01113"></a>01113 <span class="comment">// records statistics, if we forward this message</span>
  1144. <a name="l01114"></a>01114 <span class="keywordflow">if</span> (ctrlInfo &amp;&amp; ctrlInfo-&gt;<a class="code" href="classOverlayCtrlInfo.html#ad12b7ac74244fb7ab79ebf41e05fe79c">getLastHop</a>().<a class="code" href="classTransportAddress.html#a00e613d98d3412e2b92897c25aa0eb4c" title="returns ip address">getIp</a>() != <a class="code" href="classBaseRpc.html#a88eb68c06450fd12ea072f471bf1c1b8" title="NodeHandle to this node.">thisNode</a>.<a class="code" href="classTransportAddress.html#a00e613d98d3412e2b92897c25aa0eb4c" title="returns ip address">getIp</a>()) {
  1145. <a name="l01115"></a>01115 <span class="keywordflow">if</span> (msg-&gt;<a class="code" href="classBaseOverlayMessage.html#af0a4bf31778e05a809f8d55dff5bfcc1">getStatType</a>() == APP_DATA_STAT) {
  1146. <a name="l01116"></a>01116 <a class="code" href="GlobalStatistics_8h.html#af29140ebe8e0a93406a58441f7c5fec8" title="Macro used for recording statistics considering measureNetwIn parameter.">RECORD_STATS</a>(<a class="code" href="classBaseOverlay.html#a341a65ab7c50dfbc8222c1adf4f08a99" title="number of forwarded app data packets">numAppDataForwarded</a>++;
  1147. <a name="l01117"></a>01117 <a class="code" href="classBaseOverlay.html#a1c90204205e7e5b8f0f12fe4056914e6" title="number of forwarded app data bytes at out-gate">bytesAppDataForwarded</a> += msg-&gt;getByteLength());
  1148. <a name="l01118"></a>01118 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (msg-&gt;<a class="code" href="classBaseOverlayMessage.html#af0a4bf31778e05a809f8d55dff5bfcc1">getStatType</a>() == APP_LOOKUP_STAT){
  1149. <a name="l01119"></a>01119 <a class="code" href="GlobalStatistics_8h.html#af29140ebe8e0a93406a58441f7c5fec8" title="Macro used for recording statistics considering measureNetwIn parameter.">RECORD_STATS</a>(<a class="code" href="classBaseOverlay.html#a8f5ff290e99ab78f3e0bd4a489bfcadd" title="number of forwarded app lookup packets">numAppLookupForwarded</a>++;
  1150. <a name="l01120"></a>01120 <a class="code" href="classBaseOverlay.html#adeff8c454760c6eb4ca847e8dda252a7" title="number of forwarded app lookup bytes at out-gate">bytesAppLookupForwarded</a> += msg-&gt;getByteLength());
  1151. <a name="l01121"></a>01121 } <span class="keywordflow">else</span> {
  1152. <a name="l01122"></a>01122 <a class="code" href="GlobalStatistics_8h.html#af29140ebe8e0a93406a58441f7c5fec8" title="Macro used for recording statistics considering measureNetwIn parameter.">RECORD_STATS</a>(<a class="code" href="classBaseOverlay.html#a05fa895acb368180bbca74d92152d2f7" title="number of forwarded maintenance packets">numMaintenanceForwarded</a>++;
  1153. <a name="l01123"></a>01123 <a class="code" href="classBaseOverlay.html#a8dbb1ce4eee057f23bea55e5e4a7d13b" title="number of forwarded maintenance bytes at out-gate">bytesMaintenanceForwarded</a> += msg-&gt;getByteLength());
  1154. <a name="l01124"></a>01124 }
  1155. <a name="l01125"></a>01125 }
  1156. <a name="l01126"></a>01126
  1157. <a name="l01127"></a>01127 <span class="keyword">delete</span> ctrlInfo;
  1158. <a name="l01128"></a>01128
  1159. <a name="l01129"></a>01129 <span class="keywordflow">if</span> (msg &amp;&amp; (dest != <a class="code" href="classBaseRpc.html#a88eb68c06450fd12ea072f471bf1c1b8" title="NodeHandle to this node.">thisNode</a>)) {
  1160. <a name="l01130"></a>01130 msg-&gt;<a class="code" href="classBaseRouteMessage.html#a1c843714ac5feca3c13f1e39b77e9b5c">setHopCount</a>(msg-&gt;<a class="code" href="classBaseRouteMessage.html#ab59d2969c812aa35d132a68fc2baf819">getHopCount</a>() + 1);
  1161. <a name="l01131"></a>01131 }
  1162. <a name="l01132"></a>01132 <span class="keywordflow">if</span> (!ack)
  1163. <a name="l01133"></a>01133 <a class="code" href="classBaseOverlay.html#a124850e5bc8d81b3eb4f3aec75868449" title="Sends message to underlay.">sendMessageToUDP</a>(dest, msg);
  1164. <a name="l01134"></a>01134 <span class="keywordflow">else</span> {
  1165. <a name="l01135"></a>01135 <a class="code" href="classNextHopCall.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">NextHopCall</a>* nextHopCall = <span class="keyword">new</span> <a class="code" href="classNextHopCall.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">NextHopCall</a>(msg-&gt;getName());
  1166. <a name="l01136"></a>01136 nextHopCall-&gt;setBitLength(<a class="code" href="CommonMessages__m_8h.html#ad34959682756fd7714484c7326ae823b">NEXTHOPCALL_L</a>(nextHopCall));
  1167. <a name="l01137"></a>01137 nextHopCall-&gt;encapsulate(msg);
  1168. <a name="l01138"></a>01138 nextHopCall-&gt;<a class="code" href="classBaseOverlayMessage.html#a46fd21016c6fad4f167d5510f0481f49">setStatType</a>(msg-&gt;<a class="code" href="classBaseOverlayMessage.html#af0a4bf31778e05a809f8d55dff5bfcc1">getStatType</a>());
  1169. <a name="l01139"></a>01139
  1170. <a name="l01140"></a>01140 <span class="comment">// TODO parameter, in recursive mode routeRetries should be 0,</span>
  1171. <a name="l01141"></a>01141 <span class="comment">// in iterative mode routeRetries could be more than 0</span>
  1172. <a name="l01142"></a>01142 uint8_t routeRetries = 0;
  1173. <a name="l01143"></a>01143 <a class="code" href="classBaseRpc.html#ac128e0ff0d09f81b652f7d3e00ce9441" title="Sends a Remote-Procedure-Call message to the underlay ">sendUdpRpcCall</a>(dest, nextHopCall, NULL, -1, routeRetries);
  1174. <a name="l01144"></a>01144 }
  1175. <a name="l01145"></a>01145 }
  1176. <a name="l01146"></a><a class="code" href="classBaseOverlay.html#a124850e5bc8d81b3eb4f3aec75868449">01146</a> <span class="keywordtype">void</span> <a class="code" href="classBaseOverlay.html#a124850e5bc8d81b3eb4f3aec75868449" title="Sends message to underlay.">BaseOverlay::sendMessageToUDP</a>(<span class="keyword">const</span> <a class="code" href="classTransportAddress.html" title="This class implements a common transport address.">TransportAddress</a>&amp; dest,
  1177. <a name="l01147"></a>01147 cPacket* msg)
  1178. <a name="l01148"></a>01148 {
  1179. <a name="l01149"></a>01149 <span class="comment">// if there&#39;s still a control info attached to the message, remove it</span>
  1180. <a name="l01150"></a>01150 cPolymorphic* ctrlInfo = msg-&gt;removeControlInfo();
  1181. <a name="l01151"></a>01151 <span class="keywordflow">if</span> (ctrlInfo != NULL)
  1182. <a name="l01152"></a>01152 <span class="keyword">delete</span> ctrlInfo;
  1183. <a name="l01153"></a>01153
  1184. <a name="l01154"></a>01154 <span class="comment">// debug message</span>
  1185. <a name="l01155"></a>01155 <span class="keywordflow">if</span> (<a class="code" href="classBaseOverlay.html#a49ff0fb8c25792a1339d54a60c36f2cd" title="debug output ?">debugOutput</a>) {
  1186. <a name="l01156"></a>01156 EV &lt;&lt; <span class="stringliteral">&quot;[BaseOverlay::sendMessageToUDP() @ &quot;</span> &lt;&lt; <a class="code" href="classBaseRpc.html#a88eb68c06450fd12ea072f471bf1c1b8" title="NodeHandle to this node.">thisNode</a>.<a class="code" href="classTransportAddress.html#a00e613d98d3412e2b92897c25aa0eb4c" title="returns ip address">getIp</a>()
  1187. <a name="l01157"></a>01157 &lt;&lt; <span class="stringliteral">&quot; (&quot;</span> &lt;&lt; <a class="code" href="classBaseRpc.html#a88eb68c06450fd12ea072f471bf1c1b8" title="NodeHandle to this node.">thisNode</a>.<a class="code" href="classNodeHandle.html#aef531103cdf07c8353267f4d30a80112" title="returns key of this NodeHandle">getKey</a>().<a class="code" href="classOverlayKey.html#aabeb4fd284a630a82e982ba34ece4fd9" title="Returns a string representation of this key.">toString</a>(16) &lt;&lt; <span class="stringliteral">&quot;)]\n&quot;</span>
  1188. <a name="l01158"></a>01158 &lt;&lt; <span class="stringliteral">&quot; Sending &quot;</span> &lt;&lt; *msg &lt;&lt; <span class="stringliteral">&quot; to &quot;</span> &lt;&lt; dest.<a class="code" href="classTransportAddress.html#a00e613d98d3412e2b92897c25aa0eb4c" title="returns ip address">getIp</a>()
  1189. <a name="l01159"></a>01159 &lt;&lt; endl;
  1190. <a name="l01160"></a>01160 }
  1191. <a name="l01161"></a>01161
  1192. <a name="l01162"></a>01162 msg-&gt;setKind(UDP_C_DATA);
  1193. <a name="l01163"></a>01163 UDPControlInfo* udpControlInfo = <span class="keyword">new</span> UDPControlInfo();
  1194. <a name="l01164"></a>01164 udpControlInfo-&gt;setSrcAddr(<a class="code" href="classBaseRpc.html#a88eb68c06450fd12ea072f471bf1c1b8" title="NodeHandle to this node.">thisNode</a>.<a class="code" href="classTransportAddress.html#a00e613d98d3412e2b92897c25aa0eb4c" title="returns ip address">getIp</a>());
  1195. <a name="l01165"></a>01165 udpControlInfo-&gt;setSrcPort(<a class="code" href="classBaseRpc.html#a88eb68c06450fd12ea072f471bf1c1b8" title="NodeHandle to this node.">thisNode</a>.<a class="code" href="classTransportAddress.html#a4cf99c434c5110935683624dc3702e0f" title="returns port">getPort</a>());
  1196. <a name="l01166"></a>01166 udpControlInfo-&gt;setDestAddr(dest.<a class="code" href="classTransportAddress.html#a00e613d98d3412e2b92897c25aa0eb4c" title="returns ip address">getIp</a>());
  1197. <a name="l01167"></a>01167 udpControlInfo-&gt;setDestPort(dest.<a class="code" href="classTransportAddress.html#a4cf99c434c5110935683624dc3702e0f" title="returns port">getPort</a>());
  1198. <a name="l01168"></a>01168 msg-&gt;setControlInfo(udpControlInfo);
  1199. <a name="l01169"></a>01169
  1200. <a name="l01170"></a>01170 <span class="keywordflow">if</span> (dest != <a class="code" href="classBaseRpc.html#a88eb68c06450fd12ea072f471bf1c1b8" title="NodeHandle to this node.">thisNode</a>) {
  1201. <a name="l01171"></a>01171 <a class="code" href="classBaseOverlayMessage.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">BaseOverlayMessage</a>* baseOverlayMsg
  1202. <a name="l01172"></a>01172 = check_and_cast&lt;<a class="code" href="classBaseOverlayMessage.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">BaseOverlayMessage</a>*&gt;(msg);
  1203. <a name="l01173"></a>01173 <span class="comment">// record statistics, if message is not local</span>
  1204. <a name="l01174"></a>01174 <span class="keywordflow">if</span> (baseOverlayMsg-&gt;<a class="code" href="classBaseOverlayMessage.html#af0a4bf31778e05a809f8d55dff5bfcc1">getStatType</a>() == APP_DATA_STAT) {
  1205. <a name="l01175"></a>01175 <a class="code" href="GlobalStatistics_8h.html#af29140ebe8e0a93406a58441f7c5fec8" title="Macro used for recording statistics considering measureNetwIn parameter.">RECORD_STATS</a>(<a class="code" href="classBaseOverlay.html#aa8c1469e21c59a08a84dec36218582b4" title="number of sent app data packets (incl. forwarded packets)">numAppDataSent</a>++;
  1206. <a name="l01176"></a>01176 <a class="code" href="classBaseOverlay.html#ae6453766e7a58060722a6323ee3923e4" title="number of sent app data bytes (incl. forwarded bytes)">bytesAppDataSent</a> += msg-&gt;getByteLength());
  1207. <a name="l01177"></a>01177 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (baseOverlayMsg-&gt;<a class="code" href="classBaseOverlayMessage.html#af0a4bf31778e05a809f8d55dff5bfcc1">getStatType</a>() == APP_LOOKUP_STAT){
  1208. <a name="l01178"></a>01178 <a class="code" href="GlobalStatistics_8h.html#af29140ebe8e0a93406a58441f7c5fec8" title="Macro used for recording statistics considering measureNetwIn parameter.">RECORD_STATS</a>(<a class="code" href="classBaseOverlay.html#a5b42fe053fd79b9b62680cbfc740ec4f" title="number of sent app loookup packets (incl. forwarded packets)">numAppLookupSent</a>++; <a class="code" href="classBaseOverlay.html#a118e46bc3e194c63a70e28846480ffe4" title="number of sent app lookup bytes (incl. forwarded bytes)">bytesAppLookupSent</a> +=
  1209. <a name="l01179"></a>01179 msg-&gt;getByteLength());
  1210. <a name="l01180"></a>01180 } <span class="keywordflow">else</span> { <span class="comment">// MAINTENANCE_STAT</span>
  1211. <a name="l01181"></a>01181 <a class="code" href="GlobalStatistics_8h.html#af29140ebe8e0a93406a58441f7c5fec8" title="Macro used for recording statistics considering measureNetwIn parameter.">RECORD_STATS</a>(<a class="code" href="classBaseOverlay.html#af1077d5c646390fb11d4f646fc22eaaa" title="number of sent maintenance packets (incl. forwarded packets)">numMaintenanceSent</a>++; <a class="code" href="classBaseOverlay.html#a27259327737ad8092c612756c0fe6fb4" title="number of sent maintenance bytes (incl. forwarded bytes)">bytesMaintenanceSent</a> +=
  1212. <a name="l01182"></a>01182 msg-&gt;getByteLength());
  1213. <a name="l01183"></a>01183 }
  1214. <a name="l01184"></a>01184 <a class="code" href="classBaseOverlay.html#a921ac1fec5765f4099276800a82953ab" title="Collect overlay specific sent messages statistics.">recordOverlaySentStats</a>(baseOverlayMsg);
  1215. <a name="l01185"></a>01185
  1216. <a name="l01186"></a>01186 <span class="keywordflow">if</span> (dynamic_cast&lt;BaseResponseMessage*&gt;(msg) &amp;&amp; <a class="code" href="classBaseOverlay.html#a077a698fb5f760290bc67e4a50dfed9e">getMeasureAuthBlock</a>()) {
  1217. <a name="l01187"></a>01187 <span class="comment">// TODO: Also consider signed DhtPutMessages</span>
  1218. <a name="l01188"></a>01188 <a class="code" href="GlobalStatistics_8h.html#af29140ebe8e0a93406a58441f7c5fec8" title="Macro used for recording statistics considering measureNetwIn parameter.">RECORD_STATS</a>(<a class="code" href="classBaseOverlay.html#a30e11530c77c2164f0a5c98a489a9fab" title="number of bytes sent for rpc message signatures">bytesAuthBlockSent</a> += ceil(<a class="code" href="CommonMessages__m_8h.html#a06bed1f18c78d612efe98781ddd5f56f">AUTHBLOCK_L</a>/8.0));
  1219. <a name="l01189"></a>01189 }
  1220. <a name="l01190"></a>01190 } <span class="keywordflow">else</span> {
  1221. <a name="l01191"></a>01191 <span class="keywordflow">if</span> (dest.<a class="code" href="classTransportAddress.html#a00e613d98d3412e2b92897c25aa0eb4c" title="returns ip address">getIp</a>() == <a class="code" href="classBaseRpc.html#a88eb68c06450fd12ea072f471bf1c1b8" title="NodeHandle to this node.">thisNode</a>.<a class="code" href="classTransportAddress.html#a00e613d98d3412e2b92897c25aa0eb4c" title="returns ip address">getIp</a>()) { <span class="comment">// to same node, but different port</span>
  1222. <a name="l01192"></a>01192 <a class="code" href="GlobalStatistics_8h.html#af29140ebe8e0a93406a58441f7c5fec8" title="Macro used for recording statistics considering measureNetwIn parameter.">RECORD_STATS</a>(<a class="code" href="classBaseOverlay.html#ae34cc8a058a4dae47a3815cba64ceba2" title="number of packets sent to same host but different port (SimpleMultiOverlayHost)">numInternalSent</a>++; <a class="code" href="classBaseOverlay.html#ad0af3d066a89ced910b082a980f68f25" title="number of bytes sent to same host but different port (SimpleMultiOverlayHost)">bytesInternalSent</a> += msg-&gt;getByteLength());
  1223. <a name="l01193"></a>01193 }
  1224. <a name="l01194"></a>01194 }
  1225. <a name="l01195"></a>01195 send(msg, <span class="stringliteral">&quot;udpOut&quot;</span>);
  1226. <a name="l01196"></a>01196 }
  1227. <a name="l01197"></a>01197
  1228. <a name="l01198"></a>01198 <span class="comment">//------------------------------------------------------------------------</span>
  1229. <a name="l01199"></a>01199 <span class="comment">//--- Basic Routing ------------------------------------------------------</span>
  1230. <a name="l01200"></a>01200 <span class="comment">//------------------------------------------------------------------------</span>
  1231. <a name="l01201"></a>01201
  1232. <a name="l01202"></a><a class="code" href="BaseOverlay_8cc.html#a400caf95d25f6d8cedf0f008f9a697ec">01202</a> <span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="BaseOverlay_8cc.html#a400caf95d25f6d8cedf0f008f9a697ec">pendingLookups</a> = 0;
  1233. <a name="l01203"></a>01203
  1234. <a name="l01204"></a><a class="code" href="classBaseOverlay.html#af2c8b2108703c4df49217a719f280bb8">01204</a> <span class="keywordtype">void</span> <a class="code" href="classBaseOverlay.html#af2c8b2108703c4df49217a719f280bb8" title="creates a LookupSet">BaseOverlay::initLookups</a>()
  1235. <a name="l01205"></a>01205 {
  1236. <a name="l01206"></a>01206 <a class="code" href="classBaseOverlay.html#ad25b51c2d6c06dbe12c534307f43822e">lookups</a> = <a class="code" href="classBaseOverlay.html#a65cc359d4db3de08cde7ff0b3794f0c8">LookupSet</a>();
  1237. <a name="l01207"></a>01207 }
  1238. <a name="l01208"></a>01208
  1239. <a name="l01209"></a><a class="code" href="classBaseOverlay.html#abaaca6fe44d8e317d56c90a14e0fcada">01209</a> <span class="keywordtype">void</span> <a class="code" href="classBaseOverlay.html#abaaca6fe44d8e317d56c90a14e0fcada" title="deletes entries in lookups">BaseOverlay::finishLookups</a>()
  1240. <a name="l01210"></a>01210 {
  1241. <a name="l01211"></a>01211 <span class="keywordflow">while</span> (<a class="code" href="classBaseOverlay.html#ad25b51c2d6c06dbe12c534307f43822e">lookups</a>.size() &gt; 0) {
  1242. <a name="l01212"></a>01212 (*<a class="code" href="classBaseOverlay.html#ad25b51c2d6c06dbe12c534307f43822e">lookups</a>.begin())-&gt;abortLookup();
  1243. <a name="l01213"></a>01213 }
  1244. <a name="l01214"></a>01214 <a class="code" href="classBaseOverlay.html#ad25b51c2d6c06dbe12c534307f43822e">lookups</a>.clear();
  1245. <a name="l01215"></a>01215 }
  1246. <a name="l01216"></a>01216
  1247. <a name="l01217"></a><a class="code" href="classSendToKeyListener.html">01217</a> <span class="keyword">class </span><a class="code" href="classSendToKeyListener.html">SendToKeyListener</a> : <span class="keyword">public</span> <a class="code" href="classLookupListener.html" title="This class declares an abstract lookup listener.">LookupListener</a>
  1248. <a name="l01218"></a>01218 {
  1249. <a name="l01219"></a>01219 <span class="keyword">private</span>:
  1250. <a name="l01220"></a><a class="code" href="classSendToKeyListener.html#ac6a8b10c63a4595450377b9beaa00490">01220</a> <a class="code" href="classBaseOverlay.html" title="Base class for overlays.">BaseOverlay</a>* <a class="code" href="classSendToKeyListener.html#ac6a8b10c63a4595450377b9beaa00490">overlay</a>;
  1251. <a name="l01221"></a><a class="code" href="classSendToKeyListener.html#a76dd14829ae2b15ccd4a710ab6329ff4">01221</a> <a class="code" href="classBaseOverlayMessage.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">BaseOverlayMessage</a>* <a class="code" href="classSendToKeyListener.html#a76dd14829ae2b15ccd4a710ab6329ff4">msg</a>;
  1252. <a name="l01222"></a><a class="code" href="classSendToKeyListener.html#ad65c944612ead39d93ddb9cf69bfbb7a">01222</a> <a class="code" href="classGlobalStatistics.html" title="Module to record global statistics.">GlobalStatistics</a>* <a class="code" href="classSendToKeyListener.html#ad65c944612ead39d93ddb9cf69bfbb7a">globalStatistics</a>;
  1253. <a name="l01223"></a>01223 <span class="keyword">public</span>:
  1254. <a name="l01224"></a><a class="code" href="classSendToKeyListener.html#a27b16a40cfd5c515f94c9fad087d299f">01224</a> <a class="code" href="classSendToKeyListener.html#a27b16a40cfd5c515f94c9fad087d299f">SendToKeyListener</a>( <a class="code" href="classBaseOverlay.html" title="Base class for overlays.">BaseOverlay</a>* <a class="code" href="classSendToKeyListener.html#ac6a8b10c63a4595450377b9beaa00490">overlay</a>, <a class="code" href="classBaseOverlayMessage.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">BaseOverlayMessage</a>* <a class="code" href="classSendToKeyListener.html#a76dd14829ae2b15ccd4a710ab6329ff4">msg</a> ) {
  1255. <a name="l01225"></a>01225 this-&gt;overlay = overlay;
  1256. <a name="l01226"></a>01226 this-&gt;msg = msg;
  1257. <a name="l01227"></a>01227 <a class="code" href="classSendToKeyListener.html#ad65c944612ead39d93ddb9cf69bfbb7a">globalStatistics</a> = overlay-&gt;<a class="code" href="classBaseRpc.html#a9552ba3a2b09c83b3c561e65dab9f23d" title="pointer to GlobalStatistics module in this node">globalStatistics</a>;
  1258. <a name="l01228"></a>01228 <a class="code" href="BaseOverlay_8cc.html#a400caf95d25f6d8cedf0f008f9a697ec">pendingLookups</a>++;
  1259. <a name="l01229"></a>01229 }
  1260. <a name="l01230"></a>01230
  1261. <a name="l01231"></a><a class="code" href="classSendToKeyListener.html#a008de600db3cf76f5aaec9ba8dd7fb77">01231</a> <a class="code" href="classSendToKeyListener.html#a008de600db3cf76f5aaec9ba8dd7fb77">~SendToKeyListener</a>() {
  1262. <a name="l01232"></a>01232 <a class="code" href="BaseOverlay_8cc.html#a400caf95d25f6d8cedf0f008f9a697ec">pendingLookups</a>--;
  1263. <a name="l01233"></a>01233 <a class="code" href="classSendToKeyListener.html#ac6a8b10c63a4595450377b9beaa00490">overlay</a> = NULL;
  1264. <a name="l01234"></a>01234 <span class="keywordflow">if</span> (<a class="code" href="classSendToKeyListener.html#a76dd14829ae2b15ccd4a710ab6329ff4">msg</a> != NULL) {
  1265. <a name="l01235"></a>01235 <span class="keyword">delete</span> <a class="code" href="classSendToKeyListener.html#a76dd14829ae2b15ccd4a710ab6329ff4">msg</a>;
  1266. <a name="l01236"></a>01236 <a class="code" href="classSendToKeyListener.html#a76dd14829ae2b15ccd4a710ab6329ff4">msg</a> = NULL;
  1267. <a name="l01237"></a>01237 }
  1268. <a name="l01238"></a>01238 }
  1269. <a name="l01239"></a>01239
  1270. <a name="l01240"></a><a class="code" href="classSendToKeyListener.html#ae21d1e104bd5a9d0bda09e659a2938db">01240</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classSendToKeyListener.html#ae21d1e104bd5a9d0bda09e659a2938db">lookupFinished</a>(<a class="code" href="classAbstractLookup.html" title="This class declares an abstract iterative lookup.">AbstractLookup</a> *lookup) {
  1271. <a name="l01241"></a>01241 <span class="keywordflow">if</span> (dynamic_cast&lt;BaseRouteMessage*&gt;(<a class="code" href="classSendToKeyListener.html#a76dd14829ae2b15ccd4a710ab6329ff4">msg</a>)) {
  1272. <a name="l01242"></a>01242 <a class="code" href="classBaseRouteMessage.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">BaseRouteMessage</a>* routeMsg = <span class="keyword">static_cast&lt;</span><a class="code" href="classBaseRouteMessage.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">BaseRouteMessage</a>*<span class="keyword">&gt;</span>(<a class="code" href="classSendToKeyListener.html#a76dd14829ae2b15ccd4a710ab6329ff4">msg</a>);
  1273. <a name="l01243"></a>01243 <span class="keywordflow">if</span> (lookup-&gt;<a class="code" href="classAbstractLookup.html#a698d5d467c714e4d114359d1078b505d" title="Returns true, if the lookup was successful.">isValid</a>()) {
  1274. <a name="l01244"></a>01244 <span class="keywordflow">if</span> (lookup-&gt;<a class="code" href="classAbstractLookup.html#a0ad852a71fdafed808e0ebb8dcd3723e" title="Returns the result of the lookup.">getResult</a>().size()==0) {
  1275. <a name="l01245"></a>01245 EV &lt;&lt; <span class="stringliteral">&quot;[SendToKeyListener::lookupFinished()]\n&quot;</span>
  1276. <a name="l01246"></a>01246 <span class="stringliteral">&quot; [ERROR] SendToKeyListener: Valid result, &quot;</span>
  1277. <a name="l01247"></a>01247 <span class="stringliteral">&quot;but empty array.&quot;</span> &lt;&lt; endl;
  1278. <a name="l01248"></a>01248 } <span class="keywordflow">else</span> {
  1279. <a name="l01249"></a>01249 routeMsg-&gt;<a class="code" href="classBaseRouteMessage.html#a1c843714ac5feca3c13f1e39b77e9b5c">setHopCount</a>(routeMsg-&gt;<a class="code" href="classBaseRouteMessage.html#ab59d2969c812aa35d132a68fc2baf819">getHopCount</a>()
  1280. <a name="l01250"></a>01250 + lookup-&gt;<a class="code" href="classAbstractLookup.html#adf3affffd7d97d965f984f54eb3de415" title="Returns the total number of hops for all lookup paths.">getAccumulatedHops</a>());
  1281. <a name="l01251"></a>01251
  1282. <a name="l01252"></a>01252 <span class="keywordflow">for</span> (uint32_t i=0; i&lt;lookup-&gt;<a class="code" href="classAbstractLookup.html#a0ad852a71fdafed808e0ebb8dcd3723e" title="Returns the result of the lookup.">getResult</a>().size(); i++) {
  1283. <a name="l01253"></a>01253 <a class="code" href="classSendToKeyListener.html#ac6a8b10c63a4595450377b9beaa00490">overlay</a>-&gt;<a class="code" href="classBaseOverlay.html#ac93829bc8095a76e6208cf0ec12188b0">sendRouteMessage</a>(lookup-&gt;<a class="code" href="classAbstractLookup.html#a0ad852a71fdafed808e0ebb8dcd3723e" title="Returns the result of the lookup.">getResult</a>()[i],
  1284. <a name="l01254"></a>01254 <span class="keyword">static_cast&lt;</span><a class="code" href="classBaseRouteMessage.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">BaseRouteMessage</a>*<span class="keyword">&gt;</span>
  1285. <a name="l01255"></a>01255 (routeMsg-&gt;<a class="code" href="classBaseRouteMessage.html#ad63dbffa8c4c6d79c6781ed06c691a49">dup</a>()),
  1286. <a name="l01256"></a>01256 <a class="code" href="classSendToKeyListener.html#ac6a8b10c63a4595450377b9beaa00490">overlay</a>-&gt;<a class="code" href="classBaseOverlay.html#a6e9090bf68f45a31d727a6c7f0501d43" title="send ACK when receiving route message">routeMsgAcks</a>);
  1287. <a name="l01257"></a>01257 }
  1288. <a name="l01258"></a>01258 }
  1289. <a name="l01259"></a>01259 } <span class="keywordflow">else</span> {
  1290. <a name="l01260"></a>01260 EV &lt;&lt; <span class="stringliteral">&quot;[SendToKeyListener::lookupFinished()]\n&quot;</span>
  1291. <a name="l01261"></a>01261 &lt;&lt; <span class="stringliteral">&quot; Lookup failed - dropping message&quot;</span>
  1292. <a name="l01262"></a>01262 &lt;&lt; endl;
  1293. <a name="l01263"></a>01263 <span class="comment">//std::cout &lt;&lt; simTime() &lt;&lt; &quot; &quot;</span>
  1294. <a name="l01264"></a>01264 <span class="comment">// &lt;&lt; routeMsg-&gt;getSrcNode()</span>
  1295. <a name="l01265"></a>01265 <span class="comment">// &lt;&lt; &quot; [SendToKeyListener::lookupFinished()]\n&quot;</span>
  1296. <a name="l01266"></a>01266 <span class="comment">// &lt;&lt; &quot; Lookup failed - dropping message&quot;</span>
  1297. <a name="l01267"></a>01267 <span class="comment">// &lt;&lt; std::endl;</span>
  1298. <a name="l01268"></a>01268 <a class="code" href="GlobalStatistics_8h.html#af29140ebe8e0a93406a58441f7c5fec8" title="Macro used for recording statistics considering measureNetwIn parameter.">RECORD_STATS</a>(<a class="code" href="classSendToKeyListener.html#ac6a8b10c63a4595450377b9beaa00490">overlay</a>-&gt;<a class="code" href="classBaseOverlay.html#a4a82bd4b76a8d06a1d63bba98f1a34d7" title="number of dropped packets">numDropped</a>++;
  1299. <a name="l01269"></a>01269 <a class="code" href="classSendToKeyListener.html#ac6a8b10c63a4595450377b9beaa00490">overlay</a>-&gt;<a class="code" href="classBaseOverlay.html#a9e09857b97f52d340e4710580f25f7a6" title="number of dropped bytes">bytesDropped</a> += routeMsg-&gt;getByteLength());
  1300. <a name="l01270"></a>01270 }
  1301. <a name="l01271"></a>01271 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (dynamic_cast&lt;LookupCall*&gt;(<a class="code" href="classSendToKeyListener.html#a76dd14829ae2b15ccd4a710ab6329ff4">msg</a>)) {
  1302. <a name="l01272"></a>01272 <a class="code" href="classLookupCall.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">LookupCall</a>* call = <span class="keyword">static_cast&lt;</span><a class="code" href="classLookupCall.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">LookupCall</a>*<span class="keyword">&gt;</span>(<a class="code" href="classSendToKeyListener.html#a76dd14829ae2b15ccd4a710ab6329ff4">msg</a>);
  1303. <a name="l01273"></a>01273 <a class="code" href="classLookupResponse.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">LookupResponse</a>* response = <span class="keyword">new</span> <a class="code" href="classLookupResponse.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">LookupResponse</a>();
  1304. <a name="l01274"></a>01274 response-&gt;<a class="code" href="classLookupResponse.html#a1caf06537b25c06685f0d24be5cd74fe">setKey</a>(call-&gt;<a class="code" href="classLookupCall.html#ac899d550007c1e632e299e917d38b705">getKey</a>());
  1305. <a name="l01275"></a>01275 response-&gt;<a class="code" href="classLookupResponse.html#a06ef22a95a92f70807bc68b86ddd2047">setHopCount</a>(lookup-&gt;<a class="code" href="classAbstractLookup.html#adf3affffd7d97d965f984f54eb3de415" title="Returns the total number of hops for all lookup paths.">getAccumulatedHops</a>());
  1306. <a name="l01276"></a>01276 <span class="keywordflow">if</span> (lookup-&gt;<a class="code" href="classAbstractLookup.html#a698d5d467c714e4d114359d1078b505d" title="Returns true, if the lookup was successful.">isValid</a>()) {
  1307. <a name="l01277"></a>01277 response-&gt;<a class="code" href="classLookupResponse.html#a6d307ceeb8f4325c3373c3464cff45be">setIsValid</a>(<span class="keyword">true</span>);
  1308. <a name="l01278"></a>01278 response-&gt;<a class="code" href="classLookupResponse.html#ab82d47b328532843aa1f5352be560578">setSiblingsArraySize</a>(lookup-&gt;<a class="code" href="classAbstractLookup.html#a0ad852a71fdafed808e0ebb8dcd3723e" title="Returns the result of the lookup.">getResult</a>().size());
  1309. <a name="l01279"></a>01279 <span class="keywordflow">for</span> (uint32_t i=0; i&lt;lookup-&gt;<a class="code" href="classAbstractLookup.html#a0ad852a71fdafed808e0ebb8dcd3723e" title="Returns the result of the lookup.">getResult</a>().size(); i++) {
  1310. <a name="l01280"></a>01280 response-&gt;<a class="code" href="classLookupResponse.html#af95b0fd01f50e42c30dfce876648f480">setSiblings</a>(i, lookup-&gt;<a class="code" href="classAbstractLookup.html#a0ad852a71fdafed808e0ebb8dcd3723e" title="Returns the result of the lookup.">getResult</a>()[i]);
  1311. <a name="l01281"></a>01281 }
  1312. <a name="l01282"></a>01282 <span class="keywordflow">if</span> (lookup-&gt;<a class="code" href="classAbstractLookup.html#a0ad852a71fdafed808e0ebb8dcd3723e" title="Returns the result of the lookup.">getResult</a>().size() == 0) {
  1313. <a name="l01283"></a>01283 EV &lt;&lt; <span class="stringliteral">&quot;[SendToKeyListener::lookupFinished() @ &quot;</span>
  1314. <a name="l01284"></a>01284 &lt;&lt; <a class="code" href="classSendToKeyListener.html#ac6a8b10c63a4595450377b9beaa00490">overlay</a>-&gt;<a class="code" href="classBaseRpc.html#a88eb68c06450fd12ea072f471bf1c1b8" title="NodeHandle to this node.">thisNode</a>.<a class="code" href="classTransportAddress.html#a00e613d98d3412e2b92897c25aa0eb4c" title="returns ip address">getIp</a>()
  1315. <a name="l01285"></a>01285 &lt;&lt; <span class="stringliteral">&quot; (&quot;</span> &lt;&lt; <a class="code" href="classSendToKeyListener.html#ac6a8b10c63a4595450377b9beaa00490">overlay</a>-&gt;<a class="code" href="classBaseRpc.html#a88eb68c06450fd12ea072f471bf1c1b8" title="NodeHandle to this node.">thisNode</a>.<a class="code" href="classNodeHandle.html#aef531103cdf07c8353267f4d30a80112" title="returns key of this NodeHandle">getKey</a>().<a class="code" href="classOverlayKey.html#aabeb4fd284a630a82e982ba34ece4fd9" title="Returns a string representation of this key.">toString</a>(16) &lt;&lt; <span class="stringliteral">&quot;)]\n&quot;</span>
  1316. <a name="l01286"></a>01286 &lt;&lt; <span class="stringliteral">&quot; LookupCall &quot;</span>
  1317. <a name="l01287"></a>01287 &lt;&lt; call-&gt;<a class="code" href="classBaseRpcMessage.html#a79f78c32aa4461025a89e8de3bc35702">getNonce</a>()
  1318. <a name="l01288"></a>01288 &lt;&lt; <span class="stringliteral">&quot; failed! (size=0)&quot;</span> &lt;&lt; endl;
  1319. <a name="l01289"></a>01289 }
  1320. <a name="l01290"></a>01290 } <span class="keywordflow">else</span> {
  1321. <a name="l01291"></a>01291 response-&gt;<a class="code" href="classLookupResponse.html#a6d307ceeb8f4325c3373c3464cff45be">setIsValid</a>(<span class="keyword">false</span>);
  1322. <a name="l01292"></a>01292 EV &lt;&lt; <span class="stringliteral">&quot;[SendToKeyListener::lookupFinished() @ &quot;</span>
  1323. <a name="l01293"></a>01293 &lt;&lt; <a class="code" href="classSendToKeyListener.html#ac6a8b10c63a4595450377b9beaa00490">overlay</a>-&gt;<a class="code" href="classBaseRpc.html#a88eb68c06450fd12ea072f471bf1c1b8" title="NodeHandle to this node.">thisNode</a>.<a class="code" href="classTransportAddress.html#a00e613d98d3412e2b92897c25aa0eb4c" title="returns ip address">getIp</a>()
  1324. <a name="l01294"></a>01294 &lt;&lt; <span class="stringliteral">&quot; (&quot;</span> &lt;&lt; <a class="code" href="classSendToKeyListener.html#ac6a8b10c63a4595450377b9beaa00490">overlay</a>-&gt;<a class="code" href="classBaseRpc.html#a88eb68c06450fd12ea072f471bf1c1b8" title="NodeHandle to this node.">thisNode</a>.<a class="code" href="classNodeHandle.html#aef531103cdf07c8353267f4d30a80112" title="returns key of this NodeHandle">getKey</a>().<a class="code" href="classOverlayKey.html#aabeb4fd284a630a82e982ba34ece4fd9" title="Returns a string representation of this key.">toString</a>(16) &lt;&lt; <span class="stringliteral">&quot;)]\n&quot;</span>
  1325. <a name="l01295"></a>01295 &lt;&lt; <span class="stringliteral">&quot; LookupCall &quot;</span>
  1326. <a name="l01296"></a>01296 &lt;&lt; call-&gt;<a class="code" href="classBaseRpcMessage.html#a79f78c32aa4461025a89e8de3bc35702">getNonce</a>()
  1327. <a name="l01297"></a>01297 &lt;&lt; <span class="stringliteral">&quot; failed!&quot;</span> &lt;&lt; endl;
  1328. <a name="l01298"></a>01298 }
  1329. <a name="l01299"></a>01299 <a class="code" href="classSendToKeyListener.html#ac6a8b10c63a4595450377b9beaa00490">overlay</a>-&gt;<a class="code" href="classBaseRpc.html#adc06091d348c98a5efbf54fe0afe8747" title="Send Remote-Procedure response message and deletes call message.">sendRpcResponse</a>(call, response);
  1330. <a name="l01300"></a>01300 <a class="code" href="classSendToKeyListener.html#a76dd14829ae2b15ccd4a710ab6329ff4">msg</a> = NULL;
  1331. <a name="l01301"></a>01301 } <span class="keywordflow">else</span> {
  1332. <a name="l01302"></a>01302 <span class="keywordflow">throw</span> cRuntimeError(<span class="stringliteral">&quot;SendToKeyListener::lookupFinished(): &quot;</span>
  1333. <a name="l01303"></a>01303 <span class="stringliteral">&quot;Unknown message type!&quot;</span>);
  1334. <a name="l01304"></a>01304 }
  1335. <a name="l01305"></a>01305 <span class="keyword">delete</span> <span class="keyword">this</span>;
  1336. <a name="l01306"></a>01306 }
  1337. <a name="l01307"></a>01307 };
  1338. <a name="l01308"></a>01308
  1339. <a name="l01309"></a><a class="code" href="classBaseOverlay.html#ad62efdef2b674f46e5368354efb6104f">01309</a> <span class="keywordtype">void</span> <a class="code" href="classBaseOverlay.html#ad62efdef2b674f46e5368354efb6104f" title="Routes message through overlay.">BaseOverlay::route</a>(<span class="keyword">const</span> <a class="code" href="classOverlayKey.html" title="A common overlay key class.">OverlayKey</a>&amp; key, <a class="code" href="CommonMessages__m_8h.html#aad57ef0110fe8675eb299d467148bc5e" title="Enum generated from common/CommonMessages.msg by opp_msgc.">CompType</a> destComp,
  1340. <a name="l01310"></a>01310 <a class="code" href="CommonMessages__m_8h.html#aad57ef0110fe8675eb299d467148bc5e" title="Enum generated from common/CommonMessages.msg by opp_msgc.">CompType</a> srcComp, cPacket* msg,
  1341. <a name="l01311"></a>01311 <span class="keyword">const</span> std::vector&lt;TransportAddress&gt;&amp; sourceRoute,
  1342. <a name="l01312"></a>01312 <a class="code" href="CommonMessages__m_8h.html#a5bbe67ba1134d38bbb89c7c242ba6551" title="Enum generated from common/CommonMessages.msg by opp_msgc.">RoutingType</a> routingType)
  1343. <a name="l01313"></a>01313 {
  1344. <a name="l01314"></a>01314 <span class="keywordflow">if</span> (key.<a class="code" href="classOverlayKey.html#abe357a4d1babcf7d30598a61cbc0f5c2" title="Returns true, if the key is unspecified.">isUnspecified</a>() &amp;&amp;
  1345. <a name="l01315"></a>01315 (!sourceRoute.size() || sourceRoute[0].isUnspecified()))
  1346. <a name="l01316"></a>01316 <span class="keywordflow">throw</span> cRuntimeError(<span class="stringliteral">&quot;route(): Key and hint unspecified!&quot;</span>);
  1347. <a name="l01317"></a>01317
  1348. <a name="l01318"></a>01318 <span class="comment">// encapsulate in a app data message for multiplexing</span>
  1349. <a name="l01319"></a>01319 <span class="comment">// to destination component</span>
  1350. <a name="l01320"></a>01320 <a class="code" href="classBaseAppDataMessage.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">BaseAppDataMessage</a>* baseAppDataMsg =
  1351. <a name="l01321"></a>01321 <span class="keyword">new</span> <a class="code" href="classBaseAppDataMessage.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">BaseAppDataMessage</a>(<span class="stringliteral">&quot;BaseAppDataMessage&quot;</span>);
  1352. <a name="l01322"></a>01322 baseAppDataMsg-&gt;<a class="code" href="classBaseOverlayMessage.html#a1441ce272062923bae9d821ac35ed7cf">setType</a>(<a class="code" href="CommonMessages__m_8h.html#a6af1a552a7a6bce33c291758c369b17eab0641a3f5bcb1e08ee72afe9583ff5e6">APPDATA</a>);
  1353. <a name="l01323"></a>01323 baseAppDataMsg-&gt;<a class="code" href="classBaseAppDataMessage.html#aaac3c10c2cdef1373c06dc16a28cbcda">setDestComp</a>(destComp);
  1354. <a name="l01324"></a>01324 baseAppDataMsg-&gt;<a class="code" href="classBaseAppDataMessage.html#a39b6e418a8897f4c1ec6adb756deea5f">setSrcComp</a>(srcComp);
  1355. <a name="l01325"></a>01325 baseAppDataMsg-&gt;setBitLength(<a class="code" href="CommonMessages__m_8h.html#aebae47ba62d6bd9fe00ca6d779bf0e81">BASEAPPDATA_L</a>(baseAppDataMsg));
  1356. <a name="l01326"></a>01326 baseAppDataMsg-&gt;setName(msg-&gt;getName());
  1357. <a name="l01327"></a>01327
  1358. <a name="l01328"></a>01328 baseAppDataMsg-&gt;<a class="code" href="classBaseOverlayMessage.html#a46fd21016c6fad4f167d5510f0481f49">setStatType</a>(<a class="code" href="CommonMessages__m_8h.html#a25418fa818fbb01cd8c0b2c4b0732cdfad8d082af8526e80f7de088c52ad1b7c0">APP_DATA_STAT</a>);
  1359. <a name="l01329"></a>01329 baseAppDataMsg-&gt;encapsulate(msg);
  1360. <a name="l01330"></a>01330
  1361. <a name="l01331"></a>01331 <span class="comment">// debug output</span>
  1362. <a name="l01332"></a>01332 <span class="keywordflow">if</span> (<a class="code" href="classBaseOverlay.html#a49ff0fb8c25792a1339d54a60c36f2cd" title="debug output ?">debugOutput</a>) {
  1363. <a name="l01333"></a>01333 EV &lt;&lt; <span class="stringliteral">&quot;[BaseOverlay::route() @ &quot;</span> &lt;&lt; <a class="code" href="classBaseRpc.html#a88eb68c06450fd12ea072f471bf1c1b8" title="NodeHandle to this node.">thisNode</a>.<a class="code" href="classTransportAddress.html#a00e613d98d3412e2b92897c25aa0eb4c" title="returns ip address">getIp</a>()
  1364. <a name="l01334"></a>01334 &lt;&lt; <span class="stringliteral">&quot; (&quot;</span> &lt;&lt; <a class="code" href="classBaseRpc.html#a88eb68c06450fd12ea072f471bf1c1b8" title="NodeHandle to this node.">thisNode</a>.<a class="code" href="classNodeHandle.html#aef531103cdf07c8353267f4d30a80112" title="returns key of this NodeHandle">getKey</a>().<a class="code" href="classOverlayKey.html#aabeb4fd284a630a82e982ba34ece4fd9" title="Returns a string representation of this key.">toString</a>(16) &lt;&lt; <span class="stringliteral">&quot;)]\n&quot;</span>
  1365. <a name="l01335"></a>01335 &lt;&lt; <span class="stringliteral">&quot; Received message from application&quot;</span>
  1366. <a name="l01336"></a>01336 &lt;&lt; endl;
  1367. <a name="l01337"></a>01337 }
  1368. <a name="l01338"></a>01338
  1369. <a name="l01339"></a>01339 <span class="keywordflow">if</span> (key.<a class="code" href="classOverlayKey.html#abe357a4d1babcf7d30598a61cbc0f5c2" title="Returns true, if the key is unspecified.">isUnspecified</a>() &amp;&amp; sourceRoute.size() &lt;= 1) {
  1370. <a name="l01340"></a>01340 <a class="code" href="classBaseOverlay.html#a124850e5bc8d81b3eb4f3aec75868449" title="Sends message to underlay.">sendMessageToUDP</a>(sourceRoute[0], baseAppDataMsg);
  1371. <a name="l01341"></a>01341 } <span class="keywordflow">else</span> {
  1372. <a name="l01342"></a>01342 <span class="keywordflow">if</span> (<a class="code" href="classBaseOverlay.html#aa484556ed4ff9e4e97394106d0c1d323" title="internal overlay state used for setOverlayReady()">internalReadyState</a> == <span class="keyword">false</span>) {
  1373. <a name="l01343"></a>01343 <span class="comment">// overlay not ready =&gt; sendToKey doesn&#39;t work yet</span>
  1374. <a name="l01344"></a>01344 EV &lt;&lt; <span class="stringliteral">&quot;[BaseOverlay::route() @ &quot;</span>
  1375. <a name="l01345"></a>01345 &lt;&lt; <a class="code" href="classBaseRpc.html#ac3f420630d5618e81709c078b06fd9da" title="Returns the NodeHandle of this node.">getThisNode</a>().<a class="code" href="classTransportAddress.html#a00e613d98d3412e2b92897c25aa0eb4c" title="returns ip address">getIp</a>()
  1376. <a name="l01346"></a>01346 &lt;&lt; <span class="stringliteral">&quot; (&quot;</span> &lt;&lt; <a class="code" href="classBaseRpc.html#ac3f420630d5618e81709c078b06fd9da" title="Returns the NodeHandle of this node.">getThisNode</a>().<a class="code" href="classNodeHandle.html#aef531103cdf07c8353267f4d30a80112" title="returns key of this NodeHandle">getKey</a>().<a class="code" href="classOverlayKey.html#aabeb4fd284a630a82e982ba34ece4fd9" title="Returns a string representation of this key.">toString</a>(16) &lt;&lt; <span class="stringliteral">&quot;)]\n&quot;</span>
  1377. <a name="l01347"></a>01347 &lt;&lt; <span class="stringliteral">&quot; Couldn&#39;t route application message to key &quot;</span>
  1378. <a name="l01348"></a>01348 &lt;&lt; key.<a class="code" href="classOverlayKey.html#aabeb4fd284a630a82e982ba34ece4fd9" title="Returns a string representation of this key.">toString</a>(16)
  1379. <a name="l01349"></a>01349 &lt;&lt; <span class="stringliteral">&quot; because the overlay module is not ready!&quot;</span> &lt;&lt; endl;
  1380. <a name="l01350"></a>01350 <a class="code" href="GlobalStatistics_8h.html#af29140ebe8e0a93406a58441f7c5fec8" title="Macro used for recording statistics considering measureNetwIn parameter.">RECORD_STATS</a>(<a class="code" href="classBaseOverlay.html#a4a82bd4b76a8d06a1d63bba98f1a34d7" title="number of dropped packets">numDropped</a>++;
  1381. <a name="l01351"></a>01351 <a class="code" href="classBaseOverlay.html#a9e09857b97f52d340e4710580f25f7a6" title="number of dropped bytes">bytesDropped</a> += baseAppDataMsg-&gt;getByteLength());
  1382. <a name="l01352"></a>01352 <span class="keyword">delete</span> baseAppDataMsg;
  1383. <a name="l01353"></a>01353 <span class="keywordflow">return</span>;
  1384. <a name="l01354"></a>01354 }
  1385. <a name="l01355"></a>01355
  1386. <a name="l01356"></a>01356 <a class="code" href="classBaseOverlay.html#a6f2c598f5d3989a63a8cc7220f1aaf76" title="Sends a message to an overlay node, with the generic routing algorithm.">sendToKey</a>(key, baseAppDataMsg, 1, sourceRoute, routingType);
  1387. <a name="l01357"></a>01357 }
  1388. <a name="l01358"></a>01358 }
  1389. <a name="l01359"></a>01359
  1390. <a name="l01360"></a><a class="code" href="classBaseOverlay.html#a42f4c08f6408d155a9907957ecf12d79">01360</a> <span class="keywordtype">bool</span> <a class="code" href="classBaseOverlay.html#a42f4c08f6408d155a9907957ecf12d79" title="Hook for forwarded message in recursive lookup mode.">BaseOverlay::recursiveRoutingHook</a>(<span class="keyword">const</span> <a class="code" href="classTransportAddress.html" title="This class implements a common transport address.">TransportAddress</a>&amp; dest,
  1391. <a name="l01361"></a>01361 <a class="code" href="classBaseRouteMessage.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">BaseRouteMessage</a>* msg)
  1392. <a name="l01362"></a>01362 {
  1393. <a name="l01363"></a>01363 <span class="keywordflow">return</span> <span class="keyword">true</span>;
  1394. <a name="l01364"></a>01364 }
  1395. <a name="l01365"></a>01365
  1396. <a name="l01366"></a><a class="code" href="classBaseOverlay.html#a6f2c598f5d3989a63a8cc7220f1aaf76">01366</a> <span class="keywordtype">void</span> <a class="code" href="classBaseOverlay.html#a6f2c598f5d3989a63a8cc7220f1aaf76" title="Sends a message to an overlay node, with the generic routing algorithm.">BaseOverlay::sendToKey</a>(<span class="keyword">const</span> <a class="code" href="classOverlayKey.html" title="A common overlay key class.">OverlayKey</a>&amp; key, <a class="code" href="classBaseOverlayMessage.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">BaseOverlayMessage</a>* msg,
  1397. <a name="l01367"></a>01367 <span class="keywordtype">int</span> numSiblings,
  1398. <a name="l01368"></a>01368 <span class="keyword">const</span> std::vector&lt;TransportAddress&gt;&amp; sourceRoute,
  1399. <a name="l01369"></a>01369 <a class="code" href="CommonMessages__m_8h.html#a5bbe67ba1134d38bbb89c7c242ba6551" title="Enum generated from common/CommonMessages.msg by opp_msgc.">RoutingType</a> routingType)
  1400. <a name="l01370"></a>01370 {
  1401. <a name="l01371"></a>01371 <a class="code" href="classBaseRouteMessage.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">BaseRouteMessage</a>* routeMsg = NULL;
  1402. <a name="l01372"></a>01372
  1403. <a name="l01373"></a>01373 <span class="keywordflow">if</span> (routingType == <a class="code" href="CommonMessages__m_8h.html#a5bbe67ba1134d38bbb89c7c242ba6551a931137cd67090e50ef2ea3ccfb9e8d90">DEFAULT_ROUTING</a>) routingType = <a class="code" href="classBaseOverlay.html#a9e13844ea8090b84a90286f048cdcbf9">defaultRoutingType</a>;
  1404. <a name="l01374"></a>01374
  1405. <a name="l01375"></a>01375 <span class="keywordflow">if</span> (<a class="code" href="classBaseOverlay.html#a49ff0fb8c25792a1339d54a60c36f2cd" title="debug output ?">debugOutput</a>) {
  1406. <a name="l01376"></a>01376 EV &lt;&lt; <span class="stringliteral">&quot;[BaseOverlay::sendToKey() @ &quot;</span> &lt;&lt; <a class="code" href="classBaseRpc.html#a88eb68c06450fd12ea072f471bf1c1b8" title="NodeHandle to this node.">thisNode</a>.<a class="code" href="classTransportAddress.html#a00e613d98d3412e2b92897c25aa0eb4c" title="returns ip address">getIp</a>()
  1407. <a name="l01377"></a>01377 &lt;&lt; <span class="stringliteral">&quot; (&quot;</span> &lt;&lt; <a class="code" href="classBaseRpc.html#a88eb68c06450fd12ea072f471bf1c1b8" title="NodeHandle to this node.">thisNode</a>.<a class="code" href="classNodeHandle.html#aef531103cdf07c8353267f4d30a80112" title="returns key of this NodeHandle">getKey</a>().<a class="code" href="classOverlayKey.html#aabeb4fd284a630a82e982ba34ece4fd9" title="Returns a string representation of this key.">toString</a>(16) &lt;&lt; <span class="stringliteral">&quot;)]\n&quot;</span>
  1408. <a name="l01378"></a>01378 &lt;&lt; <span class="stringliteral">&quot; Sending &quot;</span> &lt;&lt; msg &lt;&lt; <span class="stringliteral">&quot; to &quot;</span> &lt;&lt; key
  1409. <a name="l01379"></a>01379 &lt;&lt; endl;
  1410. <a name="l01380"></a>01380 }
  1411. <a name="l01381"></a>01381
  1412. <a name="l01382"></a>01382 <span class="keywordflow">if</span> (key.<a class="code" href="classOverlayKey.html#abe357a4d1babcf7d30598a61cbc0f5c2" title="Returns true, if the key is unspecified.">isUnspecified</a>() &amp;&amp;
  1413. <a name="l01383"></a>01383 !(sourceRoute.size() &amp;&amp; !sourceRoute[0].isUnspecified()))
  1414. <a name="l01384"></a>01384 <span class="keywordflow">throw</span> cRuntimeError(<span class="stringliteral">&quot;BaseOverlay::sendToKey(): &quot;</span>
  1415. <a name="l01385"></a>01385 <span class="stringliteral">&quot;unspecified destination address and key!&quot;</span>);
  1416. <a name="l01386"></a>01386
  1417. <a name="l01387"></a>01387 <span class="keywordflow">if</span> (msg-&gt;<a class="code" href="classBaseOverlayMessage.html#a406e342c0841abe2d82b9bb5c1e2aabd">getType</a>() != OVERLAYROUTE) {
  1418. <a name="l01388"></a>01388 assert(!msg-&gt;getControlInfo());
  1419. <a name="l01389"></a>01389 routeMsg = <span class="keyword">new</span> <a class="code" href="classBaseRouteMessage.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">BaseRouteMessage</a>(<span class="stringliteral">&quot;BaseRouteMessage&quot;</span>);
  1420. <a name="l01390"></a>01390 routeMsg-&gt;setType(<a class="code" href="CommonMessages__m_8h.html#a6af1a552a7a6bce33c291758c369b17ea9fb39f8e1c5f2ff00e45bb7294e5524f">OVERLAYROUTE</a>);
  1421. <a name="l01391"></a>01391 routeMsg-&gt;setRoutingType(routingType);
  1422. <a name="l01392"></a>01392 routeMsg-&gt;setDestKey(key);
  1423. <a name="l01393"></a>01393 routeMsg-&gt;setSrcNode(<a class="code" href="classBaseRpc.html#a88eb68c06450fd12ea072f471bf1c1b8" title="NodeHandle to this node.">thisNode</a>);
  1424. <a name="l01394"></a>01394 routeMsg-&gt;setStatType(msg-&gt;<a class="code" href="classBaseOverlayMessage.html#af0a4bf31778e05a809f8d55dff5bfcc1">getStatType</a>());
  1425. <a name="l01395"></a>01395 <span class="comment">// copy the name of the inner message</span>
  1426. <a name="l01396"></a>01396 routeMsg-&gt;setName(msg-&gt;getName());
  1427. <a name="l01397"></a>01397 routeMsg-&gt;setBitLength(<a class="code" href="CommonMessages__m_8h.html#aa51e9b4f9362c33b9a432fd496bc31d0">BASEROUTE_L</a>(routeMsg));
  1428. <a name="l01398"></a>01398 routeMsg-&gt;encapsulate(msg);
  1429. <a name="l01399"></a>01399
  1430. <a name="l01400"></a>01400 <a class="code" href="classOverlayCtrlInfo.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">OverlayCtrlInfo</a>* routeCtrlInfo = <span class="keyword">new</span> <a class="code" href="classOverlayCtrlInfo.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">OverlayCtrlInfo</a>;
  1431. <a name="l01401"></a>01401 routeCtrlInfo-&gt;<a class="code" href="classOverlayCtrlInfo.html#a6c2c1955d30ba60f696247685dc3d6ae">setLastHop</a>(<a class="code" href="classBaseRpc.html#a88eb68c06450fd12ea072f471bf1c1b8" title="NodeHandle to this node.">thisNode</a>);
  1432. <a name="l01402"></a>01402 routeCtrlInfo-&gt;<a class="code" href="classOverlayCtrlInfo.html#a129cf7292587fa2ee6e4e6238c5e4d33">setTransportType</a>(<a class="code" href="CommonMessages__m_8h.html#aca1e72535e7f260e54ed8bbf984dade9a03dcc78e081682d383ff0baec54dcf8c">ROUTE_TRANSPORT</a>);
  1433. <a name="l01403"></a>01403 routeCtrlInfo-&gt;<a class="code" href="classOverlayCtrlInfo.html#a2e3bd66c1e71acd70a6d87817efe15db">setRoutingType</a>(routingType);
  1434. <a name="l01404"></a>01404 routeMsg-&gt;setControlInfo(routeCtrlInfo);
  1435. <a name="l01405"></a>01405
  1436. <a name="l01406"></a>01406 <span class="comment">//message marked as not already forwarded to tier1</span>
  1437. <a name="l01407"></a>01407 routeMsg-&gt;setContextPointer(NULL);
  1438. <a name="l01408"></a>01408 } <span class="keywordflow">else</span> {
  1439. <a name="l01409"></a>01409 routeMsg = check_and_cast&lt;<a class="code" href="classBaseRouteMessage.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">BaseRouteMessage</a>*&gt;(msg);
  1440. <a name="l01410"></a>01410 routingType = <span class="keyword">static_cast&lt;</span><a class="code" href="CommonMessages__m_8h.html#a5bbe67ba1134d38bbb89c7c242ba6551" title="Enum generated from common/CommonMessages.msg by opp_msgc.">RoutingType</a><span class="keyword">&gt;</span>(routeMsg-&gt;<a class="code" href="classBaseRouteMessage.html#a834dd9c8f0b2b776ed5f5b1fa285149a">getRoutingType</a>());
  1441. <a name="l01411"></a>01411 }
  1442. <a name="l01412"></a>01412
  1443. <a name="l01413"></a>01413 <span class="comment">// set timestamp for next hop</span>
  1444. <a name="l01414"></a>01414 <span class="keywordflow">if</span> (<a class="code" href="classBaseOverlay.html#a2694627a0082c456367bfa472fff56b9" title="collect delay for single hops">collectPerHopDelay</a>) {
  1445. <a name="l01415"></a>01415 routeMsg-&gt;<a class="code" href="classBaseRouteMessage.html#a585ddc2330c8ef88a104c527f7929684">setHopStamp</a>(simTime());
  1446. <a name="l01416"></a>01416 }
  1447. <a name="l01417"></a>01417
  1448. <a name="l01418"></a>01418 <span class="keywordflow">if</span> (sourceRoute.size() &amp;&amp; !sourceRoute[0].isUnspecified()) {
  1449. <a name="l01419"></a>01419 <span class="comment">// send msg to nextHop if specified (used for e.g. join rpcs)</span>
  1450. <a name="l01420"></a>01420 <a class="code" href="classOverlayCtrlInfo.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">OverlayCtrlInfo</a>* ctrlInfo = check_and_cast&lt;<a class="code" href="classOverlayCtrlInfo.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">OverlayCtrlInfo</a>*&gt;
  1451. <a name="l01421"></a>01421 (routeMsg-&gt;getControlInfo());
  1452. <a name="l01422"></a>01422 ctrlInfo-&gt;<a class="code" href="classOverlayCtrlInfo.html#a129cf7292587fa2ee6e4e6238c5e4d33">setTransportType</a>(<a class="code" href="CommonMessages__m_8h.html#aca1e72535e7f260e54ed8bbf984dade9a01580b2e886cd821bd7f3f2bcd7c690c">UDP_TRANSPORT</a>);
  1453. <a name="l01423"></a>01423 assert(routeMsg-&gt;<a class="code" href="classBaseRouteMessage.html#a4037dda18976c8d98ef3f9ed663f8dc7">getNextHopsArraySize</a>() == 0);
  1454. <a name="l01424"></a>01424 routeMsg-&gt;<a class="code" href="classBaseRouteMessage.html#a3cb14c09b287d613f26d58ad39fec4d0">setNextHopsArraySize</a>(sourceRoute.size());
  1455. <a name="l01425"></a>01425 <span class="keywordflow">for</span> (uint32_t i = 0; i &lt; sourceRoute.size(); ++i)
  1456. <a name="l01426"></a>01426 routeMsg-&gt;<a class="code" href="classBaseRouteMessage.html#a85bb1a80fafad5e8a84b1bf96eb8befc">setNextHops</a>(i, sourceRoute[i]);
  1457. <a name="l01427"></a>01427 <span class="keywordflow">if</span> (<a class="code" href="classBaseOverlay.html#a42f4c08f6408d155a9907957ecf12d79" title="Hook for forwarded message in recursive lookup mode.">recursiveRoutingHook</a>(sourceRoute[0], routeMsg)) { <span class="comment">//test</span>
  1458. <a name="l01428"></a>01428 <a class="code" href="classBaseOverlay.html#ac93829bc8095a76e6208cf0ec12188b0">sendRouteMessage</a>(sourceRoute[0], routeMsg, <a class="code" href="classBaseOverlay.html#a6e9090bf68f45a31d727a6c7f0501d43" title="send ACK when receiving route message">routeMsgAcks</a>);
  1459. <a name="l01429"></a>01429 }
  1460. <a name="l01430"></a>01430 <span class="keywordflow">return</span>;
  1461. <a name="l01431"></a>01431 }
  1462. <a name="l01432"></a>01432
  1463. <a name="l01433"></a>01433 <span class="keywordflow">if</span> ((routingType == <a class="code" href="CommonMessages__m_8h.html#a5bbe67ba1134d38bbb89c7c242ba6551ae4bd936cbb47803986c83242cbb51867">ITERATIVE_ROUTING</a>)
  1464. <a name="l01434"></a>01434 || (routingType == <a class="code" href="CommonMessages__m_8h.html#a5bbe67ba1134d38bbb89c7c242ba6551ad60cf756d6bb24af372d7fe7c279f44d">EXHAUSTIVE_ITERATIVE_ROUTING</a>)
  1465. <a name="l01435"></a>01435 ) {
  1466. <a name="l01436"></a>01436
  1467. <a name="l01437"></a>01437 <span class="comment">// create lookup and sent to key</span>
  1468. <a name="l01438"></a>01438 <a class="code" href="classAbstractLookup.html" title="This class declares an abstract iterative lookup.">AbstractLookup</a>* lookup = <a class="code" href="classBaseOverlay.html#a205a7d44401fb3d77b146e23b2904b6f" title="Creates an abstract iterative lookup instance.">createLookup</a>(routingType, routeMsg, NULL,
  1469. <a name="l01439"></a>01439 (routeMsg-&gt;<a class="code" href="classBaseOverlayMessage.html#af0a4bf31778e05a809f8d55dff5bfcc1">getStatType</a>() == APP_DATA_STAT));
  1470. <a name="l01440"></a>01440 lookup-&gt;<a class="code" href="classAbstractLookup.html#aa1bda70950cbd160ea78d1fcbd8c7767" title="Lookup siblings for a key.">lookup</a>(routeMsg-&gt;<a class="code" href="classBaseRouteMessage.html#ad983641a05758bc9d25070f1659b2f34">getDestKey</a>(), numSiblings, <a class="code" href="classBaseOverlay.html#abffe6fbd25963bc2b7542f22ba6455b9" title="maximum hop count">hopCountMax</a>,
  1471. <a name="l01441"></a>01441 0, <span class="keyword">new</span> <a class="code" href="classBaseOverlay.html#a4083c91b7d09ceaa7fd2768570814d77">SendToKeyListener</a>(<span class="keyword">this</span>, routeMsg));
  1472. <a name="l01442"></a>01442 } <span class="keywordflow">else</span> {
  1473. <a name="l01443"></a>01443 <span class="comment">// recursive routing</span>
  1474. <a name="l01444"></a>01444 <a class="code" href="classBaseKeySortedVector.html">NodeVector</a>* nextHops = <a class="code" href="classBaseOverlay.html#a7cbdce336237331b67a3c69c4e43d489" title="Implements the find node call.">findNode</a>(routeMsg-&gt;<a class="code" href="classBaseRouteMessage.html#ad983641a05758bc9d25070f1659b2f34">getDestKey</a>(),
  1475. <a name="l01445"></a>01445 <a class="code" href="classBaseOverlay.html#ad0094285f9af244aec5e5fe600126243" title="numRedundantNodes for recursive routing">recNumRedundantNodes</a>,
  1476. <a name="l01446"></a>01446 numSiblings, routeMsg);
  1477. <a name="l01447"></a>01447
  1478. <a name="l01448"></a>01448 <span class="keywordflow">if</span> (nextHops-&gt;size() == 0) {
  1479. <a name="l01449"></a>01449 EV &lt;&lt; <span class="stringliteral">&quot;[BaseOverlay::sendToKey() @ &quot;</span> &lt;&lt; <a class="code" href="classBaseRpc.html#a88eb68c06450fd12ea072f471bf1c1b8" title="NodeHandle to this node.">thisNode</a>.<a class="code" href="classTransportAddress.html#a00e613d98d3412e2b92897c25aa0eb4c" title="returns ip address">getIp</a>()
  1480. <a name="l01450"></a>01450 &lt;&lt; <span class="stringliteral">&quot; (&quot;</span> &lt;&lt; <a class="code" href="classBaseRpc.html#a88eb68c06450fd12ea072f471bf1c1b8" title="NodeHandle to this node.">thisNode</a>.<a class="code" href="classNodeHandle.html#aef531103cdf07c8353267f4d30a80112" title="returns key of this NodeHandle">getKey</a>().<a class="code" href="classOverlayKey.html#aabeb4fd284a630a82e982ba34ece4fd9" title="Returns a string representation of this key.">toString</a>(16) &lt;&lt; <span class="stringliteral">&quot;)]\n&quot;</span>
  1481. <a name="l01451"></a>01451 &lt;&lt; <span class="stringliteral">&quot; FindNode() returned NULL - dropping message&quot;</span>
  1482. <a name="l01452"></a>01452 &lt;&lt; endl;
  1483. <a name="l01453"></a>01453 <span class="comment">//std::cout &lt;&lt; simTime() &lt;&lt; &quot; &quot; &lt;&lt; thisNode.getIp() &lt;&lt; &quot; &quot; &lt;&lt; state</span>
  1484. <a name="l01454"></a>01454 <span class="comment">// &lt;&lt; &quot; FindNode() returned NULL - dropping message &quot;</span>
  1485. <a name="l01455"></a>01455 <span class="comment">// &lt;&lt; routeMsg-&gt;getName() &lt;&lt; &quot; from &quot;</span>
  1486. <a name="l01456"></a>01456 <span class="comment">// &lt;&lt; routeMsg-&gt;getSrcNode() &lt;&lt; std::endl;</span>
  1487. <a name="l01457"></a>01457
  1488. <a name="l01458"></a>01458 <span class="comment">// statistics</span>
  1489. <a name="l01459"></a>01459 <a class="code" href="GlobalStatistics_8h.html#af29140ebe8e0a93406a58441f7c5fec8" title="Macro used for recording statistics considering measureNetwIn parameter.">RECORD_STATS</a>(<a class="code" href="classBaseOverlay.html#a4a82bd4b76a8d06a1d63bba98f1a34d7" title="number of dropped packets">numDropped</a>++; <a class="code" href="classBaseOverlay.html#a9e09857b97f52d340e4710580f25f7a6" title="number of dropped bytes">bytesDropped</a> += routeMsg-&gt;getByteLength());
  1490. <a name="l01460"></a>01460 <span class="keyword">delete</span> routeMsg;
  1491. <a name="l01461"></a>01461 } <span class="keywordflow">else</span> {
  1492. <a name="l01462"></a>01462 <span class="comment">// delete message if the hop count maximum is exceeded</span>
  1493. <a name="l01463"></a>01463 <span class="keywordflow">if</span> (routeMsg-&gt;<a class="code" href="classBaseRouteMessage.html#ab59d2969c812aa35d132a68fc2baf819">getHopCount</a>() &gt;= <a class="code" href="classBaseOverlay.html#abffe6fbd25963bc2b7542f22ba6455b9" title="maximum hop count">hopCountMax</a>) {
  1494. <a name="l01464"></a>01464
  1495. <a name="l01465"></a>01465 EV &lt;&lt; <span class="stringliteral">&quot;[BaseOverlay::sendToKey() @ &quot;</span> &lt;&lt; <a class="code" href="classBaseRpc.html#a88eb68c06450fd12ea072f471bf1c1b8" title="NodeHandle to this node.">thisNode</a>.<a class="code" href="classTransportAddress.html#a00e613d98d3412e2b92897c25aa0eb4c" title="returns ip address">getIp</a>()
  1496. <a name="l01466"></a>01466 &lt;&lt; <span class="stringliteral">&quot; (&quot;</span> &lt;&lt; <a class="code" href="classBaseRpc.html#a88eb68c06450fd12ea072f471bf1c1b8" title="NodeHandle to this node.">thisNode</a>.<a class="code" href="classNodeHandle.html#aef531103cdf07c8353267f4d30a80112" title="returns key of this NodeHandle">getKey</a>().<a class="code" href="classOverlayKey.html#aabeb4fd284a630a82e982ba34ece4fd9" title="Returns a string representation of this key.">toString</a>(16) &lt;&lt; <span class="stringliteral">&quot;)]\n&quot;</span>
  1497. <a name="l01467"></a>01467 &lt;&lt; <span class="stringliteral">&quot; Discards &quot;</span> &lt;&lt; routeMsg-&gt;getName() &lt;&lt; <span class="stringliteral">&quot; from &quot;</span>
  1498. <a name="l01468"></a>01468 &lt;&lt; routeMsg-&gt;<a class="code" href="classBaseRouteMessage.html#af9787d89915f01a2055e920148015e17">getSrcNode</a>().<a class="code" href="classTransportAddress.html#a00e613d98d3412e2b92897c25aa0eb4c" title="returns ip address">getIp</a>() &lt;&lt; <span class="stringliteral">&quot;\n&quot;</span>
  1499. <a name="l01469"></a>01469 &lt;&lt; <span class="stringliteral">&quot; The hop count maximum has been exceeded (&quot;</span>
  1500. <a name="l01470"></a>01470 &lt;&lt; routeMsg-&gt;<a class="code" href="classBaseRouteMessage.html#ab59d2969c812aa35d132a68fc2baf819">getHopCount</a>() &lt;&lt; <span class="stringliteral">&quot;&gt;=&quot;</span>
  1501. <a name="l01471"></a>01471 &lt;&lt; <a class="code" href="classBaseOverlay.html#abffe6fbd25963bc2b7542f22ba6455b9" title="maximum hop count">hopCountMax</a> &lt;&lt; <span class="stringliteral">&quot;)&quot;</span>
  1502. <a name="l01472"></a>01472 &lt;&lt; endl;
  1503. <a name="l01473"></a>01473 <span class="comment">//std::cout &lt;&lt; &quot;[BaseOverlay::sendToKey() @ &quot; &lt;&lt; thisNode.getIp()</span>
  1504. <a name="l01474"></a>01474 <span class="comment">// &lt;&lt; &quot; (&quot; &lt;&lt; thisNode.getKey().toString(16) &lt;&lt; &quot;)]\n&quot;</span>
  1505. <a name="l01475"></a>01475 <span class="comment">// &lt;&lt; &quot; Discards &quot; &lt;&lt; routeMsg-&gt;getName() &lt;&lt; &quot; from &quot;</span>
  1506. <a name="l01476"></a>01476 <span class="comment">// &lt;&lt; routeMsg-&gt;getSrcNode().getIp() &lt;&lt; &quot;\n&quot;</span>
  1507. <a name="l01477"></a>01477 <span class="comment">// &lt;&lt; &quot; The hop count maximum has been exceeded (&quot;</span>
  1508. <a name="l01478"></a>01478 <span class="comment">// &lt;&lt; routeMsg-&gt;getHopCount() &lt;&lt; &quot;&gt;=&quot;</span>
  1509. <a name="l01479"></a>01479 <span class="comment">// &lt;&lt; hopCountMax &lt;&lt; &quot;)&quot;</span>
  1510. <a name="l01480"></a>01480 <span class="comment">// &lt;&lt; std::endl;</span>
  1511. <a name="l01481"></a>01481
  1512. <a name="l01482"></a>01482 <span class="comment">// statistics</span>
  1513. <a name="l01483"></a>01483 <a class="code" href="GlobalStatistics_8h.html#af29140ebe8e0a93406a58441f7c5fec8" title="Macro used for recording statistics considering measureNetwIn parameter.">RECORD_STATS</a>(<a class="code" href="classBaseOverlay.html#a4a82bd4b76a8d06a1d63bba98f1a34d7" title="number of dropped packets">numDropped</a>++;
  1514. <a name="l01484"></a>01484 <a class="code" href="classBaseOverlay.html#a9e09857b97f52d340e4710580f25f7a6" title="number of dropped bytes">bytesDropped</a> += routeMsg-&gt;getByteLength());
  1515. <a name="l01485"></a>01485 <span class="keyword">delete</span> routeMsg;
  1516. <a name="l01486"></a>01486 <span class="keyword">delete</span> nextHops;
  1517. <a name="l01487"></a>01487 <span class="keywordflow">return</span>;
  1518. <a name="l01488"></a>01488 }
  1519. <a name="l01489"></a>01489
  1520. <a name="l01490"></a>01490 <a class="code" href="classOverlayCtrlInfo.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">OverlayCtrlInfo</a>* overlayCtrlInfo =
  1521. <a name="l01491"></a>01491 <span class="keyword">dynamic_cast&lt;</span><a class="code" href="classOverlayCtrlInfo.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">OverlayCtrlInfo</a>*<span class="keyword">&gt;</span>(routeMsg-&gt;getControlInfo());
  1522. <a name="l01492"></a>01492 assert(overlayCtrlInfo);
  1523. <a name="l01493"></a>01493
  1524. <a name="l01494"></a>01494 <span class="comment">// check and choose nextHop candidate</span>
  1525. <a name="l01495"></a>01495 <a class="code" href="classNodeHandle.html" title="This class implements a node handle.">NodeHandle</a>* nextHop = NULL;
  1526. <a name="l01496"></a>01496 <span class="keywordtype">bool</span> err, isSibling;
  1527. <a name="l01497"></a>01497 isSibling = <a class="code" href="classBaseOverlay.html#ab5887b89ba9da5973068e834feb69ce7" title="Query if a node is among the siblings for a given key.">isSiblingFor</a>(<a class="code" href="classBaseRpc.html#a88eb68c06450fd12ea072f471bf1c1b8" title="NodeHandle to this node.">thisNode</a>, routeMsg-&gt;<a class="code" href="classBaseRouteMessage.html#ad983641a05758bc9d25070f1659b2f34">getDestKey</a>(),
  1528. <a name="l01498"></a>01498 numSiblings, &amp;err);
  1529. <a name="l01499"></a>01499
  1530. <a name="l01500"></a>01500 <span class="comment">// if route is recorded we can do a real loop detection</span>
  1531. <a name="l01501"></a>01501 std::set&lt;TransportAddress&gt; visitedHops;
  1532. <a name="l01502"></a>01502 <span class="keywordflow">for</span> (uint32_t i = 0; i &lt; routeMsg-&gt;<a class="code" href="classBaseRouteMessage.html#a4d937e983eb4887400e41749b55ebecb">getVisitedHopsArraySize</a>(); ++i) {
  1533. <a name="l01503"></a>01503 visitedHops.insert(routeMsg-&gt;<a class="code" href="classBaseRouteMessage.html#a5e4624df761b01f0df433ef0ace1c597">getVisitedHops</a>(i));
  1534. <a name="l01504"></a>01504 }
  1535. <a name="l01505"></a>01505
  1536. <a name="l01506"></a>01506 <span class="keywordflow">for</span> (uint32_t index = 0; nextHop == NULL &amp;&amp; nextHops-&gt;size() &gt; index;
  1537. <a name="l01507"></a>01507 ++index) {
  1538. <a name="l01508"></a>01508 nextHop = &amp;((*nextHops)[index]);
  1539. <a name="l01509"></a>01509 <span class="comment">// loop detection</span>
  1540. <a name="l01510"></a>01510 <span class="keywordflow">if</span> (((overlayCtrlInfo-&gt;<a class="code" href="classOverlayCtrlInfo.html#ad12b7ac74244fb7ab79ebf41e05fe79c">getLastHop</a>() == *nextHop) &amp;&amp;
  1541. <a name="l01511"></a>01511 (*nextHop != <a class="code" href="classBaseRpc.html#a88eb68c06450fd12ea072f471bf1c1b8" title="NodeHandle to this node.">thisNode</a>)) ||
  1542. <a name="l01512"></a>01512 (visitedHops.find(*nextHop) != visitedHops.end()) ||
  1543. <a name="l01513"></a>01513 <span class="comment">// do not forward msg to source node</span>
  1544. <a name="l01514"></a>01514 ((*nextHop == routeMsg-&gt;<a class="code" href="classBaseRouteMessage.html#af9787d89915f01a2055e920148015e17">getSrcNode</a>()) &amp;&amp;
  1545. <a name="l01515"></a>01515 (<a class="code" href="classBaseRpc.html#a88eb68c06450fd12ea072f471bf1c1b8" title="NodeHandle to this node.">thisNode</a> != routeMsg-&gt;<a class="code" href="classBaseRouteMessage.html#af9787d89915f01a2055e920148015e17">getSrcNode</a>())) ||
  1546. <a name="l01516"></a>01516 <span class="comment">// nextHop is thisNode, but isSiblingFor() is false</span>
  1547. <a name="l01517"></a>01517 ((*nextHop == <a class="code" href="classBaseRpc.html#a88eb68c06450fd12ea072f471bf1c1b8" title="NodeHandle to this node.">thisNode</a>) &amp;&amp; (!isSibling))) {
  1548. <a name="l01518"></a>01518 nextHop = NULL;
  1549. <a name="l01519"></a>01519 }
  1550. <a name="l01520"></a>01520 }
  1551. <a name="l01521"></a>01521
  1552. <a name="l01522"></a>01522 <span class="keywordflow">if</span> (nextHop == NULL) {
  1553. <a name="l01523"></a>01523 <span class="keywordflow">if</span> (!<a class="code" href="classBaseOverlay.html#a53ded56af8bba8e4caa9a9b29e01ab87">checkFindNode</a>(routeMsg)) {
  1554. <a name="l01524"></a>01524 EV &lt;&lt; <span class="stringliteral">&quot;[BaseOverlay::sendToKey() @ &quot;</span> &lt;&lt; <a class="code" href="classBaseRpc.html#a88eb68c06450fd12ea072f471bf1c1b8" title="NodeHandle to this node.">thisNode</a>.<a class="code" href="classTransportAddress.html#a00e613d98d3412e2b92897c25aa0eb4c" title="returns ip address">getIp</a>()
  1555. <a name="l01525"></a>01525 &lt;&lt; <span class="stringliteral">&quot; (&quot;</span> &lt;&lt; <a class="code" href="classBaseRpc.html#a88eb68c06450fd12ea072f471bf1c1b8" title="NodeHandle to this node.">thisNode</a>.<a class="code" href="classNodeHandle.html#aef531103cdf07c8353267f4d30a80112" title="returns key of this NodeHandle">getKey</a>().<a class="code" href="classOverlayKey.html#aabeb4fd284a630a82e982ba34ece4fd9" title="Returns a string representation of this key.">toString</a>(16) &lt;&lt; <span class="stringliteral">&quot;)]\n&quot;</span>
  1556. <a name="l01526"></a>01526 &lt;&lt; <span class="stringliteral">&quot; Discards &quot;</span> &lt;&lt; routeMsg-&gt;getName() &lt;&lt; <span class="stringliteral">&quot; from &quot;</span>
  1557. <a name="l01527"></a>01527 &lt;&lt; routeMsg-&gt;<a class="code" href="classBaseRouteMessage.html#af9787d89915f01a2055e920148015e17">getSrcNode</a>().<a class="code" href="classTransportAddress.html#a00e613d98d3412e2b92897c25aa0eb4c" title="returns ip address">getIp</a>() &lt;&lt; <span class="stringliteral">&quot;\n&quot;</span>
  1558. <a name="l01528"></a>01528 &lt;&lt; <span class="stringliteral">&quot; No useful nextHop found!&quot;</span>
  1559. <a name="l01529"></a>01529 &lt;&lt; endl;
  1560. <a name="l01530"></a>01530 <span class="comment">//std::cout &lt;&lt; thisNode.getIp() &lt;&lt; &quot; packet from &quot;</span>
  1561. <a name="l01531"></a>01531 <span class="comment">// &lt;&lt; routeMsg-&gt;getSrcNode().getIp()</span>
  1562. <a name="l01532"></a>01532 <span class="comment">// &lt;&lt; &quot; dropped: &quot; &lt;&lt; routeMsg</span>
  1563. <a name="l01533"></a>01533 <span class="comment">// &lt;&lt; &quot; &quot; &lt;&lt; state &lt;&lt; std::endl;</span>
  1564. <a name="l01534"></a>01534 <a class="code" href="GlobalStatistics_8h.html#af29140ebe8e0a93406a58441f7c5fec8" title="Macro used for recording statistics considering measureNetwIn parameter.">RECORD_STATS</a>(<a class="code" href="classBaseOverlay.html#a4a82bd4b76a8d06a1d63bba98f1a34d7" title="number of dropped packets">numDropped</a>++;
  1565. <a name="l01535"></a>01535 <a class="code" href="classBaseOverlay.html#a9e09857b97f52d340e4710580f25f7a6" title="number of dropped bytes">bytesDropped</a> += routeMsg-&gt;getByteLength());
  1566. <a name="l01536"></a>01536 }
  1567. <a name="l01537"></a>01537 <span class="keyword">delete</span> routeMsg;
  1568. <a name="l01538"></a>01538 <span class="keyword">delete</span> nextHops;
  1569. <a name="l01539"></a>01539 <span class="keywordflow">return</span>;
  1570. <a name="l01540"></a>01540 }
  1571. <a name="l01541"></a>01541
  1572. <a name="l01542"></a>01542 assert(!nextHop-&gt;<a class="code" href="classNodeHandle.html#ab5136375a4548ced7c2014a73c8743c9" title="indicates if this NodeHandle is specified">isUnspecified</a>());
  1573. <a name="l01543"></a>01543
  1574. <a name="l01544"></a>01544 <span class="comment">// callForward to app</span>
  1575. <a name="l01545"></a>01545 <span class="keywordflow">if</span> (<a class="code" href="classBaseOverlay.html#ac9acbeb30646d54f620d87641d91b113" title="forward messages to applications?">useCommonAPIforward</a> &amp;&amp;
  1576. <a name="l01546"></a>01546 dynamic_cast&lt;BaseAppDataMessage*&gt;(
  1577. <a name="l01547"></a>01547 routeMsg-&gt;getEncapsulatedPacket()) &amp;&amp;
  1578. <a name="l01548"></a>01548 routeMsg-&gt;getContextPointer() == NULL) {
  1579. <a name="l01549"></a>01549 <a class="code" href="classBaseOverlay.html#a71bcb54aa4fc66bdf97cc9c87fffc318" title="Calls forward function in application.">callForward</a>(routeMsg-&gt;<a class="code" href="classBaseRouteMessage.html#ad983641a05758bc9d25070f1659b2f34">getDestKey</a>(), routeMsg, *nextHop);
  1580. <a name="l01550"></a>01550 <span class="keyword">delete</span> nextHops;
  1581. <a name="l01551"></a>01551 <span class="keywordflow">return</span>;
  1582. <a name="l01552"></a>01552 }
  1583. <a name="l01553"></a>01553 <span class="comment">//message marked as not already forwarded</span>
  1584. <a name="l01554"></a>01554 routeMsg-&gt;setContextPointer(NULL);
  1585. <a name="l01555"></a>01555
  1586. <a name="l01556"></a>01556 <span class="comment">// is this node responsible?</span>
  1587. <a name="l01557"></a>01557 <span class="keywordflow">if</span> (*nextHop == <a class="code" href="classBaseRpc.html#a88eb68c06450fd12ea072f471bf1c1b8" title="NodeHandle to this node.">thisNode</a>) {
  1588. <a name="l01558"></a>01558 <span class="keywordflow">if</span> (isSibling &amp;&amp; !err) {
  1589. <a name="l01559"></a>01559 <span class="comment">//EV &lt;&lt; &quot;[BaseOverlay::sendToKey() @ &quot; &lt;&lt; thisNode.getIp()</span>
  1590. <a name="l01560"></a>01560 <span class="comment">// &lt;&lt; &quot; (&quot; &lt;&lt; thisNode.getKey().toString(16) &lt;&lt; &quot;)]\n&quot;</span>
  1591. <a name="l01561"></a>01561 <span class="comment">// &lt;&lt; &quot; Forwards msg for key &quot; &lt;&lt; routeMsg-&gt;getDestKey() &quot;\n&quot;</span>
  1592. <a name="l01562"></a>01562 <span class="comment">// &lt;&lt; &quot; to node &quot; &lt;&lt; (*nextHops)[0]</span>
  1593. <a name="l01563"></a>01563 <span class="comment">// &lt;&lt; endl;</span>
  1594. <a name="l01564"></a>01564 <span class="keyword">delete</span> nextHops;
  1595. <a name="l01565"></a>01565 assert(routeMsg-&gt;getControlInfo());
  1596. <a name="l01566"></a>01566 <a class="code" href="classBaseOverlay.html#ac647b32e360b4db1f0eb53b096437fd8" title="Handles a BaseOverlayMessage ">handleBaseOverlayMessage</a>(routeMsg, key);
  1597. <a name="l01567"></a>01567 <span class="keywordflow">return</span>;
  1598. <a name="l01568"></a>01568 } <span class="keywordflow">else</span> {
  1599. <a name="l01569"></a>01569 <span class="keywordflow">throw</span> cRuntimeError(<span class="stringliteral">&quot;isSiblingsFor() is true with an &quot;</span>
  1600. <a name="l01570"></a>01570 <span class="stringliteral">&quot;error: Erroneous method &quot;</span>
  1601. <a name="l01571"></a>01571 <span class="stringliteral">&quot;isSiblingFor()!&quot;</span>);
  1602. <a name="l01572"></a>01572 }
  1603. <a name="l01573"></a>01573 }
  1604. <a name="l01574"></a>01574 <span class="comment">// else forward msg if this node is not responsible for the key</span>
  1605. <a name="l01575"></a>01575 overlayCtrlInfo-&gt;<a class="code" href="classOverlayCtrlInfo.html#a790ec1f663fccc40033e6a8e714adbff">setHopCount</a>(routeMsg-&gt;<a class="code" href="classBaseRouteMessage.html#ab59d2969c812aa35d132a68fc2baf819">getHopCount</a>());
  1606. <a name="l01576"></a>01576 <span class="keywordflow">if</span> (<a class="code" href="classBaseOverlay.html#a42f4c08f6408d155a9907957ecf12d79" title="Hook for forwarded message in recursive lookup mode.">recursiveRoutingHook</a>(*nextHop, routeMsg)) {
  1607. <a name="l01577"></a>01577 <a class="code" href="classBaseOverlay.html#ac93829bc8095a76e6208cf0ec12188b0">sendRouteMessage</a>(*nextHop, routeMsg, <a class="code" href="classBaseOverlay.html#a6e9090bf68f45a31d727a6c7f0501d43" title="send ACK when receiving route message">routeMsgAcks</a>);
  1608. <a name="l01578"></a>01578 }
  1609. <a name="l01579"></a>01579 }
  1610. <a name="l01580"></a>01580 <span class="keyword">delete</span> nextHops;
  1611. <a name="l01581"></a>01581 }
  1612. <a name="l01582"></a>01582 }
  1613. <a name="l01583"></a>01583
  1614. <a name="l01584"></a><a class="code" href="classBaseOverlay.html#a53ded56af8bba8e4caa9a9b29e01ab87">01584</a> <span class="keywordtype">bool</span> <a class="code" href="classBaseOverlay.html#a53ded56af8bba8e4caa9a9b29e01ab87">BaseOverlay::checkFindNode</a>(<a class="code" href="classBaseRouteMessage.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">BaseRouteMessage</a>* routeMsg)
  1615. <a name="l01585"></a>01585 {
  1616. <a name="l01586"></a>01586 <span class="keywordflow">if</span> (dynamic_cast&lt;FindNodeCall*&gt;(routeMsg-&gt;getEncapsulatedPacket())) {
  1617. <a name="l01587"></a>01587 <a class="code" href="classFindNodeCall.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">FindNodeCall</a>* findNodeCall =
  1618. <a name="l01588"></a>01588 <span class="keyword">static_cast&lt;</span><a class="code" href="classFindNodeCall.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">FindNodeCall</a>*<span class="keyword">&gt;</span>(routeMsg-&gt;decapsulate());
  1619. <a name="l01589"></a>01589 findNodeCall
  1620. <a name="l01590"></a>01590 -&gt;setControlInfo(check_and_cast&lt;OverlayCtrlInfo*&gt;
  1621. <a name="l01591"></a>01591 (routeMsg-&gt;removeControlInfo()));
  1622. <a name="l01592"></a>01592 <a class="code" href="classBaseOverlay.html#a50680d9b44a779f314baeab200da61dc">findNodeRpc</a>(findNodeCall);
  1623. <a name="l01593"></a>01593 <span class="keywordflow">return</span> <span class="keyword">true</span>;
  1624. <a name="l01594"></a>01594 }
  1625. <a name="l01595"></a>01595 <span class="keywordflow">return</span> <span class="keyword">false</span>;
  1626. <a name="l01596"></a>01596 }
  1627. <a name="l01597"></a>01597
  1628. <a name="l01598"></a>01598 <span class="comment">//protected: create a lookup class</span>
  1629. <a name="l01599"></a><a class="code" href="classBaseOverlay.html#a205a7d44401fb3d77b146e23b2904b6f">01599</a> <a class="code" href="classAbstractLookup.html" title="This class declares an abstract iterative lookup.">AbstractLookup</a>* <a class="code" href="classBaseOverlay.html#a205a7d44401fb3d77b146e23b2904b6f" title="Creates an abstract iterative lookup instance.">BaseOverlay::createLookup</a>(<a class="code" href="CommonMessages__m_8h.html#a5bbe67ba1134d38bbb89c7c242ba6551" title="Enum generated from common/CommonMessages.msg by opp_msgc.">RoutingType</a> routingType,
  1630. <a name="l01600"></a>01600 <span class="keyword">const</span> <a class="code" href="classBaseOverlayMessage.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">BaseOverlayMessage</a>* msg,
  1631. <a name="l01601"></a>01601 <span class="keyword">const</span> cPacket* findNodeExt,
  1632. <a name="l01602"></a>01602 <span class="keywordtype">bool</span> appLookup)
  1633. <a name="l01603"></a>01603 {
  1634. <a name="l01604"></a>01604 <a class="code" href="classAbstractLookup.html" title="This class declares an abstract iterative lookup.">AbstractLookup</a>* newLookup;
  1635. <a name="l01605"></a>01605
  1636. <a name="l01606"></a>01606 <span class="keywordflow">if</span> (routingType == <a class="code" href="CommonMessages__m_8h.html#a5bbe67ba1134d38bbb89c7c242ba6551a931137cd67090e50ef2ea3ccfb9e8d90">DEFAULT_ROUTING</a>) {
  1637. <a name="l01607"></a>01607 routingType = <a class="code" href="classBaseOverlay.html#a9e13844ea8090b84a90286f048cdcbf9">defaultRoutingType</a>;
  1638. <a name="l01608"></a>01608 }
  1639. <a name="l01609"></a>01609
  1640. <a name="l01610"></a>01610 <span class="keywordflow">switch</span> (routingType) {
  1641. <a name="l01611"></a>01611 <span class="keywordflow">case</span> <a class="code" href="CommonMessages__m_8h.html#a5bbe67ba1134d38bbb89c7c242ba6551ae4bd936cbb47803986c83242cbb51867">ITERATIVE_ROUTING</a>:
  1642. <a name="l01612"></a>01612 <span class="keywordflow">case</span> <a class="code" href="CommonMessages__m_8h.html#a5bbe67ba1134d38bbb89c7c242ba6551ad60cf756d6bb24af372d7fe7c279f44d">EXHAUSTIVE_ITERATIVE_ROUTING</a>:
  1643. <a name="l01613"></a>01613 newLookup = <span class="keyword">new</span> <a class="code" href="classBaseOverlay.html#af4b6fb17cb1da8f210d175cdba0c2c5a">IterativeLookup</a>(<span class="keyword">this</span>, routingType,
  1644. <a name="l01614"></a>01614 <a class="code" href="classBaseOverlay.html#a32b8cfb47f3ef824dcf6ad882e6a6a9f">iterativeLookupConfig</a>, findNodeExt,
  1645. <a name="l01615"></a>01615 appLookup);
  1646. <a name="l01616"></a>01616 <span class="keywordflow">break</span>;
  1647. <a name="l01617"></a>01617 <span class="keywordflow">case</span> <a class="code" href="CommonMessages__m_8h.html#a5bbe67ba1134d38bbb89c7c242ba6551ad8c4eefed3d826e5da402fe582cad2c1">RECURSIVE_SOURCE_ROUTING</a>:
  1648. <a name="l01618"></a>01618 <span class="keywordflow">case</span> <a class="code" href="CommonMessages__m_8h.html#a5bbe67ba1134d38bbb89c7c242ba6551a18b63fe85aa5e81cd3fca5e3c7c9df82">SEMI_RECURSIVE_ROUTING</a>:
  1649. <a name="l01619"></a>01619 <span class="keywordflow">case</span> <a class="code" href="CommonMessages__m_8h.html#a5bbe67ba1134d38bbb89c7c242ba6551aeec4ce5cac6dae9d3d59b1347a9df957">FULL_RECURSIVE_ROUTING</a>:
  1650. <a name="l01620"></a>01620 newLookup = <span class="keyword">new</span> <a class="code" href="classBaseOverlay.html#a9d94a8362059c5c49b2cfffeb628f7cb">RecursiveLookup</a>(<span class="keyword">this</span>, routingType,
  1651. <a name="l01621"></a>01621 <a class="code" href="classBaseOverlay.html#af6573aac3c99626958737209309d7e99">recursiveLookupConfig</a>,
  1652. <a name="l01622"></a>01622 appLookup);
  1653. <a name="l01623"></a>01623 <span class="keywordflow">break</span>;
  1654. <a name="l01624"></a>01624 <span class="keywordflow">default</span>:
  1655. <a name="l01625"></a>01625 <span class="keywordflow">throw</span> cRuntimeError(<span class="stringliteral">&quot;BaseOverlay::createLookup():&quot;</span>
  1656. <a name="l01626"></a>01626 <span class="stringliteral">&quot; Unknown routingType!&quot;</span>);
  1657. <a name="l01627"></a>01627 <span class="keywordflow">break</span>;
  1658. <a name="l01628"></a>01628 }
  1659. <a name="l01629"></a>01629
  1660. <a name="l01630"></a>01630 <a class="code" href="classBaseOverlay.html#ad25b51c2d6c06dbe12c534307f43822e">lookups</a>.insert(newLookup);
  1661. <a name="l01631"></a>01631 <span class="keywordflow">return</span> newLookup;
  1662. <a name="l01632"></a>01632 }
  1663. <a name="l01633"></a>01633
  1664. <a name="l01634"></a><a class="code" href="classBaseOverlay.html#a0bfca744a28f47cae8c99243de04b005">01634</a> <span class="keywordtype">void</span> <a class="code" href="classBaseOverlay.html#a0bfca744a28f47cae8c99243de04b005" title="Removes the abstract lookup instance.">BaseOverlay::removeLookup</a>(<a class="code" href="classAbstractLookup.html" title="This class declares an abstract iterative lookup.">AbstractLookup</a>* lookup)
  1665. <a name="l01635"></a>01635 {
  1666. <a name="l01636"></a>01636 <a class="code" href="classBaseOverlay.html#ad25b51c2d6c06dbe12c534307f43822e">lookups</a>.erase(lookup);
  1667. <a name="l01637"></a>01637 }
  1668. <a name="l01638"></a>01638
  1669. <a name="l01639"></a>01639 <span class="comment">//virtual public</span>
  1670. <a name="l01640"></a><a class="code" href="classBaseOverlay.html#aa12314947ef42726ec6c7066dde8d0f9">01640</a> <a class="code" href="classOverlayKey.html" title="A common overlay key class.">OverlayKey</a> <a class="code" href="classBaseOverlay.html#aa12314947ef42726ec6c7066dde8d0f9" title="This method should implement the distance between two keys.">BaseOverlay::distance</a>(<span class="keyword">const</span> <a class="code" href="classOverlayKey.html" title="A common overlay key class.">OverlayKey</a>&amp; x,
  1671. <a name="l01641"></a>01641 <span class="keyword">const</span> <a class="code" href="classOverlayKey.html" title="A common overlay key class.">OverlayKey</a>&amp; y,
  1672. <a name="l01642"></a>01642 <span class="keywordtype">bool</span> useAlternative)<span class="keyword"> const</span>
  1673. <a name="l01643"></a>01643 <span class="keyword"></span>{
  1674. <a name="l01644"></a>01644 <span class="keywordflow">throw</span> cRuntimeError(<span class="stringliteral">&quot;BaseOverlay::distance(): Not implemented!&quot;</span>);
  1675. <a name="l01645"></a>01645 <span class="keywordflow">return</span> <a class="code" href="classOverlayKey.html#ac0d4135dff2985e3582fdbed2a37eb75" title="OverlayKey without defined key.">OverlayKey::UNSPECIFIED_KEY</a>;
  1676. <a name="l01646"></a>01646 }
  1677. <a name="l01647"></a>01647
  1678. <a name="l01648"></a>01648 <span class="comment">//protected: find closest nodes</span>
  1679. <a name="l01649"></a><a class="code" href="classBaseOverlay.html#a7cbdce336237331b67a3c69c4e43d489">01649</a> <a class="code" href="classBaseKeySortedVector.html">NodeVector</a>* <a class="code" href="classBaseOverlay.html#a7cbdce336237331b67a3c69c4e43d489" title="Implements the find node call.">BaseOverlay::findNode</a>(<span class="keyword">const</span> <a class="code" href="classOverlayKey.html" title="A common overlay key class.">OverlayKey</a>&amp; key,
  1680. <a name="l01650"></a>01650 <span class="keywordtype">int</span> numRedundantNodes,
  1681. <a name="l01651"></a>01651 <span class="keywordtype">int</span> numSiblings,
  1682. <a name="l01652"></a>01652 <a class="code" href="classBaseOverlayMessage.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">BaseOverlayMessage</a>* msg)
  1683. <a name="l01653"></a>01653 {
  1684. <a name="l01654"></a>01654 <span class="keywordflow">throw</span> cRuntimeError(<span class="stringliteral">&quot;findNode: Not implemented!&quot;</span>);
  1685. <a name="l01655"></a>01655 <span class="keywordflow">return</span> NULL;
  1686. <a name="l01656"></a>01656 }
  1687. <a name="l01657"></a>01657
  1688. <a name="l01658"></a>01658 <span class="comment">//protected: join the overlay with a given nodeID</span>
  1689. <a name="l01659"></a><a class="code" href="classBaseOverlay.html#a3eefb56c2396601373c89d21b5b58110">01659</a> <span class="keywordtype">void</span> <a class="code" href="classBaseOverlay.html#a3eefb56c2396601373c89d21b5b58110" title="Join the overlay with a given nodeID in thisNode.key.">BaseOverlay::joinOverlay</a>()
  1690. <a name="l01660"></a>01660 {
  1691. <a name="l01661"></a>01661 <span class="comment">// std::cout &lt;&lt; &quot;BaseOverlay::joinOverlay(): Not implemented!&quot; &lt;&lt; endl;</span>
  1692. <a name="l01662"></a>01662 <span class="keywordflow">return</span>;
  1693. <a name="l01663"></a>01663 }
  1694. <a name="l01664"></a>01664
  1695. <a name="l01665"></a><a class="code" href="classBaseOverlay.html#aa53ca4e1b4720ba0d2874afe29eacbf7">01665</a> <span class="keywordtype">bool</span> <a class="code" href="classBaseOverlay.html#aa53ca4e1b4720ba0d2874afe29eacbf7" title="Handles a failed node.">BaseOverlay::handleFailedNode</a>(<span class="keyword">const</span> <a class="code" href="classTransportAddress.html" title="This class implements a common transport address.">TransportAddress</a>&amp; failed)
  1696. <a name="l01666"></a>01666 {
  1697. <a name="l01667"></a>01667 <span class="keywordflow">return</span> <span class="keyword">true</span>;
  1698. <a name="l01668"></a>01668 }
  1699. <a name="l01669"></a>01669
  1700. <a name="l01670"></a>01670 <span class="comment">//------------------------------------------------------------------------</span>
  1701. <a name="l01671"></a>01671 <span class="comment">//--- RPCs ---------------------------------------------------------------</span>
  1702. <a name="l01672"></a>01672 <span class="comment">//------------------------------------------------------------------------</span>
  1703. <a name="l01673"></a>01673
  1704. <a name="l01674"></a>01674 <span class="comment">//private</span>
  1705. <a name="l01675"></a><a class="code" href="classBaseOverlay.html#a03a24a5876504b36177a0ee041d5822e">01675</a> <span class="keywordtype">bool</span> <a class="code" href="classBaseOverlay.html#a03a24a5876504b36177a0ee041d5822e">BaseOverlay::internalHandleRpcCall</a>(<a class="code" href="classBaseCallMessage.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">BaseCallMessage</a>* msg)
  1706. <a name="l01676"></a>01676 {
  1707. <a name="l01677"></a>01677 <span class="comment">// call rpc stubs</span>
  1708. <a name="l01678"></a>01678 <a class="code" href="RpcMacros_8h.html#aa75b135e279b574267e1a7dc4ab79da4" title="Marks the beginning of a Remote-Procedure-Call Switch block.">RPC_SWITCH_START</a>( msg );
  1709. <a name="l01679"></a>01679 <a class="code" href="RpcMacros_8h.html#ad81d44e9bc59d2fb2cfcacc4d5ecda35" title="Declares a RPC method delegation.">RPC_DELEGATE</a>( FindNode, <a class="code" href="classBaseOverlay.html#a50680d9b44a779f314baeab200da61dc">findNodeRpc</a> );
  1710. <a name="l01680"></a>01680 <a class="code" href="RpcMacros_8h.html#ad81d44e9bc59d2fb2cfcacc4d5ecda35" title="Declares a RPC method delegation.">RPC_DELEGATE</a>( FailedNode, <a class="code" href="classBaseOverlay.html#a1655dc0cb4ebb2f22de1d1ee29030433">failedNodeRpc</a> );
  1711. <a name="l01681"></a>01681 <a class="code" href="RpcMacros_8h.html#ad81d44e9bc59d2fb2cfcacc4d5ecda35" title="Declares a RPC method delegation.">RPC_DELEGATE</a>( <a class="code" href="classLookup.html">Lookup</a>, <a class="code" href="classBaseOverlay.html#aa9d874edfd1b52822e1693695420d5a7">lookupRpc</a> );
  1712. <a name="l01682"></a>01682 <a class="code" href="RpcMacros_8h.html#ad81d44e9bc59d2fb2cfcacc4d5ecda35" title="Declares a RPC method delegation.">RPC_DELEGATE</a>( NextHop, <a class="code" href="classBaseOverlay.html#a3eef9db326747d930a455db3b884dac4">nextHopRpc</a> );
  1713. <a name="l01683"></a>01683 <a class="code" href="RpcMacros_8h.html#a29a8a3f21e67ecb25f58608a54df5191" title="Marks the end of a Remote-Procedure-Call Switch block.">RPC_SWITCH_END</a>( );
  1714. <a name="l01684"></a>01684
  1715. <a name="l01685"></a>01685 <span class="comment">// if RPC was handled return true, else tell the parent class to handle it</span>
  1716. <a name="l01686"></a>01686 <span class="keywordflow">return</span> <a class="code" href="RpcMacros_8h.html#aa5e964b7c7129c0943237a786e455e9a">RPC_HANDLED</a> || <a class="code" href="classBaseOverlay.html#a03a24a5876504b36177a0ee041d5822e">BaseRpc::internalHandleRpcCall</a>(msg);
  1717. <a name="l01687"></a>01687 }
  1718. <a name="l01688"></a>01688
  1719. <a name="l01689"></a><a class="code" href="classBaseOverlay.html#adc50f1e153d88a20ca921e84a0dbf3b2">01689</a> <span class="keywordtype">void</span> <a class="code" href="classBaseOverlay.html#adc50f1e153d88a20ca921e84a0dbf3b2">BaseOverlay::internalHandleRpcResponse</a>(<a class="code" href="classBaseResponseMessage.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">BaseResponseMessage</a>* msg,
  1720. <a name="l01690"></a>01690 cPolymorphic* context,
  1721. <a name="l01691"></a>01691 <span class="keywordtype">int</span> rpcId, simtime_t rtt)
  1722. <a name="l01692"></a>01692 {
  1723. <a name="l01693"></a>01693 <a class="code" href="classBaseOverlay.html#adc50f1e153d88a20ca921e84a0dbf3b2">BaseRpc::internalHandleRpcResponse</a>(msg, context, rpcId, rtt);
  1724. <a name="l01694"></a>01694 }
  1725. <a name="l01695"></a>01695
  1726. <a name="l01696"></a><a class="code" href="classBaseOverlay.html#ac89854c2f011597f3421d414851f4407">01696</a> <span class="keywordtype">void</span> <a class="code" href="classBaseOverlay.html#ac89854c2f011597f3421d414851f4407">BaseOverlay::internalHandleRpcTimeout</a>(<a class="code" href="classBaseCallMessage.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">BaseCallMessage</a>* msg,
  1727. <a name="l01697"></a>01697 <span class="keyword">const</span> <a class="code" href="classTransportAddress.html" title="This class implements a common transport address.">TransportAddress</a>&amp; dest,
  1728. <a name="l01698"></a>01698 cPolymorphic* context, <span class="keywordtype">int</span> rpcId,
  1729. <a name="l01699"></a>01699 <span class="keyword">const</span> <a class="code" href="classOverlayKey.html" title="A common overlay key class.">OverlayKey</a>&amp; destKey)
  1730. <a name="l01700"></a>01700 {
  1731. <a name="l01701"></a>01701 <a class="code" href="RpcMacros_8h.html#aa75b135e279b574267e1a7dc4ab79da4" title="Marks the beginning of a Remote-Procedure-Call Switch block.">RPC_SWITCH_START</a>( msg )
  1732. <a name="l01702"></a>01702 <a class="code" href="RpcMacros_8h.html#ae07fad586ce7b9e82ad12848767a32e5">RPC_ON_CALL</a>( NextHop )
  1733. <a name="l01703"></a>01703 {
  1734. <a name="l01704"></a>01704 <a class="code" href="classBaseRouteMessage.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">BaseRouteMessage</a>* tempMsg
  1735. <a name="l01705"></a>01705 = check_and_cast&lt;<a class="code" href="classBaseRouteMessage.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">BaseRouteMessage</a>*&gt;(msg-&gt;decapsulate());
  1736. <a name="l01706"></a>01706
  1737. <a name="l01707"></a>01707 assert(!tempMsg-&gt;getControlInfo());
  1738. <a name="l01708"></a>01708 <span class="keywordflow">if</span> (!tempMsg-&gt;getControlInfo()) {
  1739. <a name="l01709"></a>01709 <a class="code" href="classOverlayCtrlInfo.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">OverlayCtrlInfo</a>* overlayCtrlInfo = <span class="keyword">new</span> <a class="code" href="classOverlayCtrlInfo.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">OverlayCtrlInfo</a>;
  1740. <a name="l01710"></a>01710 overlayCtrlInfo-&gt;<a class="code" href="classOverlayCtrlInfo.html#a6c2c1955d30ba60f696247685dc3d6ae">setLastHop</a>(<a class="code" href="classBaseRpc.html#a88eb68c06450fd12ea072f471bf1c1b8" title="NodeHandle to this node.">thisNode</a>);
  1741. <a name="l01711"></a>01711 overlayCtrlInfo-&gt;<a class="code" href="classOverlayCtrlInfo.html#a790ec1f663fccc40033e6a8e714adbff">setHopCount</a>(tempMsg-&gt;<a class="code" href="classBaseRouteMessage.html#ab59d2969c812aa35d132a68fc2baf819">getHopCount</a>());
  1742. <a name="l01712"></a>01712 overlayCtrlInfo-&gt;<a class="code" href="classOverlayCtrlInfo.html#a57150c423c6413ed906a81402e8df0f5">setSrcNode</a>(tempMsg-&gt;<a class="code" href="classBaseRouteMessage.html#af9787d89915f01a2055e920148015e17">getSrcNode</a>());
  1743. <a name="l01713"></a>01713 overlayCtrlInfo-&gt;<a class="code" href="classOverlayCtrlInfo.html#a2e3bd66c1e71acd70a6d87817efe15db">setRoutingType</a>(tempMsg-&gt;<a class="code" href="classBaseRouteMessage.html#a834dd9c8f0b2b776ed5f5b1fa285149a">getRoutingType</a>());
  1744. <a name="l01714"></a>01714 overlayCtrlInfo-&gt;<a class="code" href="classOverlayCtrlInfo.html#a129cf7292587fa2ee6e4e6238c5e4d33">setTransportType</a>(<a class="code" href="CommonMessages__m_8h.html#aca1e72535e7f260e54ed8bbf984dade9a01580b2e886cd821bd7f3f2bcd7c690c">UDP_TRANSPORT</a>);
  1745. <a name="l01715"></a>01715 tempMsg-&gt;setControlInfo(overlayCtrlInfo);
  1746. <a name="l01716"></a>01716 }
  1747. <a name="l01717"></a>01717 <span class="comment">// remove node from local routing tables</span>
  1748. <a name="l01718"></a>01718 <span class="comment">// + route message again if possible</span>
  1749. <a name="l01719"></a>01719 assert(!dest.<a class="code" href="classTransportAddress.html#a026e777c423ff2a0280edd2fa5472e74" title="indicates if TransportAddress is specified">isUnspecified</a>() &amp;&amp; destKey.<a class="code" href="classOverlayKey.html#abe357a4d1babcf7d30598a61cbc0f5c2" title="Returns true, if the key is unspecified.">isUnspecified</a>());
  1750. <a name="l01720"></a>01720 <span class="keywordflow">if</span> (<a class="code" href="classBaseOverlay.html#aa53ca4e1b4720ba0d2874afe29eacbf7" title="Handles a failed node.">handleFailedNode</a>(dest)) {
  1751. <a name="l01721"></a>01721 <span class="keywordflow">if</span> (!tempMsg-&gt;<a class="code" href="classBaseRouteMessage.html#ad983641a05758bc9d25070f1659b2f34">getDestKey</a>().<a class="code" href="classOverlayKey.html#abe357a4d1babcf7d30598a61cbc0f5c2" title="Returns true, if the key is unspecified.">isUnspecified</a>()) {
  1752. <a name="l01722"></a>01722 <span class="comment">// TODO: msg is resent only in recursive mode</span>
  1753. <a name="l01723"></a>01723 EV &lt;&lt; <span class="stringliteral">&quot;[BaseOverlay::internalHandleRpcTimeout() @ &quot;</span>
  1754. <a name="l01724"></a>01724 &lt;&lt; <a class="code" href="classBaseRpc.html#a88eb68c06450fd12ea072f471bf1c1b8" title="NodeHandle to this node.">thisNode</a>.<a class="code" href="classTransportAddress.html#a00e613d98d3412e2b92897c25aa0eb4c" title="returns ip address">getIp</a>()
  1755. <a name="l01725"></a>01725 &lt;&lt; <span class="stringliteral">&quot; (&quot;</span> &lt;&lt; <a class="code" href="classBaseRpc.html#a88eb68c06450fd12ea072f471bf1c1b8" title="NodeHandle to this node.">thisNode</a>.<a class="code" href="classNodeHandle.html#aef531103cdf07c8353267f4d30a80112" title="returns key of this NodeHandle">getKey</a>().<a class="code" href="classOverlayKey.html#aabeb4fd284a630a82e982ba34ece4fd9" title="Returns a string representation of this key.">toString</a>(16) &lt;&lt; <span class="stringliteral">&quot;)]\n&quot;</span>
  1756. <a name="l01726"></a>01726 &lt;&lt; <span class="stringliteral">&quot; Resend msg for key &quot;</span> &lt;&lt; destKey
  1757. <a name="l01727"></a>01727 &lt;&lt; endl;
  1758. <a name="l01728"></a>01728 <a class="code" href="classBaseOverlay.html#ac647b32e360b4db1f0eb53b096437fd8" title="Handles a BaseOverlayMessage ">handleBaseOverlayMessage</a>(tempMsg, destKey);
  1759. <a name="l01729"></a>01729 } <span class="keywordflow">else</span> <span class="keywordflow">if</span>(tempMsg-&gt;<a class="code" href="classBaseRouteMessage.html#a4037dda18976c8d98ef3f9ed663f8dc7">getNextHopsArraySize</a>() &gt; 1) {
  1760. <a name="l01730"></a>01730 <span class="keywordflow">for</span> (uint8_t i = 0; i &lt; tempMsg-&gt;<a class="code" href="classBaseRouteMessage.html#a4037dda18976c8d98ef3f9ed663f8dc7">getNextHopsArraySize</a>() - 1; ++i) {
  1761. <a name="l01731"></a>01731 tempMsg-&gt;<a class="code" href="classBaseRouteMessage.html#a85bb1a80fafad5e8a84b1bf96eb8befc">setNextHops</a>(i, tempMsg-&gt;<a class="code" href="classBaseRouteMessage.html#a23f57254381410520aaa67dd52b0bc6c">getNextHops</a>(i + 1));
  1762. <a name="l01732"></a>01732 }
  1763. <a name="l01733"></a>01733 tempMsg-&gt;<a class="code" href="classBaseRouteMessage.html#a3cb14c09b287d613f26d58ad39fec4d0">setNextHopsArraySize</a>(tempMsg-&gt;<a class="code" href="classBaseRouteMessage.html#a4037dda18976c8d98ef3f9ed663f8dc7">getNextHopsArraySize</a>() - 1);
  1764. <a name="l01734"></a>01734 EV &lt;&lt; <span class="stringliteral">&quot;[BaseOverlay::internalHandleRpcTimeout() @ &quot;</span>
  1765. <a name="l01735"></a>01735 &lt;&lt; <a class="code" href="classBaseRpc.html#a88eb68c06450fd12ea072f471bf1c1b8" title="NodeHandle to this node.">thisNode</a>.<a class="code" href="classTransportAddress.html#a00e613d98d3412e2b92897c25aa0eb4c" title="returns ip address">getIp</a>()
  1766. <a name="l01736"></a>01736 &lt;&lt; <span class="stringliteral">&quot; (&quot;</span> &lt;&lt; <a class="code" href="classBaseRpc.html#a88eb68c06450fd12ea072f471bf1c1b8" title="NodeHandle to this node.">thisNode</a>.<a class="code" href="classNodeHandle.html#aef531103cdf07c8353267f4d30a80112" title="returns key of this NodeHandle">getKey</a>().<a class="code" href="classOverlayKey.html#aabeb4fd284a630a82e982ba34ece4fd9" title="Returns a string representation of this key.">toString</a>(16) &lt;&lt; <span class="stringliteral">&quot;)]\n&quot;</span>
  1767. <a name="l01737"></a>01737 &lt;&lt; <span class="stringliteral">&quot; Resend msg to next available node in nextHops[]: &quot;</span>
  1768. <a name="l01738"></a>01738 &lt;&lt; tempMsg-&gt;<a class="code" href="classBaseRouteMessage.html#a23f57254381410520aaa67dd52b0bc6c">getNextHops</a>(0).<a class="code" href="classTransportAddress.html#a00e613d98d3412e2b92897c25aa0eb4c" title="returns ip address">getIp</a>()
  1769. <a name="l01739"></a>01739 &lt;&lt; std::endl;
  1770. <a name="l01740"></a>01740 <a class="code" href="classBaseOverlay.html#ac647b32e360b4db1f0eb53b096437fd8" title="Handles a BaseOverlayMessage ">handleBaseOverlayMessage</a>(tempMsg);
  1771. <a name="l01741"></a>01741 } <span class="keywordflow">else</span> {
  1772. <a name="l01742"></a>01742 EV &lt;&lt; <span class="stringliteral">&quot;[BaseOverlay::internalHandleRpcTimeout() @ &quot;</span>
  1773. <a name="l01743"></a>01743 &lt;&lt; <a class="code" href="classBaseRpc.html#a88eb68c06450fd12ea072f471bf1c1b8" title="NodeHandle to this node.">thisNode</a>.<a class="code" href="classTransportAddress.html#a00e613d98d3412e2b92897c25aa0eb4c" title="returns ip address">getIp</a>()
  1774. <a name="l01744"></a>01744 &lt;&lt; <span class="stringliteral">&quot; (&quot;</span> &lt;&lt; <a class="code" href="classBaseRpc.html#a88eb68c06450fd12ea072f471bf1c1b8" title="NodeHandle to this node.">thisNode</a>.<a class="code" href="classNodeHandle.html#aef531103cdf07c8353267f4d30a80112" title="returns key of this NodeHandle">getKey</a>().<a class="code" href="classOverlayKey.html#aabeb4fd284a630a82e982ba34ece4fd9" title="Returns a string representation of this key.">toString</a>(16) &lt;&lt; <span class="stringliteral">&quot;)]\n&quot;</span>
  1775. <a name="l01745"></a>01745 &lt;&lt; <span class="stringliteral">&quot; dropping msg for &quot;</span> &lt;&lt; dest
  1776. <a name="l01746"></a>01746 &lt;&lt; endl;
  1777. <a name="l01747"></a>01747 <a class="code" href="GlobalStatistics_8h.html#af29140ebe8e0a93406a58441f7c5fec8" title="Macro used for recording statistics considering measureNetwIn parameter.">RECORD_STATS</a>(<a class="code" href="classBaseOverlay.html#a4a82bd4b76a8d06a1d63bba98f1a34d7" title="number of dropped packets">numDropped</a>++;
  1778. <a name="l01748"></a>01748 <a class="code" href="classBaseOverlay.html#a9e09857b97f52d340e4710580f25f7a6" title="number of dropped bytes">bytesDropped</a> += tempMsg-&gt;getByteLength());
  1779. <a name="l01749"></a>01749 <span class="keyword">delete</span> tempMsg;
  1780. <a name="l01750"></a>01750 }
  1781. <a name="l01751"></a>01751 } <span class="keywordflow">else</span> {
  1782. <a name="l01752"></a>01752 <a class="code" href="GlobalStatistics_8h.html#af29140ebe8e0a93406a58441f7c5fec8" title="Macro used for recording statistics considering measureNetwIn parameter.">RECORD_STATS</a>(<a class="code" href="classBaseOverlay.html#a4a82bd4b76a8d06a1d63bba98f1a34d7" title="number of dropped packets">numDropped</a>++;
  1783. <a name="l01753"></a>01753 <a class="code" href="classBaseOverlay.html#a9e09857b97f52d340e4710580f25f7a6" title="number of dropped bytes">bytesDropped</a> += tempMsg-&gt;getByteLength());
  1784. <a name="l01754"></a>01754 <span class="keyword">delete</span> tempMsg;
  1785. <a name="l01755"></a>01755 <a class="code" href="classBaseOverlay.html#acb8855faa86247ae37ab894891d9f4dd" title="Join the overlay with a given nodeID.">join</a>();
  1786. <a name="l01756"></a>01756 }
  1787. <a name="l01757"></a>01757 <span class="keywordflow">break</span>;
  1788. <a name="l01758"></a>01758 }
  1789. <a name="l01759"></a>01759 <a class="code" href="RpcMacros_8h.html#a29a8a3f21e67ecb25f58608a54df5191" title="Marks the end of a Remote-Procedure-Call Switch block.">RPC_SWITCH_END</a>( )
  1790. <a name="l01760"></a>01760
  1791. <a name="l01761"></a>01761 <a class="code" href="classBaseOverlay.html#ac89854c2f011597f3421d414851f4407">BaseRpc::internalHandleRpcTimeout</a>(msg, dest, context, rpcId, destKey);
  1792. <a name="l01762"></a>01762 }
  1793. <a name="l01763"></a>01763
  1794. <a name="l01764"></a><a class="code" href="classBaseOverlay.html#afe4a27831cec5ad68f1ddca071461808">01764</a> <span class="keywordtype">void</span> <a class="code" href="classBaseOverlay.html#afe4a27831cec5ad68f1ddca071461808">BaseOverlay::internalSendRouteRpc</a>(<a class="code" href="classBaseRpcMessage.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">BaseRpcMessage</a>* message,
  1795. <a name="l01765"></a>01765 <span class="keyword">const</span> <a class="code" href="classOverlayKey.html" title="A common overlay key class.">OverlayKey</a>&amp; destKey,
  1796. <a name="l01766"></a>01766 <span class="keyword">const</span> std::vector&lt;TransportAddress&gt;&amp;
  1797. <a name="l01767"></a>01767 sourceRoute,
  1798. <a name="l01768"></a>01768 <a class="code" href="CommonMessages__m_8h.html#a5bbe67ba1134d38bbb89c7c242ba6551" title="Enum generated from common/CommonMessages.msg by opp_msgc.">RoutingType</a> routingType) {
  1799. <a name="l01769"></a>01769 <a class="code" href="classFindNodeCall.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">FindNodeCall</a>* findNodeCall;
  1800. <a name="l01770"></a>01770 uint32_t numSiblings = 1;
  1801. <a name="l01771"></a>01771 <span class="keywordflow">if</span> ((findNodeCall = dynamic_cast&lt;FindNodeCall*&gt;(message)))
  1802. <a name="l01772"></a>01772 numSiblings = findNodeCall-&gt;<a class="code" href="classFindNodeCall.html#ac5a68f5e9f62d37613c5ce47a9348a92">getNumSiblings</a>();
  1803. <a name="l01773"></a>01773
  1804. <a name="l01774"></a>01774 <a class="code" href="classBaseOverlay.html#a6f2c598f5d3989a63a8cc7220f1aaf76" title="Sends a message to an overlay node, with the generic routing algorithm.">sendToKey</a>(destKey, message, numSiblings, sourceRoute, routingType);
  1805. <a name="l01775"></a>01775 }
  1806. <a name="l01776"></a>01776
  1807. <a name="l01777"></a><a class="code" href="classBaseOverlay.html#a3b7e4eeca10c3052e0bb51762fe1ce71">01777</a> <span class="keywordtype">void</span> <a class="code" href="classBaseOverlay.html#a3b7e4eeca10c3052e0bb51762fe1ce71">BaseOverlay::internalSendRpcResponse</a>(<a class="code" href="classBaseCallMessage.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">BaseCallMessage</a>* call,
  1808. <a name="l01778"></a>01778 <a class="code" href="classBaseResponseMessage.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">BaseResponseMessage</a>* response)
  1809. <a name="l01779"></a>01779 {
  1810. <a name="l01780"></a>01780 <a class="code" href="classOverlayCtrlInfo.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">OverlayCtrlInfo</a>* overlayCtrlInfo =
  1811. <a name="l01781"></a>01781 check_and_cast&lt;<a class="code" href="classOverlayCtrlInfo.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">OverlayCtrlInfo</a>*&gt;(call-&gt;getControlInfo());
  1812. <a name="l01782"></a>01782
  1813. <a name="l01783"></a>01783 <a class="code" href="CommonMessages__m_8h.html#aca1e72535e7f260e54ed8bbf984dade9" title="Enum generated from common/CommonMessages.msg by opp_msgc.">TransportType</a> transportType = ROUTE_TRANSPORT;
  1814. <a name="l01784"></a>01784 <span class="keyword">const</span> <a class="code" href="classTransportAddress.html" title="This class implements a common transport address.">TransportAddress</a>* destNode;
  1815. <a name="l01785"></a>01785 <span class="keywordflow">if</span> (overlayCtrlInfo-&gt;<a class="code" href="classOverlayCtrlInfo.html#af6e31869ed325ba04288a69346988343">getSrcNode</a>().<a class="code" href="classNodeHandle.html#ab5136375a4548ced7c2014a73c8743c9" title="indicates if this NodeHandle is specified">isUnspecified</a>()) {
  1816. <a name="l01786"></a>01786 <span class="keywordflow">if</span> (<a class="code" href="classBaseOverlay.html#a84fe39074cd9dc69acf188abf3e2ea12" title="needed by KBR protocols for NAT support">sendRpcResponseToLastHop</a>) {
  1817. <a name="l01787"></a>01787 <span class="comment">// used for KBR protocols to deal with NATs</span>
  1818. <a name="l01788"></a>01788 <span class="comment">// (srcNode in call message may contain private IP address)</span>
  1819. <a name="l01789"></a>01789 destNode = &amp;(overlayCtrlInfo-&gt;<a class="code" href="classOverlayCtrlInfo.html#ad12b7ac74244fb7ab79ebf41e05fe79c">getLastHop</a>());
  1820. <a name="l01790"></a>01790 } <span class="keywordflow">else</span> {
  1821. <a name="l01791"></a>01791 <span class="comment">// used for non-KBR protocols which have to route RPC calls</span>
  1822. <a name="l01792"></a>01792 <span class="comment">// but can&#39;t use BaseRouteMessage (this doesn&#39;t work with NATs)</span>
  1823. <a name="l01793"></a>01793 destNode = &amp;(call-&gt;<a class="code" href="classBaseRpcMessage.html#ada3e122125cfb5acc7350277ca69c45a">getSrcNode</a>());
  1824. <a name="l01794"></a>01794 }
  1825. <a name="l01795"></a>01795 } <span class="keywordflow">else</span> {
  1826. <a name="l01796"></a>01796 destNode = &amp;(overlayCtrlInfo-&gt;<a class="code" href="classOverlayCtrlInfo.html#af6e31869ed325ba04288a69346988343">getSrcNode</a>());
  1827. <a name="l01797"></a>01797 }
  1828. <a name="l01798"></a>01798 <span class="keyword">const</span> <a class="code" href="classOverlayKey.html" title="A common overlay key class.">OverlayKey</a>* destKey = &amp;<a class="code" href="classOverlayKey.html#ac0d4135dff2985e3582fdbed2a37eb75" title="OverlayKey without defined key.">OverlayKey::UNSPECIFIED_KEY</a>;
  1829. <a name="l01799"></a>01799
  1830. <a name="l01800"></a>01800 <a class="code" href="CommonMessages__m_8h.html#a5bbe67ba1134d38bbb89c7c242ba6551" title="Enum generated from common/CommonMessages.msg by opp_msgc.">RoutingType</a> routingType
  1831. <a name="l01801"></a>01801 = <span class="keyword">static_cast&lt;</span><a class="code" href="CommonMessages__m_8h.html#a5bbe67ba1134d38bbb89c7c242ba6551" title="Enum generated from common/CommonMessages.msg by opp_msgc.">RoutingType</a><span class="keyword">&gt;</span>(overlayCtrlInfo-&gt;<a class="code" href="classOverlayCtrlInfo.html#a4b81411df66c4c813b664665731ee38c">getRoutingType</a>());
  1832. <a name="l01802"></a>01802
  1833. <a name="l01803"></a>01803 assert(overlayCtrlInfo-&gt;<a class="code" href="classOverlayCtrlInfo.html#ad80a56dfc9e2b8c5bc12994fee6adda2">getTransportType</a>() != INTERNAL_TRANSPORT);
  1834. <a name="l01804"></a>01804
  1835. <a name="l01805"></a>01805 <span class="keywordflow">if</span> ((overlayCtrlInfo-&gt;<a class="code" href="classOverlayCtrlInfo.html#ad80a56dfc9e2b8c5bc12994fee6adda2">getTransportType</a>() == UDP_TRANSPORT) ||
  1836. <a name="l01806"></a>01806 (routingType == <a class="code" href="CommonMessages__m_8h.html#a5bbe67ba1134d38bbb89c7c242ba6551a18b63fe85aa5e81cd3fca5e3c7c9df82">SEMI_RECURSIVE_ROUTING</a>) ||
  1837. <a name="l01807"></a>01807 (routingType == ITERATIVE_ROUTING) ||
  1838. <a name="l01808"></a>01808 (routingType == <a class="code" href="CommonMessages__m_8h.html#a5bbe67ba1134d38bbb89c7c242ba6551ad60cf756d6bb24af372d7fe7c279f44d">EXHAUSTIVE_ITERATIVE_ROUTING</a>)
  1839. <a name="l01809"></a>01809 ) {
  1840. <a name="l01810"></a>01810 <span class="comment">// received by UDP or direct response (IR, EIR or SRR routing)</span>
  1841. <a name="l01811"></a>01811 transportType = UDP_TRANSPORT;
  1842. <a name="l01812"></a>01812 overlayCtrlInfo-&gt;<a class="code" href="classOverlayCtrlInfo.html#abc4f5e4539b4858443cf29523727a995">setVisitedHopsArraySize</a>(0); <span class="comment">//???</span>
  1843. <a name="l01813"></a>01813 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> ((static_cast&lt;RoutingType&gt; (overlayCtrlInfo-&gt;<a class="code" href="classOverlayCtrlInfo.html#a4b81411df66c4c813b664665731ee38c">getRoutingType</a>())
  1844. <a name="l01814"></a>01814 == <a class="code" href="CommonMessages__m_8h.html#a5bbe67ba1134d38bbb89c7c242ba6551aeec4ce5cac6dae9d3d59b1347a9df957">FULL_RECURSIVE_ROUTING</a>)) {
  1845. <a name="l01815"></a>01815 <span class="comment">// full recursive routing</span>
  1846. <a name="l01816"></a>01816 destKey = &amp;(overlayCtrlInfo-&gt;<a class="code" href="classOverlayCtrlInfo.html#af6e31869ed325ba04288a69346988343">getSrcNode</a>().<a class="code" href="classNodeHandle.html#aef531103cdf07c8353267f4d30a80112" title="returns key of this NodeHandle">getKey</a>());
  1847. <a name="l01817"></a>01817 destNode = &amp;<a class="code" href="classNodeHandle.html#a79bf2c5e29c969cbd0b2581cb188d8a6" title="the unspecified NodeHandle">NodeHandle::UNSPECIFIED_NODE</a>;
  1848. <a name="l01818"></a>01818 }
  1849. <a name="l01819"></a>01819 <span class="comment">// else: source routing -&gt; route back over visited hops</span>
  1850. <a name="l01820"></a>01820
  1851. <a name="l01821"></a>01821 <a class="code" href="classBaseRpc.html#adc06091d348c98a5efbf54fe0afe8747" title="Send Remote-Procedure response message and deletes call message.">sendRpcResponse</a>(transportType,
  1852. <a name="l01822"></a>01822 static_cast&lt;CompType&gt;(overlayCtrlInfo-&gt;<a class="code" href="classOverlayCtrlInfo.html#a79a35b8f98c2fecef8d6bc566c4a7437">getSrcComp</a>()),
  1853. <a name="l01823"></a>01823 *destNode, *destKey, call, response);
  1854. <a name="l01824"></a>01824 }
  1855. <a name="l01825"></a>01825
  1856. <a name="l01826"></a>01826 <span class="comment">//protected: statistic helpers for IterativeLookup</span>
  1857. <a name="l01827"></a><a class="code" href="classBaseOverlay.html#aee7b3e4129a3a624b9112c3b7ae2b6a3">01827</a> <span class="keywordtype">void</span> <a class="code" href="classBaseOverlay.html#aee7b3e4129a3a624b9112c3b7ae2b6a3">BaseOverlay::countFindNodeCall</a>( <span class="keyword">const</span> <a class="code" href="classFindNodeCall.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">FindNodeCall</a>* call )
  1858. <a name="l01828"></a>01828 {
  1859. <a name="l01829"></a>01829 <a class="code" href="GlobalStatistics_8h.html#af29140ebe8e0a93406a58441f7c5fec8" title="Macro used for recording statistics considering measureNetwIn parameter.">RECORD_STATS</a>(<a class="code" href="classBaseOverlay.html#a210e4277548e47f2ec8e772ae5b6eb7f">numFindNodeSent</a>++;
  1860. <a name="l01830"></a>01830 <a class="code" href="classBaseOverlay.html#a99971f360cdde2d41d239418dfad7281">bytesFindNodeSent</a> += call-&gt;getByteLength());
  1861. <a name="l01831"></a>01831 }
  1862. <a name="l01832"></a>01832
  1863. <a name="l01833"></a><a class="code" href="classBaseOverlay.html#a189d4d1410399ecd264b5bfe6fc85e0f">01833</a> <span class="keywordtype">void</span> <a class="code" href="classBaseOverlay.html#a189d4d1410399ecd264b5bfe6fc85e0f">BaseOverlay::countFailedNodeCall</a>( <span class="keyword">const</span> <a class="code" href="classFailedNodeCall.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">FailedNodeCall</a>* call )
  1864. <a name="l01834"></a>01834 {
  1865. <a name="l01835"></a>01835 <a class="code" href="GlobalStatistics_8h.html#af29140ebe8e0a93406a58441f7c5fec8" title="Macro used for recording statistics considering measureNetwIn parameter.">RECORD_STATS</a>(<a class="code" href="classBaseOverlay.html#a2fef63e0e6d6d7c991c9cb2c95db5733">numFailedNodeSent</a>++;
  1866. <a name="l01836"></a>01836 <a class="code" href="classBaseOverlay.html#aca6ed5880fa17a3bfe432deff8d10e7c">bytesFailedNodeSent</a> += call-&gt;getByteLength());
  1867. <a name="l01837"></a>01837 }
  1868. <a name="l01838"></a>01838
  1869. <a name="l01839"></a>01839 <span class="comment">//private: rpc stub</span>
  1870. <a name="l01840"></a><a class="code" href="classBaseOverlay.html#a50680d9b44a779f314baeab200da61dc">01840</a> <span class="keywordtype">void</span> <a class="code" href="classBaseOverlay.html#a50680d9b44a779f314baeab200da61dc">BaseOverlay::findNodeRpc</a>( <a class="code" href="classFindNodeCall.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">FindNodeCall</a>* call )
  1871. <a name="l01841"></a>01841 {
  1872. <a name="l01842"></a>01842 <span class="comment">// if this node is malicious don&#39;t answer a findNodeCall</span>
  1873. <a name="l01843"></a>01843 <span class="keywordflow">if</span> (<a class="code" href="classBaseOverlay.html#a234b046348574d37d811638f0b27a89e" title="Returns true, if node is malicious.">isMalicious</a>() &amp;&amp; <a class="code" href="classBaseOverlay.html#ab53aaadb5dfe6fea1ac6b90db356cc52" title="if node is malicious, it tries a findNode attack">dropFindNodeAttack</a>) {
  1874. <a name="l01844"></a>01844 EV &lt;&lt; <span class="stringliteral">&quot;[BaseOverlay::findNodeRpc() @ &quot;</span> &lt;&lt; <a class="code" href="classBaseRpc.html#a88eb68c06450fd12ea072f471bf1c1b8" title="NodeHandle to this node.">thisNode</a>.<a class="code" href="classTransportAddress.html#a00e613d98d3412e2b92897c25aa0eb4c" title="returns ip address">getIp</a>()
  1875. <a name="l01845"></a>01845 &lt;&lt; <span class="stringliteral">&quot; (&quot;</span> &lt;&lt; <a class="code" href="classBaseRpc.html#a88eb68c06450fd12ea072f471bf1c1b8" title="NodeHandle to this node.">thisNode</a>.<a class="code" href="classNodeHandle.html#aef531103cdf07c8353267f4d30a80112" title="returns key of this NodeHandle">getKey</a>().<a class="code" href="classOverlayKey.html#aabeb4fd284a630a82e982ba34ece4fd9" title="Returns a string representation of this key.">toString</a>(16) &lt;&lt; <span class="stringliteral">&quot;)]\n&quot;</span>
  1876. <a name="l01846"></a>01846 &lt;&lt; <span class="stringliteral">&quot; Node ignores findNodeCall because this node is malicious&quot;</span>
  1877. <a name="l01847"></a>01847 &lt;&lt; endl;
  1878. <a name="l01848"></a>01848 <span class="keyword">delete</span> call;
  1879. <a name="l01849"></a>01849 <span class="keywordflow">return</span>;
  1880. <a name="l01850"></a>01850 }
  1881. <a name="l01851"></a>01851
  1882. <a name="l01852"></a>01852 <a class="code" href="classFindNodeResponse.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">FindNodeResponse</a>* findNodeResponse =
  1883. <a name="l01853"></a>01853 <span class="keyword">new</span> <a class="code" href="classFindNodeResponse.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">FindNodeResponse</a>(<span class="stringliteral">&quot;FindNodeResponse&quot;</span>);
  1884. <a name="l01854"></a>01854
  1885. <a name="l01855"></a>01855 findNodeResponse-&gt;setBitLength(<a class="code" href="CommonMessages__m_8h.html#adf1e0e3719d7a62675c9c873cee6155e">FINDNODERESPONSE_L</a>(findNodeResponse));
  1886. <a name="l01856"></a>01856 <a class="code" href="classBaseKeySortedVector.html">NodeVector</a>* nextHops = <a class="code" href="classBaseOverlay.html#a7cbdce336237331b67a3c69c4e43d489" title="Implements the find node call.">findNode</a>(call-&gt;<a class="code" href="classFindNodeCall.html#a1be5a1314a95df730b18ac73b08d07e8">getLookupKey</a>(),
  1887. <a name="l01857"></a>01857 call-&gt;<a class="code" href="classFindNodeCall.html#ad145ac485f8da308c4b976802cfa48ae">getNumRedundantNodes</a>(),
  1888. <a name="l01858"></a>01858 call-&gt;<a class="code" href="classFindNodeCall.html#ad9bb40597926cfc521e7eb8e10b5f14d">getExhaustiveIterative</a>() ? -1 : call-&gt;<a class="code" href="classFindNodeCall.html#ac5a68f5e9f62d37613c5ce47a9348a92">getNumSiblings</a>(), call);
  1889. <a name="l01859"></a>01859
  1890. <a name="l01860"></a>01860 findNodeResponse-&gt;<a class="code" href="classFindNodeResponse.html#aafe7a51c910c28bec242629aef2146df">setClosestNodesArraySize</a>(nextHops-&gt;size());
  1891. <a name="l01861"></a>01861 <span class="keywordflow">for</span> (uint32_t i=0; i &lt; nextHops-&gt;size(); i++) {
  1892. <a name="l01862"></a>01862 findNodeResponse-&gt;<a class="code" href="classFindNodeResponse.html#aff387edca2f0bdcad9a4c55bbbcd0cbf">setClosestNodes</a>(i, (*nextHops)[i]);
  1893. <a name="l01863"></a>01863 }
  1894. <a name="l01864"></a>01864
  1895. <a name="l01865"></a>01865 <span class="keywordtype">bool</span> err;
  1896. <a name="l01866"></a>01866 <span class="keywordflow">if</span> (!call-&gt;<a class="code" href="classFindNodeCall.html#ad9bb40597926cfc521e7eb8e10b5f14d">getExhaustiveIterative</a>() &amp;&amp;
  1897. <a name="l01867"></a>01867 <a class="code" href="classBaseOverlay.html#ab5887b89ba9da5973068e834feb69ce7" title="Query if a node is among the siblings for a given key.">isSiblingFor</a>(<a class="code" href="classBaseRpc.html#a88eb68c06450fd12ea072f471bf1c1b8" title="NodeHandle to this node.">thisNode</a>, call-&gt;<a class="code" href="classFindNodeCall.html#a1be5a1314a95df730b18ac73b08d07e8">getLookupKey</a>(), call-&gt;<a class="code" href="classFindNodeCall.html#ac5a68f5e9f62d37613c5ce47a9348a92">getNumSiblings</a>(),
  1898. <a name="l01868"></a>01868 &amp;err)) {
  1899. <a name="l01869"></a>01869 findNodeResponse-&gt;<a class="code" href="classFindNodeResponse.html#ae936984960adf1bc123afd2c23448df6">setSiblings</a>(<span class="keyword">true</span>);
  1900. <a name="l01870"></a>01870 }
  1901. <a name="l01871"></a>01871
  1902. <a name="l01872"></a>01872 <span class="keywordflow">if</span> (<a class="code" href="classBaseOverlay.html#a234b046348574d37d811638f0b27a89e" title="Returns true, if node is malicious.">isMalicious</a>() &amp;&amp; <a class="code" href="classBaseOverlay.html#a319a6b16e55af5e67fbbf65f6d07d5d9" title="if node is malicious, it tries a invalidNode attack">invalidNodesAttack</a>) {
  1903. <a name="l01873"></a>01873 <span class="keywordflow">if</span> (<a class="code" href="classBaseOverlay.html#ae70528858c70e2404e0d83824d6f5bbc" title="if node is malicious, it tries a isSibling attack">isSiblingAttack</a>) {
  1904. <a name="l01874"></a>01874 findNodeResponse-&gt;<a class="code" href="classFindNodeResponse.html#ae936984960adf1bc123afd2c23448df6">setSiblings</a>(<span class="keyword">true</span>);
  1905. <a name="l01875"></a>01875 } <span class="keywordflow">else</span> {
  1906. <a name="l01876"></a>01876 findNodeResponse-&gt;<a class="code" href="classFindNodeResponse.html#ae936984960adf1bc123afd2c23448df6">setSiblings</a>(<span class="keyword">false</span>);
  1907. <a name="l01877"></a>01877 }
  1908. <a name="l01878"></a>01878
  1909. <a name="l01879"></a>01879 <span class="keywordtype">int</span> resultSize = <a class="code" href="classBaseOverlay.html#ae70528858c70e2404e0d83824d6f5bbc" title="if node is malicious, it tries a isSibling attack">isSiblingAttack</a> ? call-&gt;<a class="code" href="classFindNodeCall.html#ac5a68f5e9f62d37613c5ce47a9348a92">getNumSiblings</a>() :
  1910. <a name="l01880"></a>01880 call-&gt;<a class="code" href="classFindNodeCall.html#ad145ac485f8da308c4b976802cfa48ae">getNumRedundantNodes</a>();
  1911. <a name="l01881"></a>01881
  1912. <a name="l01882"></a>01882 findNodeResponse-&gt;<a class="code" href="classFindNodeResponse.html#aafe7a51c910c28bec242629aef2146df">setClosestNodesArraySize</a>(resultSize);
  1913. <a name="l01883"></a>01883 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; resultSize; i++) {
  1914. <a name="l01884"></a>01884 findNodeResponse-&gt;<a class="code" href="classFindNodeResponse.html#aff387edca2f0bdcad9a4c55bbbcd0cbf">setClosestNodes</a>(i,
  1915. <a name="l01885"></a>01885 <a class="code" href="classNodeHandle.html" title="This class implements a node handle.">NodeHandle</a>(call-&gt;<a class="code" href="classFindNodeCall.html#a1be5a1314a95df730b18ac73b08d07e8">getLookupKey</a>() + i, IPvXAddress(IPAddress(
  1916. <a name="l01886"></a>01886 <a class="code" href="classBaseOverlay.html#ae70528858c70e2404e0d83824d6f5bbc" title="if node is malicious, it tries a isSibling attack">isSiblingAttack</a> ? (424242+i) : intuniform(42,123123))), 42));
  1917. <a name="l01887"></a>01887 <span class="preprocessor">#if 0</span>
  1918. <a name="l01888"></a>01888 <span class="preprocessor"></span> <span class="comment">// was not used for evaluation</span>
  1919. <a name="l01889"></a>01889 <span class="keywordflow">if</span> ((i == 0) &amp;&amp; <a class="code" href="classBaseOverlay.html#ae70528858c70e2404e0d83824d6f5bbc" title="if node is malicious, it tries a isSibling attack">isSiblingAttack</a>) {
  1920. <a name="l01890"></a>01890 findNodeResponse-&gt;<a class="code" href="classFindNodeResponse.html#aff387edca2f0bdcad9a4c55bbbcd0cbf">setClosestNodes</a>(0, <a class="code" href="classBaseRpc.html#a88eb68c06450fd12ea072f471bf1c1b8" title="NodeHandle to this node.">thisNode</a>);
  1921. <a name="l01891"></a>01891 }
  1922. <a name="l01892"></a>01892 <span class="preprocessor">#endif</span>
  1923. <a name="l01893"></a>01893 <span class="preprocessor"></span> }
  1924. <a name="l01894"></a>01894 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="classBaseOverlay.html#a234b046348574d37d811638f0b27a89e" title="Returns true, if node is malicious.">isMalicious</a>() &amp;&amp; <a class="code" href="classBaseOverlay.html#ae70528858c70e2404e0d83824d6f5bbc" title="if node is malicious, it tries a isSibling attack">isSiblingAttack</a>) {
  1925. <a name="l01895"></a>01895 findNodeResponse-&gt;<a class="code" href="classFindNodeResponse.html#ae936984960adf1bc123afd2c23448df6">setSiblings</a>(<span class="keyword">true</span>);
  1926. <a name="l01896"></a>01896 findNodeResponse-&gt;<a class="code" href="classFindNodeResponse.html#aafe7a51c910c28bec242629aef2146df">setClosestNodesArraySize</a>(1);
  1927. <a name="l01897"></a>01897 findNodeResponse-&gt;<a class="code" href="classFindNodeResponse.html#aff387edca2f0bdcad9a4c55bbbcd0cbf">setClosestNodes</a>(0, <a class="code" href="classBaseRpc.html#a88eb68c06450fd12ea072f471bf1c1b8" title="NodeHandle to this node.">thisNode</a>);
  1928. <a name="l01898"></a>01898 }
  1929. <a name="l01899"></a>01899
  1930. <a name="l01900"></a>01900 findNodeResponse-&gt;setBitLength(<a class="code" href="CommonMessages__m_8h.html#adf1e0e3719d7a62675c9c873cee6155e">FINDNODERESPONSE_L</a>(findNodeResponse));
  1931. <a name="l01901"></a>01901
  1932. <a name="l01902"></a>01902 <span class="keywordflow">if</span> (call-&gt;hasObject(<span class="stringliteral">&quot;findNodeExt&quot;</span>)) {
  1933. <a name="l01903"></a>01903 cPacket* findNodeExt = check_and_cast&lt;cPacket*&gt;(call-&gt;removeObject(<span class="stringliteral">&quot;findNodeExt&quot;</span>));
  1934. <a name="l01904"></a>01904 findNodeResponse-&gt;addObject(findNodeExt);
  1935. <a name="l01905"></a>01905 findNodeResponse-&gt;addBitLength(findNodeExt-&gt;getBitLength());
  1936. <a name="l01906"></a>01906 }
  1937. <a name="l01907"></a>01907
  1938. <a name="l01908"></a>01908 <a class="code" href="GlobalStatistics_8h.html#af29140ebe8e0a93406a58441f7c5fec8" title="Macro used for recording statistics considering measureNetwIn parameter.">RECORD_STATS</a>(<a class="code" href="classBaseOverlay.html#a248581eed6fedf10b2c350cbedd69773">numFindNodeResponseSent</a>++; <a class="code" href="classBaseOverlay.html#a4b2293e58a3bf5a7ddc0d28cb0669f2f">bytesFindNodeResponseSent</a> +=
  1939. <a name="l01909"></a>01909 findNodeResponse-&gt;getByteLength());
  1940. <a name="l01910"></a>01910
  1941. <a name="l01911"></a>01911 <span class="keyword">delete</span> nextHops;
  1942. <a name="l01912"></a>01912
  1943. <a name="l01913"></a>01913 <a class="code" href="classBaseRpc.html#adc06091d348c98a5efbf54fe0afe8747" title="Send Remote-Procedure response message and deletes call message.">sendRpcResponse</a>(call, findNodeResponse);
  1944. <a name="l01914"></a>01914 }
  1945. <a name="l01915"></a>01915
  1946. <a name="l01916"></a>01916
  1947. <a name="l01917"></a><a class="code" href="classBaseOverlay.html#a1655dc0cb4ebb2f22de1d1ee29030433">01917</a> <span class="keywordtype">void</span> <a class="code" href="classBaseOverlay.html#a1655dc0cb4ebb2f22de1d1ee29030433">BaseOverlay::failedNodeRpc</a>( <a class="code" href="classFailedNodeCall.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">FailedNodeCall</a>* call )
  1948. <a name="l01918"></a>01918 {
  1949. <a name="l01919"></a>01919 <a class="code" href="classFailedNodeResponse.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">FailedNodeResponse</a>* failedNodeResponse =
  1950. <a name="l01920"></a>01920 <span class="keyword">new</span> <a class="code" href="classFailedNodeResponse.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">FailedNodeResponse</a>(<span class="stringliteral">&quot;FailedNodeResponse&quot;</span>);
  1951. <a name="l01921"></a>01921 failedNodeResponse-&gt;<a class="code" href="classFailedNodeResponse.html#ac8a44e9e9cdc649d6ee7ab893a97e17f">setTryAgain</a>(<a class="code" href="classBaseOverlay.html#aa53ca4e1b4720ba0d2874afe29eacbf7" title="Handles a failed node.">handleFailedNode</a>(call-&gt;<a class="code" href="classFailedNodeCall.html#a5a47646a10bc9e34503a4635121ef85c">getFailedNode</a>()));
  1952. <a name="l01922"></a>01922 failedNodeResponse-&gt;setBitLength(<a class="code" href="CommonMessages__m_8h.html#ae470e5deb63f7debd17b8666514dae46">FAILEDNODERESPONSE_L</a>(failedNodeResponse));
  1953. <a name="l01923"></a>01923
  1954. <a name="l01924"></a>01924 <span class="keywordflow">if</span> (call-&gt;hasObject(<span class="stringliteral">&quot;findNodeExt&quot;</span>)) {
  1955. <a name="l01925"></a>01925 cPacket* findNodeExt = check_and_cast&lt;cPacket*&gt;(
  1956. <a name="l01926"></a>01926 call-&gt;removeObject(<span class="stringliteral">&quot;findNodeExt&quot;</span>));
  1957. <a name="l01927"></a>01927 failedNodeResponse-&gt;addObject(findNodeExt);
  1958. <a name="l01928"></a>01928 failedNodeResponse-&gt;addBitLength(findNodeExt-&gt;getBitLength());
  1959. <a name="l01929"></a>01929 }
  1960. <a name="l01930"></a>01930
  1961. <a name="l01931"></a>01931 <a class="code" href="GlobalStatistics_8h.html#af29140ebe8e0a93406a58441f7c5fec8" title="Macro used for recording statistics considering measureNetwIn parameter.">RECORD_STATS</a>(<a class="code" href="classBaseOverlay.html#acf40707599a177a1dd5cd9ec4e854dc8">numFailedNodeResponseSent</a>++; <a class="code" href="classBaseOverlay.html#aa62ca9476d42c748e40dd0f287823445">bytesFailedNodeResponseSent</a> +=
  1962. <a name="l01932"></a>01932 failedNodeResponse-&gt;getByteLength());
  1963. <a name="l01933"></a>01933
  1964. <a name="l01934"></a>01934 <a class="code" href="classBaseRpc.html#adc06091d348c98a5efbf54fe0afe8747" title="Send Remote-Procedure response message and deletes call message.">sendRpcResponse</a>(call, failedNodeResponse);
  1965. <a name="l01935"></a>01935 }
  1966. <a name="l01936"></a>01936
  1967. <a name="l01937"></a><a class="code" href="classBaseOverlay.html#aa9d874edfd1b52822e1693695420d5a7">01937</a> <span class="keywordtype">void</span> <a class="code" href="classBaseOverlay.html#aa9d874edfd1b52822e1693695420d5a7">BaseOverlay::lookupRpc</a>(<a class="code" href="classLookupCall.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">LookupCall</a>* call)
  1968. <a name="l01938"></a>01938 {
  1969. <a name="l01939"></a>01939 <span class="keywordtype">int</span> numSiblings = call-&gt;<a class="code" href="classLookupCall.html#a5be7c8b099438db99f2fb0c129ff1edb">getNumSiblings</a>();
  1970. <a name="l01940"></a>01940
  1971. <a name="l01941"></a>01941 <span class="keywordflow">if</span> (numSiblings &lt; 0) {
  1972. <a name="l01942"></a>01942 numSiblings = <a class="code" href="classBaseOverlay.html#acd3058ad15b470e024500dd4872e2f09" title="Query the maximum number of siblings (nodes close to a key) that are maintained by this overlay proto...">getMaxNumSiblings</a>();
  1973. <a name="l01943"></a>01943 }
  1974. <a name="l01944"></a>01944
  1975. <a name="l01945"></a>01945 <span class="keywordflow">if</span> (<a class="code" href="classBaseOverlay.html#aa484556ed4ff9e4e97394106d0c1d323" title="internal overlay state used for setOverlayReady()">internalReadyState</a> == <span class="keyword">false</span>) {
  1976. <a name="l01946"></a>01946 <span class="comment">// overlay not ready =&gt; lookup failed</span>
  1977. <a name="l01947"></a>01947 EV &lt;&lt; <span class="stringliteral">&quot;[BaseOverlay::lookupRpc() @ &quot;</span>
  1978. <a name="l01948"></a>01948 &lt;&lt; <a class="code" href="classBaseRpc.html#ac3f420630d5618e81709c078b06fd9da" title="Returns the NodeHandle of this node.">getThisNode</a>().<a class="code" href="classTransportAddress.html#a00e613d98d3412e2b92897c25aa0eb4c" title="returns ip address">getIp</a>()
  1979. <a name="l01949"></a>01949 &lt;&lt; <span class="stringliteral">&quot; (&quot;</span> &lt;&lt; <a class="code" href="classBaseRpc.html#ac3f420630d5618e81709c078b06fd9da" title="Returns the NodeHandle of this node.">getThisNode</a>().<a class="code" href="classNodeHandle.html#aef531103cdf07c8353267f4d30a80112" title="returns key of this NodeHandle">getKey</a>().<a class="code" href="classOverlayKey.html#aabeb4fd284a630a82e982ba34ece4fd9" title="Returns a string representation of this key.">toString</a>(16) &lt;&lt; <span class="stringliteral">&quot;)]\n&quot;</span>
  1980. <a name="l01950"></a>01950 &lt;&lt; <span class="stringliteral">&quot; LookupCall &quot;</span>
  1981. <a name="l01951"></a>01951 &lt;&lt; call-&gt;<a class="code" href="classBaseRpcMessage.html#a79f78c32aa4461025a89e8de3bc35702">getNonce</a>()
  1982. <a name="l01952"></a>01952 &lt;&lt; <span class="stringliteral">&quot; failed, because overlay module is not ready!&quot;</span> &lt;&lt; endl;
  1983. <a name="l01953"></a>01953
  1984. <a name="l01954"></a>01954 <a class="code" href="classLookupResponse.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">LookupResponse</a>* response = <span class="keyword">new</span> <a class="code" href="classLookupResponse.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">LookupResponse</a>();
  1985. <a name="l01955"></a>01955 response-&gt;<a class="code" href="classLookupResponse.html#a1caf06537b25c06685f0d24be5cd74fe">setKey</a>(call-&gt;<a class="code" href="classLookupCall.html#ac899d550007c1e632e299e917d38b705">getKey</a>());
  1986. <a name="l01956"></a>01956 response-&gt;<a class="code" href="classLookupResponse.html#a6d307ceeb8f4325c3373c3464cff45be">setIsValid</a>(<span class="keyword">false</span>);
  1987. <a name="l01957"></a>01957
  1988. <a name="l01958"></a>01958 <a class="code" href="classBaseRpc.html#adc06091d348c98a5efbf54fe0afe8747" title="Send Remote-Procedure response message and deletes call message.">sendRpcResponse</a>(call, response);
  1989. <a name="l01959"></a>01959
  1990. <a name="l01960"></a>01960 <span class="keywordflow">return</span>;
  1991. <a name="l01961"></a>01961 }
  1992. <a name="l01962"></a>01962
  1993. <a name="l01963"></a>01963 <span class="comment">// create lookup and sent to key</span>
  1994. <a name="l01964"></a>01964 <a class="code" href="classAbstractLookup.html" title="This class declares an abstract iterative lookup.">AbstractLookup</a>* lookup = <a class="code" href="classBaseOverlay.html#a205a7d44401fb3d77b146e23b2904b6f" title="Creates an abstract iterative lookup instance.">createLookup</a>(static_cast&lt;RoutingType&gt;(
  1995. <a name="l01965"></a>01965 call-&gt;<a class="code" href="classLookupCall.html#ad0d7ad53c1de441b8567c8c3ecf17753">getRoutingType</a>()), call, NULL, <span class="keyword">true</span>);
  1996. <a name="l01966"></a>01966 lookup-&gt;<a class="code" href="classAbstractLookup.html#aa1bda70950cbd160ea78d1fcbd8c7767" title="Lookup siblings for a key.">lookup</a>(call-&gt;<a class="code" href="classLookupCall.html#ac899d550007c1e632e299e917d38b705">getKey</a>(), numSiblings, <a class="code" href="classBaseOverlay.html#abffe6fbd25963bc2b7542f22ba6455b9" title="maximum hop count">hopCountMax</a>,
  1997. <a name="l01967"></a>01967 1, <span class="keyword">new</span> <a class="code" href="classBaseOverlay.html#a4083c91b7d09ceaa7fd2768570814d77">SendToKeyListener</a>( <span class="keyword">this</span>, call ));
  1998. <a name="l01968"></a>01968 }
  1999. <a name="l01969"></a>01969
  2000. <a name="l01970"></a><a class="code" href="classBaseOverlay.html#a3eef9db326747d930a455db3b884dac4">01970</a> <span class="keywordtype">void</span> <a class="code" href="classBaseOverlay.html#a3eef9db326747d930a455db3b884dac4">BaseOverlay::nextHopRpc</a>(<a class="code" href="classNextHopCall.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">NextHopCall</a>* call)
  2001. <a name="l01971"></a>01971 {
  2002. <a name="l01972"></a>01972 <span class="keywordflow">if</span> (<a class="code" href="classBaseOverlay.html#ab4be6d88417117fbf33a445d56af2655">state</a> != <a class="code" href="classBaseOverlay.html#a0ad4b12b0c9949661f66db7fbbf7d40fab3a263fb274a58d63b15cd61ba910335">READY</a>) {
  2003. <a name="l01973"></a>01973 <span class="comment">//TODO EV...</span>
  2004. <a name="l01974"></a>01974 <span class="keyword">delete</span> call;
  2005. <a name="l01975"></a>01975 <span class="keywordflow">return</span>;
  2006. <a name="l01976"></a>01976 }
  2007. <a name="l01977"></a>01977
  2008. <a name="l01978"></a>01978 <a class="code" href="classBaseRouteMessage.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">BaseRouteMessage</a>* routeMsg
  2009. <a name="l01979"></a>01979 = check_and_cast&lt;<a class="code" href="classBaseRouteMessage.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">BaseRouteMessage</a>*&gt;(call-&gt;decapsulate());
  2010. <a name="l01980"></a>01980
  2011. <a name="l01981"></a>01981 <a class="code" href="classOverlayCtrlInfo.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">OverlayCtrlInfo</a>* overlayCtrlInfo =
  2012. <a name="l01982"></a>01982 check_and_cast&lt;<a class="code" href="classOverlayCtrlInfo.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">OverlayCtrlInfo</a>*&gt;(call-&gt;getControlInfo()-&gt;<a class="code" href="classNextHopCall.html#a9ba4dbf11d99bbff0399ae3e0b43ab6a">dup</a>());
  2013. <a name="l01983"></a>01983 overlayCtrlInfo-&gt;setHopCount(routeMsg-&gt;<a class="code" href="classBaseRouteMessage.html#ab59d2969c812aa35d132a68fc2baf819">getHopCount</a>());
  2014. <a name="l01984"></a>01984 overlayCtrlInfo-&gt;<a class="code" href="classBaseRpcMessage.html#a02c1e30ce0998325630ef1abdcac1354">setSrcNode</a>(routeMsg-&gt;<a class="code" href="classBaseRouteMessage.html#af9787d89915f01a2055e920148015e17">getSrcNode</a>());
  2015. <a name="l01985"></a>01985 overlayCtrlInfo-&gt;setRoutingType(routeMsg-&gt;<a class="code" href="classBaseRouteMessage.html#a834dd9c8f0b2b776ed5f5b1fa285149a">getRoutingType</a>());
  2016. <a name="l01986"></a>01986
  2017. <a name="l01987"></a>01987 routeMsg-&gt;setControlInfo(overlayCtrlInfo);
  2018. <a name="l01988"></a>01988 assert(routeMsg-&gt;getControlInfo());
  2019. <a name="l01989"></a>01989
  2020. <a name="l01990"></a>01990 std::string temp(<span class="stringliteral">&quot;ACK: [&quot;</span>);
  2021. <a name="l01991"></a>01991 (temp += routeMsg-&gt;getName()) += <span class="stringliteral">&quot;]&quot;</span>;
  2022. <a name="l01992"></a>01992
  2023. <a name="l01993"></a>01993 <a class="code" href="classNextHopResponse.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">NextHopResponse</a>* response
  2024. <a name="l01994"></a>01994 = <span class="keyword">new</span> <a class="code" href="classNextHopResponse.html" title="Class generated from common/CommonMessages.msg by opp_msgc.">NextHopResponse</a>(temp.c_str());
  2025. <a name="l01995"></a>01995 response-&gt;setBitLength(<a class="code" href="CommonMessages__m_8h.html#adc9bda6bf3f1e194f083e32df15f237d">NEXTHOPRESPONSE_L</a>(response));
  2026. <a name="l01996"></a>01996 <a class="code" href="classBaseRpc.html#adc06091d348c98a5efbf54fe0afe8747" title="Send Remote-Procedure response message and deletes call message.">sendRpcResponse</a>(call, response);
  2027. <a name="l01997"></a>01997
  2028. <a name="l01998"></a>01998 <a class="code" href="classBaseOverlay.html#ac647b32e360b4db1f0eb53b096437fd8" title="Handles a BaseOverlayMessage ">handleBaseOverlayMessage</a>(routeMsg, routeMsg-&gt;<a class="code" href="classBaseRouteMessage.html#ad983641a05758bc9d25070f1659b2f34">getDestKey</a>());
  2029. <a name="l01999"></a>01999 }
  2030. <a name="l02000"></a>02000
  2031. <a name="l02001"></a><a class="code" href="classBaseOverlay.html#a2096f89814b5740257cee106b60dda15">02001</a> <span class="keywordtype">void</span> <a class="code" href="classBaseOverlay.html#a2096f89814b5740257cee106b60dda15">BaseOverlay::registerComp</a>(<a class="code" href="CommonMessages__m_8h.html#aad57ef0110fe8675eb299d467148bc5e" title="Enum generated from common/CommonMessages.msg by opp_msgc.">CompType</a> compType, cModule *module)
  2032. <a name="l02002"></a>02002 {
  2033. <a name="l02003"></a>02003 cGate *gate = NULL;
  2034. <a name="l02004"></a>02004
  2035. <a name="l02005"></a>02005 <span class="keywordflow">if</span> (module != NULL) {
  2036. <a name="l02006"></a>02006 gate = module-&gt;gate(<span class="stringliteral">&quot;direct_in&quot;</span>);
  2037. <a name="l02007"></a>02007 <span class="keywordflow">if</span> (gate == NULL) {
  2038. <a name="l02008"></a>02008 <span class="keywordflow">throw</span> cRuntimeError(<span class="stringliteral">&quot;BaseOverlay::registerComp(): The module &quot;</span>
  2039. <a name="l02009"></a>02009 <span class="stringliteral">&quot;which tried to register has &quot;</span>
  2040. <a name="l02010"></a>02010 <span class="stringliteral">&quot;no direct_in gate!&quot;</span>);
  2041. <a name="l02011"></a>02011 }
  2042. <a name="l02012"></a>02012 }
  2043. <a name="l02013"></a>02013
  2044. <a name="l02014"></a>02014 <a class="code" href="classBaseOverlay.html#a572cbbdedbbc386f1d9c3851e9250be7">compModuleList</a>[compType] = make_pair&lt;cModule*, cGate*&gt;(module, gate);
  2045. <a name="l02015"></a>02015 }
  2046. <a name="l02016"></a>02016
  2047. <a name="l02017"></a><a class="code" href="classBaseOverlay.html#a3aba2b6e93094d3cc8107d33db4b5244">02017</a> cModule* <a class="code" href="classBaseOverlay.html#a3aba2b6e93094d3cc8107d33db4b5244">BaseOverlay::getCompModule</a>(<a class="code" href="CommonMessages__m_8h.html#aad57ef0110fe8675eb299d467148bc5e" title="Enum generated from common/CommonMessages.msg by opp_msgc.">CompType</a> compType)
  2048. <a name="l02018"></a>02018 {
  2049. <a name="l02019"></a>02019 CompModuleList::iterator it = <a class="code" href="classBaseOverlay.html#a572cbbdedbbc386f1d9c3851e9250be7">compModuleList</a>.find(compType);
  2050. <a name="l02020"></a>02020
  2051. <a name="l02021"></a>02021 <span class="keywordflow">if</span> (it != <a class="code" href="classBaseOverlay.html#a572cbbdedbbc386f1d9c3851e9250be7">compModuleList</a>.end())
  2052. <a name="l02022"></a>02022 <span class="keywordflow">return</span> it-&gt;second.first;
  2053. <a name="l02023"></a>02023 <span class="keywordflow">else</span>
  2054. <a name="l02024"></a>02024 <span class="keywordflow">return</span> NULL;
  2055. <a name="l02025"></a>02025 }
  2056. <a name="l02026"></a>02026
  2057. <a name="l02027"></a><a class="code" href="classBaseOverlay.html#a5fc03fda227c0cca828109842af1b320">02027</a> cGate* <a class="code" href="classBaseOverlay.html#a5fc03fda227c0cca828109842af1b320">BaseOverlay::getCompRpcGate</a>(<a class="code" href="CommonMessages__m_8h.html#aad57ef0110fe8675eb299d467148bc5e" title="Enum generated from common/CommonMessages.msg by opp_msgc.">CompType</a> compType)
  2058. <a name="l02028"></a>02028 {
  2059. <a name="l02029"></a>02029 CompModuleList::iterator it = <a class="code" href="classBaseOverlay.html#a572cbbdedbbc386f1d9c3851e9250be7">compModuleList</a>.find(compType);
  2060. <a name="l02030"></a>02030
  2061. <a name="l02031"></a>02031 <span class="keywordflow">if</span> (it != <a class="code" href="classBaseOverlay.html#a572cbbdedbbc386f1d9c3851e9250be7">compModuleList</a>.end())
  2062. <a name="l02032"></a>02032 <span class="keywordflow">return</span> it-&gt;second.second;
  2063. <a name="l02033"></a>02033 <span class="keywordflow">else</span>
  2064. <a name="l02034"></a>02034 <span class="keywordflow">return</span> NULL;
  2065. <a name="l02035"></a>02035 }
  2066. <a name="l02036"></a>02036
  2067. <a name="l02037"></a><a class="code" href="classBaseOverlay.html#a19c2c01f99a19bb7de0b30cdd866a2e0">02037</a> <span class="keywordtype">void</span> <a class="code" href="classBaseOverlay.html#a19c2c01f99a19bb7de0b30cdd866a2e0">BaseOverlay::sendMessageToAllComp</a>(cMessage* msg, <a class="code" href="CommonMessages__m_8h.html#aad57ef0110fe8675eb299d467148bc5e" title="Enum generated from common/CommonMessages.msg by opp_msgc.">CompType</a> srcComp)
  2068. <a name="l02038"></a>02038 {
  2069. <a name="l02039"></a>02039 Enter_Method_Silent();
  2070. <a name="l02040"></a>02040 take(msg);
  2071. <a name="l02041"></a>02041
  2072. <a name="l02042"></a>02042 <span class="keywordflow">for</span> (CompModuleList::iterator it = <a class="code" href="classBaseOverlay.html#a572cbbdedbbc386f1d9c3851e9250be7">compModuleList</a>.begin();
  2073. <a name="l02043"></a>02043 it != <a class="code" href="classBaseOverlay.html#a572cbbdedbbc386f1d9c3851e9250be7">compModuleList</a>.end(); it++) {
  2074. <a name="l02044"></a>02044
  2075. <a name="l02045"></a>02045 <span class="comment">// don&#39;t send message to the origination component</span>
  2076. <a name="l02046"></a>02046 <span class="keywordflow">if</span> (it-&gt;first != srcComp)
  2077. <a name="l02047"></a>02047 sendDirect((cMessage*)msg-&gt;dup(), it-&gt;second.second);
  2078. <a name="l02048"></a>02048 }
  2079. <a name="l02049"></a>02049
  2080. <a name="l02050"></a>02050 <span class="keyword">delete</span> msg;
  2081. <a name="l02051"></a>02051 }
  2082. <a name="l02052"></a>02052
  2083. <a name="l02053"></a><a class="code" href="classBaseOverlay.html#abef37828b7f070044154f53bcd2a765b">02053</a> <span class="keywordtype">bool</span> <a class="code" href="classBaseOverlay.html#abef37828b7f070044154f53bcd2a765b" title="Returns true if overlay is one in an array, inside a SimpleMultiOverlayHost.">BaseOverlay::isInSimpleMultiOverlayHost</a>()
  2084. <a name="l02054"></a>02054 {
  2085. <a name="l02055"></a>02055 <span class="keywordflow">return</span> isVector() || getParentModule()-&gt;isVector();
  2086. <a name="l02056"></a>02056 }
  2087. <a name="l02057"></a>02057
  2088. </pre></div></div>
  2089. </div>
  2090. <hr class="footer"/><address class="footer"><small>Generated on Wed Nov 3 2010 14:40:43 for OverSim by&nbsp;
  2091. <a href="http://www.doxygen.org/index.html">
  2092. <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.1 </small></address>
  2093. </body>
  2094. </html>