adaptive-receiver.cc

Go to the documentation of this file.
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  * This program is free software; you can redistribute it and/or modify it
00006  * under the terms of the GNU General Public License as published by the
00007  * Free Software Foundation; either version 2 of the License, or (at your
00008  * option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful, but
00011  * WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  * General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License along
00016  * with this program; if not, write to the Free Software Foundation, Inc.,
00017  * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00018  *
00019  * Linking this file statically or dynamically with other modules is making
00020  * a combined work based on this file.  Thus, the terms and conditions of
00021  * the GNU General Public License cover the whole combination.
00022  *
00023  * In addition, as a special exception, the copyright holders of this file
00024  * give you permission to combine this file with free software programs or
00025  * libraries that are released under the GNU LGPL and with code included in
00026  * the standard release of ns-2 under the Apache 2.0 license or under
00027  * otherwise-compatible licenses with advertising requirements (or modified
00028  * versions of such code, with unchanged license).  You may copy and
00029  * distribute such a system following the terms of the GNU GPL for this
00030  * file and the licenses of the other code concerned, provided that you
00031  * include the source code of that other code when and as the GNU GPL
00032  * requires distribution of source code.
00033  *
00034  * Note that people who make modified versions of this file are not
00035  * obligated to grant this special exception for their modified versions;
00036  * it is their choice whether to do so.  The GNU General Public License
00037  * gives permission to release a modified version without this exception;
00038  * this exception also makes it possible to release a modified version
00039  * which carries forward this exception.
00040  */
00041 
00042 #ifndef lint
00043 static const char rcsid[] =
00044     "@(#) $Header: /nfs/jade/vint/CVSROOT/ns-2/adc/adaptive-receiver.cc,v 1.8 2005/08/26 05:05:27 tomh Exp $";
00045 #endif
00046 
00047 #include "config.h"
00048 #include "agent.h"
00049 #include "tclcl.h"
00050 #include "packet.h"
00051 #include "ip.h"
00052 #include "rtp.h"
00053 #include "adaptive-receiver.h"
00054 #include <math.h>
00055 
00056 #define myabs(r) (r<0)?-r:r
00057 
00058 AdaptiveRcvr::AdaptiveRcvr() : Agent(PT_NTYPE)
00059 {
00060     //bind("npkts_",&npkts_);
00061     //bind("ndelay_",&ndelay_);
00062     //bind("nvar_",&nvar_);
00063 }
00064 
00065 void AdaptiveRcvr::recv(Packet *pkt,Handler*)
00066 {
00067     int delay;
00068     int seq_no;
00069     hdr_cmn* ch= hdr_cmn::access(pkt);
00070     hdr_rtp *rh = hdr_rtp::access(pkt);
00071     
00072     seq_no= rh->seqno();
00073     register u_int32_t send_time = (int)ch->timestamp();
00074     
00075     u_int32_t local_time= (u_int32_t)(Scheduler::instance().clock() * SAMPLERATE);
00076     delay=adapt(pkt,local_time);
00077     Tcl::instance().evalf("%s print-delay-stats %f %f %f",name(),send_time/SAMPLERATE,local_time/SAMPLERATE,(local_time+delay)/SAMPLERATE);
00078     Packet::free(pkt);
00079 }
00080 

Generated on Tue Mar 6 16:47:43 2007 for ns2 Network Simulator 2.29 by  doxygen 1.4.6