Raw socket transfer, fixing slow TX rate (C program, linux)



Hello,

I have a question to you guys. I am developing a raw sockets client and
server to send my own information with as little overhead as possible.
The purpose it to test a several coding schemes over different
channels. The issue I have faced with is a much slower transfer rate
than I've expected. For testing purposes, I have removed all the
coding, and just left a regular transfer of N packets of size PKT_SIZE
over a regular cross over cable between two 100Mbps interfaces. The
speed is smaller than 1Mb/s, which is not right. I am either using an
incorrect packet size, or something else.. maybe this error is a
combination of several. I have tested the code with LFSR and a regular
file read and send. Also, I have checked the channel using a regular
FTP server and it's fast as it's supposed to be having 8Mb/sec for a
regular file TX.

I am using the following code for time measurements:
/*------------------------------------------------------------------------------------*/
#include <sys/time.h> // For Elapsed Time measurements
struct timeval timeval_start, timeval_stop, timeval_diff;
double timeval_diff_sec; // difference in seconds
....
gettimeofday(&timeval_start, NULL); // Wall clock time, start timer
// HERE: receive packets from a RAW SOCKET
gettimeofday(&timeval_stop, NULL); // Stop timer

if (timeval_subtract(&timeval_diff, &timeval_stop, &timeval_start))
printf("Warning: negative time\n");
// Save floating point time with respect to seconds
timeval_diff_sec = (double)timeval_diff.tv_sec +
(double)timeval_diff.tv_usec / 1E6;
/*------------------------------------------------------------------------------------*/

PKT_SIZE that I am using is 1K. I was trying not to go over ethernet's
1500Bytes of data/packet value. What do you think?

I need your suggestions to speed up the transfer. I am using C and here
is the part of the code where I am creating a socket and then sending
it.
/*------------------------------------------------------------------------------------*/
// Create a RAW socket and bind it
memset(&sll, 0, sizeof(sll));
sll.sll_family = PF_PACKET;
sll.sll_protocol = htons (ETH_P_ALL);
sll.sll_ifindex = 4;

fd = socket (PF_PACKET, SOCK_RAW, htons (ETH_P_ALL));
strcpy (ifreq.ifr_name, sock_int);
ioctl (fd, SIOCGIFINDEX, &ifreq);
sll.sll_ifindex = ifreq.ifr_ifindex;
bind (fd, (struct sockaddr *) &sll, sizeof(sll));

// Here: create packets either from file or random sequence

// Send packet to the socket
bytes_sent = write (fd, packetptr, pkt_header.pkt_total_len);
/*------------------------------------------------------------------------------------*/

THANK YOU
SB

.



Relevant Pages

  • Raw socket transfer, fixing slow TX rate (C program, linux)
    ... server to send my own information with as little overhead as possible. ... and just left a regular transfer of N packets of size PKT_SIZE ... receive packets from a RAW SOCKET ...
    (comp.os.linux.networking)
  • RAW socket: buffer size.
    ... I have a question related to RAW socket programming. ... You can also specify ID of ICMP ECHO packet. ... Before start of receiving the packets the program calls alarm ... register int nleft = len; ...
    (comp.os.linux.development.system)
  • Re: Did I get hacked into through IIS?
    ... IIS server, to capture the packets and see what they are. ... I had my regular PC running, ... > worst fear that someone copied my entire private data folder over the ...
    (microsoft.public.inetserver.iis.security)
  • Raw Sockets for packet sniffing
    ... able to inject packets through the raw socket but not to sniff packets. ... class RawSocket ... cnt = @sock.write packet_bytes ...
    (comp.lang.ruby)
  • Re: Problem in recvfrom()
    ... input..but when I run my client it doesnt reflect on the server side at ... cause its a raw socket and Richard STevens says raw sockets dont have ...
    (comp.os.linux.development.apps)