I was given a sample project which goes like this:
- Client A connects to server B.
- A sends packet to B, B returns the same packet to A.
- Client A sending throughput is configurable
- Measure turnaround time per packet.
Now step 3 is what is confusing me.
Using python, the only way I can think of "configuring throughput" is to set a delay between characters in a string.
- Take a string "test"
- Start a timer, then send "t" to the server, and have the server return it.
- Once the server returns it, stop the timer and log it.
Then call sleep()
for a determined amount of time (this is the configurable part)
Then do the same for the letters
e
s
t
Logging, the time in-between.
However, this seems silly, because I am not at all affecting the relationship between the client and server, just setting a delay between characters being sent.
Or am I missing something? Is there actually a way of "configuring" client A's throughput, and if so, what would that mean?
Thank you.
You can make client A's throughput configurable - over a broader window of say 1 second. First of all sending single packets with 1 characters is going to 'negatively affect' your throughput, because your payload is way small compared to the headers that will get attached.
The way you can achieve a decent measurable throughput is sending MSS packets (typically 1460 bytes in Ethernet environments). Now you can do it something like as follows - send 'bursts' of 'n' packets per second. So eg. if you need a throughput of 14600 you could do
Every one second. Now how do you achieve - one second? Well it's a bit tricky and very hard to get accurate - but something like this.
do a
time.time()
before thefor
, do atime.time()
after thefor
and then after that do a simpleselect
for remaining time. (That's a way of introducing a delay). So a broad skeletonThis is very simplistic - but should give a fair idea how to go about it.
Measuring turnaround time for every packet is quite hard - and doesn't tell accurately about the latency in the network for TCP, because that will be influenced by TCP flow control. Better to use UDP to measure turnaround time, if you are interested in understanding underlying network characteristics like bandwidth/latency.