开发者

Configurable rate and pattern when implement tcp ping in C

开发者 https://www.devze.com 2023-01-25 06:33 出处:网络
i am trying to implement a tcp ping function. And I hope to make the rate and开发者_运维问答 pattern of sending messages configurable. For example, send 5000 msg in 5 seconds, burst 2000 at first then

i am trying to implement a tcp ping function. And I hope to make the rate and开发者_运维问答 pattern of sending messages configurable. For example, send 5000 msg in 5 seconds, burst 2000 at first then 3 msg/ms for 1000ms. Any idea how to make it happen? Thanks in advance. ps, I am using c socket programming, write and read to send and receive msg.


I may be missing something but isn't all you have to do is have a loop where you send 2000 messages and then put the thread on Sleep() for 1ms and send 3 packets each time until you have sent the rest 3000 packets.

One thing you should know is that measuring how long time it takes for code to execute is hard. Since you are using TCP, which uses buffers, send will block if there is not enough buffer space until it can send the next message depending on amount of data, size and network status.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号