xref: /netbsd/sys/netinet/dccp_tcplike.h (revision 09ae0501)
1 /*	$KAME: dccp_tcplike.h,v 1.10 2005/07/22 09:31:14 nishida Exp $	*/
2 /*	$NetBSD: dccp_tcplike.h,v 1.3 2019/06/04 10:15:22 msaitoh Exp $ */
3 
4 /*
5  * Copyright (c) 2003 Magnus Erixzon
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * 1. Redistributions of source code must retain the above copyright
13  *    notice, this list of conditions and the following disclaimer.
14  * 2. Redistributions in binary form must reproduce the above copyright
15  *    notice, this list of conditions and the following disclaimer in the
16  *    documentation and/or other materials provided with the distribution.
17  * 3. The name of the author may not be used to endorse or promote products
18  *    derived from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30  */
31 /*
32  * Headerfile for TCP-like congestion control for DCCP
33  */
34 
35 #ifndef _NETINET_DCCP_TCPLIKE_H_
36 #define _NETINET_DCCP_TCPLIKE_H_
37 
38 /*
39  * TCPlike sender
40  */
41 
42 /* Parameter to decide when a packet is considered lost */
43 #define TCPLIKE_NUMDUPACK 3
44 /* Upperbound timeout value */
45 #define TIMEOUT_UBOUND	(30 * hz)
46 #define TCPLIKE_MIN_RTT	(hz >> 3)
47 #define TCPLIKE_INITIAL_CWND 3
48 #define TCPLIKE_INITIAL_CWNDVECTOR 512
49 
50 /* TCPlike sender congestion control block (ccb) */
51 struct tcplike_send_ccb
52 {
53 	kmutex_t mutex;
54 	struct dccpcb *pcb; /* Pointer to associated dccpcb */
55 	dccp_seq cwnd; /* congestion window */
56 	dccp_seq ssthresh;
57 	dccp_seq oldcwnd_ts; /* old cwnd tail seqnr */
58 
59 	u_int16_t rtt; /* estimated round trip-time */
60 	u_int16_t rto; /* Timeout value */
61 	u_int16_t rtt_d;
62 
63 	int16_t outstanding; /* Number of unacked packets sent */
64 	u_int16_t rcvr_ackratio; /* Receiver ack ratio */
65 
66 	u_int16_t acked_in_win; /* No of acked packets in the window */
67 	u_int8_t acked_windows; /* No of acked windows with no lost Acks */
68 
69 	u_int32_t ack_last; /* Last ok Ack packet */
70 	u_int32_t ack_miss; /* oldest missing Ack packet */
71 
72 	struct callout free_timer;
73 	struct callout rto_timer;
74 	u_int rto_timer_callout;
75 
76 	u_char *cwndvector;  /* 2 bits per packet */
77 	u_char *cv_hp;  /* head ptr for cwndvector */
78 	u_int16_t cv_size;
79 	dccp_seq cv_hs, cv_ts; /* lowest/highest seq no in cwndvector */
80 
81 	u_int8_t sample_rtt;
82 	u_int32_t timestamp;
83 
84 	dccp_seq rcvd_ack, lost_ack;
85 };
86 
87 #ifdef _KERNEL
88 
89 /* Functions declared in struct dccp_cc_sw */
90 
91 /*
92  * Initialises the sender side
93  * args: pcb  - pointer to dccpcb of associated connection
94  * returns: pointer to a tcplike_send_ccb struct on success, otherwise 0
95  */
96 void *tcplike_send_init(struct dccpcb *);
97 
98 /*
99  * Free the sender side
100  * args: ccb - ccb of sender
101  */
102 void tcplike_send_free(void *);
103 
104 /*
105  * Ask TCPlike wheter one can send a packet or not
106  * args: ccb  -  ccb block for current connection
107  * returns: 0 if ok, else <> 0.
108  */
109 int tcplike_send_packet(void *, long);
110 void tcplike_send_packet_sent(void *, int, long);
111 
112 /*
113  * Notify that an ack package was received
114  * args: ccb  -  ccb block for current connection
115  */
116 void tcplike_send_packet_recv(void *, char *, int);
117 
118 #endif
119 
120 /*
121  * TFRC Receiver
122  */
123 
124 struct ack_list
125 {
126 	u_int64_t localseq, ackthru;
127 	struct ack_list *next;
128 };
129 
130 /* TCPlike receiver congestion control block (ccb) */
131 struct tcplike_recv_ccb {
132 	kmutex_t mutex;
133 	struct dccpcb *pcb;               /* Pointer to associated dccpcb */
134 	/* No ack ratio or vector here. it's a global feature */
135 	struct ack_list *av_list;
136 	u_int16_t unacked; /* no of unacked packets */
137 	struct callout free_timer;
138 };
139 
140 #ifdef _KERNEL
141 
142 /* Functions declared in struct dccp_cc_sw */
143 
144 /*
145  * Initialises the receiver side
146  * args: pcb  -  pointer to dccpcb of associated connection
147  * returns: pointer to a tcplike_recv_ccb struct on success, otherwise 0
148  */
149 void *tcplike_recv_init(struct dccpcb *);
150 
151 /*
152  * Free the receiver side
153  * args: ccb - ccb of receiver
154  */
155 void tcplike_recv_free(void *);
156 
157 /*
158  * Tell TCPlike that a packet has been received
159  * args: ccb  -  ccb block for current connection
160  */
161 void tcplike_recv_packet_recv(void *, char *, int);
162 
163 /*
164 int tcplike_option_recv(void);
165 */
166 #endif
167 
168 #endif
169