xref: /titanic_52/usr/src/cmd/dtrace/demo/tcp/tcp1stbyte.d (revision 9cd928fe5e3ea4e05f64cfb380beb54b2623e7dc)
1*9cd928feSAlan Maguire #!/usr/sbin/dtrace -s
2*9cd928feSAlan Maguire /*
3*9cd928feSAlan Maguire  * CDDL HEADER START
4*9cd928feSAlan Maguire  *
5*9cd928feSAlan Maguire  * The contents of this file are subject to the terms of the
6*9cd928feSAlan Maguire  * Common Development and Distribution License (the "License").
7*9cd928feSAlan Maguire  * You may not use this file except in compliance with the License.
8*9cd928feSAlan Maguire  *
9*9cd928feSAlan Maguire  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*9cd928feSAlan Maguire  * or http://www.opensolaris.org/os/licensing.
11*9cd928feSAlan Maguire  * See the License for the specific language governing permissions
12*9cd928feSAlan Maguire  * and limitations under the License.
13*9cd928feSAlan Maguire  *
14*9cd928feSAlan Maguire  * When distributing Covered Code, include this CDDL HEADER in each
15*9cd928feSAlan Maguire  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*9cd928feSAlan Maguire  * If applicable, add the following below this CDDL HEADER, with the
17*9cd928feSAlan Maguire  * fields enclosed by brackets "[]" replaced with your own identifying
18*9cd928feSAlan Maguire  * information: Portions Copyright [yyyy] [name of copyright owner]
19*9cd928feSAlan Maguire  *
20*9cd928feSAlan Maguire  * CDDL HEADER END
21*9cd928feSAlan Maguire  */
22*9cd928feSAlan Maguire /*
23*9cd928feSAlan Maguire  * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
24*9cd928feSAlan Maguire  */
25*9cd928feSAlan Maguire 
26*9cd928feSAlan Maguire tcp:::connect-established
27*9cd928feSAlan Maguire {
28*9cd928feSAlan Maguire 	start[args[1]->cs_cid] = timestamp;
29*9cd928feSAlan Maguire }
30*9cd928feSAlan Maguire 
31*9cd928feSAlan Maguire tcp:::receive
32*9cd928feSAlan Maguire /start[args[1]->cs_cid] && (args[2]->ip_plength - args[4]->tcp_offset) > 0/
33*9cd928feSAlan Maguire {
34*9cd928feSAlan Maguire 	@latency["1st Byte Latency (ns)", args[2]->ip_saddr] =
35*9cd928feSAlan Maguire 	    quantize(timestamp - start[args[1]->cs_cid]);
36*9cd928feSAlan Maguire 	start[args[1]->cs_cid] = 0;
37*9cd928feSAlan Maguire }
38