LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-07-2006, 08:43 AM   #1
fpfernando
LQ Newbie
 
Registered: Oct 2005
Distribution: RH 9
Posts: 24

Rep: Reputation: 15
Packets gets repeated in raw sockets???????


hi all,


Im writing a recorder software which uses raw sockets ( Multicast Packets).

actually wot im doin is that i join the network and collect the packets and write them to a file.

but im getting a copy of all the packets.

my need is that i must get only the packet of that particular multicats IP i need with the header.

1.is there any way thro ordinary sockets i can extract the header too.

2. or thro rawsockets can i get only the packets i need


i read that the kernel gives a copy of the packet to all th rawsockets qwhich are opened at the same time. is there any way to eliminate this so that only the packet the socket needs will be provided to it.


Thanx in Advance
 
Old 03-07-2006, 08:49 AM   #2
kshkid
Member
 
Registered: Dec 2005
Distribution: RHEL3, FC3
Posts: 383

Rep: Reputation: 30
Quote:
2. or thro rawsockets can i get only the packets i need
yes,
you can get the packets you need in raw sockets.
you need to decapsulate the packet from its header
whether it is a protocol specific search ( you can get this by header length ) or message specific search .... from the decapsulated packet ... you can get that !!!
 
Old 03-07-2006, 07:12 PM   #3
primo
Member
 
Registered: Jun 2005
Posts: 542

Rep: Reputation: 34
You may use filters (Berkeley Packet Filter) with libpcap. Try it out.
 
Old 03-07-2006, 11:53 PM   #4
fpfernando
LQ Newbie
 
Registered: Oct 2005
Distribution: RH 9
Posts: 24

Original Poster
Rep: Reputation: 15
kshid,
the reason im using Raw sockets is that i need the header too.

decapsulating the payload alone wont help.

primo,
can u give me more details about libpcap. so where can i find a detailed manual about it.


Thanx Guys...
 
Old 03-08-2006, 12:53 AM   #5
primo
Member
 
Registered: Jun 2005
Posts: 542

Rep: Reputation: 34
See http://www.tcpdump.org/

There's a tutorial here:
http://www.tcpdump.org/pcap.htm

Chances are that you have it installed, at least the library itself. If not, install libpcap-devel on RPM systems. See pcap(3) (run "man 3 pcap") and tcpdump(1) for examples of filter expressions.
 
Old 03-08-2006, 02:20 AM   #6
nx5000
Senior Member
 
Registered: Sep 2005
Location: Out
Posts: 3,307

Rep: Reputation: 57
I've just written a skeletton of what you have to do.
http://www.linuxquestions.org/questi...d.php?t=422434
It's really a skeleton, it doesn't replace man pcap or reading the source code of tcpdump
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Raw Sockets Srikanth0210 Programming 2 12-05-2005 03:22 AM
Pblm in Raw Sockets fpfernando Linux - Software 1 10-08-2005 01:04 AM
Raw Ethernet Sockets alanwolfen Programming 2 01-06-2005 06:51 PM
raw sockets and C wrongman Programming 3 05-04-2004 02:17 PM
raw sockets BashTin Programming 1 06-07-2003 06:34 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:28 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration