I want to measure message latency and throughput for both TCP and UDP using C sockets. I am writing a client.c and server.c (Question 1: Do I have to?) that run on different servers to accomplish this. I have to take several measurements using different packet sizes and multiple trials and plot my results.
For message latency: Send a packet of varying size and measure the round trip time and divide by 2 to get latency. Question 2: I send a packet of size x, and then from server.c I send the packet back. So at the client I start the timer, send packet and then wait till I receive the packet then stop the timer. The timer/2 is my latency? What are the steps to go about measuring this?
For throughput: Question 3: How would I measure throughput of both? What are the steps to go about doing this?
Im a beginner to Unix socket programming in C so detail would be helpful, with emphasis on the bechnmarking aspect.
EDIT: I cannot use tools that already exist. I need to write my own.
Thanks!