Networking Forums

Networking Forums > Computer Networking > Linux Networking > Raw socket behavior

Reply
Thread Tools Display Modes

Raw socket behavior

 
 
Dan Wilson
Guest
Posts: n/a

 
      01-26-2005, 04:21 AM
I've been playing around with raw sockets (kernel 2.4.18, debian
woody) and I'm a little confused about how I should be reading from
them.

I'm aware that libpcap might be a better alternative to using raw
sockets, I'm probably going to end up using that, but just out of
curiosity ...

I'm doing something like this -

sockfd = socket (PF_INET, SOCK_RAW, IPPROTO_ICMP);
rc = recvfrom (sockfd, buffer, 1024, 0, NULL, NULL);

As far as I'm aware, I should be prepared for 'parts' of IP packets to
be delivered through the socket, but this never seems to happen, i.e.
I always get one and only one packet per call to recv. Whats more, if
the buffer passed to recv is smaller than the IP packet length, the
remainder of the packet seems to be discarded - I was expecting the
rest of it in the next call to recv.

Am I safe to just assume one packet per recv and use a big enough
buffer ?

Dan
 
Reply With Quote
 
 
 
 
Toni Erdmann
Guest
Posts: n/a

 
      01-27-2005, 01:11 PM
Dan Wilson wrote:
> Am I safe to just assume one packet per recv and use a big enough
> buffer ?


You should at least set the buffer size to
MTU == 1500 on Ethernet
See 'ifconfig' for actual size on eth0 or ...

No IP packet will (receive) or must not (send) be bigger
than the MTU (message transfer unit) size on the specific
interface.

Toni
 
Reply With Quote
Reply

Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
strange behavior when the client bind its UDP socket to a local address Christophe Lohr Linux Networking 14 01-23-2009 01:03 PM
Test socket on Master Socket not working Kevin Cowans Broadband 14 11-15-2006 09:17 PM
10038 Socket Operation on non-socket =?Utf-8?B?UkNyYWlnTGF3MUBhb2wuY29t?= Windows Networking 3 12-23-2004 03:01 AM
10038 Socket Operation on non-socket error Tim G Windows Networking 1 09-26-2004 03:04 PM
WLAN Monitor 10038 Socket operation on non-socket Bill Windows Networking 1 03-01-2004 10:34 PM



1 2 3 4 5 6 7 8 9 10 11