docs: minor typo fixes in netsniff-ng documentation
[netsniff-ng.git] / Documentation / Netsniff-ng
blob82848d94679c24f18f33041abf066613de5f441f
1 What is netsniff-ng?
2 ////////////////////
4 netsniff-ng is a high-performance network analyzer based on zero-copy
5 mechanisms. It can record pcap files to disc, replay them and also do
6 an offline and online analysis. It was the first tool of the toolkit
7 and its initial development started back in 2009 at the Max Planck
8 Institute. At that time, zero-copy mechanisms that were provided by the
9 Linux kernel, namely RX_RING and TX_RING, were not used in libpcap
10 and therefore by the majority of network analyzers. Hence, it was time
11 to dig deeper into that topic when we started writing our own analyzer
12 that was independant of any library except libc.
14 Later on, for writing pcap files to disc, we have implemented a write-back
15 mechanism based on scatter/gather I/O and also based on mmap(2). Hence,
16 the user can decide if he plans to capture a large pcap file that he needs
17 scatter/gather I/O, or for a pcap file that fits into RAM that he needs the
18 faster mmap(2) operation.
20 The newly introduced command line option of --in and --out allows a flexible
21 combination for different purposes, i.e.
22  1) --in <netdev> --out <pcap>, writes a network trace to disc
23  2) --in <pcap> --out <netdev>, replays a network trace from disc
24  3) --in <pcap>, performs an offline analysis of a trace file
25  4) --in <netdev>, performs an online analysis
26  5) --in <netdev> --out <folder>, periodically writes network trace files
27  6) --in <netdev1> --out <netdev2>, redirects network traffic
29 Those options can be combined with e.g. different filtering methods or other
30 parameters such as printing modes.
32 The kernel API of RX_RING and TX_RING is the fastest capturing or replaying
33 possibility that you can get out of the box from user space without modifying
34 your kernel sources.
36 If you want to run netsniff-ng in combination with -f or --filter <file> you
37 need to build a so called Berkeley Packet Filter program within a plaintext
38 file (here, marked as: <file>). The Berkeley Packet Filters language
39 description can be obtained from netsniff-ng's documentation section. One
40 way to create a custom filter is to use our bpfc compiler. Read the 'Bpfc'
41 documentation on how you can do this. In this case you have all the freedom
42 to build filters for your needs. The alternative way is to use tcpdumps -dd
43 option. Simply pipe the output into a textfile and pass this to netsniff-ng.
44 Furthermore, we already ship some common filter examples! Most distributions
45 will put these files into /etc/netsniff-ng/rules/.
47 If you try to create custom socket filters with tcpdump -dd, you have to edit
48 the ret opcode (0x6) of the resulting filter, otherwise your payload will be
49 cut off on older tcpdump versions:
51  0x6, 0, 0, 0xFFFFFFFF instead of 0x6, 0, 0, 0x00000060
53 The Linux kernel now takes skb->len instead of 0xFFFFFFFF. If you do not
54 change it, the kernel will take 0x00000060 as buffer length and packets larger
55 than 96 Byte will be cut off (filled with zero Bytes)! It's a bug (or feature?)
56 in libpcap's filter compiler.
58 How do you sniff in a switched environment? I rudely refer to the dSniff
59 documentation that says:
61 The easiest route is simply to impersonate the local gateway, stealing client
62 traffic en route to some remote destination. Of course, the traffic must be
63 forwarded by your attacking machine, either by enabling kernel IP forwarding
64 or with a userland program that acccomplishes the same (fragrouter -B1).
66 Several people have reportedly destroyed connectivity on their LAN to the
67 outside world by arpspoof'ing the gateway, and forgetting to enable IP
68 forwarding on the attacking machine. Don't do this. You have been warned.
70 Note that in case you are saving network traces as pcap files, you can also
71 view them in tools like Wireshark, which has a better dissector than
72 netsniff-ng. The other way round, you can also use netsniff-ng to replay traces
73 that have been recorded with Wireshark (or other utilities that support pcap
74 files). In fact, we have received mails from people switching from Wireshark
75 to netsniff-ng because of the fact that netsniff-ng seems to have less packet
76 drops, respectively is faster than Wireshark.
78 Why not PF_RING? There are two reasons for this: First reason is, that it's
79 not part of the Linux mainline kernel. A interesting discussion about getting
80 PF_RING into the kernel can be found at the netdev lists
81 (http://lists.openwall.net/netdev/2009/10/14/37) and obviously there are no
82 further efforts (browse the netdev/LKML, also netfilter) from the ntop project
83 to marry both architectures or add features to PF_PACKET. Second reason is
84 that we've evaluated the PF_RING (without the commercial Direct NIC Access
85 [DNA]) regarding its performance and came to the conclusion, that there is no
86 significant performance enhancement on our IBM HS21 Bladeserver test system.
87 ntop's DNA ships its own versions of some modified device drivers like
88 Broadcoms tg3 and NetXtreme, Intels e1000(e), igb and ixgbe. Since these
89 modifications are not official, neither to the kernel, nor to the vendors and
90 cover only a small amout of what is out there, we're not doing further
91 investigations at the moment. Also, netsniff-ng users have reported similar
92 observations as our conclusions. A benchmark with PF_RING in transparent_mode
93 0 and 1 seems even slower than netsniff-ng and in transparent_mode 2 both have
94 comparable performance numbers. The test was done on a Dell PowerEdge 2850.