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
|