/* -*- Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */ /* * Copyright (c) 2001 University of Mannheim, Praktische Informatik IV * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by Praktische Informatik IV, * University of Mannheim and ACIRI. * 4. Neither the name of the University of Mannheim nor of ACIRI * may be used to endorse or promote products derived from this * software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY U. MANNHEIM AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL U. MANNHEIM OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include "agent.h" #include "packet.h" #include "ip.h" #include "random.h" #include "tfmcc.h" #define LARGE_DOUBLE 9999999999.99 #define SAMLLFLOAT 0.0000001 /* packet status */ #define UNKNOWN 0 #define RCVD 1 #define LOST 2 #define NOLOSS 3 #define DEFAULT_NUMSAMPLES 8 #define MAX_NUM_RECVS 10000 class TfmccSinkAgent : public Agent { public: TfmccSinkAgent(); void recv(Packet*, Handler*); int command(int argc, const char*const* argv); void stop(); protected: void sendpkt(); void nextpkt(); void increase_pvec(int); void add_packet_to_history(Packet *); double adjust_history(double); double est_loss(); double est_thput(); void shift_array(int *a, int sz, int defval) ; void shift_array(double *a, int sz, double defval) ; void multiply_array(double *a, int sz, double multiplier); void print_loss(int sample, double ave_interval); double weighted_average(int start, int end, double factor, double *m, double *w, int *sample); double feedback_time(double rtt, int num_recv); int psize_; // size of received packet int fairsize_; // packet size of competing flow int avgsize_; // avg size of sent packets (EWMA) int sum_psize_; int sum_lsize_; int aggregate_packets_; // bool int aggregate_loss_; // bool double rtt_; // smoothed measured rtt double rtt_est; // use adjusted one-way delay to continue to modify the rtt double rtt_lossinit; // RTT when history was initialized double max_rtt; // max RTT (from sender) double conservative_rtt; double one_way_; // one-way delay from receiver to sender int smooth_; // for the smoother method for incorporating // incorporating new loss intervals // these assist in keep track of incming packets and calculate flost_ double last_timestamp_, last_arrival_; int hsz; char *lossvec_; int *sizevec_; double *rtvec_; double *tsvec_; int round_id ; int numsamples ; int *sample; double *weights ; double *mult ; double mult_factor_; // most recent multiple of mult array int sample_count ; int last_sample ; int maxseq; // max seq number seen int total_received_; // total # of pkts rcvd by rcvr int bval_; // value of B used in the formula double last_report_sent; // when was last feedback sent int rcvd_since_last_report; // # of packets rcvd since last report double lastloss; // when last loss occured int printStatus_; // to print estimated loss rates int tight_loop_; // flag for tight feedback loop to rep recv double fbtime_mult_; // T = mult * RTT double fb_time; // delay for feedback suppression double constant_rate_; // set to positive value to use instead of calculated rate (Bit/s) double comparison_rate; // rate at beginning of feedback round (for suppression) double suppression_rate; // sender's suppression rate int receiver_leave; // flag to indicate that CLR will leave group // these are for "faking" history after slow start int loss_seen_yet; // have we seen the first loss yet? int adjust_history_after_ss; // fake history after slow start? (0/1) int false_sample; // by how much? int discount ; // emphasize most recent loss interval // when it is very large int representative; // flag: 1 = feedback receiver int recv_id; //int ca_; //Enable Sqrt(RTT) based congestion avoidance mode double df_; // decay factor for accurate RTT estimate double rate_; int active_; };