LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   UDP Send/Receive problem on the same port (https://www.linuxquestions.org/questions/linux-networking-3/udp-send-receive-problem-on-the-same-port-934165/)

bmahjoor 03-13-2012 01:44 AM

UDP Send/Receive problem on the same port
 
Hi,
I have a packet generator connected to my MAC that sends 100 UDP packets to my port 3000(It uses port 4000 to send these packets). I have a loop that receives these packets (recvfrom(..)) and send them back immdeiately, untouched and count them. However, these packets gets to my MAC and all the way up the stack (netdev->stats.rx_packets = 100). But my recvfrom(..) only receives 63 of these and sendto(..) is called 63 times. However, the packet generator receives only 3 packets at all time. Any suggestions as to what might be happening here ? What happened to the missing 37 packets ? And why nedev->stat.tx_packets does not agree with how many times sendto() has been successfully called ? I doubt if it is prohibited to send and receive using the same socket bounded to my receive UDP port...is it ? Should I use two different sockets and bind them to two different port, one for receive and one for send ?
Thanks in advance for any suggestions.

eeekster 03-13-2012 10:04 AM

Are you checking for errors being returned from the sendto() call?

bmahjoor 03-13-2012 12:38 PM

Of course. sendto() always returns the exact number of bytes given to it to send. Today I am delving into the kernel and check the transmit routine..it should be called at least as many times as my sendto() is called.

eeekster 03-13-2012 12:48 PM

Are you sure you aren't over running the receive buffers and dropping packets?

bmahjoor 03-13-2012 04:37 PM

No, that's not the problem at all. The weird thing is sendto(..) is called and returns 63 times but the MAC driver's
transmit routine in kernel is only called 3 times. Have no idea what happened to the rest of the packets. I thought
sendto() returns only when the packet is passed to transmit routine.


All times are GMT -5. The time now is 04:08 AM.