Reputation: 477
I was given a sample project which goes like this:
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.
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.
Upvotes: 0
Views: 680
Reputation: 3595
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
burstsize = 10
for i in range(burstsize):
sock.write(data)
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 the for
, do a time.time()
after the for
and then after that do a simple select
for remaining time. (That's a way of introducing a delay). So a broad skeleton
while True:
t1 = time.time()
for i in range(burstsize):
sock.write(1460)
t2 = time.time()
if t2 - t1 < 1.0:
tout = 1.0 - (t2-t1)
select.select([], [], [], tout) #
This 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.
Upvotes: 1