Home | History | Annotate | Line # | Download | only in netinet
dccp_tfrc.h revision 1.2.20.1
      1       1.1       rjs /*	$KAME: dccp_tfrc.h,v 1.10 2005/10/26 11:36:49 nishida Exp $	*/
      2  1.2.20.1  christos /*	$NetBSD: dccp_tfrc.h,v 1.2.20.1 2019/06/10 22:09:47 christos Exp $ */
      3       1.1       rjs 
      4       1.1       rjs /*
      5       1.1       rjs  * Copyright (c) 2003  Nils-Erik Mattsson
      6       1.1       rjs  * All rights reserved.
      7       1.1       rjs  *
      8       1.1       rjs  * Redistribution and use in source and binary forms, with or without
      9       1.1       rjs  * modification, are permitted provided that the following conditions
     10       1.1       rjs  * are met:
     11       1.1       rjs  *
     12       1.1       rjs  * 1. Redistributions of source code must retain the above copyright
     13       1.1       rjs  *    notice, this list of conditions and the following disclaimer.
     14       1.1       rjs  * 2. Redistributions in binary form must reproduce the above copyright
     15       1.1       rjs  *    notice, this list of conditions and the following disclaimer in the
     16       1.1       rjs  *    documentation and/or other materials provided with the distribution.
     17       1.1       rjs  * 3. The name of the author may not be used to endorse or promote products
     18       1.1       rjs  *    derived from this software without specific prior written permission.
     19       1.1       rjs  *
     20       1.1       rjs  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     21       1.1       rjs  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     22       1.1       rjs  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     23       1.1       rjs  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     24       1.1       rjs  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     25       1.1       rjs  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     26       1.1       rjs  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     27       1.1       rjs  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     28       1.1       rjs  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     29       1.1       rjs  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     30       1.1       rjs  *
     31       1.1       rjs  * Id: dccp_tfrc.h,v 1.34 2003/05/28 17:36:15 nilmat-8 Exp
     32       1.1       rjs  */
     33       1.1       rjs 
     34       1.1       rjs 
     35       1.1       rjs #ifndef _NETINET_DCCP_TFRC_H_
     36       1.1       rjs #define _NETINET_DCCP_TFRC_H_
     37       1.1       rjs 
     38       1.1       rjs #define TFRC_STD_PACKET_SIZE    256
     39       1.1       rjs #define TFRC_MIN_PACKET_SIZE    16
     40       1.1       rjs #define TFRC_MAX_PACKET_SIZE    65535
     41       1.1       rjs 
     42       1.1       rjs #define TFRC_OPSYS_TIME_GRAN    10000
     43       1.1       rjs #define TFRC_WIN_COUNT_LIMIT    16
     44       1.1       rjs #define TFRC_WIN_COUNT_PER_RTT  4
     45       1.1       rjs #define TFRC_SMALLEST_P         4	/* 0.00004 */
     46       1.1       rjs /*
     47       1.1       rjs  * TFRC sender
     48       1.1       rjs  */
     49       1.1       rjs 
     50       1.1       rjs /* TFRC sender states */
     51       1.1       rjs #define TFRC_SSTATE_NO_SENT     1
     52       1.1       rjs #define TFRC_SSTATE_NO_FBACK	2
     53       1.1       rjs #define TFRC_SSTATE_FBACK	3
     54       1.1       rjs #define TFRC_SSTATE_TERM	4
     55       1.1       rjs 
     56       1.1       rjs /* Mechanism parameters */
     57       1.1       rjs #define TFRC_INITIAL_TIMEOUT    2
     58       1.1       rjs #define TFRC_MAX_BACK_OFF_TIME  64
     59       1.1       rjs #define TFRC_RTT_FILTER_CONST   9000	/* 0.9 */
     60       1.1       rjs #define TFRC_SEND_WAIT_TERM     20
     61       1.1       rjs 
     62       1.1       rjs /* Packet history */
     63       1.2   msaitoh TAILQ_HEAD(s_hist_head,s_hist_entry);
     64       1.1       rjs 
     65       1.1       rjs struct fixpoint {
     66       1.1       rjs 	long long num;
     67       1.1       rjs 	long long denom;
     68       1.1       rjs };
     69       1.1       rjs 
     70       1.1       rjs struct s_hist_entry {
     71       1.1       rjs 	TAILQ_ENTRY(s_hist_entry) linfo;	/* Tail queue. */
     72       1.1       rjs 	u_int64_t seq;		/* Sequence number */
     73       1.1       rjs 	struct timeval t_sent;	/* When the packet was sent */
     74       1.1       rjs 	u_int8_t win_count;	/* Windowcounter for packet */
     75       1.1       rjs };
     76       1.1       rjs 
     77       1.1       rjs /* TFRC sender congestion control block (ccb) */
     78       1.1       rjs struct tfrc_send_ccb {
     79       1.1       rjs 	kmutex_t mutex;		/* Lock for this structure */
     80       1.1       rjs 	struct dccpcb *pcb;	/* Pointer to associated dccpcb */
     81       1.1       rjs 	u_int8_t state;		/* Sender state */
     82       1.1       rjs 
     83       1.1       rjs 	struct fixpoint x;		/* Current sending rate */
     84       1.1       rjs 	struct fixpoint x_recv;	/* Receive rate */
     85       1.1       rjs 	struct fixpoint x_calc;	/* Calculated send (?) rate */
     86       1.1       rjs 
     87       1.1       rjs 	u_int16_t s;		/* Packet size */
     88       1.1       rjs 
     89       1.1       rjs 	u_int32_t rtt;		/* Estimate of current round trip time */
     90       1.1       rjs 	struct fixpoint p;	/* Current loss event rate */
     91       1.1       rjs 	u_int8_t last_win_count;	/* Last window counter sent */
     92       1.1       rjs 	/* Timestamp of earliest packet with last_win_count value sent */
     93       1.1       rjs 	struct timeval t_last_win_count;
     94       1.1       rjs 	u_int8_t idle;
     95       1.1       rjs 	u_int32_t t_rto;	/* Time out value = 4*rtt */
     96       1.1       rjs 	struct timeval t_ld;	/* Time last doubled during slow start */
     97       1.1       rjs 
     98       1.1       rjs 	struct timeval t_nom;	/* Nominal send time of next packet */
     99       1.1       rjs 	struct timeval t_ipi;	/* Interpacket (send) interval */
    100       1.1       rjs 	struct timeval delta;	/* Send timer delta */
    101       1.1       rjs 
    102       1.1       rjs 	struct callout ch_stimer;	/* Handle to scheduled send timer */
    103       1.1       rjs 	struct callout ch_nftimer;	/* Handle to no feedback timer */
    104       1.1       rjs 
    105       1.1       rjs 	struct s_hist_head hist;	/* Packet history */
    106       1.1       rjs };
    107       1.1       rjs 
    108       1.1       rjs #ifdef _KERNEL
    109       1.1       rjs 
    110       1.1       rjs /* Functions declared in struct dccp_cc_sw */
    111       1.1       rjs 
    112       1.1       rjs /*
    113       1.1       rjs  * Initialises the sender side
    114       1.1       rjs  * args: pcb  - pointer to dccpcb of associated connection
    115       1.1       rjs  * returns: pointer to a tfrc_send_ccb struct on success, otherwise 0
    116       1.1       rjs  */
    117       1.2   msaitoh void *tfrc_send_init(struct dccpcb *);
    118       1.1       rjs 
    119       1.1       rjs /*
    120       1.1       rjs  * Free the sender side
    121       1.1       rjs  * args: ccb - ccb of sender
    122       1.1       rjs  */
    123       1.1       rjs void tfrc_send_free(void *);
    124       1.1       rjs 
    125       1.1       rjs /*
    126       1.1       rjs  * Ask TFRC wheter one can send a packet or not
    127       1.1       rjs  * args: ccb  -  ccb block for current connection
    128       1.1       rjs  * returns: 1 if ok, else 0.
    129       1.1       rjs  */
    130       1.1       rjs int tfrc_send_packet(void *, long);
    131       1.1       rjs 
    132       1.1       rjs /*
    133       1.1       rjs  * Notify sender that a packet has been sent
    134       1.1       rjs  * args: ccb - ccb block for current connection
    135       1.1       rjs  *	 moreToSend - if there exists more packets to send
    136       1.1       rjs  *       datasize   - packet size
    137       1.1       rjs  */
    138       1.1       rjs void tfrc_send_packet_sent(void *, int, long);
    139       1.1       rjs 
    140       1.1       rjs /*
    141       1.1       rjs  * Notify that a an ack package was received (i.e. a feedback packet)
    142       1.1       rjs  * args: ccb  -  ccb block for current connection
    143       1.1       rjs  */
    144       1.1       rjs void tfrc_send_packet_recv(void *, char *, int);
    145       1.1       rjs 
    146       1.1       rjs #endif
    147       1.1       rjs 
    148       1.1       rjs /*
    149       1.1       rjs  * TFRC Receiver
    150       1.1       rjs  */
    151       1.1       rjs 
    152       1.1       rjs /* TFRC specific dccp options */
    153       1.1       rjs #define TFRC_OPT_LOSS_RATE	192
    154       1.1       rjs #define TFRC_OPT_LOSS_INTERVAL	193
    155       1.1       rjs //#define TFRC_OPT_ELAPSED_TIME	193
    156       1.1       rjs #define TFRC_OPT_RECEIVE_RATE	194
    157       1.1       rjs 
    158       1.1       rjs /* TFRC receiver states */
    159       1.1       rjs #define TFRC_RSTATE_NO_DATA	1
    160       1.1       rjs #define TFRC_RSTATE_DATA	2
    161       1.1       rjs #define TFRC_RSTATE_TERM        127
    162       1.1       rjs 
    163       1.1       rjs /* Receiver mechanism parameters */
    164       1.1       rjs /*
    165       1.1       rjs  * seq_num x,y; if y-x is smaller than this number (note, wrap around) then
    166       1.1       rjs  * y is newer than x
    167       1.1       rjs  */
    168       1.1       rjs #define TFRC_RECV_NEW_SEQ_RANGE 10000000
    169       1.1       rjs /* number of later packets received before one is considered lost */
    170       1.1       rjs #define TFRC_RECV_NUM_LATE_LOSS 3
    171       1.1       rjs /* length(w[]) */
    172       1.1       rjs #define TFRC_RECV_IVAL_F_LENGTH  8
    173       1.1       rjs 
    174       1.1       rjs /* Packet history */
    175       1.2   msaitoh TAILQ_HEAD(r_hist_head,r_hist_entry);
    176       1.1       rjs 
    177       1.1       rjs struct r_hist_entry {
    178       1.1       rjs 	TAILQ_ENTRY(r_hist_entry) linfo;	/* Tail queue. */
    179       1.1       rjs 	u_int64_t seq;		/* Sequence number */
    180       1.1       rjs 	struct timeval t_recv;	/* When the packet was received */
    181       1.1       rjs 	u_int8_t win_count;	/* Window counter for that packet */
    182       1.1       rjs 	u_int8_t type;		/* Packet type received */
    183       1.1       rjs 	u_int8_t ndp;		/* no data packets value */
    184       1.1       rjs };
    185       1.1       rjs 
    186       1.1       rjs /* Loss interval history */
    187       1.2   msaitoh TAILQ_HEAD(li_hist_head,li_hist_entry);
    188       1.1       rjs 
    189       1.1       rjs struct li_hist_entry {
    190       1.1       rjs 	TAILQ_ENTRY(li_hist_entry) linfo;	/* Tail queue. */
    191       1.1       rjs 	u_int32_t interval;	/* Loss interval */
    192       1.1       rjs 	u_int64_t seq;		/* Sequence number of the packet that started the interval */
    193       1.1       rjs 	u_int8_t win_count;	/* Window counter for previous received packet */
    194       1.1       rjs };
    195       1.1       rjs 
    196       1.1       rjs /* TFRC receiver congestion control block (ccb) */
    197       1.1       rjs struct tfrc_recv_ccb {
    198       1.1       rjs 	kmutex_t mutex;		/* Lock for this structure */
    199       1.1       rjs 	struct dccpcb *pcb;	/* Pointer to associated dccpcb */
    200       1.1       rjs 	u_int8_t state;		/* Receiver state */
    201       1.1       rjs 
    202       1.1       rjs 	struct fixpoint p;	/* Loss event rate */
    203       1.1       rjs 
    204       1.1       rjs 	struct li_hist_head li_hist;	/* Loss interval history */
    205       1.1       rjs 
    206       1.1       rjs 	/*
    207       1.1       rjs 	 * Highest value of the window counter received when last feedback
    208       1.1       rjs 	 * was sent
    209       1.1       rjs 	 */
    210       1.1       rjs 	u_int8_t	last_counter;
    211       1.1       rjs 	/* Sequence number of the packet above */
    212       1.1       rjs 	u_int64_t	seq_last_counter;
    213       1.1       rjs 
    214       1.1       rjs 	/* Timestamp of when last feedback was sent */
    215       1.1       rjs 	struct timeval t_last_feedback;
    216       1.1       rjs 	u_int32_t bytes_recv;	/* Bytes received since t_last_feedback */
    217       1.1       rjs 
    218       1.1       rjs 	struct r_hist_head hist;	/* Packet history */
    219       1.1       rjs 
    220       1.1       rjs 	u_int16_t s;		/* Packet size */
    221       1.1       rjs };
    222       1.1       rjs 
    223       1.1       rjs #ifdef _KERNEL
    224       1.1       rjs 
    225       1.1       rjs /* Functions declared in struct dccp_cc_sw */
    226       1.1       rjs 
    227       1.1       rjs /* Initialises the receiver side
    228       1.1       rjs  * args: pcb  -  pointer to dccpcb of associated connection
    229       1.1       rjs  * returns: pointer to a tfrc_recv_ccb struct on success, otherwise 0
    230       1.1       rjs  */
    231       1.2   msaitoh void *tfrc_recv_init(struct dccpcb *);
    232       1.1       rjs 
    233       1.1       rjs /* Free the receiver side
    234  1.2.20.1  christos  * args: ccb - ccb of receiver
    235       1.1       rjs  */
    236       1.1       rjs void tfrc_recv_free(void *);
    237       1.1       rjs 
    238       1.1       rjs /*
    239       1.1       rjs  * Tell TFRC that a packet has been received
    240       1.1       rjs  * args: ccb  -  ccb block for current connection
    241       1.1       rjs  */
    242       1.1       rjs void tfrc_recv_packet_recv(void *, char *, int);
    243       1.1       rjs 
    244       1.1       rjs #endif
    245       1.1       rjs 
    246       1.1       rjs #endif
    247