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. Thanks |
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. |
All times are GMT -5. The time now is 09:44 PM. |