00001 /* -*- Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */ 00002 /* 00003 * Copyright (c) Xerox Corporation 1997. All rights reserved. 00004 * 00005 * License is granted to copy, to use, and to make and to use derivative 00006 * works for research and evaluation purposes, provided that Xerox is 00007 * acknowledged in all documentation pertaining to any such copy or 00008 * derivative work. Xerox grants no other licenses expressed or 00009 * implied. The Xerox trade name should not be used in any advertising 00010 * without its written permission. 00011 * 00012 * XEROX CORPORATION MAKES NO REPRESENTATIONS CONCERNING EITHER THE 00013 * MERCHANTABILITY OF THIS SOFTWARE OR THE SUITABILITY OF THIS SOFTWARE 00014 * FOR ANY PARTICULAR PURPOSE. The software is provided "as is" without 00015 * express or implied warranty of any kind. 00016 * 00017 * These notices must be retained in any copies of any part of this 00018 * software. 00019 * 00020 * $Header: /nfs/jade/vint/CVSROOT/ns-2/tools/measuremod.cc,v 1.4 2000/09/01 03:04:06 haoboy Exp $ 00021 */ 00022 00023 //Basic Measurement block derived from a connector 00024 //measures bits sent and average packet delay in a measurement interval 00025 00026 #include "packet.h" 00027 #include "connector.h" 00028 #include "measuremod.h" 00029 00030 static class MeasureModClass : public TclClass { 00031 public: 00032 MeasureModClass() : TclClass("MeasureMod") {} 00033 TclObject* create(int, const char*const*) { 00034 return (new MeasureMod()); 00035 } 00036 }class_measuremod; 00037 00038 00039 MeasureMod::MeasureMod() : nbits_(0),npkts_(0) 00040 { 00041 } 00042 00043 00044 void MeasureMod::recv(Packet *p,Handler *h) 00045 { 00046 hdr_cmn *ch = hdr_cmn::access(p); 00047 nbits_ += ch->size()<<3; 00048 npkts_++; 00049 send(p,h); 00050 }
1.3.3