开发者

How to find the time taken to send data across UDP

开发者 https://www.devze.com 2022-12-21 04:45 出处:网络
I have a simple 开发者_如何学运维UDP client server written in C++ on Ubuntu 9.10 where the client sends a set to the server. How can I check how much time s it taking to sent it. I need to find the ti

I have a simple 开发者_如何学运维UDP client server written in C++ on Ubuntu 9.10 where the client sends a set to the server. How can I check how much time s it taking to sent it. I need to find the time from start of transfer to end.

Supposing my server and client are on the same machine then can I somehow save the system time and find the difference or something ?


Setup the server to immediately send a reply to the client. At the client measure the round-trip time. The time you are looking for is half the round-trip time.


If you are asking how long it takes for the packet to arrive at the server, there is no built in way to get that information.

If the server sends a reply, you can time how long it takes between sending the request and getting the reply and divide by 2 (not accurate, but a decent estimate).


You could put the time you sent the packet at in the beginning in every packet. In other words, you could create a custom header for all of your packets that would include this information.

0

精彩评论

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

关注公众号