Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have an app that sends messages over UDP in some known format. I'd like to know the rate at which these messages are sent. To be clear, I could care less about the datarate - it's a loopback, so it's somewhere near infinity + 1 - what I need to know his how often complete messages go out.

share|improve this question
    
HAve you tried using for example Wireshark? It should be able to show you exactly what's going out and when you find the interesting packets, you can filter view so that it only shows them. –  AndrejaKo Jan 3 '12 at 19:29
2  
That should be an answer, @Andreja! Go take credit for it. :) –  Darth Android Jan 3 '12 at 19:33
add comment

2 Answers

up vote 3 down vote accepted

You should look at using TCPDUMP and WireShark to capture the data and then analyze it.

If all you care about is packet rates then running netstat might give you the idea.

On Linux:

`netstat --interfaces=lo -c`

would give you an idea in 1 second intervals but there are similar flags on most modern OS'

share|improve this answer
    
anything comparable on win7 –  jamesson Jan 3 '12 at 19:47
    
@jamesson - Just use the suggested programs or use the windows version of netstat. –  Ramhound Jan 3 '12 at 20:05
    
@jamesson - have you tried WireShark –  Karlson Jan 3 '12 at 20:29
add comment

If by "message" you mean "datagram", then the answer is 100%. UDP datagrams are either sent or not, and they either arrive or do not. You should never recvfrom() only part of a UDP datagram. If the datagram ends up being larger than the network MTU, it may be fragmented at the IP layer, but any dropped fragments will result in the whole datagram being dropped not a partial message.

The speed of the loopback is not infinite: it is limited by the CPU. If you send data too fast, the outgoing UDP buffer will fill up. Then when you try to sendto() a datagram that is too big to fit in the remaining buffer space you will get an error like EAGAIN, ENOBUFS, or EMSGSIZE, depending on the implementation. If the receiver calls recvfrom() to slowly, then its incoming buffer will fill up and datagrams will be silently dropped.

A more relevant question is the percentage of datagrams sent which are actually received. At rates well below CPU saturation, this should be 100% on the loopback. But when approaching CPU saturation, or if the receiver is slow in reading the datagrams, it can become arbitrarily low.

share|improve this answer
    
A useful and intersting perspective. My system doesn't come close to cpu saturation tho, so not really applicable in my case. Thanks for the wisdom tho! –  jamesson Jan 14 '12 at 16:38
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.