am the host of ".NET Rocks!", an Internet audio talk show for .NET developers online at www.dotnetrocks.com
. My co-host Richard Campbell and I interview the movers and shakers in the .NET community. We now have over 160 shows archived online, and we publish a new show every Monday morning. For more history of the show check out the May/June 2004 issue of CoDe Magazine
, in which the first column appeared. In each issue, I like to highlight some of my favorite moments from a recent show.
In show #157 we spoke with David Smith, a Microsoft Student Ambassador at Michigan State University, and a C# MVP who is very interested in distributed systems. We talked about BitTorrent, IPv6, and BTSharp, a set of components that he has written in C# 2.0 that provide a full BitTorrent implementation. This was an interesting discussion not just because of the programming involved, but in how protocols like BitTorrent change the nature of the Internet, and could bring about a new era in publishing. BTSharp is available at http://shrinkster.com/a38
Carl Franklin: Are you still the only .NET implementation of BitTorrent that is available?
David Smith: Actually [on] my Web site I have had a lot of people posting some links to their own projects. It turns out that a lot of people have been working on it, kind of in the woodwork, and some people actually have just ported over the current implementation of BitTorrent that exists in Pythonbut it really doesn't take advantage of all of the great things that C# has to offer and it's not very fun to program against. One of them that exists is BitTorrent.Net and that's the most common one that some other developers have been playing with, but I have got a lot of positive feedback from BTSharp and people want me to keep working on it.
Carl Franklin: Well, let's talk about what it is first. Let's tell everybody what BitTorrent is. They [may] have seen it, they have heard of itprobably in the context of some nefarious activitiesbut let's just clear the air and tell everybody what it is.
David Smith: Well, BitTorrent is an algorithm for distributing information and this can be your photos to your families, this can be a photo to your friends, some music that you want to share with somebody else, some music that you made or even a show that you recorded that you wanted to distribute to people online.
Carl Franklin: Well, anything digital, basically.
David Smith: Yeah, absolutely anything.
Richard Campbell: And it wasn't the beginning of all this distributing versions of Linux?
David Smith: Yes, absolutely. Those Linux kernels are really, really big and those images are really, really bigand they didn't want to have to pay for the server costs to keep those downloads going. So they thought they would push that burden off to the client and they could have each person who is downloading the file, help to share that same file.
Carl Franklin: Now David there have been a lot of peer-to-peer programs out there especially, you heard of Kazaa, and Napster did this similar thing. There are a lot of programs out there that people use to share. And let's face it, they're sharing copyrighted material: movies, MP3s, [etc
], but what's different about BitTorrent from the rest of these? I mean, BitTorrent has got a lot more notice in the community because it's so goodwhat makes it different than all these Gnutella things and all these other peer-to-peer protocols?
David Smith: I think it really has a lot to do with the user base. So the people [who] are using Kazaa and LimeWire, I mean you get those programs because you want to download music. BitTorrent has always been a much more open program from the start. It's had a much more open audience, and the majority of the people that have been using BitTorrent have been using it for legitimate causes and good reasons, so BitTorrent has just got a better reputation.
Carl Franklin: Okay now, hold on now, because from where I sit BitTorrent has a pretty bad reputation because it's being used extensively to shuttle around complete copies of DVDs and movies and all this stuff. The BitTorrent traffic that you see, that by the way makes up the number one use of bandwidth on the Internetsurpassing e-mailisn't because they are passing around legitimate copies of Linux, right?
David Smith: Yeah, absolutely. The inventor of BitTorrent, Bram Cohen, actually has been publicizing the fact [on] his Web site [that] he will not allow pirated materials to be searched for. It really takes a public voice to stand up and say, "We don't want this technology to be used in order to abuse copyright." It takes responsibility and it takes responsible people.
Carl Franklin: I will be the first to stand up for it. I am a content producer. It is in my best interest to get my content distributed as widely as possible for free, but that's not the model that a lot of people have been using. But you're right, I think BitTorrent has that reputation because it's so good, it's used for downloading and passing around large filesand it really is fast. Can you explain how BitTorrent works and why it's as good as it is?
David Smith: Yes absolutely. It's a very simple algorithm, actually. There exists a tracker, which could be an HTTP server or Web server somewhere on the Internet. And this Web server's only job is to keep track of the IP addresses of the people who currently are downloading this file. Then somebody who wants to publish a file goes ahead and makes a Meta file and publishes it on some part of the Internet
Carl Franklin: And this is the actual .Torrent file, right?
David Smith: Yes, this is the .Torrent file that has the file size, it has the file name, it has the directory structure of whatever you're downloading, all the things that are needed to initialize the saving of this file to your disk and then you download the .Torrent file and then your BitTorrent client will parse that .Torrent file. It will then save, it will start the files and initialize the file sizes for everything and then you go to your tracker and when you first hit that tracker with your GET request, it will give you a list of IP addresses of everybody that's sharing the file.
Carl Franklin: Everybody that's also connected to the tracker, in other words.
David Smith: When you actually connect to the tracker, it's just like hitting a Web page. It's like going to Google and hitting that Web page and then you are done with it. Then you have all those IP addresses, and your connection to the tracker ends. And then you initialize TCP connections to 4 to 7 people at a time, and you send requests to those people trying to get different pieces of the file. It's all distributed and it's very random, and random is the best part of the algorithm.