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  al_int32 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$
31  */
32 
33 #if SIZEOF_LONG == 4
34   typedef long l_int32 ;
35   typedef unsigned long l_uint32 ;
36 #elif SIZEOF_INT == 4
37   typedef int l_int32 ;
38   typedef unsigned int l_uint32 ;
39 #endif
40 
41 #ifdef LOCAL
42 #define EXTERN
43 #else
44 #define EXTERN extern
45 #endif
46 
47 #include <sys/types.h>
48 #include <sys/socket.h>
49 #include <netinet/in.h>
50 #include <netinet/tcp.h>
51 #include <arpa/inet.h>
52 #include <errno.h>
53 #include <ctype.h>
54 #include <netdb.h>
55 #include <stdio.h>
56 #include <stdlib.h>
57 #include <signal.h>
58 #include <strings.h>
59 #include <string.h>
60 #include <unistd.h>
61 #include <sys/time.h>
62 #include <time.h>
63 #include <math.h>
64 #include <float.h>
65 #include <fcntl.h>
66 #include <sys/utsname.h>
67 #ifdef THRLIB
68 #include <pthread.h>
69 #endif
70 
71 /* Code numbers sent from receiver to sender using the TCP control stream */
72 #define  CTR_CODE           0x80000000
73 #define  SEND_FLEET         0x00000001
74 #define  RECV_FLEET         0x00000002
75 #define  CONTINUE_STREAM    0x00000003
76 #define  FINISHED_STREAM    0x00000007
77 #define  TERMINATE          0x00000005
78 #define  ABORT_FLEET        0x00000006
79 #define  SEND_TRAIN         0x00000008
80 #define  FINISHED_TRAIN     0x00000009
81 #define  BAD_TRAIN          0x0000000a
82 #define  GOOD_TRAIN         0x0000000b
83 
84 /* Port numbers (UDP for receiver, TCP for sender) */
85 #define UDPRCV_PORT         55001
86 #define TCPSND_PORT         55002
87 #define UDP_BUFFER_SZ       400000    /* bytes */
88 #define TREND_ARRAY_LEN     50
89 
90 
91 #define NUM_STREAM          12
92 #define MAX_STREAM_LEN      400
93 #define STREAM_LEN          100       /* # of packets */
94 #define MIN_PKT_SZ          200       /* bytes */
95 
96 #define MAX_TRAIN           5
97 #define TRAIN_LEN           50
98 
99 /* Characteristics of Packet Stream */
100 EXTERN l_int32 time_interval ;              /* in us */
101 EXTERN l_uint32 transmission_rate ; /* in bps */
102 EXTERN l_int32 cur_pkt_sz ;                 /* in bytes */
103 EXTERN l_int32 max_pkt_sz ;                 /* in bytes */
104 EXTERN l_int32 rcv_max_pkt_sz ;             /* in bytes */
105 EXTERN l_int32 snd_max_pkt_sz ;             /* in bytes */
106 EXTERN l_int32 num_stream ;
107 EXTERN l_int32 stream_len ;                 /* in packets */
108 
109 EXTERN l_int32 verbose ;
110 EXTERN l_int32 Verbose ;
111 EXTERN l_int32 VVerbose ;
112 
113