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.
© ACM (2007). See also ACM Digital Library
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.patchin the ns-2.29 folder. Then run
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 <<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.