Solved

Raw sockets to receive IP packets

Posted on 2014-03-03
2
966 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 32

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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

758 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

17 Experts available now in Live!

Get 1:1 Help Now