Networking Forums

Networking Forums > Computer Networking > Linux Networking > Raw socket captures only first 96 bytes of packet

Reply
Thread Tools Display Modes

Raw socket captures only first 96 bytes of packet

 
 
satishamara@yahoo.com
Guest
Posts: n/a

 
      08-08-2005, 07:02 PM
Hi,
I am trying to use raw socket interface to caputre packets on wire.
I am getting only first 96 bytes of packets. Wondering is there any
ioctl or setsocket option to set packet length.

Here is the code snippet ...






int recvSize = 8192;




if ( (sock=socket(PF_INET, SOCK_PACKET,
htons(ETH_P_IP)))<0) {
perror("socket");
exit(1);
}

/* Set the network card in promiscuos mode */
strncpy(ethreq.ifr_name,"eth0",IFNAMSIZ);
if (ioctl(sock,SIOCGIFFLAGS,&ethreq)==-1) {
perror("ioctl");
close(sock);
exit(1);
}
ethreq.ifr_flags|=IFF_PROMISC;
if (ioctl(sock,SIOCSIFFLAGS,&ethreq)==-1) {
perror("ioctl");
close(sock);
exit(1);
}

if(setsockopt(sock, SOL_SOCKET, SO_RCVBUF,
&recvSize, sizeof(recvSize))<0){
perror("setsockopt");
close(sock);
exit(1);
}


while (1) {
printf("----------\n");
n = recvfrom(sock,buffer,2048,0,NULL,NULL);
printf("%d bytes read\n",n);


}

}

Thanks,
Satish

 
Reply With Quote
 
 
 
 
GS
Guest
Posts: n/a

 
      08-09-2005, 01:55 PM
What is the size of buffer in recvfrom call?. Are you trying to capture
any kind of N/W packets or you have server on other side and try to
write?.

 
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
Is count of un acknowldged bytes maitained anywhere in kernel data structures for TCP socket ? Rohit Linux Networking 0 05-14-2007 12:23 PM
Raw socket captures only first 96 bytes of packet satishamara@yahoo.com Linux Networking 0 08-08-2005 06:32 PM
socket stops, bytes stuck in send-Q R. Kent Wenger Linux Networking 0 12-22-2004 09:59 PM
Can I send out an ethernet packet with over 1500 bytes in linux ? Hans Yin Linux Networking 4 12-21-2004 07:19 AM
Packet to bytes conversion Bobby Home Networking 4 04-02-2004 02:06 PM



1 2 3 4 5 6 7 8 9 10 11