Page MenuHomeFreeBSD

D604.id1095.diff
No OneTemporary

D604.id1095.diff

Index: share/man/man4/Makefile
===================================================================
--- share/man/man4/Makefile
+++ share/man/man4/Makefile
@@ -87,6 +87,7 @@
cc_cdg.4 \
cc_chd.4 \
cc_cubic.4 \
+ cc_dctcp.4 \
cc_hd.4 \
cc_htcp.4 \
cc_newreno.4 \
Index: share/man/man4/cc_dctcp.4
===================================================================
--- /dev/null
+++ share/man/man4/cc_dctcp.4
@@ -0,0 +1,135 @@
+.\"
+.\" Copyright (c) 2014 Midori Kato <katoon@sfc.wide.ad.jp>
+.\" Copyright (c) 2014 The FreeBSD Foundation
+.\" All rights reserved.
+.\"
+.\" Portions of this documentation were written at Keio University, Japan.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
+.\" ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $FreeBSD$
+.\"
+.Dd June 30, 2013
+.Dt CC_DCTCP 4
+.Os
+.Sh NAME
+.Nm cc_dctcp
+.Nd DCTCP Congestion Control Algorithm
+.Sh DESCRIPTION
+The DCTCP congestion control algorithm is designed to provide short latency
+for flows while enabling high throughput for concurrent data transfers in
+a data center network.
+It leverages ECN (Explicit Congestion Notification) in the network.
+DCTCP identifies the depth of congestion from the proportion of feedbacks with
+ECN mark.
+In terms of congestion window control, DCTCP behaves differently from classic
+ECN defined in RFC3168.
+.Pp
+The congestion window is increased/decreased based on the NewReno congestion
+control equations.
+DCTCP calculates a fraction of ECE marks in the congestion window
+while increasing the congestion window.
+When updating the congestion window, DCTCP uses the fraction, whose
+window reduction ratio is always equal or less than 1/2.
+Only when all packets are marked, congestion window is halved.
+.Pp
+In order to keep the accuracy of the ECN marked fraction, a DCTCP receiver
+mirrors back incoming (or missing) CE marks by setting (or clearing) ECE marks
+in transition to or from CE marks. This feedback methodology is also adopted
+when the receiver uses delayed ACK.
+.Pp
+FreeBSD DCTCP implementation includes two minor modifications for the one-sided
+deployment. Considering the situation that DCTCP is used as sender and classic
+ECN is used as receiver, DCTCP sets the CWR flag as the reaction to the ECE
+flag. In addition, when classic ECN is used as sender and DCTCP is used as
+receiver, DCTCP avoids to mirror back ACKs only when the CWR flag is
+set in the incoming packet.
+.Pp
+The other specifications are based on the paper and Internet Draft referenced
+in the
+.Sx SEE ALSO
+section below.
+.Sh MIB Variables
+The algorithm exposes the following tunable variables in the
+.Va net.inet.tcp.cc.dctcp
+branch of the
+.Xr sysctl 3
+MIB:
+.Bl -tag -width ".Va alpha"
+.It Va alpha
+An initial estimator of the congestion on the link.
+Default is 0.
+.It Va dctcp_shift_g
+An estimation gain in the alpha calculation
+Default is 16.
+.It Va slowstart
+A trigger to halve congestion window after slow start.
+Default does nothing to halve window.
+
+.Sh SEE ALSO
+.Xr cc_chd 4 ,
+.Xr cc_cubic 4 ,
+.Xr cc_hd 4 ,
+.Xr cc_htcp 4 ,
+.Xr cc_newreno 4 ,
+.Xr cc_vegas 4 ,
+.Xr mod_cc 4 ,
+.Xr tcp 4 ,
+.Xr mod_cc 9
+.Rs
+.%A "Mohammad Alizadeh"
+.%A "Albert Greenberg"
+.%A "David A. Maltz"
+.%A "Jitendra Padhye"
+.%A "Parveen Patel"
+.%A "Balaji Prabhakar"
+.%A "Sudipta Sengupta"
+.%A "Murari Sridharan"
+.%T "Data Center TCP (DCTCP)"
+.%U "http://research.microsoft.com/pubs/121386/dctcp-public.pdf"
+.%J "ACM SIGCOMM 2010"
+.%D "July 2010"
+.%P "63-74"
+.Re
+.Rs
+.%A "Stephen Bensley"
+.%A "Lars Eggert"
+.%A "Dave Thaler"
+.%T "Microsoft's Datacenter TCP (DCTCP): TCP Congestion Control for Datacenters"
+.%U "http://tools.ietf.org/html/draft-bensley-tcpm-dctcp-01"
+.Re
+.Sh HISTORY
+The
+.Nm
+congestion control module first appeared in
+.Fx 11.0 .
+.Pp
+The module was first released in 2014 by Midori Kato studying at Keio
+University, Japan.
+.Sh AUTHORS
+.An -nosplit
+The
+.Nm
+congestion control module and this manual page were written by
+.An Midori Kato katoon@sfc.wide.ad.jp
+and
+.An Lars Eggert lars@netapp.com
Index: share/man/man4/mod_cc.4
===================================================================
--- share/man/man4/mod_cc.4
+++ share/man/man4/mod_cc.4
@@ -77,6 +77,7 @@
.Sh SEE ALSO
.Xr cc_chd 4 ,
.Xr cc_cubic 4 ,
+.Xr cc_dctcp 4 ,
.Xr cc_hd 4 ,
.Xr cc_htcp 4 ,
.Xr cc_newreno 4 ,
Index: sys/modules/cc/Makefile
===================================================================
--- sys/modules/cc/Makefile
+++ sys/modules/cc/Makefile
@@ -3,6 +3,7 @@
SUBDIR= cc_cdg \
cc_chd \
cc_cubic \
+ cc_dctcp \
cc_hd \
cc_htcp \
cc_vegas
Index: sys/modules/cc/cc_dctcp/Makefile
===================================================================
--- /dev/null
+++ sys/modules/cc/cc_dctcp/Makefile
@@ -0,0 +1,7 @@
+# $FreeBSD$
+
+.PATH: ${.CURDIR}/../../../netinet/cc
+KMOD= cc_dctcp
+SRCS= cc_dctcp.c
+
+.include <bsd.kmod.mk>
@@ -0,0 +1,7 @@
+# $FreeBSD$
+
+.PATH: ${.CURDIR}/../../../netinet/cc
+KMOD= cc_dctcp
+SRCS= cc_dctcp.c
+
+.include <bsd.kmod.mk>
Index: sys/netinet/cc.h
===================================================================
--- sys/netinet/cc.h
+++ sys/netinet/cc.h
@@ -143,6 +143,13 @@
/* Called when data transfer resumes after an idle period. */
void (*after_idle)(struct cc_var *ccv);
+ /* Called for an additional ECN processing apart from RFC3168. */
+ int (*ecnpkt_handler)(struct cc_var *ccv, uint8_t iptos, int cwr,
+ int is_delayack);
+
+ /* Called when the host marks ECN capable transmission (ECT). */
+ int (*ect_handler)(struct cc_var *ccv);
+
STAILQ_ENTRY (cc_algo) entries;
};
Index: sys/netinet/cc/cc_dctcp.c
===================================================================
--- /dev/null
+++ sys/netinet/cc/cc_dctcp.c
@@ -0,0 +1,481 @@
+/*-
+ * Copyright (c) 2007-2008
+ * Swinburne University of Technology, Melbourne, Australia
+ * Copyright (c) 2009-2010 Lawrence Stewart <lstewart@freebsd.org>
+ * Copyright (c) 2014 Midori Kato <katoon@sfc.wide.ad.jp>
+ * Copyright (c) 2014 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * An implementation of the DCTCP algorithm for FreeBSD, based on
+ * "Data Center TCP (DCTCP)" by M. Alizadeh, A. Greenberg, D. A. Maltz,
+ * J. Padhye, P. Patel, B. Prabhakar, S. Sengupta, and M. Sridharan.,
+ * in ACM Conference on SIGCOMM 2010, New York, USA,
+ * Originally released as the contribution of Microsoft Research project.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/param.h>
+#include <sys/kernel.h>
+#include <sys/malloc.h>
+#include <sys/module.h>
+#include <sys/socket.h>
+#include <sys/socketvar.h>
+#include <sys/sysctl.h>
+#include <sys/systm.h>
+
+#include <net/vnet.h>
+
+#include <netinet/in.h>
+#include <netinet/ip.h>
+#include <netinet/cc.h>
+#include <netinet/tcp_seq.h>
+#include <netinet/tcp_var.h>
+
+#include <netinet/cc/cc_module.h>
+
+#define CAST_PTR_INT(X) (*((int*)(X)))
+
+static VNET_DEFINE(uint32_t, dctcp_alpha) = 0;
+static VNET_DEFINE(uint32_t, dctcp_shift_g) = 4;
+static VNET_DEFINE(uint32_t, dctcp_slowstart) = 0;
+#define V_dctcp_alpha VNET(dctcp_alpha)
+#define V_dctcp_shift_g VNET(dctcp_shift_g)
+#define V_dctcp_slowstart VNET(dctcp_slowstart)
+
+struct dctcp {
+ int bytes_ecn; /* # of marked bytes during a RTT */
+ int bytes_total; /* # of acked bytes during a RTT */
+ int alpha; /* the fraction of marked bytes */
+ int ce_prev; /* CE state of the last segment */
+ int save_sndnxt; /* end sequence number of the current window */
+ int ece_curr; /* ECE flag in this segment */
+ int ece_prev; /* ECE flag in the last segment */
+ uint32_t num_cong_events; /* # of congestion events */
+};
+
+static MALLOC_DEFINE(M_dctcp, "dctcp data",
+ "Per connection data required for the dctcp algorithm");
+
+static void dctcp_ack_received(struct cc_var *ccv, uint16_t type);
+static void dctcp_after_idle(struct cc_var *ccv);
+static void dctcp_cb_destroy(struct cc_var *ccv);
+static int dctcp_cb_init(struct cc_var *ccv);
+static void dctcp_cong_signal(struct cc_var *ccv, uint32_t type);
+static void dctcp_conn_init(struct cc_var *ccv);
+static void dctcp_post_recovery(struct cc_var *ccv);
+static int dctcp_ecnpkt_handler(struct cc_var *ccv, uint8_t iptos, int cwr,
+ int is_delayack);
+static int dctcp_ect_handler(struct cc_var *ccv);
+static void dctcp_update_alpha(struct cc_var *ccv);
+
+struct cc_algo dctcp_cc_algo = {
+ .name = "dctcp",
+ .ack_received = dctcp_ack_received,
+ .cb_destroy = dctcp_cb_destroy,
+ .cb_init = dctcp_cb_init,
+ .cong_signal = dctcp_cong_signal,
+ .conn_init = dctcp_conn_init,
+ .post_recovery = dctcp_post_recovery,
+ .ecnpkt_handler = dctcp_ecnpkt_handler,
+ .after_idle = dctcp_after_idle,
+ .ect_handler = dctcp_ect_handler,
+};
+
+static void
+dctcp_ack_received(struct cc_var *ccv, uint16_t type)
+{
+ struct dctcp *dctcp_data;
+ int bytes_acked = 0;
+
+ dctcp_data = ccv->cc_data;
+
+ /*
+ * DCTCP doesn't regard with ECN as a congestion.
+ * Thus, DCTCP always executes the ACK processing out
+ * of congestion recovery.
+ */
+ if (IN_CONGRECOVERY(CCV(ccv, t_flags))) {
+ EXIT_CONGRECOVERY(CCV(ccv, t_flags));
+ newreno_cc_algo.ack_received(ccv, type);
+ ENTER_CONGRECOVERY(CCV(ccv, t_flags));
+ } else
+ newreno_cc_algo.ack_received(ccv, type);
+
+ /* Updates the fraction of marked bytes. */
+ if (CCV(ccv, t_flags) & TF_ECN_PERMIT) {
+
+ if (type == CC_DUPACK)
+ bytes_acked = CCV(ccv, t_maxseg);
+
+ if (type == CC_ACK)
+ bytes_acked = ccv->bytes_this_ack;
+
+ /* Update total bytes. */
+ dctcp_data->bytes_total += bytes_acked;
+
+ /* Update total marked bytes. */
+ if (dctcp_data->ece_curr) {
+ if (!dctcp_data->ece_prev
+ && bytes_acked > CCV(ccv, t_maxseg)) {
+ dctcp_data->bytes_ecn +=
+ (bytes_acked - CCV(ccv, t_maxseg));
+ } else
+ dctcp_data->bytes_ecn += bytes_acked;
+ dctcp_data->ece_prev = 1;
+ } else {
+ if (dctcp_data->ece_prev
+ && bytes_acked > CCV(ccv, t_maxseg))
+ dctcp_data->bytes_ecn += CCV(ccv, t_maxseg);
+ dctcp_data->ece_prev = 0;
+ }
+ dctcp_data->ece_curr = 0;
+
+ /*
+ * Update the fraction of marked bytes at the end of
+ * current window size.
+ */
+ if ((IN_FASTRECOVERY(CCV(ccv, t_flags)) &&
+ SEQ_GEQ(ccv->curack, CCV(ccv, snd_recover))) ||
+ (!IN_FASTRECOVERY(CCV(ccv, t_flags)) &&
+ SEQ_GT(ccv->curack, dctcp_data->save_sndnxt)))
+ dctcp_update_alpha(ccv);
+ }
+}
+
+static void
+dctcp_after_idle(struct cc_var *ccv)
+{
+ struct dctcp *dctcp_data;
+
+ dctcp_data = ccv->cc_data;
+
+ /* Initialize internal parameters after idle time */
+ dctcp_data->bytes_ecn = 0;
+ dctcp_data->bytes_total = 0;
+ dctcp_data->save_sndnxt = CCV(ccv, snd_nxt);
+ dctcp_data->alpha = V_dctcp_alpha;
+ dctcp_data->ece_curr = 0;
+ dctcp_data->ece_prev = 0;
+ dctcp_data->num_cong_events = 0;
+
+ dctcp_cc_algo.after_idle = newreno_cc_algo.after_idle;
+}
+
+static void
+dctcp_cb_destroy(struct cc_var *ccv)
+{
+ if (ccv->cc_data != NULL)
+ free(ccv->cc_data, M_dctcp);
+}
+
+static int
+dctcp_cb_init(struct cc_var *ccv)
+{
+ struct dctcp *dctcp_data;
+
+ dctcp_data = malloc(sizeof(struct dctcp), M_dctcp, M_NOWAIT|M_ZERO);
+
+ if (dctcp_data == NULL)
+ return (ENOMEM);
+
+ /* Initialize some key variables with sensible defaults. */
+ dctcp_data->bytes_ecn = 0;
+ dctcp_data->bytes_total = 0;
+ /*
+ * When alpha is set to 0 in the beggining, DCTCP sender transfers as
+ * much data as possible until the value converges which may expand the
+ * queueing delay at the switch. When alpha is set to 1, queueing delay
+ * is kept small.
+ * Throughput-sensitive applications should have alpha = 0
+ * Latency-sensitive applications should have alpha = 1
+ *
+ * Note: DCTCP draft suggests initial alpha to be 1 but we've decided to
+ * keep it 0.
+ */
+ dctcp_data->alpha = V_dctcp_alpha;
+ dctcp_data->save_sndnxt = 0;
+ dctcp_data->ce_prev = 0;
+ dctcp_data->ece_curr = 0;
+ dctcp_data->ece_prev = 0;
+ dctcp_data->num_cong_events = 0;
+
+ ccv->cc_data = dctcp_data;
+ return (0);
+}
+
+/*
+ * Perform any necessary tasks before we enter congestion recovery.
+ */
+static void
+dctcp_cong_signal(struct cc_var *ccv, uint32_t type)
+{
+ struct dctcp *dctcp_data;
+ u_int win, mss;
+
+ dctcp_data = ccv->cc_data;
+ win = CCV(ccv, snd_cwnd);
+ mss = CCV(ccv, t_maxseg);
+
+ switch (type) {
+ case CC_NDUPACK:
+ if (!IN_FASTRECOVERY(CCV(ccv, t_flags))) {
+ if (!IN_CONGRECOVERY(CCV(ccv, t_flags))) {
+ CCV(ccv, snd_ssthresh) = mss *
+ max(win / 2 / mss, 2);
+ dctcp_data->num_cong_events++;
+ } else {
+ /* cwnd has already updated as congestion
+ * recovery. Reverse cwnd value using
+ * snd_cwnd_prev and recalculate snd_ssthresh
+ */
+ win = CCV(ccv, snd_cwnd_prev);
+ CCV(ccv, snd_ssthresh) =
+ max(win / 2 / mss, 2) * mss;
+ }
+ ENTER_RECOVERY(CCV(ccv, t_flags));
+ }
+ break;
+ case CC_ECN:
+ /*
+ * Save current snd_cwnd when the host encounters both
+ * congestion recovery and fast recovery.
+ */
+ CCV(ccv, snd_cwnd_prev) = win;
+ if (!IN_CONGRECOVERY(CCV(ccv, t_flags))) {
+ if (V_dctcp_slowstart &&
+ dctcp_data->num_cong_events++ == 0) {
+ CCV(ccv, snd_ssthresh) =
+ mss * max(win / 2 / mss, 2);
+ dctcp_data->alpha = 1024;
+ dctcp_data->bytes_ecn = 0;
+ dctcp_data->bytes_total = 0;
+ dctcp_data->save_sndnxt = CCV(ccv, snd_nxt);
+ } else
+ CCV(ccv, snd_ssthresh) = max((win - ((win *
+ dctcp_data->alpha) >> 11)) / mss, 2) * mss;
+ CCV(ccv, snd_cwnd) = CCV(ccv, snd_ssthresh);
+ ENTER_CONGRECOVERY(CCV(ccv, t_flags));
+ }
+ dctcp_data->ece_curr = 1;
+ break;
+ case CC_RTO:
+ if (CCV(ccv, t_flags) & TF_ECN_PERMIT) {
+ CCV(ccv, t_flags) |= TF_ECN_SND_CWR;
+ dctcp_update_alpha(ccv);
+ dctcp_data->save_sndnxt += CCV(ccv, t_maxseg);
+ dctcp_data->num_cong_events++;
+ }
+ break;
+ }
+}
+
+static void
+dctcp_conn_init(struct cc_var *ccv)
+{
+ struct dctcp *dctcp_data;
+
+ dctcp_data = ccv->cc_data;
+
+ if (CCV(ccv, t_flags) & TF_ECN_PERMIT)
+ dctcp_data->save_sndnxt = CCV(ccv, snd_nxt);
+}
+
+/*
+ * Perform any necessary tasks before we exit congestion recovery.
+ */
+static void
+dctcp_post_recovery(struct cc_var *ccv)
+{
+ dctcp_cc_algo.post_recovery = newreno_cc_algo.post_recovery;
+
+ if (CCV(ccv, t_flags) & TF_ECN_PERMIT)
+ dctcp_update_alpha(ccv);
+}
+
+/*
+ * Execute an additional ECN processing using ECN field in IP header and the CWR
+ * bit in TCP header.
+ *
+ * Return:
+ * 1 - Delayed ACK disabled
+ * 0 - Delayed ACK not disabled
+ */
+static int
+dctcp_ecnpkt_handler(struct cc_var *ccv, uint8_t iptos, int cwr, int is_delayack)
+{
+ struct dctcp *dctcp_data;
+ int ret;
+
+ dctcp_data = ccv->cc_data;
+ ret = 0;
+
+ switch (iptos & IPTOS_ECN_MASK) {
+ case IPTOS_ECN_CE:
+ if (!dctcp_data->ce_prev && is_delayack)
+ ret = 1;
+ dctcp_data->ce_prev = 1;
+ CCV(ccv, t_flags) |= TF_ECN_SND_ECE;
+ break;
+ case IPTOS_ECN_ECT0:
+ case IPTOS_ECN_ECT1:
+ if (dctcp_data->ce_prev && is_delayack)
+ ret = 1;
+ CCV(ccv, t_flags) &= ~TF_ECN_SND_ECE;
+ dctcp_data->ce_prev = 0;
+ break;
+ }
+
+ /*
+ * DCTCP receiver send an ACK immediately
+ * - when the CE state in between this segment
+ * and the last segment is not the same
+ * - when this segment sets the CWR flag
+ */
+ if (cwr && is_delayack)
+ ret = 0;
+
+ return (ret);
+}
+
+static int
+dctcp_ect_handler(struct cc_var *ccv)
+{
+ /* DCTCP always marks ECT */
+ return (1);
+}
+
+/*
+ * Update the fraction of marked bytes represented as 'alpha'.
+ * Also initialize several internal parameters at the end of this function.
+ */
+static void
+dctcp_update_alpha(struct cc_var *ccv)
+{
+ struct dctcp *dctcp_data;
+ int alpha_prev;
+
+ dctcp_data = ccv->cc_data;
+ alpha_prev = dctcp_data->alpha;
+ dctcp_data->bytes_total = max(dctcp_data->bytes_total, 1);
+
+ /*
+ * Update alpha: alpha = (1 - g) * alpha + g * F.
+ * Here:
+ * g is weight factor
+ * recommaded to be set to 1/16
+ * small g = slow convergence between competitive DCTCP flows
+ * large g = impacts low utilization of bandwidth at switches
+ * F is fraction of marked segments in last RTT
+ * updated every RTT
+ * Alpha must be round to 0 - 1024.
+ * XXXMIDORI Is more fine-grained alpha necessary?
+ */
+ dctcp_data->alpha = min(alpha_prev - (alpha_prev >> V_dctcp_shift_g) +
+ (dctcp_data->bytes_ecn << (10 - V_dctcp_shift_g)) /
+ dctcp_data->bytes_total, 1024);
+
+ /* Initialize internal parameters for next alpha calculation */
+ dctcp_data->bytes_ecn = 0;
+ dctcp_data->bytes_total = 0;
+ dctcp_data->save_sndnxt = CCV(ccv, snd_nxt);
+}
+
+static int
+dctcp_alpha_handler(SYSCTL_HANDLER_ARGS)
+{
+ uint32_t new;
+ int error;
+
+ new = V_dctcp_alpha;
+ error = sysctl_handle_int(oidp, &new, 0, req);
+ if (error == 0 && req->newptr != NULL) {
+ if (CAST_PTR_INT(req->newptr) > 1)
+ error = EINVAL;
+ else
+ V_dctcp_alpha = new;
+ }
+
+ return (error);
+}
+
+static int
+dctcp_shift_g_handler(SYSCTL_HANDLER_ARGS)
+{
+ uint32_t new;
+ int error;
+
+ new = V_dctcp_shift_g;
+ error = sysctl_handle_int(oidp, &new, 0, req);
+ if (error == 0 && req->newptr != NULL) {
+ if (CAST_PTR_INT(req->newptr) > 1)
+ error = EINVAL;
+ else
+ V_dctcp_shift_g = new;
+ }
+
+ return (error);
+}
+
+static int
+dctcp_slowstart_handler(SYSCTL_HANDLER_ARGS)
+{
+ uint32_t new;
+ int error;
+
+ new = V_dctcp_slowstart;
+ error = sysctl_handle_int(oidp, &new, 0, req);
+ if (error == 0 && req->newptr != NULL) {
+ if (CAST_PTR_INT(req->newptr) > 1)
+ error = EINVAL;
+ else
+ V_dctcp_slowstart = new;
+ }
+
+ return (error);
+}
+
+SYSCTL_DECL(_net_inet_tcp_cc_dctcp);
+SYSCTL_NODE(_net_inet_tcp_cc, OID_AUTO, dctcp, CTLFLAG_RW, NULL,
+ "dctcp congestion control related settings");
+
+SYSCTL_VNET_PROC(_net_inet_tcp_cc_dctcp, OID_AUTO, alpha,
+ CTLTYPE_UINT|CTLFLAG_RW, &VNET_NAME(dctcp_alpha), 0,
+ &dctcp_alpha_handler,
+ "IU", "dctcp alpha parameter");
+
+SYSCTL_VNET_PROC(_net_inet_tcp_cc_dctcp, OID_AUTO, shift_g,
+ CTLTYPE_UINT|CTLFLAG_RW, &VNET_NAME(dctcp_shift_g), 4,
+ &dctcp_shift_g_handler,
+ "IU", "dctcp shift parameter");
+
+SYSCTL_VNET_PROC(_net_inet_tcp_cc_dctcp, OID_AUTO, slowstart,
+ CTLTYPE_UINT|CTLFLAG_RW, &VNET_NAME(dctcp_slowstart), 0,
+ &dctcp_slowstart_handler,
+ "IU", "half CWND reduction after the first slow start");
+
+DECLARE_CC_MODULE(dctcp, &dctcp_cc_algo);
Index: sys/netinet/tcp_input.c
===================================================================
--- sys/netinet/tcp_input.c
+++ sys/netinet/tcp_input.c
@@ -492,6 +492,19 @@
(tlen <= tp->t_maxopd) && \
(V_tcp_delack_enabled || (tp->t_flags & TF_NEEDSYN)))
+static void inline
+cc_ecnpkt_handler(struct tcpcb *tp, struct tcphdr *th, uint8_t iptos, int tlen)
+{
+ INP_WLOCK_ASSERT(tp->t_inpcb);
+
+ if (CC_ALGO(tp)->ecnpkt_handler != NULL) {
+ if (CC_ALGO(tp)->ecnpkt_handler(tp->ccv, iptos,
+ (th->th_flags & TH_CWR), DELAY_ACK(tp, tlen))) {
+ tcp_timer_activate(tp, TT_DELACK, tcp_delacktime);
+ }
+ }
+}
+
/*
* TCP input handling is split into multiple parts:
* tcp6_input is a thin wrapper around tcp_input for the extended
@@ -1523,6 +1536,10 @@
TCPSTAT_INC(tcps_ecn_ect1);
break;
}
+
+ /* Process a packet differently from RFC3168. */
+ cc_ecnpkt_handler(tp, th, iptos, tlen);
+
/* Congestion experienced. */
if (thflags & TH_ECE) {
cc_cong_signal(tp, th, CC_ECN);
Index: sys/netinet/tcp_output.c
===================================================================
--- sys/netinet/tcp_output.c
+++ sys/netinet/tcp_output.c
@@ -161,6 +161,24 @@
CC_ALGO(tp)->after_idle(tp->ccv);
}
+static int inline
+cc_ect_handler(struct tcpcb *tp)
+{
+ INP_WLOCK_ASSERT(tp->t_inpcb);
+
+ if (CC_ALGO(tp)->ect_handler != NULL) {
+ if (CC_ALGO(tp)->ect_handler(tp->ccv))
+ return (1);
+ else
+ return (0);
+ }
+ /*
+ * Currently, only dctcp needs/implements ect_handler. So if a module
+ * does not implement it, return SUCCESS.
+ */
+ return (1);
+}
+
/*
* Tcp output routine: figure out what should be sent and send it.
*/
@@ -965,9 +983,15 @@
* If the peer has ECN, mark data packets with
* ECN capable transmission (ECT).
* Ignore pure ack packets, retransmissions and window probes.
+ * Mark data packet with ECN capable transmission (ECT)
+ * when CC_ALGO meets specific condition.
+ * Or, if the peer has ECN, mark data packets with ECT
+ * (RFC 3168). Ignore pure ack packets, retransmissions
+ * and window probes.
*/
- if (len > 0 && SEQ_GEQ(tp->snd_nxt, tp->snd_max) &&
- !((tp->t_flags & TF_FORCEDATA) && len == 1)) {
+ if (cc_ect_handler(tp) &&
+ (len > 0 && SEQ_GEQ(tp->snd_nxt, tp->snd_max)
+ && !((tp->t_flags & TF_FORCEDATA) && len == 1))) {
#ifdef INET6
if (isipv6)
ip6->ip6_flow |= htonl(IPTOS_ECN_ECT0 << 20);

File Metadata

Mime Type
text/plain
Expires
Sat, Nov 8, 8:01 AM (9 h, 30 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
25031801
Default Alt Text
D604.id1095.diff (22 KB)

Event Timeline