Networking Forums

Networking Forums > Computer Networking > Linux Networking > Raw socket transfer, fixing slow TX rate (C program, linux)

Reply
Thread Tools Display Modes

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

 
 
bobrics@gmail.com
Guest
Posts: n/a

 
      04-09-2006, 05:05 AM
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

 
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
slow ftp put transfer rate linux-tek Linux Networking 1 01-03-2007 05:44 PM
Slow Data Transfer Rate Mark S. Windows Networking 0 06-07-2006 11:03 PM
Simple client/server socket program works on one Linux machine, it doesnot work on other machine GS Linux Networking 2 05-09-2006 12:55 PM
LAN transfer rate? jtsnow Windows Networking 5 02-08-2005 11:55 PM
wireless slow transfer rate R Engdahl Windows Networking 0 01-27-2004 08:50 PM



1 2 3 4 5 6 7 8 9 10 11