<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>capture on The Official Wireshark Blog</title>
    <link>https://blog.wireshark.org/tags/capture/</link>
    <description>Recent content in capture on The Official Wireshark Blog</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-us</language>
    <lastBuildDate>Thu, 04 Feb 2010 20:11:57 +0000</lastBuildDate><atom:link href="https://blog.wireshark.org/tags/capture/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Running Wireshark as You</title>
      <link>https://blog.wireshark.org/2010/02/running-wireshark-as-you/</link>
      <pubDate>Thu, 04 Feb 2010 20:11:57 +0000</pubDate>
      
      <guid>https://blog.wireshark.org/2010/02/running-wireshark-as-you/</guid>
      <description>&lt;p&gt;Running Wireshark on Linux involves an interesting challenge&lt;sup&gt;1&lt;/sup&gt;: Capturing packets requires root access, but Wireshark is &lt;a href=&#34;http://www.wireshark.org/download/automated/sloccount.txt&#34;&gt;big program&lt;/a&gt; and we strongly recommend against running it with elevated privileges. On Linux it’s common to see Wireshark running as root, but this is nearly unheard for similarly-sized applications like Firefox and GIMP. How can we avoid running Wireshark as root?&lt;/p&gt;
&lt;p&gt;UPDATE 2010-02-10: Made changes suggested by Jaap and Balint.&lt;/p&gt;
&lt;h3 id=&#34;a-good-way&#34;&gt;A good way &lt;a href=&#34;#a-good-way&#34; class=&#34;anchor&#34;&gt;🔗&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;Notice how I said “capturing packets requires root” above? Here’s a secret — Wireshark doesn’t capture packets. A separate program called &lt;a href=&#34;http://www.wireshark.org/docs/man-pages/dumpcap.html&#34;&gt;dumpcap&lt;/a&gt; does. Compared to Wireshark, dumpcap is tiny. It’s much less complex and much safer to run as root. We can make it so that dumpcap runs as root and that only users in a particular group can run it:&lt;/p&gt;
&lt;pre&gt;$ sudo -s
# groupadd -g wireshark
# usermod -a -G wireshark gerald
# chgrp wireshark /usr/bin/dumpcap
# chmod 4750 /usr/bin/dumpcap
&lt;/pre&gt;
&lt;h3 id=&#34;a-better-way&#34;&gt;A better way &lt;a href=&#34;#a-better-way&#34; class=&#34;anchor&#34;&gt;🔗&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;It’s also possible to let dumpcap do its job without involving root access at all. For a very long time Linux has allowed the use of fine-grained permissions called &lt;a href=&#34;http://manpages.ubuntu.com/manpages/intrepid/man7/capabilities.7.html&#34;&gt;capabilities&lt;/a&gt;. In many recent distributions you can use the &lt;a href=&#34;http://manpages.ubuntu.com/manpages/intrepid/man8/setcap.8.html&#34;&gt;setcap&lt;/a&gt; utility to add capabilities to individual files.&lt;/p&gt;
&lt;p&gt;Dumpcap needs CAP_NET_RAW and CAP_NET_ADMIN, so what do we need to feed setcap? On my Ubuntu Karmic system the setcap man page points you to &lt;a href=&#34;http://manpages.ubuntu.com/manpages/intrepid/man3/cap_from_text.3.html&#34;&gt;cap_from_text&lt;/a&gt;. Cap_from_text points you to _cap_names, an array in the kernel. It would be nice if the setcap man page included a list of capability names along with a few examples. As it turns out, the names need to be in lower-case.&lt;/p&gt;
&lt;pre&gt;$ sudo -s
# sudo apt-get install libcap2-bin
# groupadd -g wireshark
# usermod -a -G wireshark gerald
# chmod 750 /usr/bin/dumpcap
# setcap cap_net_raw,cap_net_admin=eip /usr/bin/dumpcap
&lt;/pre&gt;
&lt;p&gt;&lt;span style=&#34;color: #000000;&#34;&gt;You can also set these capabilities for Wireshark and TShark directly. Fully-functional filesystem capabilities &lt;/span&gt;is something the Linux world has needed for a very long time. I’m glad they’re finally seeing wide deployment.&lt;/p&gt;
&lt;h3 id=&#34;who8217s-doing-this&#34;&gt;Who’s Doing This? &lt;a href=&#34;#who8217s-doing-this&#34; class=&#34;anchor&#34;&gt;🔗&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;Debian and Gentoo are using group-based permissions for Wireshark. Ubuntu is &lt;a href=&#34;http://brainstorm.ubuntu.com/idea/14140/&#34;&gt;working on it&lt;/a&gt;. Hopefully the other distributions will follow suit.&lt;/p&gt;
&lt;p&gt;&lt;span style=&#34;color: #808080;&#34;&gt;&lt;br /&gt; 1. This is a problem on other systems too, but it’s usually easier to solve. On Windows you can run the NPF service at startup. On OS X you can use ChmodBPF.&lt;br /&gt; &lt;/span&gt;&lt;/p&gt;
&lt;h2 id=&#34;comments&#34;&gt;Comments &lt;a href=&#34;#comments&#34; class=&#34;anchor&#34;&gt;🔗&lt;/a&gt;&lt;/h2&gt;&lt;h3 id=&#34;comment-by-jake-on-2010-02-08-054500-0000&#34;&gt;Comment by Jake on 2010-02-08 05:45:00 +0000 &lt;a href=&#34;#comment-by-jake-on-2010-02-08-054500-0000&#34; class=&#34;anchor&#34;&gt;🔗&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;Note that the recent Debian packages already implement this, something you’ll notice when installing them. Thanks Balint. For Ubuntu it’s still on Wishlist status.&lt;/p&gt;
&lt;h3 id=&#34;comment-by-balint-on-2010-02-10-041139-0000&#34;&gt;Comment by Balint on 2010-02-10 04:11:39 +0000 &lt;a href=&#34;#comment-by-balint-on-2010-02-10-041139-0000&#34; class=&#34;anchor&#34;&gt;🔗&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;Gerald,&lt;br&gt;
Could you please suggest using the wireshark system group instead of packetcapture?&lt;br&gt;
Gentoo and Debian already use wireshark group, and it would be easier for newcomers to use the same group name everywhere.&lt;/p&gt;
&lt;p&gt;I plan to update the Debian packages to use setcap, thanks for the hint.&lt;/p&gt;
&lt;h3 id=&#34;comment-by-gerald-combs-on-2010-02-10-105909-0000&#34;&gt;Comment by Gerald Combs on 2010-02-10 10:59:09 +0000 &lt;a href=&#34;#comment-by-gerald-combs-on-2010-02-10-105909-0000&#34; class=&#34;anchor&#34;&gt;🔗&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;I changed the example group to “wireshark” and mentioned Gentoo, Debian, and Ubuntu.&lt;/p&gt;
&lt;h3 id=&#34;comment-by-balint-on-2010-02-17-102851-0000&#34;&gt;Comment by Balint on 2010-02-17 10:28:51 +0000 &lt;a href=&#34;#comment-by-balint-on-2010-02-17-102851-0000&#34; class=&#34;anchor&#34;&gt;🔗&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;It would also make sense to use groupadd -g -r wireshark instead of groupadd -g wireshark to make the new group a system group. That would match and nicely coexist with Debian’s and Ubuntu’s installation method.&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Capture Filters and Offsets</title>
      <link>https://blog.wireshark.org/2009/10/capture-filters-and-offsets/</link>
      <pubDate>Mon, 05 Oct 2009 13:03:53 +0000</pubDate>
      
      <guid>https://blog.wireshark.org/2009/10/capture-filters-and-offsets/</guid>
      <description>&lt;p&gt;A couple of questions have come up on the &lt;a href=&#34;http://www.wireshark.org/lists/&#34;&gt;wireshark-users&lt;/a&gt; mailing list recently about using capture filters for MPLS and VLANs. Each user was having the same problem yet these are different network technologies — what do they have to do with each other?&lt;/p&gt;
&lt;p&gt;The answer is &lt;em&gt;offsets&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;Let’s take an up-close and personal look at the capture filter “ip src host 10.16.32.48”. We can do this by running &lt;em&gt;tcpdump -d&lt;/em&gt;, which takes a filter, compiles it, and dumps out the result. The dump of our filter looks like this:&lt;/p&gt;
&lt;pre&gt;&lt;span style=&#34;color: #008000;&#34;&gt;(000) ldh      [12]
(001) jeq      #0x800           jt 2    jf 5&lt;/span&gt;
&lt;span style=&#34;color: #0000ff;&#34;&gt;(002) ld       [26]&lt;/span&gt;
&lt;span style=&#34;color: #0000ff;&#34;&gt;(003) jeq      #0xa102030       jt 4    jf 5&lt;/span&gt;
(004) ret      #96
(005) ret      #0&lt;/pre&gt;
&lt;p&gt;If this makes no sense don’t worry. You just need to know that the &lt;span style=&#34;color: #008000;&#34;&gt;first two lines look for the IP ethertype (0x800) starting at byte 12&lt;/span&gt; and the &lt;span style=&#34;color: #0000ff;&#34;&gt;next two lines look for the IP address 10.16.32.48 (0xa102030) starting at byte 26&lt;/span&gt;. This is the minimum amount of checking required for that capture filter if you’re running IP over Ethernet.&lt;/p&gt;
&lt;p&gt;What happens if you’re using 802.1q?&lt;/p&gt;
&lt;p&gt;&lt;a href=&#34;http://en.wikipedia.org/wiki/802.1q&#34;&gt;802.1q inserts an extra four bytes in front of the ethertype&lt;/a&gt;, so this filter won’t do what you want. The ethertype will be at offset 16 instead of 12, and the IP source address will be at offset 30 instead of 26. Libpcap and WinPcap don’t know you’re using .1q, and adding a check to the filter code would add a lot of unnecessary overhead. We have to add the word “vlan” to our filter to get the right offsets, e.g. “vlan and ip src host 10.16.32.48”:&lt;/p&gt;
&lt;pre&gt;(000) ldh      [12]
(001) jeq      #0x8100          jt 2    jf 7
(002) ldh      [16]
(003) jeq      #0x800           jt 4    jf 7
&lt;span style=&#34;color: #0000ff;&#34;&gt;(004) ld       [30]&lt;/span&gt;
&lt;span style=&#34;color: #0000ff;&#34;&gt;(005) jeq      #0xa102030       jt 6    jf 7&lt;/span&gt;
(006) ret      #96
(007) ret      #0&lt;/pre&gt;
&lt;p&gt;There’s a gotcha here, though. What if we change the “and” to an “or”?&lt;/p&gt;
&lt;pre&gt;(000) ldh      [12]
(001) jeq      #0x8100          jt 6    jf 2
(002) ldh      [16]
(003) jeq      #0x800           jt 4    jf 7
&lt;span style=&#34;color: #0000ff;&#34;&gt;(004) ld       [30]&lt;/span&gt;
&lt;span style=&#34;color: #0000ff;&#34;&gt;(005) jeq      #0xa102030       jt 6    jf 7&lt;/span&gt;
(006) ret      #96
(007) ret      #0&lt;/pre&gt;
&lt;p&gt;We’re looking for the IP address at byte 30. Shouldn’t we be looking at both 26 and 30?&lt;/p&gt;
&lt;p&gt;The filter compiler uses a base offset for fetching data from the packet. Any time you use “vlan”, “mpls”, or “pppoes” in a capture filter, this offset is increased &lt;strong&gt;from that point on&lt;/strong&gt;. It’s also &lt;strong&gt;cumulative&lt;/strong&gt;. That is, while all of these filters are logically equivalent, they’re not in practice:&lt;/p&gt;
&lt;p style=&#34;padding-left: 30px;&#34;&gt;
  ip src host 10.16.32.48 or vlan or vlan &lt;span style=&#34;color: #808080;&#34;&gt;&lt;em&gt;(Looks for 10.16.32.48 at offset 26)&lt;/em&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style=&#34;padding-left: 30px;&#34;&gt;
  vlan or ip src host 10.16.32.48 or vlan &lt;span style=&#34;color: #808080;&#34;&gt;&lt;em&gt;(Now it&amp;#8217;s looking at offset 30)&lt;/em&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style=&#34;padding-left: 30px;&#34;&gt;
  vlan or vlan or ip src host 10.16.32.48 &lt;span style=&#34;color: #808080;&#34;&gt;&lt;em&gt;(Offset 34. When will it ever end?)&lt;/em&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;“vlan” and “mpls” increase the base offset by 4. “pppoes” increases it by 8.&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Missing Packets and Chimnies</title>
      <link>https://blog.wireshark.org/2009/09/missing-packets-and-chimnies/</link>
      <pubDate>Thu, 17 Sep 2009 00:33:43 +0000</pubDate>
      
      <guid>https://blog.wireshark.org/2009/09/missing-packets-and-chimnies/</guid>
      <description>&lt;p&gt;You’ve just fired up Wireshark on your Windows Server 2003 or 2008 system and you’re not seeing nearly the amount of traffic you should. What’s happening?&lt;/p&gt;
&lt;p&gt;The Windows Server 2003 Scalable Networking Pack introduced a feature called &lt;a href=&#34;http://wiki.wireshark.org/CaptureSetup/Offloading&#34;&gt;TCP Chimney Offload&lt;/a&gt;. Chimney offloading lets the OS networking stack hand off established TCP connections to the NIC for processing. This frees up the CPU, bus, and memory for other things and lets you scale up the number of connections you can handle. Hooray! Once the OS hands a connection off to the NIC, that traffic completely bypasses WinPcap and therefore doesn’t show up in Wireshark. You see the TCP connection setup and non-TCP traffic but no TCP data. Oops.&lt;/p&gt;
&lt;p&gt;How do you fix the problem? It depends on your environment.&lt;/p&gt;
&lt;p&gt;You can disable chimney offloading as described in &lt;a href=&#34;http://support.microsoft.com/kb/912222&#34;&gt;KB 91222&lt;/a&gt; (Server 2003) or &lt;a href=&#34;http://support.microsoft.com/kb/951037&#34;&gt;KB 951037&lt;/a&gt; (Server 2008). If you have a gigabit NIC you can probably get away with leaving it disabled. If you have a 10 gig NIC this might affect your performance. You can also SPAN or tap in and capture on an external machine, assuming you’re sufficiently equipped.&lt;/p&gt;
</description>
    </item>
    
  </channel>
</rss>
