1.\" 2.\" Copyright (c) 2010 The FreeBSD Foundation 3.\" 4.\" Portions of this software were developed at the Centre for Advanced 5.\" Internet Architectures, Swinburne University of Technology, Melbourne, 6.\" Australia by Lawrence Stewart under sponsorship from the FreeBSD 7.\" Foundation. 8.\" 9.\" Redistribution and use in source and binary forms, with or without 10.\" modification, are permitted provided that the following conditions 11.\" are met: 12.\" 1. Redistributions of source code must retain the above copyright 13.\" notice, this list of conditions, and the following disclaimer, 14.\" without modification, immediately at the beginning of the file. 15.\" 2. The name of the author may not be used to endorse or promote products 16.\" derived from this software without specific prior written permission. 17.\" 18.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 19.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR 22.\" ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28.\" SUCH DAMAGE. 29.\" 30.\" $FreeBSD$ 31.\" 32.Dd April 26, 2023 33.Dt SIFTR 4 34.Os 35.Sh NAME 36.Nm SIFTR 37.Nd Statistical Information For TCP Research 38.Sh SYNOPSIS 39To load 40the driver 41as a module at run-time, run the following command as root: 42.Bd -literal -offset indent 43kldload siftr 44.Ed 45.Pp 46Alternatively, to load 47the driver 48as a module at boot time, add the following line into the 49.Xr loader.conf 5 50file: 51.Bd -literal -offset indent 52siftr_load="YES" 53.Ed 54.Sh DESCRIPTION 55The 56.Nm 57.Po 58.Em S Ns tatistical 59.Em I Ns nformation 60.Em F Ns or 61.Em T Ns CP 62.Em R Ns esearch 63.Pc 64kernel module logs a range of statistics on active TCP connections to 65a log file. 66It provides the ability to make highly granular measurements of TCP connection 67state, aimed at system administrators, developers and researchers. 68.Ss Compile-time Configuration 69The default operation of 70.Nm 71is to capture IPv4 TCP/IP packets. 72.Nm 73can be configured to support IPv4 and IPv6 by uncommenting: 74.Bd -literal -offset indent 75CFLAGS+=-DSIFTR_IPV6 76.Ed 77.Pp 78in 79.Aq sys/modules/siftr/Makefile 80and recompiling. 81.Pp 82In the IPv4-only (default) mode, standard dotted decimal notation (e.g. 83"136.186.229.95") is used to format IPv4 addresses for logging. 84In IPv6 mode, standard dotted decimal notation is used to format IPv4 addresses, 85and standard colon-separated hex notation (see RFC 4291) is used to format IPv6 86addresses for logging. 87Note that SIFTR uses uncompressed notation to format IPv6 addresses. 88For example, the address "fe80::20f:feff:fea2:531b" would be logged as 89"fe80:0:0:0:20f:feff:fea2:531b". 90.Ss Run-time Configuration 91.Nm 92utilises the 93.Xr sysctl 8 94interface to export its configuration variables to user-space. 95The following variables are available: 96.Bl -tag -offset indent -width Va 97.It Va net.inet.siftr.enabled 98controls whether the module performs its 99measurements or not. 100By default, the value is set to 0, which means the module 101will not be taking any measurements. 102Having the module loaded with 103.Va net.inet.siftr.enabled 104set to 0 will have no impact on the performance of the network stack, as the 105packet filtering hooks are only inserted when 106.Va net.inet.siftr.enabled 107is set to 1. 108.El 109.Bl -tag -offset indent -width Va 110.It Va net.inet.siftr.ppl 111controls how many inbound/outbound packets for a given TCP connection will cause 112a log message to be generated for the connection. 113By default, the value is set to 1, which means the module will log a message for 114every packet of every TCP connection. 115The value can be set to any integer in the range [1,2^32], and can be changed at 116any time, even while the module is enabled. 117.El 118.Bl -tag -offset indent -width Va 119.It Va net.inet.siftr.logfile 120controls the path to the file that the module writes its log messages to. 121By default, the file /var/log/siftr.log is used. 122The path can be changed at any time, even while the module is enabled. 123.El 124.Bl -tag -offset indent -width Va 125.It Va net.inet.siftr.port_filter 126controls on which source or destination port siftr should capture 127.Nm . 128By default, the value is set to 0, which means all ports are eligible for logging. 129Set to any other value, only packets where either the source or destination 130port is equal to this number are logged. 131.El 132.Ss Log Format 133A typical 134.Nm 135log file will contain 3 different types of log message. 136All messages are written in plain ASCII text. 137.Pp 138Note: The 139.Qq \e 140present in the example log messages in this section indicates a 141line continuation and is not part of the actual log message. 142.Pp 143The first type of log message is written to the file when the module is 144enabled and starts collecting data from the running kernel. 145The text below shows an example module enable log. 146The fields are tab delimited key-value 147pairs which describe some basic information about the system. 148.Bd -literal -offset indent 149enable_time_secs=1238556193 enable_time_usecs=462104 \\ 150siftrver=1.2.2 hz=1000 tcp_rtt_scale=32 \\ 151sysname=FreeBSD sysver=604000 ipmode=4 152.Ed 153.Pp 154Field descriptions are as follows: 155.Bl -tag -offset indent -width Va 156.It Va enable_time_secs 157time at which the module was enabled, in seconds since the UNIX epoch. 158.El 159.Bl -tag -offset indent -width Va 160.It Va enable_time_usecs 161time at which the module was enabled, in microseconds since enable_time_secs. 162.El 163.Bl -tag -offset indent -width Va 164.It Va siftrver 165version of 166.Nm . 167.El 168.Bl -tag -offset indent -width Va 169.It Va sysname 170operating system name. 171.El 172.Bl -tag -offset indent -width Va 173.It Va sysver 174operating system version. 175.El 176.Bl -tag -offset indent -width Va 177.It Va ipmode 178IP mode as defined at compile time. 179An ipmode of "4" means IPv6 is not supported and IP addresses are logged in 180regular dotted quad format. 181An ipmode of "6" means IPv6 is supported, and IP addresses are logged in dotted 182quad or hex format, as described in the 183.Qq Compile-time Configuration 184subsection. 185.El 186.Pp 187The second type of log message is written to the file when a data log message 188is generated. 189The text below shows an example data log triggered by an IPv4 190TCP/IP packet. 191The data is CSV formatted. 192.Bd -literal -offset indent 193o,0xbec491a5,1238556193.463551,172.16.7.28,22,172.16.2.5,55931, \\ 1941073725440,172312,34,66560,66608,8,1,4,1448,936,1,996,255, \\ 19533304,208,66608,0,208,0 196.Ed 197.Pp 198Field descriptions are as follows: 199.Bl -tag -offset indent -width Va 200.It Va 1 201Direction of packet that triggered the log message. 202Either 203.Qq i 204for in, or 205.Qq o 206for out. 207.El 208.Bl -tag -offset indent -width Va 209.It Va 2 210Time at which the packet that triggered the log message was processed by 211the 212.Xr pfil 9 213hook function, in seconds and microseconds since the UNIX epoch. 214.El 215.Bl -tag -offset indent -width Va 216.It Va 3 217The IPv4 or IPv6 address of the local host, in dotted quad (IPv4 packet) 218or colon-separated hex (IPv6 packet) notation. 219.El 220.Bl -tag -offset indent -width Va 221.It Va 4 222The TCP port that the local host is communicating via. 223.El 224.Bl -tag -offset indent -width Va 225.It Va 5 226The IPv4 or IPv6 address of the foreign host, in dotted quad (IPv4 packet) 227or colon-separated hex (IPv6 packet) notation. 228.El 229.Bl -tag -offset indent -width Va 230.It Va 6 231The TCP port that the foreign host is communicating via. 232.El 233.Bl -tag -offset indent -width Va 234.It Va 7 235The slow start threshold for the flow, in bytes. 236.El 237.Bl -tag -offset indent -width Va 238.It Va 8 239The current congestion window for the flow, in bytes. 240.El 241.Bl -tag -offset indent -width Va 242.It Va 9 243The current state of the t_flags2 field for the flow. 244.El 245.Bl -tag -offset indent -width Va 246.It Va 10 247The current sending window for the flow, in bytes. 248The post scaled value is reported, except during the initial handshake (first 249few packets), during which time the unscaled value is reported. 250.El 251.Bl -tag -offset indent -width Va 252.It Va 11 253The current receive window for the flow, in bytes. 254The post scaled value is always reported. 255.El 256.Bl -tag -offset indent -width Va 257.It Va 12 258The current window scaling factor for the sending window. 259.El 260.Bl -tag -offset indent -width Va 261.It Va 13 262The current window scaling factor for the receiving window. 263.El 264.Bl -tag -offset indent -width Va 265.It Va 14 266The current state of the TCP finite state machine, as defined 267in 268.Aq Pa netinet/tcp_fsm.h . 269.El 270.Bl -tag -offset indent -width Va 271.It Va 15 272The maximum segment size for the flow, in bytes. 273.El 274.Bl -tag -offset indent -width Va 275.It Va 16 276The current smoothed RTT estimate for the flow, in units of microsecond. 277.El 278.Bl -tag -offset indent -width Va 279.It Va 17 280SACK enabled indicator. 1 if SACK enabled, 0 otherwise. 281.El 282.Bl -tag -offset indent -width Va 283.It Va 18 284The current state of the TCP flags for the flow. 285See 286.Aq Pa netinet/tcp_var.h 287for information about the various flags. 288.El 289.Bl -tag -offset indent -width Va 290.It Va 19 291The current retransmission timeout length for the flow, in units microsecond. 292.El 293.Bl -tag -offset indent -width Va 294.It Va 20 295The current size of the socket send buffer in bytes. 296.El 297.Bl -tag -offset indent -width Va 298.It Va 21 299The current number of bytes in the socket send buffer. 300.El 301.Bl -tag -offset indent -width Va 302.It Va 22 303The current size of the socket receive buffer in bytes. 304.El 305.Bl -tag -offset indent -width Va 306.It Va 23 307The current number of bytes in the socket receive buffer. 308.El 309.Bl -tag -offset indent -width Va 310.It Va 24 311The current number of unacknowledged bytes in-flight. 312Bytes acknowledged via SACK are not excluded from this count. 313.El 314.Bl -tag -offset indent -width Va 315.It Va 25 316The current number of segments in the reassembly queue. 317.El 318.Bl -tag -offset indent -width Va 319.It Va 26 320Flowid for the connection. 321A caveat: Zero '0' either represents a valid flowid or a default value when it's 322not being set. 323There is no easy way to differentiate without looking at actual 324network interface card and drivers being used. 325.El 326.Bl -tag -offset indent -width Va 327.It Va 27 328Flow type for the connection. 329Flowtype defines which protocol fields are hashed to produce the flowid. 330A complete listing is available in 331.Pa sys/mbuf.h 332under 333.Dv M_HASHTYPE_* . 334.El 335.Pp 336The third type of log message is written to the file when the module is disabled 337and ceases collecting data from the running kernel. 338The text below shows an example module disable log. 339The fields are tab delimited key-value pairs which provide statistics about 340operations since the module was most recently enabled. 341.Bd -literal -offset indent 342disable_time_secs=1238556197 disable_time_usecs=933607 \\ 343num_inbound_tcp_pkts=356 num_outbound_tcp_pkts=627 \\ 344total_tcp_pkts=983 num_inbound_skipped_pkts_malloc=0 \\ 345num_outbound_skipped_pkts_malloc=0 num_inbound_skipped_pkts_tcb=0 \\ 346num_outbound_skipped_pkts_tcb=0 num_inbound_skipped_pkts_icb=0 \\ 347num_outbound_skipped_pkts_icb=0 total_skipped_tcp_pkts=0 \\ 348flow_list=172.16.7.28;22-172.16.2.5;55931, 349.Ed 350.Pp 351Field descriptions are as follows: 352.Bl -tag -offset indent -width Va 353.It Va disable_time_secs 354Time at which the module was disabled, in seconds since the UNIX epoch. 355.El 356.Bl -tag -offset indent -width Va 357.It Va disable_time_usecs 358Time at which the module was disabled, in microseconds since disable_time_secs. 359.El 360.Bl -tag -offset indent -width Va 361.It Va num_inbound_tcp_pkts 362Number of TCP packets that traversed up the network stack. 363This only includes inbound TCP packets during the periods when 364.Nm 365was enabled. 366.El 367.Bl -tag -offset indent -width Va 368.It Va num_outbound_tcp_pkts 369Number of TCP packets that traversed down the network stack. 370This only includes outbound TCP packets during the periods when 371.Nm 372was enabled. 373.El 374.Bl -tag -offset indent -width Va 375.It Va total_tcp_pkts 376The summation of num_inbound_tcp_pkts and num_outbound_tcp_pkts. 377.El 378.Bl -tag -offset indent -width Va 379.It Va num_inbound_skipped_pkts_malloc 380Number of inbound packets that were not processed because of failed 381.Fn malloc 382calls. 383.El 384.Bl -tag -offset indent -width Va 385.It Va num_outbound_skipped_pkts_malloc 386Number of outbound packets that were not processed because of failed 387.Fn malloc 388calls. 389.El 390.Bl -tag -offset indent -width Va 391.It Va num_inbound_skipped_pkts_tcb 392Number of inbound packets that were not processed because of failure to find the 393TCP control block associated with the packet. 394.El 395.Bl -tag -offset indent -width Va 396.It Va num_outbound_skipped_pkts_tcb 397Number of outbound packets that were not processed because of failure to find 398the TCP control block associated with the packet. 399.El 400.Bl -tag -offset indent -width Va 401.It Va num_inbound_skipped_pkts_icb 402Number of inbound packets that were not processed because of failure to find the 403IP control block associated with the packet. 404.El 405.Bl -tag -offset indent -width Va 406.It Va num_outbound_skipped_pkts_icb 407Number of outbound packets that were not processed because of failure to find 408the IP control block associated with the packet. 409.El 410.Bl -tag -offset indent -width Va 411.It Va total_skipped_tcp_pkts 412The summation of all skipped packet counters. 413.El 414.Bl -tag -offset indent -width Va 415.It Va flow_list 416A CSV list of TCP flows that triggered data log messages to be generated since 417the module was loaded. 418Each flow entry in the CSV list is 419formatted as 420.Qq local_ip;local_port-foreign_ip;foreign_port . 421If there are no entries in the list (i.e., no data log messages were generated), 422the value will be blank. 423If there is at least one entry in the list, a trailing comma will always be 424present. 425.El 426.Pp 427The total number of data log messages found in the log file for a module 428enable/disable cycle should equate to total_tcp_pkts - total_skipped_tcp_pkts. 429.Sh IMPLEMENTATION NOTES 430.Nm 431hooks into the network stack using the 432.Xr pfil 9 433interface. 434In its current incarnation, it hooks into the AF_INET/AF_INET6 (IPv4/IPv6) 435.Xr pfil 9 436filtering points, which means it sees packets at the IP layer of the network 437stack. 438This means that TCP packets inbound to the stack are intercepted before 439they have been processed by the TCP layer. 440Packets outbound from the stack are intercepted after they have been processed 441by the TCP layer. 442.Pp 443The diagram below illustrates how 444.Nm 445inserts itself into the stack. 446.Bd -literal -offset indent 447---------------------------------- 448 Upper Layers 449---------------------------------- 450 ^ | 451 | | 452 | | 453 | v 454 TCP in TCP out 455---------------------------------- 456 ^ | 457 |________ _________| 458 | | 459 | v 460 --------- 461 | SIFTR | 462 --------- 463 ^ | 464 ________| |__________ 465 | | 466 | v 467IPv{4/6} in IPv{4/6} out 468---------------------------------- 469 ^ | 470 | | 471 | v 472Layer 2 in Layer 2 out 473---------------------------------- 474 Physical Layer 475---------------------------------- 476.Ed 477.Pp 478.Nm 479uses the 480.Xr alq 9 481interface to manage writing data to disk. 482.Pp 483At first glance, you might mistakenly think that 484.Nm 485extracts information from 486individual TCP packets. 487This is not the case. 488.Nm 489uses TCP packet events (inbound and outbound) for each TCP flow originating from 490the system to trigger a dump of the state of the TCP control block for that 491flow. 492With the PPL set to 1, we are in effect sampling each TCP flow's control block 493state as frequently as flow packets enter/leave the system. 494For example, setting PPL to 2 halves the sampling rate i.e., every second flow 495packet (inbound OR outbound) causes a dump of the control block state. 496.Pp 497The distinction between interrogating individual packets versus interrogating the 498control block is important, because 499.Nm 500does not remove the need for packet capturing tools like 501.Xr tcpdump 1 . 502.Nm 503allows you to correlate and observe the cause-and-affect relationship between 504what you see on the wire (captured using a tool like 505.Xr tcpdump 1 Ns ) 506and changes in the TCP control block corresponding to the flow of interest. 507It is therefore useful to use 508.Nm 509and a tool like 510.Xr tcpdump 1 511to gather the necessary data to piece together the complete picture. 512Use of either tool on its own will not be able to provide all of the necessary 513data. 514.Pp 515As a result of needing to interrogate the TCP control block, certain packets 516during the lifecycle of a connection are unable to trigger a 517.Nm 518log message. 519The initial handshake takes place without the existence of a control block and 520the final ACK is exchanged when the connection is in the TIMEWAIT state. 521.Pp 522.Nm 523was designed to minimise the delay introduced to packets traversing the network 524stack. 525This design called for a highly optimised and minimal hook function that 526extracted the minimal details necessary whilst holding the packet up, and 527passing these details to another thread for actual processing and logging. 528.Pp 529This multithreaded design does introduce some contention issues when accessing 530the data structure shared between the threads of operation. 531When the hook function tries to place details in the structure, it must first 532acquire an exclusive lock. 533Likewise, when the processing thread tries to read details from the structure, 534it must also acquire an exclusive lock to do so. 535If one thread holds the lock, the other must wait before it can obtain it. 536This does introduce some additional bounded delay into the kernel's packet 537processing code path. 538.Pp 539In some cases (e.g., low memory, connection termination), TCP packets that enter 540the 541.Nm 542.Xr pfil 9 543hook function will not trigger a log message to be generated. 544.Nm 545refers to this outcome as a 546.Qq skipped packet . 547Note that 548.Nm 549always ensures that packets are allowed to continue through the stack, even if 550they could not successfully trigger a data log message. 551.Nm 552will therefore not introduce any packet loss for TCP/IP packets traversing the 553network stack. 554.Ss Important Behaviours 555The behaviour of a log file path change whilst the module is enabled is as 556follows: 557.Bl -enum 558.It 559Attempt to open the new file path for writing. 560If this fails, the path change will fail and the existing path will continue to 561be used. 562.It 563Assuming the new path is valid and opened successfully: 564.Bl -dash 565.It 566Flush all pending log messages to the old file path. 567.It 568Close the old file path. 569.It 570Switch the active log file pointer to point at the new file path. 571.It 572Commence logging to the new file. 573.El 574.El 575.Pp 576During the time between the flush of pending log messages to the old file and 577commencing logging to the new file, new log messages will still be generated and 578buffered. 579As soon as the new file path is ready for writing, the accumulated log messages 580will be written out to the file. 581.Sh EXAMPLES 582To enable the module's operations, run the following command as root: 583sysctl net.inet.siftr.enabled=1 584.Pp 585To change the granularity of log messages such that 1 log message is 586generated for every 10 TCP packets per connection, run the following 587command as root: 588sysctl net.inet.siftr.ppl=10 589.Pp 590To change the log file location to /tmp/siftr.log, run the following 591command as root: 592sysctl net.inet.siftr.logfile=/tmp/siftr.log 593.Sh SEE ALSO 594.Xr tcpdump 1 , 595.Xr tcp 4 , 596.Xr sysctl 8 , 597.Xr alq 9 , 598.Xr pfil 9 599.Sh ACKNOWLEDGEMENTS 600Development of this software was made possible in part by grants from the 601Cisco University Research Program Fund at Community Foundation Silicon Valley, 602and the FreeBSD Foundation. 603.Sh HISTORY 604.Nm 605first appeared in 606.Fx 7.4 607and 608.Fx 8.2 . 609.Pp 610.Nm 611was first released in 2007 by Lawrence Stewart and James Healy whilst working on 612the NewTCP research project at Swinburne University of Technology's Centre for 613Advanced Internet Architectures, Melbourne, Australia, which was made possible 614in part by a grant from the Cisco University Research Program Fund at Community 615Foundation Silicon Valley. 616More details are available at: 617.Pp 618http://caia.swin.edu.au/urp/newtcp/ 619.Pp 620Work on 621.Nm 622v1.2.x was sponsored by the FreeBSD Foundation as part of 623the 624.Qq Enhancing the FreeBSD TCP Implementation 625project 2008-2009. 626More details are available at: 627.Pp 628https://www.freebsdfoundation.org/ 629.Pp 630http://caia.swin.edu.au/freebsd/etcp09/ 631.Sh AUTHORS 632.An -nosplit 633.Nm 634was written by 635.An Lawrence Stewart Aq Mt lstewart@FreeBSD.org 636and 637.An James Healy Aq Mt jimmy@deefa.com . 638.Pp 639This manual page was written by 640.An Lawrence Stewart Aq Mt lstewart@FreeBSD.org . 641.Sh BUGS 642Current known limitations and any relevant workarounds are outlined below: 643.Bl -dash 644.It 645The internal queue used to pass information between the threads of operation is 646currently unbounded. 647This allows 648.Nm 649to cope with bursty network traffic, but sustained high packet-per-second 650traffic can cause exhaustion of kernel memory if the processing thread cannot 651keep up with the packet rate. 652.It 653If using 654.Nm 655on a machine that is also running other modules utilising the 656.Xr pfil 9 657framework e.g. 658.Xr dummynet 4 , 659.Xr ipfw 8 , 660.Xr pf 4 Ns , 661the order in which you load the modules is important. 662You should kldload the other modules first, as this will ensure TCP packets 663undergo any necessary manipulations before 664.Nm 665.Qq sees 666and processes them. 667.It 668There is a known, harmless lock order reversal warning between the 669.Xr pfil 9 670mutex and tcbinfo TCP lock reported by 671.Xr witness 4 672when 673.Nm 674is enabled in a kernel compiled with 675.Xr witness 4 676support. 677.It 678There is no way to filter which TCP flows you wish to capture data for. 679Post processing is required to separate out data belonging to particular flows 680of interest. 681.It 682The module does not detect deletion of the log file path. 683New log messages will simply be lost if the log file being used by 684.Nm 685is deleted whilst the module is set to use the file. 686Switching to a new log file using the 687.Em net.inet.siftr.logfile 688variable will create the new file and allow log messages to begin being written 689to disk again. 690The new log file path must differ from the path to the deleted file. 691.It 692The hash table used within the code is sized to hold 65536 flows. 693This is not a 694hard limit, because chaining is used to handle collisions within the hash table 695structure. 696However, we suspect (based on analogies with other hash table performance data) 697that the hash table look up performance (and therefore the module's packet 698processing performance) will degrade in an exponential manner as the number of 699unique flows handled in a module enable/disable cycle approaches and surpasses 70065536. 701.It 702There is no garbage collection performed on the flow hash table. 703The only way currently to flush it is to disable 704.Nm . 705.It 706The PPL variable applies to packets that make it into the processing thread, 707not total packets received in the hook function. 708Packets are skipped before the PPL variable is applied, which means there may be 709a slight discrepancy in the triggering of log messages. 710For example, if PPL was set to 10, and the 8th packet since the last log message 711is skipped, the 11th packet will actually trigger the log message to be 712generated. 713This is discussed in greater depth in CAIA technical report 070824A. 714.It 715At the time of writing, there was no simple way to hook into the TCP layer 716to intercept packets. 717.Nm Ap s 718use of IP layer hook points means all IP 719traffic will be processed by the 720.Nm 721.Xr pfil 9 722hook function, which introduces minor, but nonetheless unnecessary packet delay 723and processing overhead on the system for non-TCP packets as well. 724Hooking in at the IP layer is also not ideal from the data gathering point of 725view. 726Packets traversing up the stack will be intercepted and cause a log message 727generation BEFORE they have been processed by the TCP layer, which means we 728cannot observe the cause-and-affect relationship between inbound events and the 729corresponding TCP control block as precisely as could be. 730Ideally, 731.Nm 732should intercept packets after they have been processed by the TCP layer i.e. 733intercept packets coming up the stack after they have been processed by 734.Fn tcp_input , 735and intercept packets coming down the stack after they have been 736processed by 737.Fn tcp_output . 738The current code still gives satisfactory granularity though, as inbound events 739tend to trigger outbound events, allowing the cause-and-effect to be observed 740indirectly by capturing the state on outbound events as well. 741.It 742The 743.Qq inflight bytes 744value logged by 745.Nm 746does not take into account bytes that have been 747.No SACK Ap ed 748by the receiving host. 749.It 750Compressed notation is not used for IPv6 address representation. 751This consumes more bytes than is necessary in log output. 752.El 753