FD.io VPP  v19.08-27-gf4dcae4
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 
18 static void
20 {
21  tc->ssthresh = clib_max (tcp_flight_size (tc) / 2, 2 * tc->snd_mss);
22 }
23 
24 static void
26 {
27  tc->ssthresh = clib_max (tcp_flight_size (tc) / 2, 2 * tc->snd_mss);
28  tc->cwnd = tcp_loss_wnd (tc);
29 }
30 
31 static void
33 {
34  tc->cwnd = tc->ssthresh;
35 }
36 
37 static void
39 {
40  if (tcp_in_slowstart (tc))
41  {
42  tc->cwnd += clib_min (tc->snd_mss, tc->bytes_acked);
43  }
44  else
45  {
46  /* tc->cwnd += clib_max ((tc->snd_mss * tc->snd_mss) / tc->cwnd, 1); */
47  tcp_cwnd_accumulate (tc, tc->cwnd, tc->bytes_acked);
48  }
49 }
50 
51 void
53  tcp_rate_sample_t * rs)
54 {
55  if (ack_type == TCP_CC_DUPACK)
56  {
57  if (!tcp_opts_sack_permitted (tc))
58  tc->cwnd += tc->snd_mss;
59  }
60  else if (ack_type == TCP_CC_PARTIALACK)
61  {
62  /* RFC 6582 Sec. 3.2 */
63  if (!tcp_opts_sack_permitted (&tc->rcv_opts))
64  {
65  /* Deflate the congestion window by the amount of new data
66  * acknowledged by the Cumulative Acknowledgment field.
67  * If the partial ACK acknowledges at least one SMSS of new data,
68  * then add back SMSS bytes to the congestion window. This
69  * artificially inflates the congestion window in order to reflect
70  * the additional segment that has left the network. This "partial
71  * window deflation" attempts to ensure that, when fast recovery
72  * eventually ends, approximately ssthresh amount of data will be
73  * outstanding in the network.*/
74  tc->cwnd = (tc->cwnd > tc->bytes_acked + tc->snd_mss) ?
75  tc->cwnd - tc->bytes_acked : tc->snd_mss;
76  if (tc->bytes_acked > tc->snd_mss)
77  tc->cwnd += tc->snd_mss;
78  }
79  }
80 }
81 
82 static void
84 {
85  tc->ssthresh = tc->snd_wnd;
86  tc->cwnd = tcp_initial_cwnd (tc);
87 }
88 
90  .name = "newreno",
91  .congestion = newreno_congestion,
92  .loss = newreno_loss,
93  .recovered = newreno_recovered,
94  .rcv_ack = newreno_rcv_ack,
95  .rcv_cong_ack = newreno_rcv_cong_ack,
96  .init = newreno_conn_init
97 };
98 
101 {
102  clib_error_t *error = 0;
103 
105 
106  return error;
107 }
108 
110 
111 /*
112  * fd.io coding-style-patch-verification: ON
113  *
114  * Local Variables:
115  * eval: (c-set-style "gnu")
116  * End:
117  */
static void newreno_recovered(tcp_connection_t *tc)
Definition: tcp_newreno.c:32
static void newreno_conn_init(tcp_connection_t *tc)
Definition: tcp_newreno.c:83
#define clib_min(x, y)
Definition: clib.h:295
struct _tcp_connection tcp_connection_t
static void newreno_loss(tcp_connection_t *tc)
Definition: tcp_newreno.c:25
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:173
#define tcp_in_slowstart(tc)
Definition: tcp.h:430
static u32 tcp_flight_size(const tcp_connection_t *tc)
Our estimate of the number of bytes in flight (pipe size)
Definition: tcp.h:848
enum _tcp_cc_ack_t tcp_cc_ack_t
static void tcp_cwnd_accumulate(tcp_connection_t *tc, u32 thresh, u32 bytes)
Definition: tcp.h:893
vlib_main_t * vm
Definition: buffer.c:312
clib_error_t * newreno_init(vlib_main_t *vm)
Definition: tcp_newreno.c:100
static void newreno_rcv_ack(tcp_connection_t *tc, tcp_rate_sample_t *rs)
Definition: tcp_newreno.c:38
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:88
struct _tcp_cc_algorithm tcp_cc_algorithm_t
Definition: tcp.h:277
#define clib_max(x, y)
Definition: clib.h:288
static u32 tcp_initial_cwnd(const tcp_connection_t *tc)
Initial cwnd as per RFC5681.
Definition: tcp.h:873
static const tcp_cc_algorithm_t tcp_newreno
Definition: tcp_newreno.c:89
void newreno_rcv_cong_ack(tcp_connection_t *tc, tcp_cc_ack_t ack_type, tcp_rate_sample_t *rs)
Definition: tcp_newreno.c:52
#define tcp_opts_sack_permitted(_to)
Definition: tcp_packet.h:160
static u32 tcp_loss_wnd(const tcp_connection_t *tc)
Definition: tcp.h:906
static void newreno_congestion(tcp_connection_t *tc)
Definition: tcp_newreno.c:19