Data transfer rate

Data transfer rate

Postby tanuck » Wed Apr 03, 2013 7:52 pm

Hi,

Trying to progress my knowledge this week my learning some socket programming.

I coded a simple http server and have now finished a server and client for simple file transfer. I wanted to add to this by adding a data transfer rate per second print out on the client. Not sure how to do this, searching on google hasn't brought up anything very helpful.

Can anyone offer me some advice please?

Regards
tanuck
 
Posts: 2
Joined: Wed Apr 03, 2013 7:49 pm

Re: Data transfer rate

Postby setrofim » Thu Apr 04, 2013 5:45 am

You can use time.time() to keep track of how long things are taking. Send the data in blocks, and keep track of how much you've sent so far. As you send each block, your transfer rate is total_bytes_sent / seconds_since_start. You can either keep these measurements from the start of the transfer, or for each X blocks transfered. If you want to output the transfer rate "in place" (i.e. without printing each successive value on a new line), use sys.stdout.write() and don't write '\n' at the end (or use print with a trailing comma); use '\b' (backspace) characters to "erase" the previous content.

Post some code if you want more help.
setrofim
 
Posts: 288
Joined: Mon Mar 04, 2013 7:52 pm

Re: Data transfer rate

Postby tanuck » Thu Apr 04, 2013 7:05 pm

Thanks a lot. More simple that i first thought. Managed to get it working in no time :) thank you
tanuck
 
Posts: 2
Joined: Wed Apr 03, 2013 7:49 pm


Return to Networking

Who is online

Users browsing this forum: No registered users and 2 guests

cron