Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Raw sockets to receive IP packets

Posted on 2014-03-03
2
1,067 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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Suggested Solutions

The purpose of this article is to demonstrate how we can use conditional statements using Python.
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

839 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