MLDonkey Forum Index
Homepage •  Bugs •  Tasks •  Patches •  SF.net Project Page •  ChangeLog •  German forum •  Links •  Wiki •  Downloads
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
MLdonkey gets confused by eMules rotational block requests
Goto page 1, 2, 3  Next
 
Post new topic   Reply to topic    MLDonkey Forum Index -> Development
View previous topic :: View next topic  
Author Message
spiralvoice
Sage


Joined: 06 Jan 2003
Posts: 3776
Location: Germany

PostPosted: Fri Jan 05, 2007 7:51 pm    Post subject: MLdonkey gets confused by eMules rotational block requests Reply with quote

(Moved this interesting thread to the dev forum)
(split from the thread "about current upload full chunks patch")

I will have a look at the patches next week.
TripleM wrote:
mldonkey retransmits a massive amount of data.

Confirmed, this problem has to be fixed ASAP, also for older versions
so distros can update their releases. This is a major problem, afaik
MLDonkey uploades ~30% of the data twice when the other client
is an eMule compatible one...

@TripleM: Can you provide a single patch which only fixes this problem
which does not depend on any other patches so it can be applied on
older versions of MLDonkey as well?
_________________
Link overview and precompiled cores here: http://mldonkey.sourceforge.net/DownloadLinks


Last edited by spiralvoice on Sat Jan 06, 2007 9:00 pm; edited 1 time in total
Back to top
View user's profile Send private message
TripleM
user


Joined: 27 Oct 2005
Posts: 95
Location: Germany

PostPosted: Sat Jan 06, 2007 1:11 am    Post subject: Reply with quote

spiralvoice wrote:
@TripleM: Can you provide a single patch which only fixes this problem
which does not depend on any other patches so it can be applied on
older versions of MLDonkey as well?

i provided a small patch in a post above in code-tags, which changes mldonkeys behaviour, so that intermediate pakets of a block are allways of ed2k-paketsize (10kb).
Code:
--- src/networks/donkey/donkeyFiles.ml  21 Nov 2006 22:34:33 -0000      1.22
+++ src/networks/donkey/donkeyFiles.ml  26 Dec 2006 15:37:25 -0000
@@ -130,8 +130,8 @@
               end else
             let max_len = up.up_end_chunk -- up.up_pos in
             let max_len = Int64.to_int max_len in
-            let msg_block_size_int = min msg_block_size_int per_client in
-            if max_len <= msg_block_size_int then
+            let allowed_msg_block_size_int = min msg_block_size_int per_client in
+            if max_len <= allowed_msg_block_size_int then
 (* last block from chunk *)
               begin
                 if !verbose_upload then
@@ -151,6 +151,7 @@
               end
             else
 (* small block from chunk *)
+              if allowed_msg_block_size_int = msg_block_size_int then
               begin
                 send_small_block c sock up.up_file up.up_pos
                   msg_block_size_int;

this way you get rid of most of the duplicated data. the rest seems intentional, caused through loss or similar. it is not the smartest patch Laughing , but i didnt wanted to change much.


so long,

p.s.: if you are interested in tracking duplicated requests, or requests, which are part of other already queued requests, the full-chunk-upload-alternative has some additional logging.
Back to top
View user's profile Send private message
spiralvoice
Sage


Joined: 06 Jan 2003
Posts: 3776
Location: Germany

PostPosted: Sat Jan 06, 2007 8:57 pm    Post subject: Reply with quote

TripleM wrote:
this way you get rid of most of the duplicated data.

Published a 50MB file with MLDonkey, downloading with eMule 0.47c.
Without your patch 90MB had to be uploaded to complete the file with eMule.
With your patch on todays vanilla CVS it was (only Wink) 85MB.

eMule rotates block requests, it asks for three blocks at once, maybe
MLDonkey gets confused by this...

http://hydranode.com/docs/ed2k/ed2kproto.php#upload
Quote:
After receiving OP_ACCEPTUPLOADREQ, the remote client will proceed to request chunks from us. In eDonkey2000 network, a chunk size is 180k (notice the difference from partsize). The chunks are requested using OP_REQCHUNKS packet:

OP_REQCHUNKS = 0x47, //!< <hash>hash[3*<u32>begin][3*<u32>end]

The packet contains three begin offsets and three end offsets of the requested chunks. ED2K data ranges logic defines that the end offset is exclusive, thus range (0, 0) is considered as invalidrange. If the client wishes less than three chunks, it may set the remaining ranges to (0, 0) to indicate that.

Note:
This is slightly different from HydraNode Range API, where end offset is considered inclusive.

Implementors should be warned about different behaviours of different clients when it comes to chunk requests. Namely, eMule (and compatible) clients use "rotational chunkrequest" scheme, where each REQCHUNKS packet contains one new chunk and two older chunks; for example:

Packet1: 0..101, 101..201, 201..301 // initial req
Packet2: 101..201, 201..301, 301..401 // sent after completing 0..101
Packet3: 201..301, 301..401, 401..501 // sent after completing 101..201

MLDonkeys, and some other clients, however, only send single requests:

Packet1: 0..101, 101..201, 201..301 // initial req
Packet2: 301..401, 0..0, 0..0 // after completing 0..101
Packet3: 401..501, 0..0, 0..0 // after completing 101..201

This can lead to duplicate data being sent by mldonkeys, if a rotational chunkrequest scheme is used when communicating with them. For that reason, HydraNode uses non-rotational request scheme with all clients, since all clients handle it properly.

After receiving OP_REQCHUNKS, the uploading clients starts sending data. The requested chunks are split into (up to) 10kb blocks, each transmitted as a separate packet, using OP_SENDINGCHUNK opcode. Optionally, clients supporting eMule extended protocol may use OP_PACKEDCHUNK packet (which is sent using PR_EMULE). In compressed packet, the data part of the packet is compressed using zlib (but not the packet header - this is different from OfferFiles packet, where everything after the opcode is compressed). Also, in case of a compressed packet, the end offset bytes in the packet header indicate the length of the compressed data, not the end offset of the uncompressed data. Note that compression is not required - if data compression results in larger amount of data, data should be sent uncompressed instead, using OP_SENDINGCHUNK packet.

_________________
Link overview and precompiled cores here: http://mldonkey.sourceforge.net/DownloadLinks
Back to top
View user's profile Send private message
pango
Sage


Joined: 31 Oct 2002
Posts: 2436

PostPosted: Sat Jan 06, 2007 10:07 pm    Post subject: Reply with quote

DonkeyClient.new_chunk checks that received requested ranges aren't already in the list of known requests (up_chunks) before adding them, so either:

  • some ranges are received again after having being served and removed from up_chunks already
  • overlapping ranges are received (requesting several times the same data, but not using exactly the same beginning and ending offsets), so above filtering fails (less likely)

Either way, just testing whether received requested ranges are already in the list of not yet served requests isn't enough; How do eMule peers solve the problem ? Do they enforce requests offsets to be monotonic (new accepted requests can only have offsets larger than previous ones) ? Are already served requests "blacklisted" for a while ?
Or is this an artefact of our larger output buffering ? (I doubt it; For streaming to work, sender has to go on with next request(s) before waiting for current request to be acknowleged; So it must be a common problem)

Untested patch:
ftp://ftp.berlios.de/pub/mldonkey/pango/avoid_duplicate_sending.patch


Last edited by pango on Sun Jan 07, 2007 3:51 pm; edited 1 time in total
Back to top
View user's profile Send private message
spiralvoice
Sage


Joined: 06 Jan 2003
Posts: 3776
Location: Germany

PostPosted: Sat Jan 06, 2007 11:15 pm    Post subject: Reply with quote

spiralvoice wrote:
Published a 50MB file with MLDonkey, downloading with eMule 0.47c.
Without your patch 90MB had to be uploaded to complete the file with eMule.
With your patch (TripleMīs) on todays vanilla CVS it was (only Wink) 85MB.

pango wrote:
Untested patch:
ftp://ftp.berlios.de/pub/mldonkey/pango/avoid_duplicate_sending.patch

With this patch according to MLDonkey and eMule stats 94.2 MB are transfered for the 50MB file.
_________________
Link overview and precompiled cores here: http://mldonkey.sourceforge.net/DownloadLinks
Back to top
View user's profile Send private message
spiralvoice
Sage


Joined: 06 Jan 2003
Posts: 3776
Location: Germany

PostPosted: Sat Jan 06, 2007 11:20 pm    Post subject: Reply with quote

http://www.mldonkey.org/forum/viewtopic.php?p=42465#42465

Translation: MLdonkey 2.7.0 and Mulus 0.18.1 are also affected
by this problem. As Mulus is based in MLDonkey 2.5.16 I guess
this bug is very old and caused by a change in eMule behaviour
which MLDonkey never adapted to.
_________________
Link overview and precompiled cores here: http://mldonkey.sourceforge.net/DownloadLinks
Back to top
View user's profile Send private message
pango
Sage


Joined: 31 Oct 2002
Posts: 2436

PostPosted: Sat Jan 06, 2007 11:29 pm    Post subject: Reply with quote

Mmmh then, unless there's a bug in my patch, they must do very nasty things, like sending overlapping requests with different offsets ?
If that's the case, it may be harder to fix "cleanly"...

We really need an actual communication trace to understand what's going on
Back to top
View user's profile Send private message
pango
Sage


Joined: 31 Oct 2002
Posts: 2436

PostPosted: Sun Jan 07, 2007 12:13 am    Post subject: Reply with quote

Mmmh one possible reason why my patch doesn't work: when all requests have been served (which is possible since we have large output buffers), all upload information is dropped by DonkeyFiles.send_client_block (c.client_upload <- None), so black listed requests are also forgotten.
The question is, what will break if we remove that instruction...

ftp://ftp.berlios.de/pub/mldonkey/pango/avoid_duplicate_sending_v3.patch

(Thinking of it, it could be the single reason why zones are being sent several times; And up_done_chunks logic could be superfluous).


Last edited by pango on Sun Jan 07, 2007 12:39 am; edited 1 time in total
Back to top
View user's profile Send private message
spiralvoice
Sage


Joined: 06 Jan 2003
Posts: 3776
Location: Germany

PostPosted: Sun Jan 07, 2007 12:36 am    Post subject: Reply with quote

A block means 10240 bytes.
A zone means 184320 bytes -> 18 blocks
A chunk means 9728000 bytes -> 52,78 zones

Here is a log from MLDonkey -> eMule 0.47c data transfer:

Explanation of the log:
Quote:
2007/01/07 00:20:39 [cO] Sending testfile.txt to 192.168.1.1 (eMU 0.47c) 'emule1', begin 11202560 len 10240
<-->
2007/01/07 00:20:39 [cO] Sending testfile.txt to 192.168.1.1 (eMU 0.47c) 'emule1', begin 11366400 len 10240

Such a block with "<-->" in between means MLDonkey sent blocks sized
10240 bytes from offset 11202560 to 11366400. I removed the lines
between the both lines above to be able to read the log more easily.

Now the log:
Quote:
2007/01/07 00:20:39 [cO] NO CHUNKS
2007/01/07 00:20:39 [EDK] Message from client[3] emule1(eMule) D[192.168.1.1:30005]
2007/01/07 00:20:39 [EDK] QUERY BLOCS OF EDK_HASH_EDK_HASH_EDK_HASH_EDK_HASH [11202560 - 11386880] [11386880 - 11571200] [11571200 - 11755520]
2007/01/07 00:20:39 [EDK] donkeyClient: uploader 192.168.1.1 (eMU 0.47c) 'emule1' ask for block
2007/01/07 00:20:39 [EDK] QueryBloc treated
2007/01/07 00:20:39 [EDK] Message from client[3] emule1(eMule) D[192.168.1.1:30005]
2007/01/07 00:20:39 [EDK] QUERY BLOCS OF EDK_HASH_EDK_HASH_EDK_HASH_EDK_HASH [11386880 - 11571200] [11571200 - 11755520] [11755520 - 11939840]
2007/01/07 00:20:39 [EDK] donkeyClient: uploader 192.168.1.1 (eMU 0.47c) 'emule1' ask for block
2007/01/07 00:20:39 [EDK] QueryBloc treated
2007/01/07 00:20:39 [EDK] Message from client[3] emule1(eMule) D[192.168.1.1:30005]
2007/01/07 00:20:39 [EDK] QUERY BLOCS OF EDK_HASH_EDK_HASH_EDK_HASH_EDK_HASH [11571200 - 11755520] [11755520 - 11939840] [11939840 - 12124160]
2007/01/07 00:20:39 [EDK] donkeyClient: uploader 192.168.1.1 (eMU 0.47c) 'emule1' ask for block
2007/01/07 00:20:39 [EDK] QueryBloc treated

MLDonkey received three zone requests with 5 different zones requested.
Now sending the first zone, here the request again:
Quote:
2007/01/07 00:20:39 [EDK] QUERY BLOCS OF EDK_HASH_EDK_HASH_EDK_HASH_EDK_HASH [11202560 - 11386880] [11386880 - 11571200] [11571200 - 11755520]

Now the transfer:
Quote:
2007/01/07 00:20:39 [cO] Sending testfile.txt to 192.168.1.1 (eMU 0.47c) 'emule1', begin 11202560 len 10240
<-->
2007/01/07 00:20:39 [cO] Sending testfile.txt to 192.168.1.1 (eMU 0.47c) 'emule1', begin 11366400 len 10240
2007/01/07 00:20:39 [cO] End of chunk (10240) 11386880 testfile.txt

This looks ok, now the next zone:
Quote:
2007/01/07 00:20:39 [EDK] QUERY BLOCS OF EDK_HASH_EDK_HASH_EDK_HASH_EDK_HASH [11202560 - 11386880] [11386880 - 11571200] [11571200 - 11755520]

Quote:
2007/01/07 00:20:39 [cO] Sending testfile.txt to 192.168.1.1 (eMU 0.47c) 'emule1', begin 11376640 len 10240
<-->
2007/01/07 00:20:39 [cO] Sending testfile.txt to 192.168.1.1 (eMU 0.47c) 'emule1', begin 11550720 len 10240
2007/01/07 00:20:39 [cO] End of chunk (10240) 11571200 testfile.txt

2007/01/07 00:20:39 [cO] Sending testfile.txt to 192.168.1.1 (eMU 0.47c) 'emule1', begin 11560960 len 10240
<-->
2007/01/07 00:20:39 [cO] Sending testfile.txt to 192.168.1.1 (eMU 0.47c) 'emule1', begin 11735040 len 10240
2007/01/07 00:20:39 [cO] End of chunk (10240) 11755520 testfile.txt

2007/01/07 00:20:39 [cO] Sending testfile.txt to 192.168.1.1 (eMU 0.47c) 'emule1', begin 11745280 len 10240
<-->
2007/01/07 00:20:39 [cO] Sending testfile.txt to 192.168.1.1 (eMU 0.47c) 'emule1', begin 11919360 len 10240
2007/01/07 00:20:39 [cO] End of chunk (10240) 11939840 testfile.txt

The last of the three zone requests quoted again:
Quote:
2007/01/07 00:20:39 [EDK] Message from client[3] emule1(eMule) D[192.168.1.1:30005]
2007/01/07 00:20:39 [EDK] QUERY BLOCS OF EDK_HASH_EDK_HASH_EDK_HASH_EDK_HASH [11571200 - 11755520] [11755520 - 11939840] [11939840 - 12124160]
2007/01/07 00:20:39 [EDK] donkeyClient: uploader 192.168.1.1 (eMU 0.47c) 'emule1' ask for block
2007/01/07 00:20:39 [EDK] QueryBloc treated

Quote:
2007/01/07 00:20:39 [cO] Sending testfile.txt to 192.168.1.1 (eMU 0.47c) 'emule1', begin 11929600 len 10240
<-->
2007/01/07 00:20:39 [cO] Sending testfile.txt to 192.168.1.1 (eMU 0.47c) 'emule1', begin 12103680 len 10240
2007/01/07 00:20:39 [cO] End of chunk (10240) 12124160 testfile.txt

2007/01/07 00:20:39 [cO] Sending testfile.txt to 192.168.1.1 (eMU 0.47c) 'emule1', begin 12113920 len 10240
2007/01/07 00:20:39 [cO] NO CHUNKS

Now all five zone requests were served by MLDonkey, as you can see
all subsequent zones sent had the wrong offset, except the first one
all are 10240 bytes too low... I do not know why the last block was sent...

These are the next zone requests by eMule:
Quote:
2007/01/07 00:20:39 [EDK] Message from client[3] emule1(eMule) D[192.168.1.1:30005]
2007/01/07 00:20:39 [EDK] QUERY BLOCS OF 3AF93D706ECAEACA4848001C5BBF8FF7 [11755520 - 11939840] [11939840 - 12124160] [12124160 - 12308480]
2007/01/07 00:20:39 [EDK] donkeyClient: uploader 192.168.1.1 (eMU 0.47c) 'emule1' ask for block
2007/01/07 00:20:39 [EDK] QueryBloc treated
2007/01/07 00:20:39 [EDK] Message from client[3] emule1(eMule) D[192.168.1.1:30005]
2007/01/07 00:20:39 [EDK] QUERY BLOCS OF 3AF93D706ECAEACA4848001C5BBF8FF7 [11939840 - 12124160] [12124160 - 12308480] [12308480 - 12492800]
2007/01/07 00:20:39 [EDK] donkeyClient: uploader 192.168.1.1 (eMU 0.47c) 'emule1' ask for block
2007/01/07 00:20:39 [EDK] QueryBloc treated
2007/01/07 00:20:39 [EDK] Message from client[3] emule1(eMule) D[192.168.1.1:30005]
2007/01/07 00:20:39 [EDK] QUERY BLOCS OF 3AF93D706ECAEACA4848001C5BBF8FF7 [12124160 - 12308480] [12308480 - 12492800] [12492800 - 12677120]
2007/01/07 00:20:39 [EDK] donkeyClient: uploader 192.168.1.1 (eMU 0.47c) 'emule1' ask for block
2007/01/07 00:20:39 [EDK] QueryBloc treated

_________________
Link overview and precompiled cores here: http://mldonkey.sourceforge.net/DownloadLinks
Back to top
View user's profile Send private message
pango
Sage


Joined: 31 Oct 2002
Posts: 2436

PostPosted: Sun Jan 07, 2007 12:47 am    Post subject: Reply with quote

To test my hypothesis that client_upload <- None is the real culpit, I made a different patch with all the up_done_chunks logic removed:

ftp://ftp.berlios.de/pub/mldonkey/pango/avoid_duplicate_sending_v4.patch
Back to top
View user's profile Send private message
spiralvoice
Sage


Joined: 06 Jan 2003
Posts: 3776
Location: Germany

PostPosted: Sun Jan 07, 2007 12:50 am    Post subject: Reply with quote

pango wrote:
ftp://ftp.berlios.de/pub/mldonkey/pango/avoid_duplicate_sending_v3.patch

With this patch eMule receives only 540kb, then MLdonkey stops sending data.

Edit: v4 of your patch has the same bug, again only 540kb upload, this
means three zones, so only the first eMule zone request was handled.
_________________
Link overview and precompiled cores here: http://mldonkey.sourceforge.net/DownloadLinks
Back to top
View user's profile Send private message
pango
Sage


Joined: 31 Oct 2002
Posts: 2436

PostPosted: Sun Jan 07, 2007 1:01 am    Post subject: Reply with quote

spiralvoice wrote:
Now all five zone requests were served by MLDonkey, as you can see
all subsequent zones sent had the wrong offset, except the first one
all are 10240 bytes too low... I do not know why the last block was sent...

I think you shouldn't worry too much about this one, that's because the "End of chunk" message is logged before the last block is actually sent:

Code:

                if !verbose_upload then
                    lprintf_nl "End of chunk (%d) %Ld %s" max_len up.up_end_chunk (file_best_name up.up_file);
                send_small_block c sock up.up_file up.up_pos max_len;

swapping the two should make logs more readable Smile
Back to top
View user's profile Send private message
pango
Sage


Joined: 31 Oct 2002
Posts: 2436

PostPosted: Sun Jan 07, 2007 1:04 am    Post subject: Reply with quote

spiralvoice wrote:
With this patch eMule receives only 540kb, then MLdonkey stops sending data.

This is consistent with the "new state" (client_upload <> None, but no request to serve) has broken something. Good luck finding what...
(By the way, I'm not sure I'm observing that problem here (?) what's your client_buffer_size ?)


Thinking of it once more, I think the up_done_chunks logic is useful; Otherwise we must not finish sending the second zone before we received the second request packet (the one with the first zone removed). Because if we send the two first zone and then receive that request, we will send the second zone again...
Back to top
View user's profile Send private message
spiralvoice
Sage


Joined: 06 Jan 2003
Posts: 3776
Location: Germany

PostPosted: Sun Jan 07, 2007 1:37 pm    Post subject: Reply with quote

pango wrote:
(By the way, I'm not sure I'm observing that problem here (?) what's your client_buffer_size ?)

Default, 500000. I am using MLdonkey in a local test setup on my machine.
Transfer takes place with 4-5 MB/s, maybe this is too fast for MLDonkey?
_________________
Link overview and precompiled cores here: http://mldonkey.sourceforge.net/DownloadLinks
Back to top
View user's profile Send private message
pango
Sage


Joined: 31 Oct 2002
Posts: 2436

PostPosted: Sun Jan 07, 2007 3:08 pm    Post subject: Reply with quote

500000 is not large enough to store 3 zones (540kB), but on a fast-enough link, the third can be send (and the requested zones list emptied) before the next batch of requests arrives. On my 128kbps uplink, I never get the "NO CHUNKS" messages in the logs, and streaming works fine.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    MLDonkey Forum Index -> Development All times are GMT
Goto page 1, 2, 3  Next
Page 1 of 3

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Sourceforge.net Logo