1217806Slstewart/*-
2217806Slstewart * Copyright (c) 2009-2010
3217806Slstewart * 	Swinburne University of Technology, Melbourne, Australia
4217806Slstewart * Copyright (c) 2010 Lawrence Stewart <lstewart@freebsd.org>
5217806Slstewart * All rights reserved.
6217806Slstewart *
7217806Slstewart * This software was developed at the Centre for Advanced Internet
8220560Slstewart * Architectures, Swinburne University of Technology, by David Hayes, made
9220560Slstewart * possible in part by a grant from the Cisco University Research Program Fund
10220560Slstewart * at Community Foundation Silicon Valley.
11217806Slstewart *
12217806Slstewart * Redistribution and use in source and binary forms, with or without
13217806Slstewart * modification, are permitted provided that the following conditions
14217806Slstewart * are met:
15217806Slstewart * 1. Redistributions of source code must retain the above copyright
16217806Slstewart *    notice, this list of conditions and the following disclaimer.
17217806Slstewart * 2. Redistributions in binary form must reproduce the above copyright
18217806Slstewart *    notice, this list of conditions and the following disclaimer in the
19217806Slstewart *    documentation and/or other materials provided with the distribution.
20217806Slstewart *
21217806Slstewart * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
22217806Slstewart * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23217806Slstewart * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24217806Slstewart * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
25217806Slstewart * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26217806Slstewart * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27217806Slstewart * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28217806Slstewart * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29217806Slstewart * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30217806Slstewart * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31217806Slstewart * SUCH DAMAGE.
32217806Slstewart *
33217806Slstewart * $FreeBSD: releng/10.3/sys/netinet/khelp/h_ertt.h 220560 2011-04-12 08:13:18Z lstewart $
34217806Slstewart */
35217806Slstewart
36217806Slstewart/*
37217806Slstewart * The ERTT (Enhanced Round Trip Time) Khelp module calculates an estimate of
38217806Slstewart * the instantaneous TCP RTT which, for example, is used by delay-based
39217806Slstewart * congestion control schemes. When the module is loaded, ERTT data is
40217806Slstewart * calculated for each active TCP connection and encapsulated within a
41217806Slstewart * "struct ertt".
42217806Slstewart *
43217806Slstewart * This software was first released in 2010 by David Hayes and Lawrence Stewart
44220560Slstewart * whilst working on the NewTCP research project at Swinburne University of
45220560Slstewart * Technology's Centre for Advanced Internet Architectures, Melbourne,
46220560Slstewart * Australia, which was made possible in part by a grant from the Cisco
47220560Slstewart * University Research Program Fund at Community Foundation Silicon Valley.
48220560Slstewart * Testing and development was further assisted by a grant from the FreeBSD
49220560Slstewart * Foundation. More details are available at:
50217806Slstewart *   http://caia.swin.edu.au/urp/newtcp/
51217806Slstewart */
52217806Slstewart
53217806Slstewart#ifndef	_NETINET_KHELP_H_ERTT_
54217806Slstewart#define	_NETINET_KHELP_H_ERTT_
55217806Slstewart
56217806Slstewartstruct txseginfo;
57217806Slstewart
58217806Slstewart/* Structure used as the ertt data block. */
59217806Slstewartstruct ertt {
60217806Slstewart	/* Information about transmitted segments to aid in RTT calculation. */
61217806Slstewart	TAILQ_HEAD(txseginfo_head, txseginfo) txsegi_q;
62217806Slstewart	/* Bytes TX so far in marked RTT. */
63217806Slstewart	long		bytes_tx_in_rtt;
64217806Slstewart	/* Final version of above. */
65217806Slstewart	long		bytes_tx_in_marked_rtt;
66217806Slstewart	/* cwnd for marked RTT. */
67217806Slstewart	unsigned long	marked_snd_cwnd;
68217806Slstewart	/* Per-packet measured RTT. */
69217806Slstewart	int		rtt;
70217806Slstewart	/* Maximum RTT measured. */
71217806Slstewart	int		maxrtt;
72217806Slstewart	/* Minimum RTT measured. */
73217806Slstewart	int		minrtt;
74217806Slstewart	/* Guess if the receiver is using delayed ack. */
75217806Slstewart	int		dlyack_rx;
76217806Slstewart	/* Keep track of inconsistencies in packet timestamps. */
77217806Slstewart	int		timestamp_errors;
78217806Slstewart	/* RTT for a marked packet. */
79217806Slstewart	int		markedpkt_rtt;
80217806Slstewart	/* Flags to signal conditions between hook function calls. */
81217806Slstewart	uint32_t	flags;
82217806Slstewart};
83217806Slstewart
84217806Slstewart/* Flags for struct ertt. */
85217806Slstewart#define	ERTT_NEW_MEASUREMENT		0x01
86217806Slstewart#define	ERTT_MEASUREMENT_IN_PROGRESS	0x02
87217806Slstewart#define	ERTT_TSO_DISABLED		0x04
88217806Slstewart
89217806Slstewart#endif /* _NETINET_KHELP_H_ERTT_ */
90