summaryrefslogtreecommitdiffstats
path: root/src/vnet/session/transport.c
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2019-11-13 19:09:47 -0800
committerDave Barach <openvpp@barachs.net>2019-11-20 18:34:07 +0000
commit11e9e351046d8f4ab61b8aaf975046215fba7c5d (patch)
tree950838b8740b5b7e56a5157df8ac748b3868c920 /src/vnet/session/transport.c
parentd28437cdf2133533c9092b881ce0e4c243d6c1f6 (diff)
session tcp: support pacer idle timeouts
Type: feature To avoid excessive bursts, pacer must be provided with an estimated rtt for the connection. That's used to compute an idle timeout, i.e., time after which the bucket is reset to 1 mtu due to inactivity. For now, idle timeout is computed as 5% of the rtt. Change-Id: Ia0b752fe7b4ad0ce97b477fb886b0133a2321541 Signed-off-by: Florin Coras <fcoras@cisco.com>
Diffstat (limited to 'src/vnet/session/transport.c')
-rw-r--r--src/vnet/session/transport.c48
1 files changed, 17 insertions, 31 deletions
diff --git a/src/vnet/session/transport.c b/src/vnet/session/transport.c
index 902c7400af9..c8c58357afd 100644
--- a/src/vnet/session/transport.c
+++ b/src/vnet/session/transport.c
@@ -599,9 +599,9 @@ format_transport_pacer (u8 * s, va_list * args)
now = transport_us_time_now (thread_index);
diff = now - pacer->last_update;
- s = format (s, "rate %lu bucket %lu t/p %.3f last_update %U",
+ s = format (s, "rate %lu bucket %lu t/p %.3f last_update %U idle %u",
pacer->bytes_per_sec, pacer->bucket, pacer->tokens_per_period,
- format_clib_us_time, diff);
+ format_clib_us_time, diff, pacer->idle_timeout_us);
return s;
}
@@ -611,15 +611,14 @@ spacer_max_burst (spacer_t * pacer, clib_us_time_t time_now)
u64 n_periods = (time_now - pacer->last_update);
u64 inc;
- if (PREDICT_FALSE (n_periods > 5e4))
+ if (PREDICT_FALSE (n_periods > pacer->idle_timeout_us))
{
pacer->last_update = time_now;
pacer->bucket = TRANSPORT_PACER_MIN_BURST;
return TRANSPORT_PACER_MIN_BURST;
}
- if (n_periods > 0
- && (inc = (f32) n_periods * pacer->tokens_per_period) > 10)
+ if ((inc = (f32) n_periods * pacer->tokens_per_period) > 10)
{
pacer->last_update = time_now;
pacer->bucket = clib_min (pacer->bucket + inc, pacer->bytes_per_sec);
@@ -636,11 +635,14 @@ spacer_update_bucket (spacer_t * pacer, u32 bytes)
}
static inline void
-spacer_set_pace_rate (spacer_t * pacer, u64 rate_bytes_per_sec)
+spacer_set_pace_rate (spacer_t * pacer, u64 rate_bytes_per_sec,
+ clib_us_time_t rtt)
{
ASSERT (rate_bytes_per_sec != 0);
pacer->bytes_per_sec = rate_bytes_per_sec;
pacer->tokens_per_period = rate_bytes_per_sec * CLIB_US_TIME_PERIOD;
+ pacer->idle_timeout_us = clib_max (rtt * TRANSPORT_PACER_IDLE_FACTOR,
+ TRANSPORT_PACER_MIN_IDLE);
}
static inline u64
@@ -658,17 +660,19 @@ spacer_reset (spacer_t * pacer, clib_us_time_t time_now, u64 bucket)
void
transport_connection_tx_pacer_reset (transport_connection_t * tc,
- u64 rate_bytes_per_sec, u32 start_bucket)
+ u64 rate_bytes_per_sec, u32 start_bucket,
+ clib_us_time_t rtt)
{
- spacer_set_pace_rate (&tc->pacer, rate_bytes_per_sec);
+ spacer_set_pace_rate (&tc->pacer, rate_bytes_per_sec, rtt);
spacer_reset (&tc->pacer, transport_us_time_now (tc->thread_index),
start_bucket);
}
void
-transport_connection_tx_pacer_reset_bucket (transport_connection_t * tc)
+transport_connection_tx_pacer_reset_bucket (transport_connection_t * tc,
+ u32 bucket)
{
- spacer_reset (&tc->pacer, transport_us_time_now (tc->thread_index), 0);
+ spacer_reset (&tc->pacer, transport_us_time_now (tc->thread_index), bucket);
}
void
@@ -678,14 +682,14 @@ transport_connection_tx_pacer_init (transport_connection_t * tc,
{
tc->flags |= TRANSPORT_CONNECTION_F_IS_TX_PACED;
transport_connection_tx_pacer_reset (tc, rate_bytes_per_sec,
- initial_bucket);
+ initial_bucket, 1e6);
}
void
transport_connection_tx_pacer_update (transport_connection_t * tc,
- u64 bytes_per_sec)
+ u64 bytes_per_sec, clib_us_time_t rtt)
{
- spacer_set_pace_rate (&tc->pacer, bytes_per_sec);
+ spacer_set_pace_rate (&tc->pacer, bytes_per_sec, rtt);
}
u32
@@ -695,24 +699,6 @@ transport_connection_tx_pacer_burst (transport_connection_t * tc)
transport_us_time_now (tc->thread_index));
}
-u32
-transport_connection_snd_space (transport_connection_t * tc, u16 mss)
-{
- u32 snd_space, max_paced_burst;
-
- snd_space = tp_vfts[tc->proto].send_space (tc);
- if (snd_space && transport_connection_is_tx_paced (tc))
- {
- clib_us_time_t now = transport_us_time_now (tc->thread_index);
- max_paced_burst = spacer_max_burst (&tc->pacer, now);
- max_paced_burst =
- (max_paced_burst < TRANSPORT_PACER_MIN_BURST) ? 0 : max_paced_burst;
- snd_space = clib_min (snd_space, max_paced_burst);
- return snd_space >= mss ? snd_space - snd_space % mss : snd_space;
- }
- return snd_space;
-}
-
u64
transport_connection_tx_pacer_rate (transport_connection_t * tc)
{