Contact.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 "Contact.h"
00019 #include "bundling/Bundle.h"
00020 #include "bundling/BundleDaemon.h"
00021 #include "bundling/BundleEvent.h"
00022 #include "bundling/BundleList.h"
00023 #include "conv_layers/ConvergenceLayer.h"
00024 
00025 namespace dtn {
00026 
00030 Contact::Contact(Link* link)
00031     : RefCountedObject("/dtn/contact/refs"),
00032       Logger("Contact", "/dtn/contact/%s",link->name()),
00033       link_(link), cl_info_(NULL)
00034 {
00035     ::gettimeofday(&start_time_, 0);
00036     duration_ms_ = 0;
00037     bps_         = 0;
00038     latency_ms_  = 0;
00039     
00040     log_info("new contact *%p", this);
00041 }
00042 
00043 Contact::~Contact()
00044 {
00045     ASSERT(cl_info_ == NULL);
00046 }
00047 
00051 int
00052 Contact::format(char* buf, size_t sz) const
00053 {
00054     return snprintf(buf, sz, "contact %s (started %u.%u)",
00055                     link_->nexthop(),
00056                     (u_int32_t)start_time_.tv_sec,
00057                     (u_int32_t)start_time_.tv_usec);
00058 }
00059 
00060 void
00061 Contact::serialize(oasys::SerializeAction *a)
00062 {
00063     // casting won't be necessary after port to oasys::Time
00064     a->process("start_time_sec",
00065         reinterpret_cast< u_int32_t * >(&start_time_.tv_sec));
00066     a->process("start_time_usec",
00067         reinterpret_cast< u_int32_t * >(&start_time_.tv_usec));
00068 
00069     a->process("duration", &duration_ms_);
00070     a->process("bps", &bps_);
00071     a->process("latency", &latency_ms_);
00072     a->process("link", link_);
00073 }
00074 
00075 } // namespace dtn

Generated on Sat Sep 8 08:43:26 2007 for DTN Reference Implementation by  doxygen 1.5.3