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