Networking Forums

Networking Forums > Computer Networking > Linux Networking > sendmsg(): Message too long [*stressnet*]

Reply
Thread Tools Display Modes

sendmsg(): Message too long [*stressnet*]

 
 
Yannick Loth
Guest
Posts: n/a

 
      07-13-2005, 03:43 PM
Hello everybody

I try to use the sendmsg() function to send several packets through a
AF_PACKET SOCK_RAW socket using one system call.
Once the packets are loaded into memory, I try to send the first ones,
but unfortunately sendmsg() fails, returns -1 and perror() gives me the
message: Message to long

The struct msghdr is filled with a struct sockaddr_ll address, no flag,
and the array of struct iovec.

I use Linux 2.6.11.4-21.7-default (SuSE Linux 9.3 Professional).

The program I develop is limited by the overhead due to repeated calls
to sendto() when sending packets to the network. If I could use
sendmsg(), there would be much less overhead and the performances I'd
get would be much better.

Using writev() doesn't help much, as it doesn't send every packet alone
with its own FCS (it concatenates them all and sends them with only 1
FCS/CRC, thus it makes 1 big packet of my smaller packets, and this is
not wanted).

Is there some other function or API I can use to get better performance
for sending packets at very high bitrates, even very small packets?
(sendto is only bitrate-reliable until 150 Mbit/s, which is too small
for my use, and I guess sendmsg() would help there).

What's wrong with this code?

Thanks
Yannick
http://www.loth.be/yannick/stressnet/index.html

(if this is not the right list, which list would be ok?)

-----------------
-Here's the code-
-----------------
namespace stressnet{
struct packetListElement
{
struct iovec * data;
struct packetListElement * next;
};
}

struct msghdr msgHeader;
struct iovec *iovArray=new struct iovec[2];
struct stressnet:acketListElement *ple;
ple=df->getPListRootElement();
for(int i=0;i<2;++i)
{
memcpy(iovArray+i,ple->data,sizeof(struct iovec));
std::cout<<ple->data->iov_len<<std::endl;
ple=ple->next;
}
msgHeader.msg_iovlen=2;
msgHeader.msg_name=(void *)pSocket->getLocalSockAddr();
/* this is a pointer to a struct sockaddr_ll socket address
* which is correctly initialized as it does work with sendto()
*/
msgHeader.msg_namelen=sizeof(struct sockaddr_ll);
msgHeader.msg_control=NULL;
/* no ancillary data
*/
msgHeader.msg_controllen=0;

int result;
if ((result=sendmsg (pSocket->getSocketDescriptor(), &msgHeader, 0))<0)
{
perror("sendmsg() failed");
}

std::cout<<result<<std::endl;

-------------------
-Here's the output-
-------------------

Raw socket successfully created!
Socket family: 17
Ethernet protocol: 3
Interface index: 2
Socket bound!
60
60
sendmsg() failed: Message too long
-1
 
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
Why is pktgen v1.3 causing an error message like this? (See message body) gregg.drwho8@gmail.com Linux Networking 0 12-29-2006 03:43 AM
pppd & gprs cannot get ip (long message) Eismann Linux Networking 1 10-03-2006 11:51 PM
Kernel upgrade -> no network access (ping: sendmsg: Operation not permitted) smythe70@hotmail.com Linux Networking 10 09-17-2006 01:55 AM
multiple sendmsg and single user-kernel switch avivgr Linux Networking 0 10-13-2005 06:28 PM
U.S. Robotics 805416 + Windows XP SP2 + WPA = problems? (Long message) Lucifer Wireless Internet 1 11-13-2004 09:15 PM



1 2 3 4 5 6 7 8 9 10 11