ngtcp2_rst.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. #ifdef HAVE_CONFIG_H
  28. # include <config.h>
  29. #endif /* defined(HAVE_CONFIG_H) */
  30. #include <ngtcp2/ngtcp2.h>
  31. #include "ngtcp2_window_filter.h"
  32. typedef struct ngtcp2_rtb_entry ngtcp2_rtb_entry;
  33. typedef struct ngtcp2_conn_stat ngtcp2_conn_stat;
  34. /**
  35. * @struct
  36. *
  37. * ngtcp2_rs contains connection state for delivery rate estimation.
  38. */
  39. typedef struct ngtcp2_rs {
  40. ngtcp2_duration interval;
  41. uint64_t delivered;
  42. uint64_t prior_delivered;
  43. ngtcp2_tstamp prior_ts;
  44. uint64_t tx_in_flight;
  45. uint64_t lost;
  46. uint64_t prior_lost;
  47. ngtcp2_duration send_elapsed;
  48. ngtcp2_duration ack_elapsed;
  49. int64_t last_end_seq;
  50. int is_app_limited;
  51. } ngtcp2_rs;
  52. void ngtcp2_rs_init(ngtcp2_rs *rs);
  53. /*
  54. * ngtcp2_rst implements delivery rate estimation described in
  55. * https://ietf-wg-ccwg.github.io/draft-cardwell-ccwg-bbr/draft-cardwell-ccwg-bbr.html
  56. */
  57. typedef struct ngtcp2_rst {
  58. ngtcp2_rs rs;
  59. uint64_t delivered;
  60. ngtcp2_tstamp delivered_ts;
  61. ngtcp2_tstamp first_sent_ts;
  62. uint64_t app_limited;
  63. uint64_t lost;
  64. /* last_seq is the sequence number of packets across all packet
  65. number spaces. If we would adopt single packet number sequence
  66. across all packet number spaces, we can replace this with a
  67. packet number. */
  68. int64_t last_seq;
  69. int is_cwnd_limited;
  70. } ngtcp2_rst;
  71. void ngtcp2_rst_init(ngtcp2_rst *rst);
  72. void ngtcp2_rst_on_pkt_sent(ngtcp2_rst *rst, ngtcp2_rtb_entry *ent,
  73. const ngtcp2_conn_stat *cstat);
  74. void ngtcp2_rst_on_ack_recv(ngtcp2_rst *rst, ngtcp2_conn_stat *cstat);
  75. void ngtcp2_rst_update_rate_sample(ngtcp2_rst *rst, const ngtcp2_rtb_entry *ent,
  76. ngtcp2_tstamp ts);
  77. void ngtcp2_rst_update_app_limited(ngtcp2_rst *rst, ngtcp2_conn_stat *cstat);
  78. #endif /* !defined(NGTCP2_RST_H) */