00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
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
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 }