<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> <title>DTN Reference Implementation: Node.cc Source File</title> <link href="tabs.css" rel="stylesheet" type="text/css"> <link href="doxygen.css" rel="stylesheet" type="text/css"> </head><body> <!-- Generated by Doxygen 1.5.8 --> <div class="navigation" id="top"> <div class="tabs"> <ul> <li><a href="main.html"><span>Main Page</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li><a href="annotated.html"><span>Classes</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> </ul> </div> <div class="tabs"> <ul> <li><a href="files.html"><span>File List</span></a></li> <li><a href="globals.html"><span>File Members</span></a></li> </ul> </div> <h1>Node.cc</h1><a href="sim_2Node_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> <a name="l00002"></a>00002 <span class="comment"> * Copyright 2004-2006 Intel Corporation</span> <a name="l00003"></a>00003 <span class="comment"> * </span> <a name="l00004"></a>00004 <span class="comment"> * Licensed under the Apache License, Version 2.0 (the "License");</span> <a name="l00005"></a>00005 <span class="comment"> * you may not use this file except in compliance with the License.</span> <a name="l00006"></a>00006 <span class="comment"> * You may obtain a copy of the License at</span> <a name="l00007"></a>00007 <span class="comment"> * </span> <a name="l00008"></a>00008 <span class="comment"> * http://www.apache.org/licenses/LICENSE-2.0</span> <a name="l00009"></a>00009 <span class="comment"> * </span> <a name="l00010"></a>00010 <span class="comment"> * Unless required by applicable law or agreed to in writing, software</span> <a name="l00011"></a>00011 <span class="comment"> * distributed under the License is distributed on an "AS IS" BASIS,</span> <a name="l00012"></a>00012 <span class="comment"> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</span> <a name="l00013"></a>00013 <span class="comment"> * See the License for the specific language governing permissions and</span> <a name="l00014"></a>00014 <span class="comment"> * limitations under the License.</span> <a name="l00015"></a>00015 <span class="comment"> */</span> <a name="l00016"></a>00016 <a name="l00017"></a>00017 <span class="preprocessor">#ifdef HAVE_CONFIG_H</span> <a name="l00018"></a>00018 <span class="preprocessor"></span><span class="preprocessor"># include <<a class="code" href="dtn-config_8h.html">dtn-config.h</a>></span> <a name="l00019"></a>00019 <span class="preprocessor">#endif</span> <a name="l00020"></a>00020 <span class="preprocessor"></span> <a name="l00021"></a>00021 <span class="preprocessor">#include <oasys/thread/Timer.h></span> <a name="l00022"></a>00022 <span class="preprocessor">#include "<a class="code" href="SimEvent_8h.html">SimEvent.h</a>"</span> <a name="l00023"></a>00023 <span class="preprocessor">#include "<a class="code" href="SimLog_8h.html">SimLog.h</a>"</span> <a name="l00024"></a>00024 <span class="preprocessor">#include "<a class="code" href="sim_2Node_8h.html">Node.h</a>"</span> <a name="l00025"></a>00025 <span class="preprocessor">#include "<a class="code" href="BundleDaemon_8h.html">bundling/BundleDaemon.h</a>"</span> <a name="l00026"></a>00026 <span class="preprocessor">#include "<a class="code" href="ContactManager_8h.html">contacts/ContactManager.h</a>"</span> <a name="l00027"></a>00027 <span class="preprocessor">#include "<a class="code" href="contacts_2Link_8h.html">contacts/Link.h</a>"</span> <a name="l00028"></a>00028 <span class="preprocessor">#include "<a class="code" href="BundleRouter_8h.html">routing/BundleRouter.h</a>"</span> <a name="l00029"></a>00029 <span class="preprocessor">#include "<a class="code" href="RouteTable_8h.html">routing/RouteTable.h</a>"</span> <a name="l00030"></a>00030 <span class="preprocessor">#include "<a class="code" href="Registration_8h.html">reg/Registration.h</a>"</span> <a name="l00031"></a>00031 <a name="l00032"></a>00032 <span class="keyword">using namespace </span>dtn; <a name="l00033"></a>00033 <a name="l00034"></a>00034 <span class="keyword">namespace </span>dtnsim { <a name="l00035"></a>00035 <a name="l00036"></a>00036 <span class="comment">//----------------------------------------------------------------------</span> <a name="l00037"></a><a class="code" href="classdtnsim_1_1Node.html#074e93c9bad5de54eb57ddffff72ef75">00037</a> <a class="code" href="classdtnsim_1_1Node.html#074e93c9bad5de54eb57ddffff72ef75" title="Constructor.">Node::Node</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* name) <a name="l00038"></a>00038 : <a class="code" href="classdtn_1_1BundleDaemon.html" title="Class that handles the basic event / action mechanism.">BundleDaemon</a>(), name_(name), <a name="l00039"></a>00039 storage_config_(<span class="stringliteral">"storage"</span>, <a name="l00040"></a>00040 <span class="stringliteral">"memorydb"</span>, <a name="l00041"></a>00041 <span class="stringliteral">"DTN"</span>, <span class="stringliteral">""</span>) <a name="l00042"></a>00042 <a name="l00043"></a>00043 { <a name="l00044"></a>00044 logpathf(<span class="stringliteral">"/node/%s"</span>, name); <a name="l00045"></a>00045 log_info(<span class="stringliteral">"node %s initializing..."</span>, name); <a name="l00046"></a>00046 <a name="l00047"></a>00047 <a class="code" href="classdtnsim_1_1Node.html#d9b58bb48d37ea621beb559338291ea3" title="Fake-Durable storage.">storage_config_</a>.init_ = <span class="keyword">true</span>; <a name="l00048"></a>00048 <a class="code" href="classdtnsim_1_1Node.html#d9b58bb48d37ea621beb559338291ea3" title="Fake-Durable storage.">storage_config_</a>.tidy_ = <span class="keyword">true</span>; <a name="l00049"></a>00049 <a class="code" href="classdtnsim_1_1Node.html#d9b58bb48d37ea621beb559338291ea3" title="Fake-Durable storage.">storage_config_</a>.tidy_wait_ = 0; <a name="l00050"></a>00050 <a class="code" href="classdtnsim_1_1Node.html#d9b58bb48d37ea621beb559338291ea3" title="Fake-Durable storage.">storage_config_</a>.leave_clean_file_ = <span class="keyword">false</span>; <a name="l00051"></a>00051 <a name="l00052"></a>00052 <span class="comment">// XXX/demmer see comment in BundlePayload::init</span> <a name="l00053"></a>00053 <a class="code" href="classdtnsim_1_1Node.html#d9b58bb48d37ea621beb559338291ea3" title="Fake-Durable storage.">storage_config_</a>.<a class="code" href="classdtn_1_1DTNStorageConfig.html#47eba04a1384e682f940d679a2578cea" title="Directory to store payload files.">payload_dir_</a> = <span class="stringliteral">"NO_PAYLOAD_FILES"</span>; <a name="l00054"></a>00054 } <a name="l00055"></a>00055 <a name="l00056"></a>00056 <span class="comment">//----------------------------------------------------------------------</span> <a name="l00057"></a>00057 <span class="keywordtype">void</span> <a name="l00058"></a><a class="code" href="classdtnsim_1_1Node.html#4414744591be052f32086caab4c4ebde">00058</a> <a class="code" href="classdtnsim_1_1Node.html#4414744591be052f32086caab4c4ebde" title="Virtual initialization function.">Node::do_init</a>() <a name="l00059"></a>00059 { <a name="l00060"></a>00060 BundleDaemon::instance_ = <span class="keyword">this</span>; <a name="l00061"></a>00061 <a name="l00062"></a>00062 <a class="code" href="classdtn_1_1BundleDaemon.html#83688d1a99907ab38c64cd4ddb443358" title="The active bundle actions handler.">actions_</a> = <span class="keyword">new</span> <a class="code" href="classdtn_1_1BundleDaemon.html#e81b8ce094725bbc983ec42961d8032e">BundleActions</a>(); <a name="l00063"></a>00063 <a class="code" href="classdtnsim_1_1Node.html#68523cb4ac21974e55273049f4a90c7e" title="The event queue.">eventq_</a> = <span class="keyword">new</span> std::queue<BundleEvent*>(); <a name="l00064"></a>00064 <a name="l00065"></a>00065 <span class="comment">// forcibly create a new timer system and storage systems</span> <a name="l00066"></a>00066 oasys::Singleton<oasys::TimerSystem>::force_set_instance(NULL); <a name="l00067"></a>00067 oasys::TimerSystem::create(); <a name="l00068"></a>00068 <a class="code" href="classdtnsim_1_1Node.html#ebf1cc7d563fac70eeddcf450ec9b9ea">timersys_</a> = oasys::TimerSystem::instance(); <a name="l00069"></a>00069 <a name="l00070"></a>00070 <a class="code" href="classdtnsim_1_1Node.html#0cbd475b36f5f23d1eabab80e59be58d" title="Fake-Durable storage.">store_</a> = <span class="keyword">new</span> oasys::DurableStore(<span class="stringliteral">"/dtnsim/storage"</span>); <a name="l00071"></a>00071 <a class="code" href="classdtnsim_1_1Node.html#0cbd475b36f5f23d1eabab80e59be58d" title="Fake-Durable storage.">store_</a>->create_store(<a class="code" href="classdtnsim_1_1Node.html#d9b58bb48d37ea621beb559338291ea3" title="Fake-Durable storage.">storage_config_</a>); <a name="l00072"></a>00072 <a name="l00073"></a>00073 <span class="comment">// we only have one GlobalStore because it's useful to have unique</span> <a name="l00074"></a>00074 <span class="comment">// bundle ids across all nodes in the system, so initialize it the</span> <a name="l00075"></a>00075 <span class="comment">// first node that gets created</span> <a name="l00076"></a>00076 <span class="keywordflow">if</span> (! GlobalStore::initialized()) { <a name="l00077"></a>00077 <span class="keywordflow">if</span> (GlobalStore::init(<a class="code" href="classdtnsim_1_1Node.html#d9b58bb48d37ea621beb559338291ea3" title="Fake-Durable storage.">storage_config_</a>, <a class="code" href="classdtnsim_1_1Node.html#0cbd475b36f5f23d1eabab80e59be58d" title="Fake-Durable storage.">store_</a>) != 0) { <a name="l00078"></a>00078 PANIC(<span class="stringliteral">"Error initializing GlobalStore"</span>); <a name="l00079"></a>00079 } <a name="l00080"></a>00080 } <a name="l00081"></a>00081 <a name="l00082"></a>00082 <span class="comment">// the other stores are faux-singletons with an instance per node</span> <a name="l00083"></a>00083 BundleStore::force_set_instance(NULL); <a name="l00084"></a>00084 ProphetStore::force_set_instance(NULL); <a name="l00085"></a>00085 LinkStore::force_set_instance(NULL); <a name="l00086"></a>00086 RegistrationStore::force_set_instance(NULL); <a name="l00087"></a>00087 <a name="l00088"></a>00088 log_info(<span class="stringliteral">"creating storage tables"</span>); <a name="l00089"></a>00089 <span class="keywordflow">if</span> ((BundleStore::init(<a class="code" href="classdtnsim_1_1Node.html#d9b58bb48d37ea621beb559338291ea3" title="Fake-Durable storage.">storage_config_</a>, <a class="code" href="classdtnsim_1_1Node.html#0cbd475b36f5f23d1eabab80e59be58d" title="Fake-Durable storage.">store_</a>) != 0) || <a name="l00090"></a>00090 (LinkStore::init(<a class="code" href="classdtnsim_1_1Node.html#d9b58bb48d37ea621beb559338291ea3" title="Fake-Durable storage.">storage_config_</a>, <a class="code" href="classdtnsim_1_1Node.html#0cbd475b36f5f23d1eabab80e59be58d" title="Fake-Durable storage.">store_</a>) != 0) || <a name="l00091"></a>00091 (ProphetStore::init(<a class="code" href="classdtnsim_1_1Node.html#d9b58bb48d37ea621beb559338291ea3" title="Fake-Durable storage.">storage_config_</a>, <a class="code" href="classdtnsim_1_1Node.html#0cbd475b36f5f23d1eabab80e59be58d" title="Fake-Durable storage.">store_</a>) != 0) || <a name="l00092"></a>00092 (RegistrationStore::init(<a class="code" href="classdtnsim_1_1Node.html#d9b58bb48d37ea621beb559338291ea3" title="Fake-Durable storage.">storage_config_</a>, <a class="code" href="classdtnsim_1_1Node.html#0cbd475b36f5f23d1eabab80e59be58d" title="Fake-Durable storage.">store_</a>) != 0)) <a name="l00093"></a>00093 { <a name="l00094"></a>00094 PANIC(<span class="stringliteral">"Error initializing storage tables"</span>); <a name="l00095"></a>00095 } <a name="l00096"></a>00096 <a name="l00097"></a>00097 <a class="code" href="classdtnsim_1_1Node.html#70a9ca590a1dd34edc510a32cc321ac7" title="Fake-Durable storage.">bundle_store_</a> = BundleStore::instance(); <a name="l00098"></a>00098 <a class="code" href="classdtnsim_1_1Node.html#df5cdf590d56fc1e6d0b26543f757058" title="Fake-Durable storage.">prophet_store_</a> = ProphetStore::instance(); <a name="l00099"></a>00099 <a class="code" href="classdtnsim_1_1Node.html#235f8e658986689890ebe8d945c99e3d" title="Fake-Durable storage.">link_store_</a> = LinkStore::instance(); <a name="l00100"></a>00100 <a class="code" href="classdtnsim_1_1Node.html#ace72cb87ffc528a9fa15ef65d087bc4" title="Fake-Durable storage.">reg_store_</a> = RegistrationStore::instance(); <a name="l00101"></a>00101 } <a name="l00102"></a>00102 <a name="l00103"></a>00103 <span class="comment">//----------------------------------------------------------------------</span> <a name="l00104"></a>00104 <span class="keywordtype">void</span> <a name="l00105"></a><a class="code" href="classdtnsim_1_1Node.html#5f8ad70a765bbb1b8d8e8d07ef502036">00105</a> <a class="code" href="classdtnsim_1_1Node.html#5f8ad70a765bbb1b8d8e8d07ef502036" title="Set the node as the &quot;active&quot; node in the simulation.">Node::set_active</a>() <a name="l00106"></a>00106 { <a name="l00107"></a>00107 <span class="keywordflow">if</span> (instance_ == <span class="keyword">this</span>) <span class="keywordflow">return</span>; <a name="l00108"></a>00108 <a name="l00109"></a>00109 instance_ = <span class="keyword">this</span>; <a name="l00110"></a>00110 oasys::Singleton<oasys::TimerSystem>::force_set_instance(<a class="code" href="classdtnsim_1_1Node.html#ebf1cc7d563fac70eeddcf450ec9b9ea">timersys_</a>); <a name="l00111"></a>00111 oasys::Log::instance()->set_prefix(<a class="code" href="classdtnsim_1_1Node.html#e08954a873c45b5778c2250b3bd7ce30">name_</a>.c_str()); <a name="l00112"></a>00112 <a name="l00113"></a>00113 BundleStore::force_set_instance(<a class="code" href="classdtnsim_1_1Node.html#70a9ca590a1dd34edc510a32cc321ac7" title="Fake-Durable storage.">bundle_store_</a>); <a name="l00114"></a>00114 ProphetStore::force_set_instance(<a class="code" href="classdtnsim_1_1Node.html#df5cdf590d56fc1e6d0b26543f757058" title="Fake-Durable storage.">prophet_store_</a>); <a name="l00115"></a>00115 LinkStore::force_set_instance(<a class="code" href="classdtnsim_1_1Node.html#235f8e658986689890ebe8d945c99e3d" title="Fake-Durable storage.">link_store_</a>); <a name="l00116"></a>00116 RegistrationStore::force_set_instance(<a class="code" href="classdtnsim_1_1Node.html#ace72cb87ffc528a9fa15ef65d087bc4" title="Fake-Durable storage.">reg_store_</a>); <a name="l00117"></a>00117 } <a name="l00118"></a>00118 <a name="l00119"></a>00119 <span class="comment">//----------------------------------------------------------------------</span> <a name="l00120"></a>00120 <span class="keywordtype">void</span> <a name="l00121"></a><a class="code" href="classdtnsim_1_1Node.html#ce2bf5e05e9fa6890f42fa921deadaba">00121</a> <a class="code" href="classdtnsim_1_1Node.html#ce2bf5e05e9fa6890f42fa921deadaba" title="Second pass at initialization, called by the simulator once the whole config has...">Node::configure</a>() <a name="l00122"></a>00122 { <a name="l00123"></a>00123 <a class="code" href="classdtnsim_1_1Node.html#5f8ad70a765bbb1b8d8e8d07ef502036" title="Set the node as the &quot;active&quot; node in the simulation.">set_active</a>(); <a name="l00124"></a>00124 <a name="l00125"></a>00125 <a class="code" href="classdtn_1_1BundleDaemon.html#a5c8a244aad225987f9359ee1c2a1101" title="The active bundle router.">router_</a> = BundleRouter::create_router(BundleRouter::config_.type_.c_str()); <a name="l00126"></a>00126 <a class="code" href="classdtn_1_1BundleDaemon.html#a5c8a244aad225987f9359ee1c2a1101" title="The active bundle router.">router_</a>-><a class="code" href="classdtn_1_1BundleRouter.html#58bdadd6a5f618d44cd4c2084acc707c">initialize</a>(); <a name="l00127"></a>00127 } <a name="l00128"></a>00128 <a name="l00129"></a>00129 <span class="comment">//----------------------------------------------------------------------</span> <a name="l00130"></a>00130 <span class="keywordtype">void</span> <a name="l00131"></a><a class="code" href="classdtnsim_1_1Node.html#0986c0f6d3eeec3fba7779a3d6d38513">00131</a> <a class="code" href="classdtnsim_1_1Node.html#0986c0f6d3eeec3fba7779a3d6d38513" title="Virtual post function, overridden in the simulator to use the modified event queue...">Node::post_event</a>(<a class="code" href="classdtn_1_1BundleEvent.html" title="Event base class.">BundleEvent</a>* event, <span class="keywordtype">bool</span> at_back) <a name="l00132"></a>00132 { <a name="l00133"></a>00133 (void)at_back; <a name="l00134"></a>00134 log_debug(<span class="stringliteral">"posting event (%p) with type %s at %s "</span>, <a name="l00135"></a>00135 event, event-><a class="code" href="classdtn_1_1BundleEvent.html#34ad7fcefe5984584fe304fdecc96d4b" title="Used for printing.">type_str</a>(),at_back ? <span class="stringliteral">"back"</span> : <span class="stringliteral">"head"</span>); <a name="l00136"></a>00136 <a name="l00137"></a>00137 <a class="code" href="classdtnsim_1_1Node.html#68523cb4ac21974e55273049f4a90c7e" title="The event queue.">eventq_</a>->push(event); <a name="l00138"></a>00138 } <a name="l00139"></a>00139 <a name="l00140"></a>00140 <span class="comment">//----------------------------------------------------------------------</span> <a name="l00141"></a>00141 <span class="keywordtype">bool</span> <a name="l00142"></a><a class="code" href="classdtnsim_1_1Node.html#ec11501277a101b0e58382de65dad675">00142</a> <a class="code" href="classdtnsim_1_1Node.html#ec11501277a101b0e58382de65dad675" title="Drain and process a bundle event from the queue, if one exists.">Node::process_one_bundle_event</a>() <a name="l00143"></a>00143 { <a name="l00144"></a>00144 <a class="code" href="classdtn_1_1BundleEvent.html" title="Event base class.">BundleEvent</a>* event; <a name="l00145"></a>00145 <span class="keywordflow">if</span> (!<a class="code" href="classdtnsim_1_1Node.html#68523cb4ac21974e55273049f4a90c7e" title="The event queue.">eventq_</a>->empty()) { <a name="l00146"></a>00146 <span class="keyword">event</span> = <a class="code" href="classdtnsim_1_1Node.html#68523cb4ac21974e55273049f4a90c7e" title="The event queue.">eventq_</a>->front(); <a name="l00147"></a>00147 <a class="code" href="classdtnsim_1_1Node.html#68523cb4ac21974e55273049f4a90c7e" title="The event queue.">eventq_</a>->pop(); <a name="l00148"></a>00148 <a class="code" href="classdtn_1_1BundleDaemon.html#6590936f52512c792e7c26bf02ddabc8" title="Main event handling function.">handle_event</a>(event); <a name="l00149"></a>00149 <span class="keyword">delete</span> event; <a name="l00150"></a>00150 log_debug(<span class="stringliteral">"event (%p) %s processed and deleted"</span>,event,event-><a class="code" href="classdtn_1_1BundleEvent.html#34ad7fcefe5984584fe304fdecc96d4b" title="Used for printing.">type_str</a>()); <a name="l00151"></a>00151 <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l00152"></a>00152 } <a name="l00153"></a>00153 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00154"></a>00154 } <a name="l00155"></a>00155 <a name="l00156"></a>00156 <span class="comment">//----------------------------------------------------------------------</span> <a name="l00157"></a>00157 <span class="keywordtype">void</span> <a name="l00158"></a><a class="code" href="classdtnsim_1_1Node.html#bf0a05a33ba6ad52d63bc4083b03f8a4">00158</a> <a class="code" href="classdtnsim_1_1Node.html#bf0a05a33ba6ad52d63bc4083b03f8a4" title="Run the given event immediately.">Node::run_one_event_now</a>(<a class="code" href="classdtn_1_1BundleEvent.html" title="Event base class.">BundleEvent</a>* event) <a name="l00159"></a>00159 { <a name="l00160"></a>00160 <a class="code" href="classdtnsim_1_1Node.html" title="Class representing a node in the simulator (i.e.">Node</a>* cur_active = <a class="code" href="classdtnsim_1_1Node.html#0092d41cdd29927ede0833a8164885e9" title="Return the current active node.">active_node</a>(); <a name="l00161"></a>00161 <a class="code" href="classdtnsim_1_1Node.html#5f8ad70a765bbb1b8d8e8d07ef502036" title="Set the node as the &quot;active&quot; node in the simulation.">set_active</a>(); <a name="l00162"></a>00162 <a class="code" href="classdtn_1_1BundleDaemon.html#6590936f52512c792e7c26bf02ddabc8" title="Main event handling function.">handle_event</a>(event); <a name="l00163"></a>00163 log_debug(<span class="stringliteral">"event (%p) %s processed"</span>,event,event-><a class="code" href="classdtn_1_1BundleEvent.html#34ad7fcefe5984584fe304fdecc96d4b" title="Used for printing.">type_str</a>()); <a name="l00164"></a>00164 cur_active-><a class="code" href="classdtnsim_1_1Node.html#5f8ad70a765bbb1b8d8e8d07ef502036" title="Set the node as the &quot;active&quot; node in the simulation.">set_active</a>(); <a name="l00165"></a>00165 } <a name="l00166"></a>00166 <a name="l00167"></a>00167 <span class="comment">//----------------------------------------------------------------------</span> <a name="l00168"></a>00168 <span class="keywordtype">void</span> <a name="l00169"></a><a class="code" href="classdtnsim_1_1Node.html#5e28e4d8b0ae960002aec66a189b2c05">00169</a> <a class="code" href="classdtnsim_1_1Node.html#5e28e4d8b0ae960002aec66a189b2c05" title="Virtual function from SimEventHandler.">Node::process</a>(<a class="code" href="classdtnsim_1_1SimEvent.html">SimEvent</a>* e) <a name="l00170"></a>00170 { <a name="l00171"></a>00171 <span class="keywordflow">switch</span> (e-><a class="code" href="classdtnsim_1_1SimEvent.html#bce459b06f5ab4673ed662e7d4aec1ad">type</a>()) { <a name="l00172"></a>00172 <span class="keywordflow">case</span> <a class="code" href="namespacedtnsim.html#61b536ebb250b12bfe00104b1f33ef4d8596082fcc66c6a30e055876698de9bc" title="Generic event for delayed bundle events.">SIM_BUNDLE_EVENT</a>: <a name="l00173"></a>00173 <a class="code" href="classdtnsim_1_1Node.html#0986c0f6d3eeec3fba7779a3d6d38513" title="Virtual post function, overridden in the simulator to use the modified event queue...">post_event</a>(((<a class="code" href="classdtnsim_1_1SimBundleEvent.html">SimBundleEvent</a>*)e)->event_); <a name="l00174"></a>00174 <span class="keywordflow">break</span>; <a name="l00175"></a>00175 <a name="l00176"></a>00176 <span class="keywordflow">default</span>: <a name="l00177"></a>00177 NOTREACHED; <a name="l00178"></a>00178 } <a name="l00179"></a>00179 } <a name="l00180"></a>00180 <a name="l00181"></a>00181 <span class="comment">//----------------------------------------------------------------------</span> <a name="l00182"></a>00182 <span class="keywordtype">void</span> <a name="l00183"></a><a class="code" href="classdtnsim_1_1Node.html#2a573065ddac7d2f9523546659bc55ca">00183</a> <a class="code" href="classdtnsim_1_1Node.html#2a573065ddac7d2f9523546659bc55ca" title="Overridden event handlers from BundleDaemon.">Node::handle_bundle_delivered</a>(<a class="code" href="classdtn_1_1BundleDeliveredEvent.html" title="Event class for local bundle delivery.">BundleDeliveredEvent</a>* event) <a name="l00184"></a>00184 { <a name="l00185"></a>00185 SimLog::instance()->log_arrive(<span class="keyword">this</span>, event-><a class="code" href="classdtn_1_1BundleDeliveredEvent.html#da93626e6dcfca7b887be2d7a17fa8ac" title="The delivered bundle.">bundleref_</a>.object()); <a name="l00186"></a>00186 <a class="code" href="classdtnsim_1_1Node.html#2a573065ddac7d2f9523546659bc55ca" title="Overridden event handlers from BundleDaemon.">BundleDaemon::handle_bundle_delivered</a>(event); <a name="l00187"></a>00187 } <a name="l00188"></a>00188 <a name="l00189"></a>00189 <span class="comment">//----------------------------------------------------------------------</span> <a name="l00190"></a>00190 <span class="keywordtype">void</span> <a name="l00191"></a><a class="code" href="classdtnsim_1_1Node.html#a50d612c8e5c31110fb6000f4e46d5e2">00191</a> <a class="code" href="classdtnsim_1_1Node.html#a50d612c8e5c31110fb6000f4e46d5e2" title="Event type specific handlers.">Node::handle_bundle_received</a>(<a class="code" href="classdtn_1_1BundleReceivedEvent.html" title="Event class for new bundle arrivals.">BundleReceivedEvent</a>* event) <a name="l00192"></a>00192 { <a name="l00193"></a>00193 <a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>* bundle = <span class="keyword">event</span>->bundleref_.object(); <a name="l00194"></a>00194 SimLog::instance()->log_recv(<span class="keyword">this</span>, bundle); <a name="l00195"></a>00195 <a name="l00196"></a>00196 <span class="comment">// XXX/demmer this needs to look at the history of all duplicates,</span> <a name="l00197"></a>00197 <span class="comment">// not just the duplicates right now...</span> <a name="l00198"></a>00198 <a name="l00199"></a>00199 <a class="code" href="classdtn_1_1Bundle.html" title="The internal representation of a bundle.">Bundle</a>* duplicate = <a class="code" href="classdtn_1_1BundleDaemon.html#feb7761e0df0015e0af4dca266d7bd47" title="Check if there are any bundles in the pending queue that match the source id, timestamp...">find_duplicate</a>(bundle); <a name="l00200"></a>00200 <span class="keywordflow">if</span> (duplicate != NULL) { <a name="l00201"></a>00201 SimLog::instance()->log_dup(<span class="keyword">this</span>, bundle); <a name="l00202"></a>00202 } <a name="l00203"></a>00203 <a class="code" href="classdtnsim_1_1Node.html#a50d612c8e5c31110fb6000f4e46d5e2" title="Event type specific handlers.">BundleDaemon::handle_bundle_received</a>(event); <a name="l00204"></a>00204 } <a name="l00205"></a>00205 <a name="l00206"></a>00206 <span class="comment">//----------------------------------------------------------------------</span> <a name="l00207"></a>00207 <span class="keywordtype">void</span> <a name="l00208"></a><a class="code" href="classdtnsim_1_1Node.html#f37ddd1f3a80a3d4a42526bece7f470f">00208</a> <a class="code" href="classdtnsim_1_1Node.html#f37ddd1f3a80a3d4a42526bece7f470f" title="Event type specific handlers.">Node::handle_bundle_transmitted</a>(<a class="code" href="classdtn_1_1BundleTransmittedEvent.html" title="Event class for bundle or fragment transmission.">BundleTransmittedEvent</a>* event) <a name="l00209"></a>00209 { <a name="l00210"></a>00210 SimLog::instance()->log_xmit(<span class="keyword">this</span>, event-><a class="code" href="classdtn_1_1BundleTransmittedEvent.html#1d7eb733d3768632525dc99663473b2c" title="The transmitted bundle.">bundleref_</a>.object()); <a name="l00211"></a>00211 <a class="code" href="classdtnsim_1_1Node.html#f37ddd1f3a80a3d4a42526bece7f470f" title="Event type specific handlers.">BundleDaemon::handle_bundle_transmitted</a>(event); <a name="l00212"></a>00212 } <a name="l00213"></a>00213 <a name="l00214"></a>00214 <a name="l00215"></a>00215 <span class="comment">//----------------------------------------------------------------------</span> <a name="l00216"></a>00216 <span class="keywordtype">void</span> <a name="l00217"></a><a class="code" href="classdtnsim_1_1Node.html#f4577b4131d52ea9f225e33d900307f7">00217</a> <a class="code" href="classdtnsim_1_1Node.html#f4577b4131d52ea9f225e33d900307f7" title="Event type specific handlers.">Node::handle_bundle_expired</a>(<a class="code" href="classdtn_1_1BundleExpiredEvent.html" title="Event class for bundle expiration.">BundleExpiredEvent</a>* event) <a name="l00218"></a>00218 { <a name="l00219"></a>00219 SimLog::instance()->log_expire(<span class="keyword">this</span>, event-><a class="code" href="classdtn_1_1BundleExpiredEvent.html#ff03d709b5e05b88f372b75d8644c7eb" title="The expired bundle.">bundleref_</a>.object()); <a name="l00220"></a>00220 <a class="code" href="classdtnsim_1_1Node.html#f4577b4131d52ea9f225e33d900307f7" title="Event type specific handlers.">BundleDaemon::handle_bundle_expired</a>(event); <a name="l00221"></a>00221 } <a name="l00222"></a>00222 <a name="l00223"></a>00223 } <span class="comment">// namespace dtnsim</span> </pre></div></div> <hr size="1"><address style="text-align: right;"><small>Generated on Fri Jan 30 09:26:57 2009 for DTN Reference Implementation by <a href="http://www.doxygen.org/index.html"> <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.8 </small></address> </body> </html>