Turn-the world's smallest P2P software-emulebt Software Framework Analysis

Source: Internet
Author: User

 

Emulebt is an open-source software project (www.emulebt.com ". Because eMule and Bt functions are integrated at the same time, the capacity is only 460 kb, which attracts some people's attention. Because many people are interested in the functions of Emule and BT, note also spent a lot of time asking professionals to analyze it. The following table lists the features of Emule and Bt for readers.

 

Emulebt is a software written based on the idea of fully installing C ++. In this way, its class encapsulation is better. In terms of the entire software architecture, it is very clear.

 

Software Framework:

 

Emulebt is divided into two frameworks: Ui, user operation interface, kernel, and core part of Emule protocol and Bt protocol communication.

 

In the UI section, we see Operation interfaces such as "transmission", "Search", and "sharing". The kernel is operated through the UI, for example, when we add a download task through the interface, the task is displayed on our UI, which is actually driven by the kernel.

 

 

Figure 1 emulebt UI

 

 

 

Why should we separate them? From a large number of actual software development processes, we often encounter changes to the software interface requirements, but the actual functions do not need to be greatly changed. A common example is that Company A needs a product for entertainment users, while Company B needs a product for enterprise users. But they both need to download these files. This structure is advantageous:

 

1) division of labor and cooperation can be appropriate for project personnel to perform their respective duties;

 

2) clear structure, facilitating software maintenance;

 

3) modular design facilitates software expansion;

 

4) separate implementation, facilitating migration of various software parts

 

The structure is as follows:

 

 

 

 

 

 

The interface is relatively simple. Let's talk about the core part first.

 

 

 

The core structure is clearly illustrated by a graph:

 

 

 

 

At present, emulebt only well encapsulates the core of Emule and BT, while the HTTP protocol only implements a simple encapsulation. For example, he uses his own HTTP class for downloading BT seeds.

 

We have analyzed the entire emulebt and roughly divided its system structure into a list of the above-mentioned graphic relationships.

 

Now we will introduce the following:

 

BTKernel:It is a class structure encapsulated by the BT protocol, such as the overall structure of protocol interaction such as handshake and request packet. When the BT Protocol needs to operate on files, public file classes are used for operations.

 

EMuleKernel: A class structure encapsulated by eMule, such as communication and requests with the server. The cache technology is used to download and reduce disk losses.

 

HTTP kernel: Based on technical analysis, emulebt also provides development interfaces for HTTP, FTP, MMS, RTSP, and P2s, but it only reserves program interface specifications and does not implement code, the reason is unknown.

 

Callback class: during the development of emulebt code, it is estimated that it was completed by two persons, one being the UI part and the other being the kernel part. There are a large number of callback entries in the kernel, which makes it easier for UI users to expand during development. We often encounter file downloading, we need to perform other operations on the file on the operation interface, such as moving and playing. The reserved callback entry is very useful.

 

Configuration class: emulebt uses the issuance mode of a single execution file. All of its default configurations are generated when the program runs for the first time. The generated configuration file uses the right configuration class to control the kernel, such as the number of simultaneous connections, the maximum, and the lowest download speed.

 

Emulebt supports multi-language versions. Two standard language versions are generated under the Lang directory. One is the English version and the other is the Simplified Chinese version. You can write other language versions based on these two standard versions.

 

Status: the Status class detects and displays the execution status of the software, such as the number of downloaded files, the number of bytes, and the number of uploaded files:

 

 

 

 

Timer class: the transaction management class that requires regular updates or operations in the software. It has the UPnP class, Thread class, and host class.

 

In P2P technology, UPnP is often used to implement direct TCP transfer, but different devices have small differences, and the methods supported by different devices are not the same, in the process of software startup, in order to save system overhead and synchronization, the Timer class is used to realize the addressing and interaction of UPnP.

 

Experienced software developers know that a lot of work in Windows is performed in a single step. For example, to implement a DNS-to-IP address conversion process, such operations consume software resources, if you use a thread to do this, it will slightly improve this situation. Of course, there are still better methods, but emulebt does not seem to have used another method.

 

Cache: When P2P software transmits data to each other, it will certainly perform very frequent read/write operations on the hard disk. Good software must reduce this operation mode, and emulebt is no exception, in order to protect the hard disk, the program implements the cache class and stores frequently used data in the memory, which reduces the disk operation times and improves the efficiency.

 

Sharing class: The sharing mechanisms of Emule and Bt are not the same. Therefore, under the sharing class, emulebt separates the sharing class of Emule and the sharing class of BT. EMule shares 9 m blocks, and the hash value must be sent to the ed2k server (of course, Kad is another implementation method ), BT decides the block size and hash value by the torrent file. After understanding this, we can understand why the shared class requires a Thread class. EMule submits the downloaded package to the ed2k server, and displays the shared content in the UI.

 

Task class: it is a common class. emulebt regards download and upload as a task. The user stops, starts, and sorts downloads on the operation interface. Task classes and file classes are closely linked.

 

File class: The file class is a class for file operations. Both eMule and Bt implement file operations based on this class. It encapsulates NTFS, the operating modes of different file systems, such as fat.

 

There are still a lot of things that have not been introduced, such as the internal details of the eMule class and Bt class. For example, our socket class is of interest .... If you are interested, you canEmulebtDownload the latest version test from the official website (www.emulebt.com:

 

We will continue to analyze this software

 

 

 

-- Xiao Chen

 

 

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.