SimRegistration.cc

Go to the documentation of this file.
00001 /*
00002  *    Copyright 2004-2006 Intel Corporation
00003  * 
00004  *    Licensed under the Apache License, Version 2.0 (the "License");
00005  *    you may not use this file except in compliance with the License.
00006  *    You may obtain a copy of the License at
00007  * 
00008  *        http://www.apache.org/licenses/LICENSE-2.0
00009  * 
00010  *    Unless required by applicable law or agreed to in writing, software
00011  *    distributed under the License is distributed on an "AS IS" BASIS,
00012  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  *    See the License for the specific language governing permissions and
00014  *    limitations under the License.
00015  */
00016 
00017 
00018 #include <oasys/util/StringBuffer.h>
00019 
00020 #include "Simulator.h"
00021 #include "SimRegistration.h"
00022 #include "Topology.h"
00023 #include "bundling/Bundle.h"
00024 #include "bundling/BundleDaemon.h"
00025 #include "bundling/BundleEvent.h"
00026 #include "storage/GlobalStore.h"
00027 
00028 using namespace dtn;
00029 
00030 namespace dtnsim {
00031 
00032 SimRegistration::SimRegistration(Node* node, const EndpointID& endpoint)
00033     : Registration(GlobalStore::instance()->next_regid(),
00034                    endpoint, DEFER, 0), node_(node)
00035 {
00036     logpathf("/reg/%s/%d", node->name(), regid_);
00037 
00038     log_debug("new sim registration");
00039 }
00040 
00041 void
00042 SimRegistration::deliver_bundle(Bundle* bundle)
00043 {
00044     size_t payload_len = bundle->payload_.length();
00045 
00046     log_info("N[%s]: RCV id:%d %s -> %s size:%zu",
00047              node_->name(), bundle->bundleid_,
00048              bundle->source_.c_str(), bundle->dest_.c_str(),
00049              payload_len);
00050 
00051     BundleDaemon::post(new BundleDeliveredEvent(bundle, this));
00052 
00053     // hold a reference on the bundle to put it in the arrivals table
00054     double now = Simulator::time();
00055     arrivals_[now] = bundle; 
00056 }
00057 
00058 } // namespace dtnsim

Generated on Sat Sep 8 08:36:18 2007 for DTN Reference Implementation by  doxygen 1.5.3