]> git.saurik.com Git - apple/network_cmds.git/blob - ecnprobe/session.h
network_cmds-543.200.16.tar.gz
[apple/network_cmds.git] / ecnprobe / session.h
1 /*
2 Copyright (c) 2000
3 International Computer Science Institute
4 All rights reserved.
5
6 This file may contain software code originally developed for the
7 Sting project. The Sting software carries the following copyright:
8
9 Copyright (c) 1998, 1999
10 Stefan Savage and the University of Washington.
11 All rights reserved.
12
13 Redistribution and use in source and binary forms, with or without
14 modification, are permitted provided that the following conditions
15 are met:
16 1. Redistributions of source code must retain the above copyright
17 notice, this list of conditions and the following disclaimer.
18 2. Redistributions in binary form must reproduce the above copyright
19 notice, this list of conditions and the following disclaimer in the
20 documentation and/or other materials provided with the distribution.
21 3. All advertising materials mentioning features or use of this software
22 must display the following acknowledgment:
23 This product includes software developed by ACIRI, the AT&T
24 Center for Internet Research at ICSI (the International Computer
25 Science Institute). This product may also include software developed
26 by Stefan Savage at the University of Washington.
27 4. The names of ACIRI, ICSI, Stefan Savage and University of Washington
28 may not be used to endorse or promote products derived from this software
29 without specific prior written permission.
30
31 THIS SOFTWARE IS PROVIDED BY ICSI AND CONTRIBUTORS ``AS IS'' AND
32 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
33 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
34 ARE DISCLAIMED. IN NO EVENT SHALL ICSI OR CONTRIBUTORS BE LIABLE
35 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
39 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
40 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
41 SUCH DAMAGE.
42 */
43
44 #define MAXREQUESTLEN 1000
45
46 #define SESSION_DEBUG_LOW 1
47 #define SESSION_DEBUG_MEDIUM 2
48 #define SESSION_DEBUG_HIGH 3
49
50 struct TcpSession {
51
52 /* target name, as specified by the user */
53 char targetName[MAXHOSTNAMELEN];
54
55 /* DNS name of hosts */
56 char targetHostName[MAXHOSTNAMELEN];
57 char sourceHostName[MAXHOSTNAMELEN];
58
59 /* raw socket we use to send on */
60 int socket;
61
62 /* connection endpoint identifiers */
63 u_int32_t src;
64 u_int16_t sport;
65 u_int32_t dst;
66 u_int16_t dport;
67
68 /* sender info, from RFC 793 */
69 u_int32_t iss; // initial send sequence
70 u_int32_t snd_una; // sequence numbers of unacknowledged data
71 u_int32_t snd_nxt; // sequence number to be sent next
72 u_int16_t snd_wnd;
73 u_int16_t sndmss;
74
75 /* Receiver info */
76 u_int32_t irs;
77 u_int32_t rcv_wnd;
78 u_int32_t rcv_nxt;
79 u_int32_t maxseqseen;
80 u_int16_t mss;
81
82 /* timing */
83 double rtt;
84 u_int8_t ttl;
85 double start_time;
86
87 /* data buffer */
88 u_int8_t *dataRcvd ;
89
90 /* basic results */
91 int totSent;
92 int totRcvd;
93 int totSeenSent;
94 int totDataPktsRcvd;
95 int totOutofSeq;
96 int hsz;
97
98 /* basic control*/
99 int epochTime;
100 int debug;
101 int verbose;
102 int initSession;
103 int initCapture;
104 int initFirewall;
105 int firewall_rule_number;
106 char *filename;
107 int maxpkts;
108
109 /* New loss-rate parameters */
110 float loss_rate;
111 float prop_delay;
112
113 /* results are suspect for various reasons */
114 int rtt_unreliable;
115 int ignore_result;
116
117 /* Drops and reordering startistics */
118 int num_reordered;
119 int num_unwanted_drops;
120 int num_rtos;
121 int num_reord_ret;
122 int num_dup_transmissions;
123 int num_dup_acks;
124 int num_pkts_0_dup_acks;
125 int num_pkts_1_dup_acks;
126 int num_pkts_2_dup_acks;
127 int num_pkts_3_dup_acks;
128 int num_pkts_4_or_more_dup_acks;
129 int num_dupack_ret;
130
131 /* For PMTUD test */
132 int mtu;
133
134 /* For ByteCounting test */
135 int bytecounting_type;
136 int ack_bytes; /* How many bytes covered per ACK */
137 int ack_rate; /* ACK [every | every other | every third |...] packet */
138
139 /* For WindowScale Option test */
140 u_int8_t receiving_shift_count;
141 u_int8_t sending_shift_count;
142
143 /* For MidBoxTTL test */
144 int curr_ttl;
145
146 int dont_send_reset;
147 };
148
149 //void SendSessionPacket(struct IPPacket *packet,
150 void SendSessionPacket(struct IPPacket *packet,
151 u_int16_t ip_len, /* Total size of IP datagram */
152 u_int8_t tcp_flags,
153 u_int16_t ip_optlen, /* IP options len - New */
154 u_int16_t optlen, /* TCP options len */
155 u_int8_t iptos);
156
157 void SendICMPReply(struct IPPacket *p);
158
159 void SendPkt(struct IPPacket *p, u_int16_t ip_len, int ip_optlen, int tcp_optlen);
160
161 void SendICMPPkt(struct ICMPUnreachableErrorPacket *p, u_int16_t ip_len);
162
163 void StorePacket (struct IPPacket *p);
164
165 int EstablishSession(u_int32_t sourceAddress, \
166 u_int16_t sourcePort, \
167 u_int32_t targetAddress,
168 u_int16_t targetPort, \
169 int ip_optlen,\
170 char *ip_opt,\
171 int mss,
172 int optlen,
173 char *opt, \
174 int maxwin,
175 int maxpkts,
176 u_int8_t iptos,
177 u_int8_t tcp_flags);
178
179 void rcvData (void (*ackData)(struct IPPacket *p));
180
181 void SendRequest(char *filename, void (*ackData)(struct IPPacket *p));
182
183 int PrepareRequest(char *data, char *filename) ;