user269037
user269037

Reputation: 560

How to find the time taken to send data across UDP

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 ?

Upvotes: 1

Views: 908

Answers (3)

xian
xian

Reputation: 4703

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.

Upvotes: 0

edgar.holleis
edgar.holleis

Reputation: 5001

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.

Upvotes: 1

R Samuel Klatchko
R Samuel Klatchko

Reputation: 76601

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).

Upvotes: 0

Related Questions