Solved

Raw sockets to receive IP packets

Posted on 2014-03-03
2
997 Views
Last Modified: 2014-03-04
Hi there,
I am trying to open a raw socket to capture IP packets.
When I use the option, "IPPROTO_TCP" I am able to capture the tcp packets, and similarly IPPROTO_UDP works for udp packets.  However, when I use IPPROTO_RAW I am not capturing any packets.  I am using Ubuntu Linux.  What could be wrong here?

When using IPPROTO_IP, I am getting an error( 93 - Protocol not supported)

 sock_raw = socket(AF_INET , SOCK_RAW , IPPROTO_RAW);

thank you.
0
Comment
Question by:ambuli
2 Comments
 
LVL 33

Accepted Solution

by:
sarabande earned 500 total points
ID: 39900915
an IPPROTO_RAW protocol is for send only. if you want to receive raw messages you should use htons(ETH_P_ALL) for protocol.

see
http://ubuntuforums.org/archive/index.php/t-1292481.html

for sample code or man pages

http://manpages.ubuntu.com/manpages/lucid/man7/raw.7.html

http://manpages.ubuntu.com/manpages/lucid/man7/packet.7.html

for more information.

note, raw sockets normally were used to implement a new ip4 protocol or by net sniffers. they are badly portable and you may get issues with installed security mechanisms.

Sara
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
The purpose of this article is to demonstrate how we can use conditional statements using Python.
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now