build: flowtop: Only build ioops with GeoIP support enabled
[netsniff-ng.git] / netsniff-ng.8
blobc6356bf76f65618df008a957c1f09261eb9dd980
1 .\" netsniff-ng - the packet sniffing beast
2 .\" Copyright 2013 Daniel Borkmann.
3 .\" Subject to the GPL, version 2.
4 .TH NETSNIFF-NG 8 "03 March 2013" "Linux" "netsniff-ng toolkit"
5 .SH NAME
6 netsniff-ng \- the packet sniffing beast
7 .PP
8 .SH SYNOPSIS
9 .PP
10 \fBnetsniff-ng\fR { [\fIoptions\fR] [\fIfilter-expression\fR] }
11 .PP
12 .SH DESCRIPTION
13 .PP
14 netsniff-ng is a fast, minimal tool to analyze network packets, capture
15 pcap files, replay pcap files, and redirect traffic between interfaces
16 with the help of zero-copy packet(7) sockets. netsniff-ng uses both Linux
17 specific RX_RING and TX_RING interfaces to perform zero-copy. This is to avoid
18 copy and system call overhead between kernel and user address space. When we
19 started working on netsniff-ng, the pcap(3) library did not use this
20 zero-copy facility.
21 .PP
22 netsniff-ng is Linux specific, meaning there is no support for other
23 operating systems. Therefore we can keep the code footprint quite minimal and to
24 the point. Linux packet(7) sockets and its RX_RING and TX_RING interfaces
25 bypass the normal packet processing path through the networking stack.
26 This is the fastest capturing or transmission performance one can get from user
27 space out of the box, without having to load unsupported or non-mainline
28 third-party kernel modules. We explicitly refuse to build netsniff-ng on top of
29 ntop/PF_RING. Not because we do not like it (we do find it interesting), but
30 because of the fact that it is not part of the mainline kernel. Therefore, the
31 ntop project has to maintain and sync out-of-tree drivers to adapt them to their
32 DNA. Eventually, we went for untainted Linux kernel, since its code has a higher
33 rate of review, maintenance, security and bug fixes.
34 .PP
35 netsniff-ng also supports early packet filtering in the kernel. It has support
36 for low-level and high-level packet filters that are translated into Berkeley
37 Packet Filter instructions.
38 .PP
39 netsniff-ng can capture pcap files in several different pcap formats that
40 are interoperable with other tools. It has different pcap I/O methods supported
41 (scatter-gather, mmap(2), read(2), and write(2)) for efficient to-disc capturing.
42 netsniff-ng is also able to rotate pcap files based on data size or time
43 intervals, thus, making it a useful backend tool for subsequent traffic
44 analysis.
45 .PP
46 netsniff-ng itself also supports analysis, replaying, and dumping of raw 802.11
47 frames. For online or offline analysis, netsniff-ng has a built-in packet
48 dissector for the current 802.3 (Ethernet), 802.11* (WLAN), ARP, MPLS, 802.1Q
49 (VLAN), 802.1QinQ, LLDP, IPv4, IPv6, ICMPv4, ICMPv6, IGMP, TCP and UDP,
50 including GeoIP location analysis. Since netsniff-ng does not establish any
51 state or perform reassembly during packet dissection, its memory footprint is quite
52 low, thus, making netsniff-ng quite efficient for offline analysis of large
53 pcap files as well.
54 .PP
55 Note that netsniff-ng is currently not multithreaded. However, this does not
56 prevent you from starting multiple netsniff-ng instances that are pinned to
57 different, non-overlapping CPUs and f.e. have different BPF filters attached.
58 Likely that at some point in time your harddisc might become a bottleneck
59 assuming you do not rotate such pcaps in ram (and from there periodically
60 scheduled move to slower medias). You can then use mergecap(1) to transform
61 all pcaps into a single large pcap. Thus, netsniff-ng then works multithreaded
62 eventually.
63 .PP
64 netsniff-ng can also be used to debug netlink traffic.
65 .PP
66 .SH OPTIONS
67 .PP
68 .SS -i <dev|pcap|->, -d <dev|pcap|->, --in <dev|pcap|->, --dev <dev|pcap|->
69 Defines an input device. This can either be a networking device, a pcap file
70 or stdin (\[lq]\-\[rq]). In case of a pcap file, the pcap type (\[lq]\-D\[rq]
71 option) is determined automatically by the pcap file magic. In case of stdin,
72 it is assumed that the input stream is a pcap file.
73 .PP
74 .SS -o <dev|pcap|dir|cfg|->, --out <dev|pcap|dir|cfg|->
75 Defines the output device. This can either be a networking device, a pcap file,
76 a folder, a trafgen(8) configuration file or stdout (\[lq]-\[rq]). In the case of a pcap
77 file that should not have the default pcap type (0xa1b2c3d4), the additional
78 option \[lq]\-T\[rq] must be provided. If a directory is given, then, instead of a
79 single pcap file, multiple pcap files are generated with rotation based on
80 maximum file size or a given interval (\[lq]\-F\[rq] option). A trafgen configuration
81 file can currently only be specified if the input device is a pcap file. If
82 stdout is given as a device, then a trafgen configuration will be written to
83 stdout if the input device is a pcap file, or a pcap file if the input device
84 is a networking device.
85 .PP
86 .SS -f, --filter <bpf-file|expr>
87 Specifies to not dump all traffic, but to filter the network packet haystack.
88 As a filter, either a bpfc(8) compiled file can be passed as a parameter or
89 a tcpdump(1)-like filter expression in quotes. For details regarding the
90 bpf-file have a look at bpfc(8), for details regarding a tcpdump(1)-like filter
91 have a look at section \[lq]filter example\[rq] or at pcap-filter(7). A filter
92 expression may also be passed to netsniff-ng without option \[lq]\-f\[rq] in case
93 there is no subsequent option following after the command-line filter expression.
94 .PP
95 .SS -t, --type <type>
96 This defines some sort of filtering mechanisms in terms of addressing. Possible
97 values for type are \[lq]host\[rq] (to us), \[lq]broadcast\[rq] (to all), \[lq]multicast\[rq] (to
98 group), \[lq]others\[rq] (promiscuous mode) or \[lq]outgoing\[rq] (from us).
99 .PP
100 .SS -F, --interval <size|time>
101 If the output device is a folder, with \[lq]\-F\[rq], it is possible to define the pcap
102 file rotation interval either in terms of size or time. Thus, when the interval
103 limit has been reached, a new pcap file will be started. As size parameter, the
104 following values are accepted \[lq]<num>KiB/MiB/GiB\[rq]; As time parameter,
105 it can be \[lq]<num>s/sec/min/hrs\[rq].
107 .SS -J, --jumbo-support
108 By default, in pcap replay or redirect mode, netsniff-ng's ring buffer frames
109 are a fixed size of 2048 bytes. This means that if you are expecting jumbo
110 frames or even super jumbo frames to pass through your network, then you need
111 to enable support for that by using this option. However, this has the
112 disadvantage of performance degradation and a bigger memory footprint for the
113 ring buffer. Note that this doesn't affect (pcap) capturing mode, since tpacket
114 in version 3 is used!
116 .SS -R, --rfraw
117 In case the input or output networking device is a wireless device, it is
118 possible with netsniff-ng to turn this into monitor mode and create a mon<X>
119 device that netsniff-ng will be listening on instead of wlan<X>, for instance.
120 This enables netsniff-ng to analyze, dump, or even replay raw 802.11 frames.
122 .SS -n <0|uint>, --num <0|uint>
123 Process a number of packets and then exit. If the number of packets is 0, then
124 this is equivalent to infinite packets resp. processing until interrupted.
125 Otherwise, a number given as an unsigned integer will limit processing.
127 .SS -P <name>, --prefix <name>
128 When dumping pcap files into a folder, a file name prefix can be defined with
129 this option. If not otherwise specified, the default prefix is \[lq]dump\-\[rq]
130 followed by a Unix timestamp. Use \[lq]\-\-prefex ""\[rq] to set filename as
131 seconds since the Unix Epoch e.g. 1369179203.pcap
133 .SS -T <pcap-magic>, --magic <pcap-magic>
134 Specify a pcap type for storage. Different pcap types with their various meta
135 data capabilities are shown with option \[lq]\-D\[rq]. If not otherwise
136 specified, the pcap-magic 0xa1b2c3d4, also known as a standard tcpdump-capable
137 pcap format, is used. Pcap files with swapped endianness are also supported.
139 .SS -D, --dump-pcap-types
140 Dump all available pcap types with their capabilities and magic numbers that
141 can be used with option \[lq]\-T\[rq] to stdout and exit.
143 .SS -B, --dump-bpf
144 If a Berkeley Packet Filter is given, for example via option \[lq]\-f\[rq], then
145 dump the BPF disassembly to stdout during ring setup. This only serves for informative
146 or verification purposes.
148 .SS -r, --rand
149 If the input and output device are both networking devices, then this option will
150 randomize packet order in the output ring buffer.
152 .SS -M, --no-promisc
153 The networking interface will not be put into promiscuous mode. By default,
154 promiscuous mode is turned on.
156 .SS -A, --no-sock-mem
157 On startup and shutdown, netsniff-ng tries to increase socket read and
158 write buffers if appropriate. This option will prevent netsniff-ng from doing
161 .SS -m, --mmap
162 Use mmap(2) as pcap file I/O. This is the default when replaying pcap files.
164 .SS -G, --sg
165 Use scatter-gather as pcap file I/O. This is the default when capturing
166 pcap files.
168 .SS -c, --clrw
169 Use slower read(2) and write(2) I/O. This is not the default case anywhere, but in
170 some situations it could be preferred as it has a lower latency on write-back
171 to disc.
173 .SS -S <size>, --ring-size <size>
174 Manually define the RX_RING resp. TX_RING size in \[lq]<num>KiB/MiB/GiB\[rq]. By
175 default, the size is determined based on the network connectivity rate.
177 .SS -k <uint>, --kernel-pull <uint>
178 Manually define the interval in micro-seconds where the kernel should be triggered
179 to batch process the ring buffer frames. By default, it is every 10us, but it can
180 manually be prolonged, for instance.
182 .SS -b <cpu>, --bind-cpu <cpu>
183 Pin netsniff-ng to a specific CPU and also pin resp. migrate the NIC's IRQ
184 CPU affinity to this CPU. This option should be preferred in combination with
185 \[lq]\-s\[rq] in case a middle to high packet rate is expected.
187 .SS -u <uid>, --user <uid> resp. -g <gid>, --group <gid>
188 After ring setup drop privileges to a non-root user/group combination.
190 .SS -H, --prio-high
191 Set this process as a high priority process in order to achieve a higher
192 scheduling rate resp. CPU time. This is however not the default setting, since
193 it could lead to starvation of other processes, for example low priority kernel
194 threads.
196 .SS -Q, --notouch-irq
197 Do not reassign the NIC's IRQ CPU affinity settings.
199 .SS -s, --silent
200 Do not enter the packet dissector at all and do not print any packet information
201 to the terminal. Just shut up and be silent. This option should be preferred in
202 combination with pcap recording or replay, since it will not flood your terminal
203 which causes a significant performance degradation.
205 .SS -q, --less
206 Print a less verbose one-line information for each packet to the terminal.
208 .SS -X, --hex
209 Only dump packets in hex format to the terminal.
211 .SS -l, --ascii
212 Only display ASCII printable characters.
214 .SS -U, --update
215 If geographical IP location is used, the built-in database update
216 mechanism will be invoked to get Maxmind's latest database. To configure
217 search locations for databases, the file /etc/netsniff-ng/geoip.conf contains
218 possible addresses. Thus, to save bandwidth or for mirroring of Maxmind's
219 databases (to bypass their traffic limit policy), different hosts or IP
220 addresses can be placed into geoip.conf, separated by a newline.
222 .SS -V, --verbose
223 Be more verbose during startup i.e. show detailed ring setup information.
225 .SS -v, --version
226 Show version information and exit.
228 .SS -h, --help
229 Show user help and exit.
231 .SH USAGE EXAMPLE
233 .SS netsniff-ng
234 The most simple command is to just run \[lq]netsniff-ng\[rq]. This will start
235 listening on all available networking devices in promiscuous mode and dump
236 the packet dissector output to the terminal. No files will be recorded.
238 .SS  netsniff-ng --in eth0 --out dump.pcap -s -T 0xa1e2cb12 -b 0 tcp or udp
239 Capture TCP or UDP traffic from the networking device eth0 into the pcap file
240 named dump.pcap, which has netsniff-ng specific pcap extensions (see
241 \[lq]netsniff-ng \-D\[rq] for capabilities). Also, do not print the content to
242 the terminal and pin the process and NIC IRQ affinity to CPU 0. The pcap write
243 method is scatter-gather I/O.
245 .SS  netsniff-ng --in wlan0 --rfraw --out dump.pcap --silent --bind-cpu 0
246 Put the wlan0 device into monitoring mode and capture all raw 802.11 frames
247 into the file dump.pcap. Do not dissect and print the content to the terminal
248 and pin the process and NIC IRQ affinity to CPU 0. The pcap write method is
249 scatter-gather I/O.
251 .SS  netsniff-ng --in dump.pcap --mmap --out eth0 -k1000 --silent --bind-cpu 0
252 Replay the pcap file dump.pcap which is read through mmap(2) I/O and send
253 the packets out via the eth0 networking device. Do not dissect and print the
254 content to the terminal and pin the process and NIC IRQ affinity to CPU 0.
255 Also, trigger the kernel every 1000us to traverse the TX_RING instead of every
256 10us. Note that the pcap magic type is detected automatically from the pcap
257 file header.
259 .SS  netsniff-ng --in eth0 --out eth1 --silent --bind-cpu 0 --type host -r
260 Redirect network traffic from the networking device eth0 to eth1 for traffic
261 that is destined for our host, thus ignore broadcast, multicast and promiscuous
262 traffic. Randomize the order of packets for the outgoing device and do not
263 print any packet contents to the terminal. Also, pin the process and NIC IRQ
264 affinity to CPU 0.
266 .SS  netsniff-ng --in team0 --out /opt/probe/ -s -m --interval 100MiB -b 0
267 Capture on an aggregated team0 networking device and dump packets into multiple
268 pcap files that are split into 100MiB each. Use mmap(2) I/O as a pcap write
269 method, support for super jumbo frames is built-in (does not need to be
270 configured here), and do not print the captured data to the terminal. Pin
271 netsniff-ng and NIC IRQ affinity to CPU 0. The default pcap magic type is
272 0xa1b2c3d4 (tcpdump-capable pcap).
274 .SS  netsniff-ng --in vlan0 --out dump.pcap -c -u `id -u bob` -g `id -g bob`
275 Capture network traffic on device wlan0 into a pcap file called dump.pcap
276 by using normal read(2), write(2) I/O for the pcap file (slower but less
277 latency). Also, after setting up the RX_RING for capture, drop privileges
278 from root to the user and group \[lq]bob\[rq]. Invoke the packet dissector and print
279 packet contents to the terminal for further analysis.
281 .SS  netsniff-ng --in any --filter http.bpf -B --ascii -V
282 Capture from all available networking interfaces and install a low-level
283 filter that was previously compiled by bpfc(8) into http.bpf in order to
284 filter HTTP traffic. Super jumbo frame support is automatically enabled and
285 only print human readable packet data to the terminal, and also be more
286 verbose during setup phase. Moreover, dump a BPF disassembly of http.bpf.
288 .SS  netsniff-ng --in dump.pcap --out dump.cfg --silent
289 Convert the pcap file dump.pcap into a trafgen(8) configuration file dump.cfg.
290 Do not print pcap contents to the terminal.
292 .SS netsniff-ng -i dump.pcap -f beacon.bpf -o -
293 Convert the pcap file dump.pcap into a trafgen(8) configuration file and write
294 it to stdout. However, do not dump all of its content, but only the one that
295 passes the low-level filter for raw 802.11 from beacon.bpf. The BPF engine
296 here is invoked in user space inside of netsniff-ng, so Linux extensions
297 are not available.
299 .SS cat foo.pcap | netsniff-ng -i - -o -
300 Read a pcap file from stdin and convert it into a trafgen(8) configuration
301 file to stdout.
303 .SS modprobe nlmon
304 .SS ip link add type nlmon
305 .SS ip link set nlmon0 up
306 .SS netsniff-ng -i nlmon0 -o dump.pcap -s
307 .SS ip link set nlmon0 down
308 .SS ip link del dev nlmon0
309 .SS rmmod nlmon
310 In this example, netlink traffic is being captured. If not already done, a
311 netlink monitoring device needs to be set up before it can be used to capture
312 netlink socket buffers (iproute2's ip(1) commands are given for nlmon device
313 setup and teardown). netsniff-ng can then make use of the nlmon device as
314 an input device. In this example a pcap file with netlink traffic is being
315 recorded.
317 .SH CONFIG FILES
319 Files under /etc/netsniff-ng/ can be modified to extend netsniff-ng's
320 functionality:
322     * oui.conf - OUI/MAC vendor database
323     * ether.conf - Ethernet type descriptions
324     * tcp.conf - TCP port/services map
325     * udp.conf - UDP port/services map
326     * geoip.conf - GeoIP database mirrors
328 .SH FILTER EXAMPLE
330 netsniff-ng supports both, low-level and high-level filters that are
331 attached to its packet(7) socket. Low-level filters are described in
332 the bpfc(8) man page.
334 Low-level filters can be used with netsniff-ng in the following way:
336     1. bpfc foo > bar
337     2. netsniff-ng \-f bar
339 Here, foo is the bpfc program that will be translated into a netsniff-ng
340 readable \[lq]opcodes\[rq] file and passed to netsniff-ng through the \-f
341 option.
343 Similarly, high-level filter can be either passed through the \-f option,
344 e.g. \-f "tcp or udp" or at the end of all options without the \[lq]\-f\[rq].
346 The filter syntax is the same as in tcpdump(8), which is described in
347 the man page pcap-filter(7). Just to quote some examples from pcap-filter(7):
349 .SS host sundown
350 To select all packets arriving at or departing from sundown.
352 .SS host helios and \(hot or ace\)
353 To select traffic between helios and either hot or ace.
355 .SS ip host ace and not helios
356 To select all IP packets between ace and any host except helios.
358 .SS net ucb-ether
359 To select all traffic between local hosts and hosts at Berkeley.
361 .SS gateway snup and (port ftp or ftp-data)
362 To select all FTP traffic through Internet gateway snup.
364 .SS ip and not net localnet
365 To select traffic neither sourced from, nor destined for, local hosts. If you
366 have a gateway to another network, this traffic should never make it onto
367 your local network.
369 .SS tcp[tcpflags] & (tcp-syn|tcp-fin) != 0 and not src and dst net localnet
370 To select the start and end packets (the SYN and FIN packets) of each TCP
371 conversation that involve a non-local host.
373 .SS tcp port 80 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)
374 To select all IPv4 HTTP packets to and from port 80, that is to say, print only packets
375 that contain data, not, for example, SYN and FIN packets and ACK-only packets.
376 (IPv6 is left as an exercise for the reader.)
378 .SS gateway snup and ip[2:2] > 576
379 To select IP packets longer than 576 bytes sent through gateway snup.
381 .SS ether[0] & 1 = 0 and ip[16] >= 224
382 To select IP broadcast or multicast packets that were not sent via Ethernet
383 broadcast or multicast.
385 .SS icmp[icmptype] != icmp-echo and icmp[icmptype] != icmp-echoreply
386 To select all ICMP packets that are not echo requests or replies
387 (that is to say, not "ping" packets).
389 .SH PCAP FORMATS:
391 netsniff-ng supports a couple of pcap formats, visible through ``netsniff-ng \-D'':
393 .SS tcpdump-capable pcap (default)
394 Pcap magic number is encoded as 0xa1b2c3d4 resp. 0xd4c3b2a1. As packet meta data
395 this format contains the timeval in microseconds, the original packet length and
396 the captured packet length.
398 .SS tcpdump-capable pcap with ns resolution
399 Pcap magic number is encoded as 0xa1b23c4d resp. 0x4d3cb2a1. As packet meta data
400 this format contains the timeval in nanoseconds, the original packet length and
401 the captured packet length.
403 .SS Alexey Kuznetzov's pcap
404 Pcap magic number is encoded as 0xa1b2cd34 resp. 0x34cdb2a1. As packet meta data
405 this format contains the timeval in microseconds, the original packet length,
406 the captured packet length, the interface index (sll_ifindex), the packet's
407 protocol (sll_protocol), and the packet type (sll_pkttype).
409 .SS netsniff-ng pcap
410 Pcap magic number is encoded as 0xa1e2cb12 resp. 0x12cbe2a1. As packet meta data
411 this format contains the timeval in nanoseconds, the original packet length,
412 the captured packet length, the timestamp hw/sw source, the interface index
413 (sll_ifindex), the packet's protocol (sll_protocol), the packet type (sll_pkttype)
414 and the hardware type (sll_hatype).
416 For further implementation details or format support in your application,
417 have a look at pcap_io.h.
419 .SH NOTE
420 To avoid confusion, it should be noted that there is another network
421 analyzer with a similar name, called NetSniff, that is unrelated to
422 the netsniff-ng project.
424 For introducing bit errors, delays with random variation and more
425 while replaying pcaps, make use of tc(8) with its disciplines such
426 as netem.
428 netsniff-ng does only some basic, architecture generic tuning on
429 startup. If you are considering to do high performance capturing,
430 you need to carefully tune your machine, both hardware and software.
431 Simply letting netsniff-ng run without thinking about your underlying
432 system might not necessarily give you the desired performance. Note
433 that tuning your system is always a tradeoff and fine-grained
434 balancing act (throughput versus latency). You should know what
435 you are doing!
437 One recommendation for software-based tuning is tuned(8). Besides
438 that, there are many other things to consider. Just to throw you
439 a few things that you might want to look at: NAPI networking drivers,
440 tickless kernel, I/OAT DMA engine, Direct Cache Access, RAM-based
441 file systems, multi-queues, and many more things. Also, you might
442 want to read the kernel's Documentation/networking/scaling.txt file
443 regarding technologies such as RSS, RPS, RFS, aRFS and XPS. Also
444 check your ethtool(8) settings, for example regarding offloading or
445 Ethernet pause frames.
447 Moreover, to get a deeper understanding of netsniff-ng internals
448 and how it interacts with the Linux kernel, the kernel documentation
449 under Documentation/networking/{packet_mmap.txt, filter.txt,
450 multiqueue.txt} might be of interest.
452 How do you sniff in a switched environment? I rudely refer to dSniff's
453 documentation that says:
455 The easiest route is simply to impersonate the local gateway, stealing
456 client traffic en route to some remote destination. Of course, the traffic
457 must be forwarded by your attacking machine, either by enabling kernel IP
458 forwarding or with a userland program that accomplishes the same
459 (fragrouter \-B1).
461 Several people have reportedly destroyed connectivity on their LAN to the
462 outside world by ARP spoofing the gateway, and forgetting to enable IP
463 forwarding on the attacking machine. Do not do this. You have been warned.
465 A safer option than ARP spoofing would be to use a "port mirror" function
466 if your switch hardware supports it and if you have access to the switch.
468 If you do not need to dump all possible traffic, you have to consider
469 running netsniff-ng with a BPF filter for the ingress path. For that
470 purpose, read the bpfc(8) man page.
472 Also, to aggregate multiple NICs that you want to capture on, you
473 should consider using team devices, further explained in libteam resp.
474 teamd(8).
476 The following netsniff-ng pcap magic numbers are compatible with other
477 tools, at least tcpdump or Wireshark:
479     0xa1b2c3d4 (tcpdump-capable pcap)
480     0xa1b23c4d (tcpdump-capable pcap with ns resolution)
481     0xa1b2cd34 (Alexey Kuznetzov's pcap)
483 Pcap files with different meta data endianness are supported by netsniff-ng
484 as well.
486 .SH BUGS
488 When replaying pcap files, the timing information from the pcap packet
489 header is currently ignored.
491 Also, when replaying pcap files, demultiplexing traffic among multiple
492 networking interfaces does not work. Currently, it is only sent via the
493 interface that is given by the \-\-out parameter.
495 When performing traffic capture on the Ethernet interface, the pcap file
496 is created and packets are received but without a 802.1Q header. When one
497 uses tshark, all headers are visible, but netsniff-ng removes 802.1Q
498 headers. Is that normal behavior?
500 Yes and no. The way VLAN headers are handled in PF_PACKET sockets by the
501 kernel is somewhat \[lq]problematic\[rq] [1]. The problem in the Linux kernel
502 is that some drivers already handle VLANs, others do not. Those who handle it
503 can have different implementations, such as hardware acceleration and so on.
504 So in some cases the VLAN tag is even stripped before entering the protocol
505 stack, in some cases probably not. The bottom line is that a "hack" was
506 introduced in PF_PACKET so that a VLAN ID is visible in some helper data
507 structure that is accessible from the RX_RING.
509 Then it gets really messy in the user space to artificially put the VLAN
510 header back into the right place. Not to mention the resulting performance
511 implications on all of libpcap(3) tools since parts of the packet need to
512 be copied for reassembly via memmove(3).
514 A user reported the following, just to demonstrate this mess: some tests were
515 made with two machines, and it seems that results depend on the driver ...
517     AR8131:
518       ethtool \-k eth0 gives "rx-vlan-offload: on"
519       - wireshark gets the vlan header
520       - netsniff-ng doesn't get the vlan header
521       ethtool \-K eth0 rxvlan off
522       - wireshark gets a QinQ header even though noone sent QinQ
523       - netsniff-ng gets the vlan header
525     RTL8111/8168B:
526       ethtool \-k eth0 gives "rx-vlan-offload: on"
527       - wireshark gets the vlan header
528       - netsniff-ng doesn't get the vlan header
529       ethtool \-K eth0 rxvlan off
530       - wireshark gets the vlan header
531       - netsniff-ng doesn't get the vlan header
533 Even if we agreed on doing the same workaround as libpcap, we still will
534 not be able to see QinQ, for instance, due to the fact that only one VLAN tag
535 is stored in the kernel helper data structure. We think that there should be
536 a good consensus on the kernel space side about what gets transferred to
537 userland first.
539 Update (28.11.2012): the Linux kernel and also bpfc(8) has built-in support
540 for hardware accelerated VLAN filtering, even though tags might not be visible
541 in the payload itself as reported here. However, the filtering for VLANs works
542 reliable if your NIC supports it. See bpfc(8) for an example.
544    [1] http://lkml.indiana.edu/hypermail/linux/kernel/0710.3/3816.html
546 .SH LEGAL
547 netsniff-ng is licensed under the GNU GPL version 2.0.
549 .SH HISTORY
550 .B netsniff-ng
551 was originally written for the netsniff-ng toolkit by Daniel Borkmann. Bigger
552 contributions were made by Emmanuel Roullit, Markus Amend, Tobias Klauser and
553 Christoph Jaeger. It is currently maintained by Tobias Klauser
554 <tklauser@distanz.ch> and Daniel Borkmann <dborkma@tik.ee.ethz.ch>.
556 .SH SEE ALSO
557 .BR trafgen (8),
558 .BR mausezahn (8),
559 .BR ifpps (8),
560 .BR bpfc (8),
561 .BR flowtop (8),
562 .BR astraceroute (8),
563 .BR curvetun (8)
565 .SH AUTHOR
566 Manpage was written by Daniel Borkmann.
568 .SH COLOPHON
569 This page is part of the Linux netsniff-ng toolkit project. A description of the project,
570 and information about reporting bugs, can be found at http://netsniff-ng.org/.