Network speed

  • Thread starter Thread starter Abubakar
  • Start date Start date
A

Abubakar

Hi,
I have a small sockets application and I'm adding a feature in it to
transfer files. Since I also want to give it a transfer resume feature so
this means I'll be transfering in specific bytes per pass. I want to know
the local LAN or, if or internet, internet connection speed like 5k/s or
50k/s (as we see in the downloads of IE) so that I can pass that amount of
data in write method of networkstream object. So how do I get the speed
figure?
 
They find the numbers through inspection of an actual transfer. Time how much
data you receive over time and average
this out to get a per second metric. The bytes per pass metric you are speaking
of really doesn't matter. If you are doing
a resume feature you simply need to allocate a blank file of the end size, and
then mark in the file the location where the
transfer was stopped so you can later seek and resume from there.

This isn't an easy application to write. You'll need to do some reading and
break down some of your misconceptions. For
instance, I can achieve the same speed by writing 10 10k buffers to the network
stream as I can for writing 1 100k buffer.
You see having your buffer the same size as the connection speed isn't how you
saturate a connection. You simply write
buffers as quickly as you can and the size of them really doesn't matter (okay,
size will matter at some point and you'll need
to tune your application to find the optimum buffer size, if you search on the
web, some people have already done this for
you and you can use their numbers).
 
Actually I wrote this file transfer (which was a feature of some app out of
many other features) and named it Simplest File Transfer Protocol or SFTP 2
years back which also had a resume feature and that was in c++. The way I
wrote it was I used to send some fixed buffer to the other computer and wait
for its return like for example

sender would pass : <open file>c:\data.dat
reciever would return : <opened>
sender : <write> hello
receiver : <more>
sender : <write> world
receiver : <more>
sender : <finish>
receiver : <closed>

here the "hello" and "world" (representing data to be written) are just for
example and the "write", "more", "open" etc are also examples however the
actual commands were similar. It also had a "resume" command which was used
by the receiver to ask the sender to open the file and move the file pointer
to lets say X position and than sending a "more" command which would intiate
file resume.
a resume feature you simply need to allocate a blank file of the end size,
and
yeah I know I did the same :-)

In that app my approach was like only send a 3k bytes at a time, because it
was for internet and I had slow internet connections. Are you suggesting
that I do the same this time and just decide upon a fixed number of bytes to
be sent untill the file finishes?
 
Back
Top