1 /*
2  This file is part of pathload.
3 
4  pathload is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or
7  (at your option) any later version.
8 
9  pathload is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with pathload; if not, write to the Free Software
16  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17 */
18 
19 /*-------------------------------------------------
20    pathload : an end-to-end available bandwidth
21               estimation tool
22    Author   : Manish Jain ( jain@cc.gatech.edu )
23               Constantinos Dovrolis (dovrolis@cc.gatech.edu )
24    Release  : Ver 1.3.2
25    Support  : This work was supported by the SciDAC
26               program of the US department
27 --------------------------------------------------*/
28 
29 /*
30  * $Header: /net/cvs/bwtest/pathload/pathload_rcv.h,v 1.72 2006/05/19 20:21:15 jain Exp $
31  */
32 
33 #ifdef LOCAL
34 #define EXTERN
35 #else
36 #define EXTERN extern
37 #endif
38 
39 #define SCALE_FACTOR                2
40 #define NOTREND                     1
41 #define INCREASING                  2
42 #define GREY                        3
43 
44 #define MEDIUM_LOSS_RATE            3
45 #define HIGH_LOSS_RATE              15
46 #define MIN_PARTITIONED_STREAM_LEN  5       /* number of packet */
47 #define MIN_STREAM_LEN              36      /* # of packets */
48 #define PCT_THRESHOLD               .55
49 #define PDT_THRESHOLD               .4
50 #define AGGREGATE_THRESHOLD         .6
51 
52 #define NUM_RETRY_RATE_MISMATCH     0
53 #define NUM_RETRY_CS                1
54 #define MAX_LOSSY_STREAM_FRACTION   50
55 
56 #define MIN_TIME_INTERVAL           7         /* microsecond */
57 #define MAX_TIME_INTERVAL           200000    /* microsecond */
58 
59 EXTERN l_int32 aggregate_trend_result() ;
60 EXTERN double time_to_us_delta(struct timeval tv1, struct timeval tv2);
61 EXTERN double get_avg(double data[], l_int32 no_values);
62 EXTERN double pairwise_comparision_test (double array[] , l_int32 start , l_int32 end);
63 EXTERN double pairwise_diff_test(double array[] ,l_int32 start , l_int32 end);
64 EXTERN l_int32 rate_adjustment(l_int32 flag);
65 EXTERN l_int32 eliminate_sndr_side_CS (double sndr_time_stamp[], l_int32 split_owd[] ) ;
66 EXTERN l_int32 eliminate_rcvr_side_CS ( double rcvr_time_stamp[] , double[], double[],l_int32,l_int32,l_int32 *,l_int32 * ) ;
67 EXTERN l_int32 eliminate_b2b_pkt_ic ( double rcvr_time_stamp[] , double[], double[],l_int32,l_int32,l_int32 *,l_int32 * ) ;
68 EXTERN void adjust_offset_to_zero(double owd[], l_int32 last_pkt_id);
69 EXTERN l_int32 recv_fleet() ;
70 EXTERN void print_contextswitch_info(l_int32 num_sndr_cs[], l_int32 num_rcvr_cs[],l_int32 discard[],l_int32 stream_cnt);
71 EXTERN void *ctrl_listen(void *) ;
72 EXTERN void radj_notrend() ;
73 EXTERN void radj_increasing() ;
74 EXTERN void radj_greymin() ;
75 EXTERN void radj_greymax() ;
76 EXTERN l_int32 calc_param();
77 EXTERN void get_sending_rate() ;
78 EXTERN double  get_adr() ;
79 EXTERN l_int32 recv_train(l_int32 , struct timeval *, l_int32 );
80 EXTERN l_int32 recvfrom_latency(struct sockaddr_in rcv_udp_addr);
81 EXTERN double grey_bw_resolution() ;
82 EXTERN void get_pct_trend(double[] , l_int32[], l_int32 ) ;
83 EXTERN void get_pdt_trend(double[] , l_int32[], l_int32 ) ;
84 EXTERN void get_trend(double owdfortd[],l_int32 pkt_cnt );
85 EXTERN l_int32 get_sndr_time_interval(double snd_time[],double *sum);
86 EXTERN void sig_alrm();
87 EXTERN void terminate_gracefully(struct timeval exp_start_time);
88 EXTERN l_int32 check_intr_coalescence(struct timeval time[],l_int32, l_int32 * );
89 EXTERN void order_float(float unord_arr[],float ord_arr[],l_int32 start, l_int32 num_elems);
90 EXTERN void order_dbl(double unord_arr[],double ord_arr[], l_int32 start,l_int32 no_elems) ;
91 EXTERN void order_int(l_int32 unord_arr[], l_int32 ord_arr[], l_int32 no_elems);
92 EXTERN l_int32 max(l_int32,l_int32 ) ;
93 EXTERN void send_ctr_mesg(char *ctr_buff, l_int32 ctr_code) ;
94 EXTERN l_int32 recv_ctr_mesg(l_int32 ctr_strm, char *ctr_buff) ;
95 EXTERN l_int32 equal(double a , double b);
96 EXTERN l_int32 less_than(double a , double b);
97 EXTERN l_int32 grtr_than(double a , double b);
98 EXTERN void netlogger();
99 EXTERN void print_time(FILE *fp, l_int32 time);
100 EXTERN void help();
101 EXTERN void sig_sigusr1() ;
102 
103 EXTERN l_int32 exp_flag  ;
104 EXTERN l_int32 grey_flag  ;
105 EXTERN double tr ;
106 EXTERN double adr ;
107 EXTERN double tr_max ;
108 EXTERN double tr_min ;
109 EXTERN double grey_max  , grey_min  ;
110 EXTERN l_int32 sock_tcp, sock_udp;
111 EXTERN struct timeval first_time, second_time ;
112 EXTERN l_int32 exp_fleet_id  ;
113 EXTERN float bw_resol;
114 EXTERN l_uint32 min_time_interval, snd_latency, rcv_latency ;
115 EXTERN l_int32 repeat_fleet ;
116 EXTERN l_int32 counter ; /* # of consecutive times act-rate != req-rate */
117 EXTERN l_int32 converged_gmx_rmx ;
118 EXTERN l_int32 converged_gmn_rmn ;
119 EXTERN l_int32 converged_rmn_rmx ;
120 EXTERN l_int32 converged_gmx_rmx_tm ;
121 EXTERN l_int32 converged_gmn_rmn_tm ;
122 EXTERN l_int32 converged_rmn_rmx_tm ;
123 EXTERN double cur_actual_rate , cur_req_rate ;
124 EXTERN double prev_actual_rate , prev_req_rate ;
125 EXTERN double max_rate , min_rate ;
126 EXTERN l_int32 max_rate_flag , min_rate_flag ;
127 EXTERN l_int32 bad_fleet_cs , bad_fleet_rate_mismatch ;
128 EXTERN l_int32 retry_fleet_cnt_cs , retry_fleet_cnt_rate_mismatch ;
129 EXTERN FILE *pathload_fp, *netlog_fp  ;
130 EXTERN double pct_metric[50], pdt_metric[50];
131 EXTERN l_int32 trend_idx ;
132 EXTERN double snd_time_interval ;
133 EXTERN l_int32 min_rsleep_time ;
134 EXTERN l_int32 num ;
135 EXTERN l_int32 slow;
136 EXTERN l_int32 interrupt_coalescence;
137 EXTERN l_int32 ic_flag ;
138 EXTERN l_int32 netlog ;
139 EXTERN char hostname[256];
140 EXTERN l_int32 repeat_1, repeat_2;
141 EXTERN l_int32 lower_bound;
142 EXTERN l_int32 increase_stream_len;
143 EXTERN l_int32 requested_delay ;
144 EXTERN struct timeval  exp_start_time ;
145 
146 #ifdef THRLIB
147 typedef struct
148 {
149     pthread_t ptid ;
150     l_int32 finished_stream ;
151     l_int32 stream_cnt;
152 } thr_arg;
153 #endif
154