Find the answer to your Linux question:
Results 1 to 4 of 4
Hi, I want to learn TCP/IP protocol etc., so I want to read raw information from my ethernet card. But I couldn't find eth0 file descriptor in /dev or in ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    May 2007
    Posts
    2

    Where is eth0 ?


    Hi,

    I want to learn TCP/IP protocol etc., so I want to read raw information from my ethernet card. But I couldn't find eth0 file descriptor in /dev or in other directories.

    To sum;

    -how can I read from eth0?
    -is there another way to read raw packets?

    Thanks...

  2. #2
    Linux Engineer Thrillhouse's Avatar
    Join Date
    Jun 2006
    Location
    Arlington, VA, USA
    Posts
    1,377
    You can use tcpdump.
    Code:
    $tcpdump -i eth0
    or
    Code:
    $tcpdump -c 25 -i eth0
    to read 25 packets from eth0 and then quit.

    If you want a more sophisticated "packet sniffer", you can use Wireshark.

  3. #3
    Just Joined!
    Join Date
    May 2007
    Posts
    2
    Thank you, I can use it.

    But I can not say I'm satisfied. I want to read packets directly from eth0 in my C program. Like reading a file or writing to /dev/audio.

    How can I do that?

  4. #4
    Linux Engineer Thrillhouse's Avatar
    Join Date
    Jun 2006
    Location
    Arlington, VA, USA
    Posts
    1,377
    I don't think you can read directly from a NIC in C but then again, I don't really know C that well. You might be able to read IP packets with a socket interface though.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •