David P. MottFri Jan 16 17:19:09 PST 2004
Hi, all --
Since I don't want to set off (another?) flame war on the BitTorrent
group, I wanted to float some random thoughts here and see what people
thought of them.
If they have merit, then I'll post 'em to the group.
If you have time, please let me know what you think. Thanks.
First, let me say this -- I like BitTorrent. A BitTorrent Tracker is easy
to set up and use, and there are a variety of clients that are also easy
to use, all of which makes BitTorrent popular. And, it all seems to work.
But, there are a few problems with it. I've been thinking about what's
"wrong" or "broken" with BitTorrent, and what could be done to fix it
(haven't we all?).
So, my thoughts are these:
1. BitTorrent isn't scalable (with respect to the trackers).
I think that's pretty much what Bram's recent post is saying.
2. Related to #1, peers don't share enough data
Metadata and peer lists seem like a good way to reduce tracker
load, thereby increasing scalability
3. The whole system of pieces and subpieces is kludgy.
It's too easy to send a bad subpiece (which can be caught later, but
then recovery algorithms and "bad" peer detection complicate the
mess, or you just have to keep downloading the whole piece again,
hoping that you eventually get it.
4. tit-for-tat just doesn't work.
5. BitTorrent isn't open to protocol extensions.
Most protocol specs that I play with say something like "We reserve
messages 200-255 for future use, the rest can be reserved by writing
to such_and_such a group for inclusion in the spec"
--------------------------------------------------------------
So, first: #1 can probably be fixed with #2.
Thoughts?
--------------------------------------------------------------
As for #3, here's what I'm thinking. If metadata gets shared among peers,
then the size of it becomes less of a concern (provided that it doesn't
get an order of magnitude bigger than it is now). So, let's say that we
impose the following "rules" on metadata files and the peer protocol:
1. Each piece in the metadata file has an SHA1 hash for validation
(same as today)
2. Each piece is referenced by number (same as today)
3. Each piece is allowed to be no bigger than 2^20 (currently, that's the
max size for requesting a subpiece)
4. The peer protocol is changed to simply request a piece. No offsets,
no lengths.
That makes things lots simpler, doesn't it? In the spirit of "don't trust
anything from your peers", you don't have to sit on a subpiece for awhile
until you can verify it. You get to verify it right there, and perhaps
even blackflag "bad" peers immediately.
This also makes the metadata bigger. Especially if the metadata gets
reorganized such that you can verify each file described in the metadata
independently of others (i.e. pieces don't span file boundaries), then it
gets somewhat bigger again.
But, it seems like this is not an order N size increase, nor an order of
magnitude increase. Maybe a 5x increase (I haven't crunched any numbers
yet). And, it's a one-time download for a peer. Okay, it's an N-upload
when peers are providing that data, but we were already talking about
that. I guess if there's any concern there, it's chewing your *upload*
bandwidth much more than your *download* bandwidth.
This is the one that I'd really like to hear about.
Thoughts?
--------------------------------------------------------------
Tit for tat. It seems to me that unless you build this right into the
wire protocol, then it's hard to enforce it. Without exploring all of the
startup and boundary cases, I was toying with this concept:
Peers would have a message 'req_resp', which contains a single request and
response. Ignoring the starting case, the idea is that a client would
have a request pending from a peer. When it is answered, a new request
for a piece from that peer is prepended to the response, hence 'req_resp'.
The peer can start processing that request when it gets the first part of
the TCP/IP packet, since it's in the front.
I was also thining that peers that connect TO YOU should send you a piece
first, thereby preventing "bad" peers from continually re-connecting to
get a "free" piece.
Obviously, peers with nothing to send would have to be cut some slack, but
then there should also be a way to manage peers that always report that
they have nothing.
I think that this would also encourage a new peer to go get "rarest first"
pieces from everyone, so that they can have something to trade with
others. (That's a start condition there... need to be able to get pieces
when you have none to share to begin with).
There are probably *lots* of problems with this, the first being "maybe
tit-for-tat *shouldn't* work, why limit ASDL users to 10kbps download just
because their max upload is 10kbps?".
Thoughts?
--------------------------------------------------------------
#5.
So, I was thinking about how to handle the options bitfield. My thoughts
on that went something like "There needs to be a central authority that
defines the bits... it'd be nice if the bits had names... if they had
names, then we could use that as a key for plugging in features...
bencoded dictionaries have keys... wouldn't it be nice to have a message
like "caps" that describes the capabilities of a peer, in a bencoded
dictionary. It could look like this:
caps =>
{
bzip => 1
gzip => 1
nohave => 1
peerlist => 1
metadata => 1
}
(or maybe that should just be an array of names)
Then, that's just one message, and no bits out of the bitfield. You can
extend that dictionary to your heart's content. Features between two
peers are only enabled on that wire if both agree to support something
(i.e. the intersection of the caps dictionaries from each peer).
But, I remember that Bram once said that he wanted to keep bencoded
messages out of the wire protocol. So, that would probably get shot down
pretty quickly.
Anyway, if Bram left a block of messages open for us to play with, we
could extend the protocol and see what works and what doesn't work. If
something works, he could adopt it. Otherwise... well, what's the harm in
letting us play?
Thoughts?
--------------------------------------------------------------
If you've gotten this far, thanks for reading. I look forward to your
feedback.
-Dave