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