Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 05-11-2010, 09:44 PM   #1
LQ Newbie
Registered: May 2010
Posts: 2

Rep: Reputation: 0
Problem getting more than one udp packet to remote end using sendmsg()

I am trying to send data via UDP using sendmsg on the sending side, and recvfrom() on the receiving end.

The setup for my data is to have an iovec that has a packet hdr, followed by an iovec that has a payload, then to have subsequent sets of these two types of iovecs.

On the receive end, I have a while true loop that does a recvfrom() receiving a size of 1 hdr/payload combination.

When I do send out a message that has a total of just 4 iovecs (hdr/payload/hdr/payload) and I use recvfrom on the remote end
with a receive size of a hdr/payload set, only the first hdr/payload of the sendmsg is received. I was under the impression that using this
while true loop would allow me to receive multiple sets of this hdr/payload combination that is sent out by sendmsg().

My intent is to have a iovec len = to the maximum allowed size on my
sendmsg() call and to receive that data at the remote end.

Is that 2nd set of data getting dropped on the floor because I am only trying to read half of the data that was sent? If so, Is there a way that I could change the behaviour of how the data is sent out.

Old 05-12-2010, 11:43 PM   #2
LQ Newbie
Registered: May 2010
Posts: 2

Original Poster
Rep: Reputation: 0
Follow up:
Further testing showed the following:
tcpdump on the source side indicated that when two hdr/payload packets worth of data was sent in a sendmsg call, that the udp packet jad a size of 2800 some bytes. The same was true when running tcpdump on the receive side. This implies that
there was fragmentation going on during the packet transmission. When I did a recvfrom() call allowing enough space for the
full 2800+ bytes then they were all stored into the allocated buffer.

So my initial assumption that the sendmsg with multiple iovecs would cause a send of multiple udp packets was incorrect.
All of the data from the sendmsg() call fit into one (fragmented) udp packet. So if I want to send more than one payloads worth of data in a sendmsg() call, I need to have an appropriatly sized recv buffer on the remote side.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
received UDP packet length sasubillis Linux - Software 1 02-12-2010 08:57 AM
Blocking UDP packet sailwind Linux - Software 3 04-08-2009 05:07 AM
udp packet loss problem vlyamtse Linux - Networking 2 02-12-2008 09:59 AM
UDP packet oss dazdaz Linux - Networking 2 04-05-2004 02:30 PM
UDP: short packet markus1982 Linux - Security 4 08-12-2003 09:03 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:12 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration