Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6689115
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:28:54+00:00 2026-05-26T05:28:54+00:00

Background: I’m teaching myself about packet sniffing. I run a very simple server in

  • 0

Background: I’m teaching myself about packet sniffing. I run a very simple server in one shell, telnet to it from another, then try different methods to sniff on traffic. When I use raw sockets (IPPROTO_TCP), I capture what I send fine. I capture merely what I send, nothing else from the internet. libcap’s behavior confuses me as follows:

(1) First, to check it out, I capture all devices with pcap_findalldevs (see (2) below as well). I find wlan0 fine. If I connect to ‘all traffic’ (per the man page) using

if ( !( pcap_handle = pcap_open_live(NULL, 4096, 1, 0, errbuf) ) )

I capture what I send (plus more, see (3)).
when I try to connect to it using

if ( !( pcap_handle = pcap_open_live("wlan0", 4096, 1, 0, errbuf) ) )

, which to me seems the proper way of doing this, not ‘all’, i capture lots of general traffic, but nothing I send. Ideas?

(2) I first find all devices using pcap_findalldevs. As the pcap_if_t structure possibly has several elements, I print all those out, to see the following:

Devices found:

1. eth0 - None:
    family: 17, address: 2.0.0.0
2. wlan0 - None:
    family: 17, address: 3.0.0.0
    family: AF_INET, address: 192.168.0.159
    family: 10, address: 0.0.0.0
3. usbmon1 - USB bus number 1:
4. usbmon2 - USB bus number 2:
5. usbmon3 - USB bus number 3:
6. usbmon4 - USB bus number 4:
7. usbmon5 - USB bus number 5:
8. any - Pseudo-device that captures on all interfaces:
9. lo - None:
    family: 17, address: 1.0.0.0
    family: AF_INET, address: 127.0.0.1
    family: 10, address: 0.0.0.0

I am all new to this. Some devices offer capturing of AF_INET (=IPv4), IPv6 (10), and packet (17). when I connect to “wlan0”, how is it ensured I connect to the proper of the ‘addresses’ of some device? Is that related to the problem?

(3) When using raw sockets, I really only capture what I sent to my server. When I use libcap, I also capture what, from the bytes printed out, must be internet headers. I am all new to this. If someone could elaborate what exactly I capture here which i don’t capture on raw sockets, this would be appreciated. Are those UDP or ICMP packets which, by definition, my IPPPROTO_TCP socket would not capture, which would be why I didn’t see those using raw sockets?

Many thanks.

Edit: I work under Ubuntu 10.04 on a Toshiba netbook, using gcc/gdb combo.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T05:28:54+00:00Added an answer on May 26, 2026 at 5:28 am
    1. It’s somewhat surprising that, when capturing on wlan0, you’re not seeing packets you send, if they’re actually being sent over your Wi-Fi device. Are you sending them to other machines on your Wi-Fi network? If, for example, you’re sending them to other processes on your machine, they’ll show up on lo, not on wlan0 (and if you send them to other machines on your Wi-Fi network, rather than to other processes on your machine, they will not show up on lo – no, all traffic doesn’t eventually go through the loopback interface).
    2. The list of addresses you get from pcap_findalldevs() is NOT a list of addresses for which you can capture on that interface, it’s just a list of network addresses the system has for that interface. You don’t get to choose which addresses for which to capture – it captures for all of them. You capture on an interface, not an address.
    3. Libpcap is different from a raw socket; it gives you lower-layer headers than the ones for the data being sent or received, as well as that data. For an Ethernet device, you’ll see Ethernet headers; for a Wi-Fi device, what you see depends on the OS you’re on and the headers you select (on Linux, which is what you’re using, you’ll probably see Ethernet headers unless you capture in “monitor mode”, in which case you’ll either see Wi-Fi headers or some “radio” header such as radiotap headers followed by Wi-Fi headers); for the “any” device, you’ll see “Linux cooked headers”; and so on. You’ll need to call pcap_datalink() after calling pcap_open_live() to find out the header type for the interface; see the list of link-layer types (pcap_datalink() will return the DLT_ value, as listed there; don’t assume the number given there is the same as the DLT_ value, compare with the DLT_ value by name).
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Background I am writing and using a very simple CGI-based (Perl) content management tool
Background I'm trying to implement a simple web server part as a web interface
Background: Over the next month, I'll be giving three talks about or at least
Background: I'm running a Minecraft server for friends on a VPS, and I'm attempting
Background: I have a performance-critical query I'd like to run and I don't care
Background: I've wrote a small library that is able to create asp.net controls from
Background: I have viewed this question as well as this one - sadly, to
Background: I know, via pypi, about DOAP . Is there something similar to describe
Background: I am getting a Internal Server 500 24 50 error after deploying an
Background Use Ajax to fire an event to the web server when a list

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.