FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
tcp_newreno.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017-2019 Cisco and/or its affiliates.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at:
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include <vnet/tcp/tcp.h>
17 #include <vnet/tcp/tcp_inlines.h>
18 
19 typedef struct nwreno_cfg_
20 {
23 
25  .ssthresh = 0x7FFFFFFFU,
26 };
27 
28 static void
30 {
31  tc->ssthresh = clib_max (tcp_flight_size (tc) / 2, 2 * tc->snd_mss);
32  tc->cwnd = tc->ssthresh;
33 }
34 
35 static void
37 {
38  tc->cwnd = tcp_loss_wnd (tc);
39 }
40 
41 static void
43 {
44  tc->cwnd = tc->ssthresh;
45 }
46 
47 static void
49 {
50  if (tcp_in_slowstart (tc))
51  {
52  tc->cwnd += clib_min (tc->snd_mss, tc->bytes_acked);
53  }
54  else
55  {
56  /* tc->cwnd += clib_max ((tc->snd_mss * tc->snd_mss) / tc->cwnd, 1); */
57  tcp_cwnd_accumulate (tc, tc->cwnd, tc->bytes_acked);
58  }
59 }
60 
61 void
63  tcp_rate_sample_t * rs)
64 {
65  if (ack_type == TCP_CC_DUPACK)
66  {
67  if (!tcp_opts_sack_permitted (tc))
68  tc->cwnd += tc->snd_mss;
69  }
70  else if (ack_type == TCP_CC_PARTIALACK)
71  {
72  /* RFC 6582 Sec. 3.2 */
73  if (!tcp_opts_sack_permitted (&tc->rcv_opts))
74  {
75  /* Deflate the congestion window by the amount of new data
76  * acknowledged by the Cumulative Acknowledgment field.
77  * If the partial ACK acknowledges at least one SMSS of new data,
78  * then add back SMSS bytes to the congestion window. This
79  * artificially inflates the congestion window in order to reflect
80  * the additional segment that has left the network. This "partial
81  * window deflation" attempts to ensure that, when fast recovery
82  * eventually ends, approximately ssthresh amount of data will be
83  * outstanding in the network.*/
84  tc->cwnd = (tc->cwnd > tc->bytes_acked + tc->snd_mss) ?
85  tc->cwnd - tc->bytes_acked : tc->snd_mss;
86  if (tc->bytes_acked > tc->snd_mss)
87  tc->cwnd += tc->snd_mss;
88  }
89  }
90 }
91 
92 static void
94 {
95  tc->ssthresh = newreno_cfg.ssthresh;
96  tc->cwnd = tcp_initial_cwnd (tc);
97 }
98 
99 static uword
101 {
102  u32 ssthresh = 0x7FFFFFFFU;
103 
104  if (!input)
105  return 0;
106 
108 
110  {
111  if (unformat (input, "ssthresh %u", &ssthresh))
112  newreno_cfg.ssthresh = ssthresh;
113  else
114  return 0;
115  }
116  return 1;
117 }
118 
120  .name = "newreno",
121  .unformat_cfg = newreno_unformat_config,
122  .congestion = newreno_congestion,
123  .loss = newreno_loss,
124  .recovered = newreno_recovered,
125  .rcv_ack = newreno_rcv_ack,
126  .rcv_cong_ack = newreno_rcv_cong_ack,
127  .init = newreno_conn_init
128 };
129 
130 clib_error_t *
132 {
133  clib_error_t *error = 0;
134 
136 
137  return error;
138 }
139 
141 
142 /*
143  * fd.io coding-style-patch-verification: ON
144  *
145  * Local Variables:
146  * eval: (c-set-style "gnu")
147  * End:
148  */
nwreno_cfg_
Definition: tcp_newreno.c:19
newreno_unformat_config
static uword newreno_unformat_config(unformat_input_t *input)
Definition: tcp_newreno.c:100
tcp_inlines.h
clib_max
#define clib_max(x, y)
Definition: clib.h:335
tcp_newreno
const static tcp_cc_algorithm_t tcp_newreno
Definition: tcp_newreno.c:119
tcp_initial_cwnd
static u32 tcp_initial_cwnd(const tcp_connection_t *tc)
Initial cwnd as per RFC5681.
Definition: tcp_inlines.h:105
newreno_init
clib_error_t * newreno_init(vlib_main_t *vm)
Definition: tcp_newreno.c:131
tcp_connection_t
struct _tcp_connection tcp_connection_t
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
unformat_input_t
struct _unformat_input_t unformat_input_t
tcp_loss_wnd
static u32 tcp_loss_wnd(const tcp_connection_t *tc)
Definition: tcp_inlines.h:138
newreno_cfg
static newreno_cfg_t newreno_cfg
Definition: tcp_newreno.c:24
newreno_conn_init
static void newreno_conn_init(tcp_connection_t *tc)
Definition: tcp_newreno.c:93
error
Definition: cJSON.c:88
unformat
uword unformat(unformat_input_t *i, const char *fmt,...)
Definition: unformat.c:978
TCP_CC_NEWRENO
@ TCP_CC_NEWRENO
Definition: tcp_types.h:248
unformat_skip_white_space
uword unformat_skip_white_space(unformat_input_t *input)
Definition: unformat.c:821
unformat_check_input
static uword unformat_check_input(unformat_input_t *i)
Definition: format.h:163
uword
u64 uword
Definition: types.h:112
if
if(node->flags &VLIB_NODE_FLAG_TRACE) vnet_interface_output_trace(vm
newreno_rcv_cong_ack
void newreno_rcv_cong_ack(tcp_connection_t *tc, tcp_cc_ack_t ack_type, tcp_rate_sample_t *rs)
Definition: tcp_newreno.c:62
tcp_opts_sack_permitted
#define tcp_opts_sack_permitted(_to)
Definition: tcp_packet.h:159
clib_min
#define clib_min(x, y)
Definition: clib.h:342
newreno_congestion
static void newreno_congestion(tcp_connection_t *tc)
Definition: tcp_newreno.c:29
TCP_CC_DUPACK
@ TCP_CC_DUPACK
Definition: tcp_types.h:258
tcp_rate_sample_
Definition: tcp_types.h:221
tcp_cc_algo_register
void tcp_cc_algo_register(tcp_cc_algorithm_type_e type, const tcp_cc_algorithm_t *vft)
Register exiting cc algo type.
Definition: tcp.c:85
tcp_in_slowstart
#define tcp_in_slowstart(tc)
Definition: tcp_types.h:417
u32
unsigned int u32
Definition: types.h:88
VLIB_INIT_FUNCTION
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:172
tcp.h
tcp_cwnd_accumulate
static void tcp_cwnd_accumulate(tcp_connection_t *tc, u32 thresh, u32 bytes)
Definition: tcp_inlines.h:125
newreno_cfg_t
struct nwreno_cfg_ newreno_cfg_t
newreno_recovered
static void newreno_recovered(tcp_connection_t *tc)
Definition: tcp_newreno.c:42
newreno_rcv_ack
static void newreno_rcv_ack(tcp_connection_t *tc, tcp_rate_sample_t *rs)
Definition: tcp_newreno.c:48
vlib_main_t
Definition: main.h:102
tcp_cc_algorithm_t
struct _tcp_cc_algorithm tcp_cc_algorithm_t
Definition: tcp_types.h:253
tcp_flight_size
static u32 tcp_flight_size(const tcp_connection_t *tc)
Our estimate of the number of bytes in flight (pipe size)
Definition: tcp_inlines.h:89
clib_error_t
Definition: clib_error.h:21
vlib_init_function_t
clib_error_t *() vlib_init_function_t(struct vlib_main_t *vm)
Definition: init.h:51
newreno_loss
static void newreno_loss(tcp_connection_t *tc)
Definition: tcp_newreno.c:36
TCP_CC_PARTIALACK
@ TCP_CC_PARTIALACK
Definition: tcp_types.h:259
nwreno_cfg_::ssthresh
u32 ssthresh
Definition: tcp_newreno.c:21
tcp_cc_ack_t
enum _tcp_cc_ack_t tcp_cc_ack_t
UNFORMAT_END_OF_INPUT
#define UNFORMAT_END_OF_INPUT
Definition: format.h:137