**Protocol Measurements in BitTorrent Environments**

Razvan Deaconescu ˘ *University POLITEHNICA of Bucharest Romania*

#### **1. Introduction**

22 Will-be-set-by-IN-TECH

284 Advanced Topics in Measurements

ITU-T (1991). Integrated services digital network (ISDN)-Basic access interface for use on metallic loops for application on the network side of the NT (layer 1 specification).

ITU-T (1999b). ITU-T G996.1 - Test Procedures for Digital Subscriber Line (DSL) Transceivers.

ITU-T (2005a). Asymmetric Digital Subscriber Line (ADSL) transceivers - Extended

ITU-T (2006). Very high speed digital subscriber line transceivers 2 (VDSL2), *ITU-T*

Magesacher, T., Rius i Riu, J., Ödling, P., Börjesson, P., Tilocca, M. & Valentini, M. (2006).

Moraes, R. B., Dortschy, B., Klautau, A. & Riu, J. R. i. (2010). Semiblind spectrum balancing

Odling, P., Magesacher, T., Host, S., Borjesson, P., Berg, M. & Areizaga, E. (2009). The fourth generation broadband concept, *IEEE Communications Magazine* 47(1): 62 –69. Oksman, V., Schenk, H., Clausen, A., Cioffi, J., Mohseni, M., Ginis, G., Nuzman, C., Maes, J.,

proliferates 100 MB/s DSL, *IEEE Communications Magazine* 48(10): 140 –148. Song, K. B., Chung, S. T., Ginis, G. & Cioffi, J. (2002). Dynamic spectrum management for next-generation DSL systems, *IEEE Communications Magazine* 40(10): 101 – 109. Starr, T., Cioffi, J. M. & Silverman, P. J. (1999). *Understanding Digital Subscriber Line Technology*,

van den Brink, R. F. (2010). Enabling 4GBB via hybrid-FttH, the missing link in FttH scenarios,

Vergara, A., Moral, A. & PeÌ ˛ A andrez, J. (2010). Costa: A model to analyze next generation

*Network Strategy and Planning Symposium (NETWORKS), 2010*, pp. 1 –6. Yoho, J. J. (2001). *Physically-Based Realizable Modeling and Network Synthesis of Subscriber*

broadband access platform competition, *14th International Telecommunications*

*Loops Utilized in DSL Technology*, PhD thesis, Virginia Polytechnic Institute and State

for DSL, *IEEE Transactions on Signal Processing* 58(7): 3717–3727.

Limits of ultra-wideband communication over copper, *International Conference on*

Peeters, M., Fisher, K. & Eriksson, P.-E. (2010). The ITU-T's new G.vector standard

ITU-T (1999a). Asymmetric Digital Subscriber Line (ADSL) transceivers.

bandwidth ADSL2 (ADSL2+).

*Recommendation G.993.2* .

Prentice-Hall.

BBF 2010.1395.

University.

ITU-T (2003). Asymmetric Digital Subscriber Line Transceivers 2 (ADSL2).

ITU-T (2005b). Very high speed digital subscriber line transceivers (VDSL).

*Communication Technology, 2006. ICCT '06.*, pp. 1 –4.

Based on BitTorrent's success story (it has managed to become the number one protocol of the internet in a matter of years), the scientific community has delved heavily in analysing, understanding and improving its performance. Research focus has ranged from measurements (Pouwelse et al. (2004)) to protocol improvements (Tian et al. (2007)), from social networking (Pouwelse et al. (2008)) to moderation techniques (Pouwelse et al. (2005)), from content distribution enhancements (Vlavianos et al. (2006)) to network infrastructure impact (Das & Kangasharju (2006)).

The BitTorrent protocol currently (October, 20111) accounts for one of the largest percentages of the Internet traffic. Designed to provoke peers to give more in order to get more, the BitTorrent protocol is a prime choice for large data distribution. BitTorrent's design relies on several key elements:


In this chapter we present a novel approach involving client-side information collection regarding client and protocol implementation. We have instrumented a libtorrent-rasterbar client3 and a Tribler4 client to provide verbose information regarding BitTorrent protocol implementation. These results are collected and subsequently processed and analysed through a rendering interface.

The aim is to measure and analyze protocol messages while in real-world environments. To achieve this aim, a virtualized infrastructure had been used for realistic environments; apart

<sup>1</sup> http://www.sandvine.com/news/global\_broadband\_trends.asp

<sup>2</sup> though this can be circumvented as shown in BitThief (Locher et al. (2006))

<sup>3</sup> http://www.rasterbar.com/products/libtorrent/

<sup>4</sup> http://www.tribler.org/trac/

BitTorrent Environments 3

Protocol Measurements in BitTorrent Environments 287

a handshake whose peer\_id does not match with the expected one – it must keep a list with peers addresses and ports and their corresponding peer\_id's – then it also must drop the

The length prefix is a four byte big-endian value representing the sum of message ID and payload sizes. The message ID is a single decimal byte. The payload is message dependent.

The Keep-alive message is the only message without any message ID and payload. It is sent to maintain the connection alive if no other message has been sent for a given amount

The Interested message is sent when the client is interested in something that the remote

The Not interested message is sent when the client is not interested in anything that the

The piece index is a 4 bytes value representing the zero-based index of a piece that has just been successfully downloaded and verified via its hash value present in the torrent file.

The bitfield message may only be sent immediately after the handshake sequence has occurred and before any other message is sent. It is optional and need not be sent if a client has no pieces. The Bitfield payload has the length X and its bits represent the pieces that have been successfully downloaded. The high bit in the first byte corresponds to piece index 0. A set bit indicates a valid and available piece, and a cleared bit indicates a missing

The Request message is sent when requesting a block. Index is the zero-based index of the piece containing the requested block, begin is the block offset inside the piece and length

The Piece message is sent when delivering a block to an interested peer. Index is the zero-based index of the piece containing the delivered block, begin is the block offset inside

The Choke message is sent when the client wants to choke a remote peer.

The Unchoke message is sent when the client wants to unchoke a remote peer.

connection.

Remaining protocol messages use the format:

of time. The amount of time is about two minutes.

<length><message ID><payload>

• **keep-alive** (*<*len=0000*>*)

• **choke** (*<*len=0001*><*id=0*>*)

• **unchoke** (*<*len=0001*><*id=1*>*)

• **interested** (*<*len=0001*><*id=2*>*)

• **not interested** (*<*len=0001*><*id=2*>*)

piece. Any spare bits are set to zero.

represents the block size.

• **have** (*<*len=0005*><*id=4*><*piece index*>*)

• **bitfield** (*<*len=0001+X*><*id=5*><*bitfield*>*)

• **request** (*<*len=0013*><*id=6*><*index*><*begin*><*length*>*)

• **piece** (*<*len=0009+X*><*id=7*><*index*><*begin*><*block*>*)

the piece and block represents the X-sized block data.

peer has to offer.

remote peer has to offer.

from it, clients and trackers running in a real-world swarm have been used and instrumented to provide valuable protocol information and parameters. No simulators (see Naicken et al. (2007)) have been used for collecting, measuring and analyzing protocol parameters, rather a "keep it real as much as possible" approach. Information, messages and parameters are collected directly from peers and trackers that are part of a real-world Peer-to-Peer swarm.

An approach to providing a unified model for collecting information would be a standard for developing a logging implementation for various clients, such that if using a common easy to parse output format, all information about messages exchanged between the active participants can be centralized and followed by new improvements. Such an approach would ensure maximum flexibility, albeit at the cost of having to update all clients in use, which is why we have focused on the above on an approach of collecting and analysing logging information directly provided by BitTorrent clients.

The action chronology for measuring parameters had been collecting data, parsing and storing it and then subjecting protocol parameters to processing and analysis. The rest of this chapter presents the measured parameters, approaches to collecting, parsing and storing information into an "easy to be used" format and then putting it to analysis and interpretation.
