BitTorrent in ns-2

Overview:

Peer-to-peer (P2P) networks can reduce the distribution cost of large media files for the original provider of the data significantly. Thereby, the BitTorrent protocol is widely used in the Internet today. Most research work studies the protocol analytically, by simulations at the flow-level or real world experiments. Thereby, for flow-level simulations the influence of neglecting packet-level characteristics is not yet quantified.
Therefore, we implemented a BitTorrent-like protocol for the network simulator ns-2. We denote it as BitTorrent-like, because we do not intend to implement a specific version of BitTorrent, but aim at assessing the differences between a full simulation of all network layers and simplified simulations on the application-layer. Thus, some functionalities were simplified and others were omitted. In detail, in our simulator no torrent file is used and the downloaded data is not checked for data integrity by hash values. The HTTP tracker protocol is not implemented. That is, all tracker traffic is directly given to the peers rather than being transmitted over the network. We use this simplification because we are predominantly interested in the efficiency of the data transfers between the peers. Each peer runs the original unchoking algorithm. Thereby, anti-snubbing and the endgame-mode are neglected. We omitted the endgame mode in our implementation because it is not clearly specified when a peer switches to the endgame mode. Hence, different implementations realize it differently. Furthermore, anti-snubbing was omitted because it can result in situations where a peer does not contribute its upload bandwidth although it can transfer data to other peers. This can cause inefficiency in the network.
However, we implemented the super-seeding functionality because it improves considerably the performance for the flash crowd scenario. The BitTorrent implementation is modular. That is, the peer and the piece selection algorithms can be replaced by alternatives. Thus, different implementations of BitTorrent-like networks can be compared easily by simulations.

Reference:

K. Eger, T. Hoßfeld, A. Binzenhöfer, G. Kunzmann, "Efficient Simulation of Large-Scale P2P Networks: Packet-level vs. Flow-level Simulations", 2nd Workshop on the Use of P2P, GRID and Agents for the Development of Content Networks (UPGRADE-CN'07) in conjunction with IEEE HPDC, Monterey Bay, USA, June 2007
© ACM (2007). See also ACM Digital Library


Contact:

Kolja Eger
e-mail: eger@tuhh.de

Source code:

see attachments

The patch changes the source code of agent.cc, agent.h, node.cc, node.h, tcp-full.cc, tcp-full.h and Makefile.in. Additionally, it adds the folder bittorrent/ with the corresponding files of the BitTorrent implementation. To apply changes run

patch -p1 < bittorrent.patch

in the ns-2.29 folder. Then run

make clean
./configure
make


The two sample scripts simulate a flash crowd with initially only one seed and a number of leechers in the network. Parameters for the examples are number of peers, seed of random number generator and upload bandwidth in kbps. The command

./ns bt_flashcrowd_star.tcl 10 1 1000

will run a packet-level simulation of 10 peers each with a upload bandwidth of 1000kbps.

A log file is generated by the log_statistics function in  BitTorrentApp.c :
    file_op << 
id << " " <<
start_time << " " <<
first_chunk_time << " " <<
download_finished << " " <<
stop_time << " " <<
download_finished - start_time << " " <<
endl;

Per leaving peer one line with id, start_time, time when peer gets first chunk, time when peer finishes download, time when peer leaves, and total download time.
ċ
bittorrent.patch
(127k)
Kolja Eger,
18 Mar 2010, 12:15
ċ
bt_flashcrowd_flow.tcl
(3k)
Kolja Eger,
18 Mar 2010, 12:15
ċ
bt_flashcrowd_star.tcl
(4k)
Kolja Eger,
18 Mar 2010, 12:15
Comments