00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #ifndef lint
00036 static const char rcsid[] =
00037 "@(#) $Header: /nfs/jade/vint/CVSROOT/ns-2/plm/loss-monitor-plm.cc,v 1.2 2000/09/01 03:04:11 haoboy Exp $ (LBL)";
00038 #endif
00039
00040 #include <tclcl.h>
00041 #include "loss-monitor.h"
00042
00043 class PLMLossMonitor : public LossMonitor {
00044 public:
00045 PLMLossMonitor();
00046 virtual void recv(Packet* pkt, Handler*);
00047 protected:
00048
00049 int flag_PP_;
00050 double packet_time_PP_;
00051 int fid_PP_;
00052 };
00053
00054 static class PLMLossMonitorClass : public TclClass {
00055 public:
00056 PLMLossMonitorClass() : TclClass("Agent/LossMonitor/PLM") {}
00057 TclObject* create(int, const char*const*) {
00058 return (new PLMLossMonitor());
00059 }
00060 } class_loss_mon_plm;
00061
00062 PLMLossMonitor::PLMLossMonitor() : LossMonitor()
00063 {
00064 flag_PP_ = 0;
00065 bind("flag_PP_", &flag_PP_);
00066 bind("packet_time_PP_", &packet_time_PP_);
00067 bind("fid_PP_", &fid_PP_);
00068 bind("seqno_", &seqno_);
00069 }
00070
00071 void PLMLossMonitor::recv(Packet* pkt, Handler*)
00072 {
00073 packet_time_PP_ = Scheduler::instance().clock();
00074 hdr_ip* iph = HDR_IP(pkt);
00075 fid_PP_ = iph->flowid();
00076
00077 hdr_rtp* p = HDR_RTP(pkt);
00078 seqno_ = p->seqno();
00079 bytes_ += HDR_CMN(pkt)->size();
00080 flag_PP_ = p->flags();
00081 ++npkts_;
00082
00083
00084
00085 if (expected_ >= 0) {
00086 int loss = seqno_ - expected_;
00087 if (loss > 0) {
00088 nlost_ += loss;
00089 Tcl::instance().evalf("%s log-loss", name());
00090 }
00091 }
00092 Tcl::instance().evalf("%s log-PP", name());
00093 last_packet_time_ = Scheduler::instance().clock();
00094 expected_ = seqno_ + 1;
00095 Packet::free(pkt);
00096 }