[p2p-hackers] Control network file transfer rate
y f
yfttyp2p at gmail.com
Thu Feb 23 15:05:40 UTC 2006
is this the simplist way:
while (1) {
old_time = gettimeofday( );
select(fds);
if (cur_time = gettimeofday( ) - old_time > 1 sec)
destroy ignore_list;
for (all fd whose bit is set) {
if (fd in ignore_list)
mark it and contiue;
do read/write;
add the data_size to this fd's data_total_within_this_second;
/* which is hashed link list */
if (data_total_within_this_second > max_data_within_a_second)
add it to ignore_list;
}
}
and with the tcp semantic, if we slow down the receiver speed, then the
sender's sending speed is slowed down accordingly. of course it will eat
much memory as we get a full socket receiving-queue at the beginning time.
I hope I say some right and can-do words. or there is a simple ioclt(sd,
...), or fcntl(sd, ...) can tell the sender what speed we like ?
Wish you a nice day !
On 2/23/06, Yifei Zeng <mac.ibook at gmail.com> wrote:
>
> Hi all.
>
> I am writing a peer-to-peer file sharing application in Java.
>
> Could someone help me with how to control the download/upload rate of
> the file transfer (practically) through internet?
>
> just like the BitTorrent clients (Bitcomet, Azureus), most of them
> have the function for the user to set the download / upload rate limit.
>
> How should I do in java to achieve this? Can someone please give me
> some ideas or hints?
>
> I am currently using non-blocking IO and socket and for each file
> transfer between two peers there is a non-blocking socket associated
> with it. And my application only has single thread to achieve all
> socket read / write request.
>
> Thanks
>
> Yifei
> _______________________________________________
> p2p-hackers mailing list
> p2p-hackers at zgp.org
> http://zgp.org/mailman/listinfo/p2p-hackers
> _______________________________________________
> Here is a web page listing P2P Conferences:
> http://www.neurogrid.net/twiki/bin/view/Main/PeerToPeerConferences
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://zgp.org/pipermail/p2p-hackers/attachments/20060223/43de8c2e/attachment.htm
More information about the P2p-hackers
mailing list