Debian Codegraph @

testsuite/systemtap.examples/network/tcp_trace.stp

raw
1 #! /usr/bin/env stap
2 /*
3 * Copyright (C) 2009 IBM Corp.
4 * Copyright (C) 2015 Red Hat, Inc.
5 *
6 * This file is part of systemtap, and is free software. You can
7 * redistribute it and/or modify it under the terms of the GNU General
8 * Public License (GPL); either version 2, or (at your option) any
9 * later version.
10 *
11 * Version 0.1 [email protected] 2009-05-13
12 * Version 0.3 [email protected] 2009-05-20
13 * Version 1.0 [email protected] 2009-09-24
14 * Version 1.1 [email protected] 2009-10-08
15 *
16 * Tcp connection tracing utility.
17 *
18 * Description:
19 * This script traces tcp connections and displays connection parameters.
20 * The filter option specifies what parameters are to be displayed. Address
21 * "rules" must be supplied to limit what connections are to be traced.
22 *
23 * Synopsis:
24 * tcp_trace.stp [filter=all|state|txq|rxq|srtt|snd_cwnd|snd_wnd|rexmit\
25 * |pmtu|ssthresh|timer|rcvwnd|length]\
26 * [timeout=<N sec>]\
27 * [update=change|all]\
28 *
29 * Rule format:
30 * <local ip-address>:<local-port>-<remote ip-address>:<remote-port>
31 *
32 * filter tcp_trace collects the socket state and other connection
33 * parameters from various probe points in the tcp stack; however,
34 * not all this data may needed when debugging a tcp problem.
35 * Specifying only the required parameters reduces analysis time.
36 * Multiple parameters can be specified by using
37 * ','.
38 *
39 * timeout (optional) When a timeout value (in seconds) is specified
40 * tcp_trace will automatically terminate it's run at the end of
41 * the specified time. By default the script will run until the
42 * user terminates it by typing a ^c.
43 *
44 * update (optional) By default the script only displays data if there
45 * is a value change in a parameters specified in the "filter".
46 * This can be changed by specifying "update=all", which will
47 * output parameters of every packet that hits the probe.
48 * Note: Changes to the packet length will not trigger an update.
49 *
50 * Rules Rules limit what connections will be traced. Multiple rules may
51 * be given separated by a space. A wild-card value can be used
52 * for any component of the filter. Rules can be used to limit
53 * tracing to a single socket or allow many sockets to be traced.
54 * Memory consumed by the tracer will increase with the number
55 * of connections being traced.
56 *
57 * The Rule Format is:
58 * <local-address>:<local-port>-<remote address>:<remote-port>
59 *
60 * -Address are specified as ipv4 dot notation address.
61 * -Ports are specified as decimal numbers.
62 *
63 * "*" character can be used in any field to indicate a wild-card
64 * value.
65 *
66 * Note: The number of active sockets that can be traced is
67 * limited by MAXMAPENTRIES.
68 *
69 * Examples:
70 * Here are some examples of using tcp_trace:
71 *
72 * Trace TCP connection from 172.16.15.160 to 172.16.15.1 on
73 * port 22 with state,txq,rxq,pmtu filter.
74 *
75 * tcp_trace.stp filter=state,txq,rxq,pmtu timeout=100\
76 * 172.16.15.160:*-172.16.15.1:22
77 *
78 * Trace TCP connection from any address to the local http server.
79 * all parameters are displayed for every packet.
80 *
81 * tcp_trace.stp filter=all update=all *.*.*.*:*-*.*.*.*:80
82 */
83
84 global tcp_state;
85 global timer_info;
86
87 global filter;
88 global key_list;
89 global lastkey;
90 global number_of_rules;
91
92 global timeout = -1;
93 global always_update;
94
95 global snd_cwnd_flg;
96 global snd_cwnd;
97
98 global snd_wnd_flg;
99 global snd_wnd;
100
101 global srtt_flg;
102 global srtt;
103
104 global state_flg;
105 global state;
106
107 global txq_flg;
108 global txq;
109
110 global rxq_flg;
111 global rxq;
112
113 global rexmit_flg;
114 global rexmit;
115
116 global pmtu_flg;
117 global pmtu;
118
119 global ssthresh_flg;
120 global ssthresh;
121
122 global timer_flg;
123 global tx_timer;
124 global find_timer;
125
126 global rcvwnd_flg;
127 global rcvwnd;
128
129 global length_flg;
130 global length;
131
132 probe begin
133 {
134 number_of_rules = process_cmdline()
135
136 if ( number_of_rules < 1)
137 usage("One or more connection rules must be specified!")
138 if ( number_of_rules < 0 )
139 usage("Incorrect connection rule format!")
140
141 init_tcp_state()
142 init_timer_info()
143
144 printf("Start TCP Probing.....\n\n");
145 print_header();
146 }
147
148 function init_tcp_state ()
149 {
150 tcp_state[1] = "ESTABLISHED"
151 tcp_state[2] = "SYN_SENT"
152 tcp_state[3] = "SYN_RECV"
153 tcp_state[4] = "FIN_WAIT1"
154 tcp_state[5] = "FIN_WAIT2"
155 tcp_state[6] = "TIME_WAIT"
156 tcp_state[7] = "CLOSE"
157 tcp_state[8] = "CLOSE_WAIT"
158 tcp_state[9] = "LAST_ACK"
159 tcp_state[10] = "LISTEN"
160 tcp_state[11] = "CLOSING"
161 }
162
163 function state_num2str:string ( state:long )
164 {
165 return (state in tcp_state ? tcp_state[state] : "UNDEF")
166 }
167
168 function init_timer_info ()
169 {
170 timer_info[0] = ""
171 timer_info[1] = "Rxmit"
172 timer_info[2] = "Delack"
173 timer_info[3] = "Probe"
174 timer_info[4] = "Keepalv"
175 }
176
177 function timer_info_num2str:string ( timer:long )
178 {
179 return (timer in timer_info ? timer_info[timer] : "UNDEF")
180 }
181
182 probe kernel.{function("tcp_rcv_established"),
183 function("tcp_rcv_state_process")}
184 {
185 sk = $sk
186 key = filter_key(sk)
187 if ( !key ) next;
188
189 if ( is_packet_updated(key,sk) ) {
190 length[key] = $skb->len;
191 print_packet_info(key, 0)
192 }
193 }
194
195 probe kernel.function("tcp_transmit_skb")
196 {
197 sk = $sk
198 key = filter_key(sk)
199 if ( !key ) next;
200
201 if ( is_packet_updated(key,sk) ) {
202 length[key] = $skb->len;
203 print_packet_info(key, 1)
204 }
205 }
206
207 probe kernel.function("tcp_keepalive_timer")
208 {
209 if ( !timer_flg ) next;
210
211 sk = @choose_defined($data,
212 & @container_of($t, "struct sock", sk_timer))
213 key = filter_key(sk)
214 if ( !key ) next;
215
216 is_packet_updated(key,sk)
217 length[key] = 0
218 tx_timer[key] = 4;
219 print_packet_info(key, 1)
220 tx_timer[key] = 0;
221 }
222
223 probe kernel.function("tcp_delack_timer")
224 {
225 if ( !timer_flg ) next;
226
227 sk = @choose_defined($data,
228 & @container_of($t, "struct inet_connection_sock", icsk_delack_timer)->icsk_inet->sk)
229 key = filter_key(sk)
230 if ( !key ) next;
231
232 is_packet_updated(key,sk)
233 length[key] = 0
234 tx_timer[key] = 2;
235 print_packet_info(key, 1)
236 tx_timer[key] = 0;
237 }
238
239 probe kernel.function("tcp_send_probe0")
240 {
241 if ( !timer_flg ) next;
242
243 sk = $sk
244 key = filter_key(sk)
245 if ( !key ) next;
246
247 if ( find_timer[key] == 3 ) {
248 find_timer[key] = 0
249 tx_timer[key] = 3;
250 is_packet_updated(key,sk)
251 length[key] = 0
252 print_packet_info(key, 1)
253 tx_timer[key] = 0;
254 }
255 }
256
257 probe kernel.function("tcp_retransmit_skb")
258 {
259 if ( !timer_flg ) next;
260
261 sk = $sk;
262 key = filter_key(sk)
263 if ( !key ) next;
264
265 if ( find_timer[key] == 1 ) {
266 find_timer[key] = 0
267 tx_timer[key] = 1;
268 is_packet_updated(key,sk)
269 length[key] = $skb->len
270 print_packet_info(key,1)
271 tx_timer[key] = 0;
272 }
273 }
274
275 probe kernel.function("tcp_write_timer")
276 {
277 if ( !timer_flg ) next;
278
279 sk = @choose_defined($data,
280 & @container_of($t, "struct inet_connection_sock", icsk_retransmit_timer)->icsk_inet->sk )
281 key = filter_key(sk)
282 if ( !key ) next;
283
284 /* Don't trace calls to tcp_retransmit_skb()
285 * or tcp_send_probe0 that were not the result of a
286 * write timer expiration.
287 */
288 find_timer[key] = @cast(sk, "inet_connection_sock")->icsk_pending
289 }
290
291 %( kernel_v > "2.6.24" %?
292 probe kernel.function("tcp_set_state")
293 {
294 sk = $sk
295 new_state = $state
296 TCP_CLOSE = 7
297 TCP_CLOSE_WAIT = 8
298 key = filter_key(sk)
299 if ( key && ((new_state == TCP_CLOSE)||(new_state == TCP_CLOSE_WAIT))){
300 if (state_flg && state[key]) print_close(key,new_state);
301 clean_up(key);
302 }
303 }
304 %)
305
306 function print_header()
307 {
308 printf("%-22s","Source Address")
309 printf("%-22s","Dest Address")
310 if (state_flg) printf("%-12s","State")
311 if (timer_flg) printf("%-8s","Timer")
312 if (txq_flg) printf("%8s","Tx-Q")
313 if (rxq_flg) printf("%8s","Rx-Q")
314 if (pmtu_flg) printf("%8s","PMTU")
315 if (snd_cwnd_flg) printf("%8s","SndCwnd")
316 if (snd_wnd_flg) printf("%8s","SndWnd")
317 if (rcvwnd_flg) printf("%8s","RcvWnd")
318 if (srtt_flg) printf("%8s","SSRT")
319 if (ssthresh_flg) printf("%14s","Ssthreshold")
320 if (rexmit_flg) printf("%8s","Rexmit")
321 if (length_flg) printf("%8s","Length")
322 printf("\n");
323 }
324
325 function print_packet_info:long ( key:long, SourceIsLocal:long)
326 {
327 foreach ( [laddr, raddr, lport, rport] in key_list ){
328 if ( key_list[laddr, raddr, lport, rport] == key )
329 break
330 }
331
332 local_addr = sprintf("%s:%d",ip_ntop(htonl(laddr)), lport)
333 remote_addr = sprintf("%s:%d",ip_ntop(htonl(raddr)) ,rport)
334
335 SourceIsLocal ? printf("%-22s%-22s",local_addr,remote_addr):
336 printf("%-22s%-22s",remote_addr,local_addr)
337
338 if (state_flg) printf("%-12s",state_num2str(state[key]))
339 if (timer_flg) printf("%-8s",timer_info_num2str(tx_timer[key]))
340 if (txq_flg) printf("%8d",txq[key])
341 if (rxq_flg) printf("%8d",rxq[key])
342 if (pmtu_flg) printf("%8d",pmtu[key])
343 if (snd_cwnd_flg) printf("%8d",snd_cwnd[key])
344 if (snd_wnd_flg) printf("%8d",snd_wnd[key])
345 if (rcvwnd_flg) printf("%8d",rcvwnd[key])
346 if (srtt_flg) printf("%8d",srtt[key])
347 if (ssthresh_flg) printf("%14d",ssthresh[key])
348 if (rexmit_flg) printf("%8d",rexmit[key])
349 if (length_flg && length[key]) printf("%8d", length[key])
350 printf("\n");
351 }
352
353 %( kernel_v > "2.6.24" %?
354 function print_close:long (key:long, new_state:long)
355 {
356 foreach ( [laddr, raddr, lport, rport] in key_list ){
357 if ( key_list[laddr, raddr, lport, rport] == key )
358 break
359 }
360
361 local_addr = sprintf("%s:%d",ip_ntop(htonl(laddr)), lport)
362 remote_addr = sprintf("%s:%d",ip_ntop(htonl(raddr)) ,rport)
363
364 printf("%-22s%-22s",local_addr,remote_addr)
365 printf("%-12s",state_num2str(new_state))
366 printf("\n");
367 }
368 %)
369
370 /*
371 * Update the values in the data collection arrays, returns 1 if one or more
372 * values have changed.
373 */
374 function is_packet_updated:long ( key:long, sk:long )
375 {
376 packet_updated = 0
377
378 if ( !key ) return 0
379
380 if ( state_flg ) {
381 new_state = @cast(sk, "sock_common")->skc_state
382 if( always_update || (state[key] != new_state) ){
383 state[key]= new_state
384 packet_updated = 1
385 }
386 }
387
388 if ( txq_flg ) {
389 if(@cast(sk, "sock_common")->skc_state == 10)
390 new_txq = @cast(sk, "sock")->sk_max_ack_backlog
391 else
392 new_txq = @cast(sk, "tcp_sock")->write_seq -
393 @cast(sk, "tcp_sock")->snd_una
394 if( always_update || (txq[key] != new_txq) ){
395 txq[key] = new_txq
396 packet_updated = 1
397 }
398 }
399
400 if ( rxq_flg ) {
401 if(@cast(sk, "sock_common")->skc_state == 10)
402 new_rxq = @cast(sk, "sock")->sk_ack_backlog
403 else
404 new_rxq = @cast(sk, "tcp_sock")->rcv_nxt -
405 @cast(sk, "tcp_sock")->copied_seq
406
407 if( always_update || (rxq[key] != new_rxq) ){
408 rxq[key] = new_rxq
409 packet_updated = 1
410 }
411 }
412
413 if( rexmit_flg ) {
414 new_rexmit = @cast(sk, "inet_connection_sock")->icsk_retransmits
415 if( always_update || (rexmit[key] != new_rexmit ) ){
416 rexmit[key] = new_rexmit
417 packet_updated = 1
418 }
419 }
420
421 if ( pmtu_flg ) {
422 new_pmtu = @cast(sk, "inet_connection_sock")->icsk_pmtu_cookie
423 if( always_update || (pmtu[key] != new_pmtu) ){
424 pmtu[key] = new_pmtu
425 packet_updated = 1
426 }
427 }
428
429 if ( snd_cwnd_flg ) {
430 new_snd_cwnd = @cast(sk, "tcp_sock")->snd_cwnd
431 if( always_update || (snd_cwnd[key] != new_snd_cwnd) ){
432 snd_cwnd[key] = new_snd_cwnd
433 packet_updated = 1
434 }
435 }
436
437
438 if ( snd_wnd_flg ) {
439 new_snd_wnd = @cast(sk, "tcp_sock")->snd_wnd
440 if( always_update || (snd_wnd[key] != new_snd_wnd) ){
441 snd_wnd[key] = new_snd_wnd
442 packet_updated = 1
443 }
444 }
445
446 if ( srtt_flg ) {
447 new_srtt = @choose_defined(@cast(sk, "tcp_sock")->srtt_us,
448 @cast(sk, "tcp_sock")->srtt)
449 if( always_update || (srtt[key] != new_srtt) ){
450 srtt[key] = new_srtt
451 packet_updated = 1
452 }
453 }
454
455 if( ssthresh_flg ) {
456 new_ssthresh = tcp_current_ssthresh(sk)
457 if( always_update || (ssthresh[key] != new_ssthresh) ){
458 ssthresh[key] = new_ssthresh
459 packet_updated = 1
460 }
461 }
462
463 if ( rcvwnd_flg ) {
464 new_rcvwnd = @cast(sk, "tcp_sock")->rcv_wnd
465 if( always_update || (rcvwnd[key] != new_rcvwnd) ){
466 rcvwnd[key] = new_rcvwnd
467 packet_updated = 1
468 }
469 }
470
471 return packet_updated
472 }
473
474 /*
475 * copied from:
476 * include/net/tcp.h:tcp_current_ssthresh()
477 */
478 function tcp_current_ssthresh(sk:long)
479 {
480 if ((1 << @cast(sk, "inet_connection_sock")->icsk_ca_state) &
481 ((1 << 2) | (1 << 3))){
482 return @cast(sk, "tcp_sock")->snd_ssthresh
483 }else{
484 return netmax(@cast(sk, "tcp_sock")->snd_ssthresh,
485 ((@cast(sk, "tcp_sock")->snd_cwnd >>1)+
486 (@cast(sk, "tcp_sock")->snd_cwnd >> 2)))
487 }
488 }
489
490 function netmax:long (val1:long, val2:long)
491 {
492 if(val1 > val2)
493 return val1
494 else
495 return val2
496 }
497
498 /* All command line arguments other than the address rules are processed
499 * first and must be placed on the command line prior to any address rules.
500 */
501 function process_cmdline:long ()
502 {
503 filter_number = 0
504 for (i=1; i <= argc; i++) {
505 argument = tokenize(argv[i], "=")
506
507 if (argument == "help")
508 usage("")
509
510 if (argument == "filter") {
511 filter_given=1;
512 argv[i]=""
513 while(strlen(byte = tokenize(argv[i], ",")) != 0) {
514 argv[i] = ""
515 if ( byte == "snd_cwnd" ) {
516 snd_cwnd_flg = 1; continue };
517 if ( byte == "snd_wnd" ) {
518 snd_wnd_flg = 1; continue };
519 if ( byte == "srtt" ) {
520 srtt_flg = 1; continue };
521 %( kernel_v > "2.6.24" %?
522 if ( byte == "state" ) {
523 state_flg = 1; continue };
524 %:
525 state_flg = 0;
526 %)
527 if ( byte == "txq" ) {
528 txq_flg = 1; continue };
529 if ( byte == "rxq" ) {
530 rxq_flg = 1; continue };
531 if ( byte == "rexmit" ) {
532 rexmit_flg = 1; continue };
533 if ( byte == "pmtu" ) {
534 pmtu_flg = 1; continue };
535 if ( byte == "ssthresh" ) {
536 ssthresh_flg = 1; continue };
537 if ( byte == "timer" ) {
538 timer_flg = 1; continue };
539 if ( byte == "rcvwnd" ) {
540 rcvwnd_flg = 1; continue };
541 if ( byte == "length" ) {
542 length_flg = 1; continue };
543 if ( byte == "all" ) {
544 snd_cwnd_flg = snd_wnd_flg = srtt_flg =
545 txq_flg = rxq_flg =
546 rexmit_flg = pmtu_flg = ssthresh_flg =
547 timer_flg = rcvwnd_flg = length_flg = 1;
548 %( kernel_v > "2.6.24" %?
549 state_flg = 1;
550 %)
551 continue
552 };
553 usage("Unknown filter value given!")
554 }
555 continue;
556 }
557
558 if ( argument == "timeout" ){
559 argv[i]=""
560 timeout=strtol(tokenize(argv[i], "="),10)
561 continue;
562 }
563
564 if ( argument == "update") {
565 argv[i]=""
566 update_disp = tokenize(argv[i], "=")
567 if (update_disp == "all")
568 always_update = 1;
569 continue;
570 }
571
572 /* Anything on the command line after this point must
573 * be an address rule.
574 */
575 source = tokenize(argv[i], "-")
576 argv[i] = ""
577 dest = tokenize(argv[i], "-")
578
579 source_addr = tokenize(source, ":")
580 source=""
581 source_port = tokenize(source, ":")
582
583 dest_addr = tokenize(dest, ":")
584 dest=""
585 dest_port = tokenize(dest, ":")
586
587 /* stap bug */
588 if ( dest_port == "fobar") i=i;
589
590 ++filter_number;
591 j=filter_number*6;
592 filter[j] = ipv4_pton(source_addr,0) // Source address
593 filter[j+1] = ipv4_pton(source_addr,1) // Source address mask
594 filter[j+2] = ipv4_portton(source_port) // Source port
595 filter[j+3] = ipv4_pton(dest_addr,0) // Dest address
596 filter[j+4] = ipv4_pton(dest_addr,1) // Dest address mask
597 filter[j+5] = ipv4_portton(dest_port) // Dest port
598
599 if (filter[j]< -1 ||
600 filter[j+1] < -1 ||
601 filter[j+2] < -1 ||
602 filter[j+3] < -1 ||
603 filter[j+4] < -1 ||
604 filter[j+5] < -1 ) return -1;
605
606 }
607
608 /* default filter is all */
609 if ( !filter_given )
610 snd_cwnd_flg = snd_wnd_flg = srtt_flg =
611 txq_flg = rxq_flg =
612 rexmit_flg = pmtu_flg = ssthresh_flg =
613 timer_flg = rcvwnd_flg = length_flg = 1;
614 %( kernel_v > "2.6.24" %?
615 state_flg = 1;
616 %)
617 return filter_number;
618 }
619
620 /*
621 * Convert an ascii integer values between 0 and 65534 to a u16 port number.
622 * "*" are treated as wildcards and will be converted to -1.
623 */
624 function ipv4_portton:long (port:string)
625 {
626 if ( port == "*" )
627 return -1;
628
629 pport=strtol(port,10);
630
631 if ( pport > 0xffff ){
632 printf("Bad port number %s\n",port)
633 return -22;
634 }
635
636 return pport
637 }
638
639 /*
640 * Convert ipv4 dot notation address into longs.
641 * Supports "*" in any field treating it as a wildcard by making the byte=0.
642 * If make_mask is set it creates a mask based on the "*" fields. All non='*'
643 * bytes are set to 0xff all * fields are set to 0x0;.
644 */
645 function ipv4_pton:long (addr:string, make_mask:long)
646 {
647 i=32;
648 ip=0;
649 ips=addr;
650 while(strlen(byte = tokenize(ips, ".")) != 0) {
651 i-=8;
652 ips="";
653
654 if ( byte == "*" ){
655 byte = "0"
656 } else {
657 if ( make_mask ) byte = "255";
658 }
659
660 j=strtol(byte,10);
661 if ( j > 255 ){
662 printf("bad address %s\n",addr)
663 return -22;
664 }
665 ip=ip+(j<<i) // left shift the byte into the address
666 }
667 if ( i != 0 ){
668 printf("bad address %s\n",addr)
669 return -22;
670 }
671 return ip;
672 }
673
674 /*
675 * Returns a unique value (stored in the global key_list) based on the socket
676 * address tuple. A new value is created if one does not already exist.
677 */
678 function build_key:long (laddr:long, raddr:long, lport:long, rport:long)
679 {
680 if ( key_list[laddr, raddr, lport, rport] )
681 return key_list[laddr, raddr, lport, rport]
682 else
683 return key_list[laddr, raddr, lport, rport] = ++lastkey
684 }
685
686 /*
687 * Checks the tuple against the rule list. If we pass through the rule
688 * then return a unique key value, otherwise return zero.
689 */
690 function filter_key:long (sk:long)
691 {
692 laddr = tcpmib_local_addr(sk);
693 raddr = tcpmib_remote_addr(sk);
694 lport = tcpmib_local_port(sk);
695 rport = tcpmib_remote_port(sk);
696
697 for (i=1; i <= number_of_rules; i++){
698 j=i*6;
699
700 // Local filter
701 local_filter=remote_filter=0;
702 if ( (laddr&filter[j+1]) == filter[j] ) {
703 if ( (filter[j+2] == -1 ) || (lport == filter[j+2]))
704 local_filter = 1;
705 }
706 // Remote filter
707 if ( (raddr&filter[j+4]) == filter[j+3] ) {
708 if ( (filter[j+5] == -1 ) || (rport == filter[j+5]))
709 remote_filter = 1;
710 }
711 if(local_filter && remote_filter){
712 return build_key(laddr, raddr, lport, rport);
713 }
714 }
715 return 0;
716 }
717
718 /* Free up a slot in the data arrays */
719 %( kernel_v > "2.6.24" %?
720 function clean_up (key:long)
721 {
722 foreach ( [laddr, raddr, lport, rport] in key_list ){
723 if ( key_list[laddr, raddr, lport, rport] == key ){
724 break
725 }
726 }
727
728 delete key_list[laddr, raddr, lport, rport]
729
730 if (snd_cwnd_flg) delete snd_cwnd[key];
731 if (snd_wnd_flg) delete snd_wnd[key];
732 if (srtt_flg) delete srtt[key];
733 if (state_flg) delete state[key];
734 if (txq_flg) delete txq[key];
735 if (rxq_flg) delete rxq[key];
736 if (rexmit_flg) delete rexmit[key];
737 if (pmtu_flg) delete pmtu[key];
738 if (ssthresh_flg) delete ssthresh[key];
739 if ( timer_flg ) {
740 delete tx_timer[key];
741 delete find_timer[key];
742 }
743 if (rcvwnd_flg) delete rcvwnd[key];
744 delete length[key];
745 }
746 %)
747
748 /* Terminates the run in timeout seconds, using global timeout value */
749 probe timer.s(1) {
750 if ( timeout == -1 ) next
751 if ( !--timeout ) exit()
752 }
753
754 function usage (msg:string)
755 {
756 printf("\nUsage:\n");
757 printf("\ttcp_trace.stp filter=<list of filters>[timeout=<sec>] \n");
758 printf("\t\t\t[update=change|all] Rule\n\n");
759 printf("\tRule format:");
760 printf("<local address>:<local-port>-<remote address>:<remote-port>\n");
761 %( kernel_v > "2.6.24" %?
762 printf("\tFilter values: all|state|txq|rxq|srtt|snd_cwnd|snd_wnd|\n");
763 %:
764 printf("\tFilter values: all|txq|rxq|srtt|snd_cwnd|snd_wnd|\n");
765 %)
766 printf("\t\t\trexmit|pmtu|ssthresh|timer|rcvwnd\n\n");
767 printf("%s\n\n",msg);
768 error(msg);
769 }