1 /* 2 * ngtcp2 3 * 4 * Copyright (c) 2019 ngtcp2 contributors 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining 7 * a copy of this software and associated documentation files (the 8 * "Software"), to deal in the Software without restriction, including 9 * without limitation the rights to use, copy, modify, merge, publish, 10 * distribute, sublicense, and/or sell copies of the Software, and to 11 * permit persons to whom the Software is furnished to do so, subject to 12 * the following conditions: 13 * 14 * The above copyright notice and this permission notice shall be 15 * included in all copies or substantial portions of the Software. 16 * 17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 */ 25 #ifndef NGTCP2_RST_H 26 #define NGTCP2_RST_H 27 28 #ifdef HAVE_CONFIG_H 29 # include <config.h> 30 #endif /* HAVE_CONFIG_H */ 31 32 #include <ngtcp2/ngtcp2.h> 33 34 #include "ngtcp2_window_filter.h" 35 36 typedef struct ngtcp2_rtb_entry ngtcp2_rtb_entry; 37 38 /** 39 * @struct 40 * 41 * ngtcp2_rs contains connection state for delivery rate estimation. 42 */ 43 typedef struct ngtcp2_rs { 44 ngtcp2_duration interval; 45 uint64_t delivered; 46 uint64_t prior_delivered; 47 ngtcp2_tstamp prior_ts; 48 uint64_t tx_in_flight; 49 uint64_t lost; 50 uint64_t prior_lost; 51 ngtcp2_duration send_elapsed; 52 ngtcp2_duration ack_elapsed; 53 int is_app_limited; 54 } ngtcp2_rs; 55 56 void ngtcp2_rs_init(ngtcp2_rs *rs); 57 58 /* 59 * ngtcp2_rst implements delivery rate estimation described in 60 * https://tools.ietf.org/html/draft-cheng-iccrg-delivery-rate-estimation-00 61 */ 62 typedef struct ngtcp2_rst { 63 ngtcp2_rs rs; 64 ngtcp2_window_filter wf; 65 uint64_t delivered; 66 ngtcp2_tstamp delivered_ts; 67 ngtcp2_tstamp first_sent_ts; 68 uint64_t app_limited; 69 uint64_t next_round_delivered; 70 uint64_t round_count; 71 uint64_t lost; 72 int is_cwnd_limited; 73 } ngtcp2_rst; 74 75 void ngtcp2_rst_init(ngtcp2_rst *rst); 76 77 void ngtcp2_rst_on_pkt_sent(ngtcp2_rst *rst, ngtcp2_rtb_entry *ent, 78 const ngtcp2_conn_stat *cstat); 79 int ngtcp2_rst_on_ack_recv(ngtcp2_rst *rst, ngtcp2_conn_stat *cstat, 80 uint64_t pkt_delivered); 81 void ngtcp2_rst_update_rate_sample(ngtcp2_rst *rst, const ngtcp2_rtb_entry *ent, 82 ngtcp2_tstamp ts); 83 void ngtcp2_rst_update_app_limited(ngtcp2_rst *rst, ngtcp2_conn_stat *cstat); 84 85 #endif /* NGTCP2_RST_H */ 86